Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/2117
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/17/2117/1
fdo#57950: Remove some chained appends in filter
Change-Id: I2386eb47ad7190d626966020e96c1a7ddc07ab4a
---
M dictionaries
M filter/source/config/cache/filtercache.cxx
M filter/source/config/cache/filterfactory.cxx
M filter/source/svg/svgwriter.cxx
M helpcontent2
5 files changed, 31 insertions(+), 87 deletions(-)
diff --git a/dictionaries b/dictionaries
index 350dc59..0aeb113 160000
--- a/dictionaries
+++ b/dictionaries
-Subproject commit 350dc590b04041f15d6c570075ade425e4db93ad
+Subproject commit 0aeb113339d2bdeb0cb7fe3a9a2b1ae1c3fd9367
diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx
index 7ae9377..1e45cfb 100644
--- a/filter/source/config/cache/filtercache.cxx
+++ b/filter/source/config/cache/filtercache.cxx
@@ -412,11 +412,9 @@
if ( !bIsHelpFilter && !impl_isModuleInstalled(sDocService) )
{
- ::rtl::OUStringBuffer sMsg(256);
- sMsg.appendAscii("The requested filter '"
);
- sMsg.append (sItem
);
- sMsg.appendAscii("' exists ... but it shouldnt; because the corresponding OOo module
was not installed.");
- throw css::container::NoSuchElementException(sMsg.makeStringAndClear(),
css::uno::Reference< css::uno::XInterface >());
+ OUString sMsg("The requested filter '" + sItem +
+ "' exists ... but it shouldnt; because the corresponding OOo module was
not installed.");
+ throw css::container::NoSuchElementException(sMsg, css::uno::Reference<
css::uno::XInterface >());
}
}
@@ -1039,7 +1037,7 @@
// If there are some real errors throw a RuntimException!
// If there are some warnings only, show an assertion.
sal_Int32 nErrors = 0;
- ::rtl::OUStringBuffer sLog(256);
+ OUStringBuffer sLog(256);
CacheItemList::iterator pIt;
@@ -1074,19 +1072,13 @@
aType[PROPNAME_NAME] >>= sInternalTypeNameCheck;
if (!sInternalTypeNameCheck.equals(sType))
{
- sLog.appendAscii("Warning\t:\t");
- sLog.appendAscii("The type \"" );
- sLog.append (sType );
- sLog.appendAscii("\" does support the property \"Name\" correctly.\n");
+ sLog.append("Warning\t:\t" "The type \"" + sType + "\" does support the property
\"Name\" correctly.\n");
++nWarnings;
}
if (!ce && !cu)
{
- sLog.appendAscii("Warning\t:\t");
- sLog.appendAscii("The type \"" );
- sLog.append (sType );
- sLog.appendAscii("\" does not contain any URL pattern nor any extensions.\n");
+ sLog.append("Warning\t:\t" "The type \"" + sType + "\" does not contain any URL
pattern nor any extensions.\n");
++nWarnings;
}
#endif
@@ -1162,10 +1154,7 @@
(!bReferencedByHandler)
)
{
- sLog.appendAscii("Warning\t:\t" );
- sLog.appendAscii("The type \"" );
- sLog.append (sType );
- sLog.appendAscii("\" isnt used by any filter, loader or content handler.\n");
+ sLog.append("Warning\t:\t" "The type \"" + sType + "\" isnt used by any filter,
loader or content handler.\n");
++nWarnings;
}
}
@@ -1178,20 +1167,15 @@
if (bAllFiltersShouldExist)
{
++nWarnings; // preferred filters can point to a non-installed office module !
no error ... it's a warning only .-(
- sLog.appendAscii("error\t:\t");
+ sLog.append("error\t:\t");
}
else
{
++nWarnings;
- sLog.appendAscii("warning\t:\t");
+ sLog.append("warning\t:\t");
}
- sLog.appendAscii("The type \"" );
- sLog.append (sType );
- sLog.appendAscii("\" points to an invalid filter \"");
- sLog.append (sPrefFilter );
- sLog.appendAscii("\".\n" );
-
+ sLog.append("The type \"" + sType + "\" points to an invalid filter \"" +
sPrefFilter + "\".\n");
continue;
}
@@ -1200,14 +1184,8 @@
aPrefFilter[PROPNAME_TYPE] >>= sFilterTypeReg;
if (sFilterTypeReg != sType)
{
- sLog.appendAscii("error\t:\t" );
- sLog.appendAscii("The preferred filter \"" );
- sLog.append (sPrefFilter );
- sLog.appendAscii("\" of type \"" );
- sLog.append (sType );
- sLog.appendAscii("is registered for another type \"");
- sLog.append (sFilterTypeReg );
- sLog.appendAscii("\".\n" );
+ sLog.append("error\t:\t" "The preferred filter \"" + sPrefFilter + "\" of type \""
+ sType +
+ "is registered for another type \"" + sFilterTypeReg + "\".\n");
++nErrors;
}
@@ -1215,12 +1193,8 @@
aPrefFilter[PROPNAME_FLAGS] >>= nFlags;
if ((nFlags & FLAGVAL_IMPORT) != FLAGVAL_IMPORT)
{
- sLog.appendAscii("error\t:\t" );
- sLog.appendAscii("The preferred filter \"" );
- sLog.append (sPrefFilter );
- sLog.appendAscii("\" of type \"" );
- sLog.append (sType );
- sLog.appendAscii("\" is not an IMPORT filter!\n");
+ sLog.append("error\t:\t" "The preferred filter \"" + sPrefFilter + "\" of type \""
+
+ sType + "\" is not an IMPORT filter!\n");
++nErrors;
}
@@ -1228,10 +1202,8 @@
aPrefFilter[PROPNAME_NAME] >>= sInternalFilterNameCheck;
if (!sInternalFilterNameCheck.equals(sPrefFilter))
{
- sLog.appendAscii("Warning\t:\t" );
- sLog.appendAscii("The filter \"" );
- sLog.append (sPrefFilter );
- sLog.appendAscii("\" does support the property \"Name\" correctly.\n");
+ sLog.append("Warning\t:\t" "The filter \"" + sPrefFilter +
+ "\" does support the property \"Name\" correctly.\n");
++nWarnings;
}
}
@@ -1249,8 +1221,7 @@
(sDefaultFrameLoader.isEmpty() )
)
{
- sLog.appendAscii("error\t:\t" );
- sLog.appendAscii("There is no valid default frame loader!?\n");
+ sLog.append("error\t:\t" "There is no valid default frame loader!?\n");
++nErrors;
}
@@ -1531,13 +1502,8 @@
css::uno::Any aVal = xConfig->getByName(sSetName);
if (!(aVal >>= xSet) || !xSet.is())
{
- ::rtl::OUStringBuffer sMsg(256);
- sMsg.appendAscii("Could not open configuration set \"");
- sMsg.append (sSetName );
- sMsg.appendAscii("\"." );
- throw css::uno::Exception(
- sMsg.makeStringAndClear(),
- css::uno::Reference< css::uno::XInterface >());
+ OUString sMsg("Could not open configuration set \"" + sSetName + "\".");
+ throw css::uno::Exception(sMsg, css::uno::Reference< css::uno::XInterface >());
}
lItems = xSet->getElementNames();
}
@@ -1587,12 +1553,8 @@
{
if (pItem == pCache->end())
{
- ::rtl::OUStringBuffer sMsg(256);
- sMsg.appendAscii("item \"" );
- sMsg.append (pItems[i] );
- sMsg.appendAscii("\" not found for update!");
- throw css::uno::Exception(sMsg.makeStringAndClear() ,
- css::uno::Reference< css::uno::XInterface >());
+ OUString sMsg("item \"" + pItems[i] + "\" not found for update!");
+ throw css::uno::Exception(sMsg, css::uno::Reference< css::uno::XInterface >());
}
try
{
@@ -1680,14 +1642,10 @@
return;
::rtl::OUString sName = rItem.getUnpackedValueOrDefault(PROPNAME_NAME, ::rtl::OUString());
- ::rtl::OUStringBuffer sMsg(256);
- sMsg.appendAscii("Fallback scenario for filter or type '" );
- sMsg.append (sName );
- sMsg.appendAscii("' and locale '" );
- sMsg.append (sActLocale );
- sMsg.appendAscii("' failed. Please check your filter configuration.");
+ OUString sMsg("Fallback scenario for filter or type '" + sName + "' and locale '" +
+ sActLocale + "' failed. Please check your filter configuration.");
- OSL_FAIL(_FILTER_CONFIG_TO_ASCII_(sMsg.makeStringAndClear()));
+ OSL_FAIL(_FILTER_CONFIG_TO_ASCII_(sMsg));
#endif
return;
}
@@ -1745,12 +1703,8 @@
css::uno::Any aVal = xSet->getByName(sItem);
if (!(aVal >>= xItem) || !xItem.is())
{
- ::rtl::OUStringBuffer sMsg(256);
- sMsg.appendAscii("found corrupted item \"");
- sMsg.append (sItem );
- sMsg.appendAscii("\"." );
- throw css::uno::Exception(sMsg.makeStringAndClear() ,
- css::uno::Reference< css::uno::XInterface >());
+ OUString sMsg("found corrupted item \"" + sItem + "\".");
+ throw css::uno::Exception(sMsg, css::uno::Reference< css::uno::XInterface >());
}
#ifdef WORKAROUND_EXCEPTION_PROBLEM
}
diff --git a/filter/source/config/cache/filterfactory.cxx
b/filter/source/config/cache/filterfactory.cxx
index d55b3c4..020fd13 100644
--- a/filter/source/config/cache/filterfactory.cxx
+++ b/filter/source/config/cache/filterfactory.cxx
@@ -199,10 +199,8 @@
if (pos != -1)
{
OSL_FAIL("DEPRECATED!\nPlease use new query format: 'matchByDocumentService=...'");
- ::rtl::OUStringBuffer sPatchedQuery(256);
- sPatchedQuery.appendAscii("matchByDocumentService=");
- sPatchedQuery.append (sNewQuery.copy(7) );
- sNewQuery = sPatchedQuery.makeStringAndClear();
+ OUString sPatchedQuery("matchByDocumentService=" + sNewQuery.copy(7));
+ sNewQuery = sPatchedQuery;
}
// analyze query and split it into its tokens
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 36fc03f..8ba1446 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -138,15 +138,8 @@
rColorStr = "none";
else
{
- ::rtl::OUStringBuffer aStyle;
- aStyle.appendAscii( "rgb(" );
- aStyle.append( (sal_Int32) rColor.GetRed() );
- aStyle.appendAscii( "," );
- aStyle.append( (sal_Int32) rColor.GetGreen() );
- aStyle.appendAscii( "," );
- aStyle.append( (sal_Int32) rColor.GetBlue() );
- aStyle.appendAscii( ")" );
- rColorStr = aStyle.makeStringAndClear();
+ rColorStr = "rgb(" + OUString::number(rColor.GetRed()) + "," +
OUString::number(rColor.GetGreen()) +
+ "," + OUString::number(rColor.GetBlue()) + ")";
}
}
@@ -2871,8 +2864,7 @@
Point aPt;
Size aSz;
Sequence< sal_Int8 > aSeq( (sal_Int8*) aOStm.GetData(), aOStm.Tell() );
- rtl::OUStringBuffer aBuffer;
- aBuffer.appendAscii( "data:image/png;base64," );
+ OUStringBuffer aBuffer( "data:image/png;base64," );
::sax::Converter::encodeBase64( aBuffer, aSeq );
if( bApplyMapping )
diff --git a/helpcontent2 b/helpcontent2
index f614280..5df1183 160000
--- a/helpcontent2
+++ b/helpcontent2
-Subproject commit f6142808eb98d363d48a0c661206f98571df0203
+Subproject commit 5df11836790b705261ba5cc72f3e52a4569472a4
--
To view, visit https://gerrit.libreoffice.org/2117
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2386eb47ad7190d626966020e96c1a7ddc07ab4a
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Marcos Souza <marcos.souza.org@gmail.com>
Context
- [PATCH] fdo#57950: Remove some chained appends in filter · Marcos Souza (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.