summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-09-30 13:54:26 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-10-03 19:50:44 +0200
commitad1557f5d775739230e0e2252c293948977b42a0 (patch)
tree610e2e849d87583888c0c658088044d6dc3966a5 /oox
parent7e7dd7f152bc7457437f541e7ff88d69e9f8e765 (diff)
A more lightweight O[U]StringConcatenation
...compared to a full-blown O[U]String, for temporary objects holding an O[U]StringConcat result that can then be used as a std::[u16]string_view. It's instructive to see how some invocations of operator ==, operator !=, and O[U]StringBuffer::insert with an O[U]StringConcat argument required implicit materialization of an O[U]String temporary, and how that expensive operation has now been made explicit with the explicit O[U]StringConcatenation ctor. (The additional operator == and operator != overloads are necessary because the overloads taking two std::[u16]string_view parameters wouldn't even be found here with ADL. And the OUString-related ones would cause ambiguities in at least sal/qa/rtl/strings/test_oustring_stringliterals.cxx built with RTL_STRING_UNITTEST, so have simply been disabled for that special test-code case.) Change-Id: Id29799fa8da21a09ff9794cbc7cc9b366e6803b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122890 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/xmlfilterbase.cxx4
-rw-r--r--oox/source/export/drawingml.cxx12
-rw-r--r--oox/source/export/shapes.cxx2
-rw-r--r--oox/source/ole/vbaexport.cxx12
4 files changed, 15 insertions, 15 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 091c5c17e12e..371439b022a2 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -1176,7 +1176,7 @@ void XmlFilterBase::exportCustomFragments()
const OUString fragmentPath = "customXml/item" + OUString::number(j+1) + ".xml";
if (customXmlDom.is())
{
- addRelation(oox::getRelationship(Relationship::CUSTOMXML), OUString("../" + fragmentPath));
+ addRelation(oox::getRelationship(Relationship::CUSTOMXML), OUStringConcatenation("../" + fragmentPath));
uno::Reference<xml::sax::XSAXSerializable> serializer(customXmlDom, uno::UNO_QUERY);
uno::Reference<xml::sax::XWriter> writer = xml::sax::Writer::create(comphelper::getProcessComponentContext());
@@ -1197,7 +1197,7 @@ void XmlFilterBase::exportCustomFragments()
// Adding itemprops's relationship entry to item.xml.rels file
addRelation(openFragmentStream(fragmentPath, "application/xml"),
oox::getRelationship(Relationship::CUSTOMXMLPROPS),
- OUString("itemProps"+OUString::number(j+1)+".xml"));
+ OUStringConcatenation("itemProps"+OUString::number(j+1)+".xml"));
}
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 2f8043aad2e7..4326ce2fa01d 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -5119,7 +5119,7 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX
OUString dataFileName = "diagrams/data" + OUString::number(nDiagramId) + ".xml";
OString dataRelId = OUStringToOString(
mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMDATA),
- OUString(sRelationCompPrefix + dataFileName)),
+ OUStringConcatenation(sRelationCompPrefix + dataFileName)),
RTL_TEXTENCODING_UTF8);
// add layout relation
@@ -5127,7 +5127,7 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX
OString layoutRelId
= OUStringToOString(mpFB->addRelation(mpFS->getOutputStream(),
oox::getRelationship(Relationship::DIAGRAMLAYOUT),
- OUString(sRelationCompPrefix + layoutFileName)),
+ OUStringConcatenation(sRelationCompPrefix + layoutFileName)),
RTL_TEXTENCODING_UTF8);
// add style relation
@@ -5135,7 +5135,7 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX
OString styleRelId
= OUStringToOString(mpFB->addRelation(mpFS->getOutputStream(),
oox::getRelationship(Relationship::DIAGRAMQUICKSTYLE),
- OUString(sRelationCompPrefix + styleFileName)),
+ OUStringConcatenation(sRelationCompPrefix + styleFileName)),
RTL_TEXTENCODING_UTF8);
// add color relation
@@ -5143,7 +5143,7 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX
OString colorRelId
= OUStringToOString(mpFB->addRelation(mpFS->getOutputStream(),
oox::getRelationship(Relationship::DIAGRAMCOLORS),
- OUString(sRelationCompPrefix + colorFileName)),
+ OUStringConcatenation(sRelationCompPrefix + colorFileName)),
RTL_TEXTENCODING_UTF8);
OUString drawingFileName;
@@ -5153,7 +5153,7 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX
drawingFileName = "diagrams/drawing" + OUString::number(nDiagramId) + ".xml";
OUString drawingRelId = mpFB->addRelation(
mpFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMDRAWING),
- OUString(sRelationCompPrefix + drawingFileName));
+ OUStringConcatenation(sRelationCompPrefix + drawingFileName));
// the data dom contains a reference to the drawing relation. We need to update it with the new generated
// relation value before writing the dom to a file
@@ -5284,7 +5284,7 @@ void DrawingML::writeDiagramRels(const uno::Sequence<uno::Sequence<uno::Any>>& x
PropertySet aProps(xOutStream);
aProps.setAnyProperty(PROP_RelId, uno::makeAny(sRelId.toInt32()));
- mpFB->addRelation(xOutStream, sType, OUString("../" + sFragment));
+ mpFB->addRelation(xOutStream, sType, OUStringConcatenation("../" + sFragment));
OUString sDir = OUString::createFromAscii(GetComponentDir());
uno::Reference<io::XOutputStream> xBinOutStream
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index bc120abe1627..dca1775112bb 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2146,7 +2146,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
OUString const sRelId = mpFB->addRelation(
mpFS->getOutputStream(), sRelationType,
- OUString(OUString::createFromAscii(GetRelationCompPrefix()) + sFileName));
+ OUStringConcatenation(OUString::createFromAscii(GetRelationCompPrefix()) + sFileName));
mpFS->startElementNS(mnXmlNamespace, XML_graphicFrame);
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 372f821aa0b7..2c24593c981e 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -779,7 +779,7 @@ void exportModuleStream(SvStream& rStrm, const OUString& rSourceCode, const OUSt
{
SvMemoryStream aModuleStream(4096, 4096);
- exportString(aModuleStream, OUString("Attribute VB_Name = \"" + aElementName + "\"\r\n"));
+ exportString(aModuleStream, OUStringConcatenation("Attribute VB_Name = \"" + aElementName + "\"\r\n"));
if (rInfo.ModuleType == 4)
{
if (isWorkbook(rInfo.ModuleObject))
@@ -847,16 +847,16 @@ void exportPROJECTStream(SvStream& rStrm, const css::uno::Reference<css::contain
css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName);
if(aModuleInfo.ModuleType == 1)
{
- exportString(rStrm, OUString("Module=" + rModuleName + "\r\n"));
+ exportString(rStrm, OUStringConcatenation("Module=" + rModuleName + "\r\n"));
}
else if(aModuleInfo.ModuleType == 4)
{
- exportString(rStrm, OUString("Document=" + rModuleName + "/&H00000000\r\n"));
+ exportString(rStrm, OUStringConcatenation("Document=" + rModuleName + "/&H00000000\r\n"));
}
}
// section 2.3.1.11 ProjectName
- exportString(rStrm, OUString("Name=\"" + projectName + "\"\r\n"));
+ exportString(rStrm, OUStringConcatenation("Name=\"" + projectName + "\"\r\n"));
// section 2.3.1.12 ProjectHelpId
exportString(rStrm, u"HelpContextID=\"0\"\r\n");
@@ -917,11 +917,11 @@ void exportPROJECTStream(SvStream& rStrm, const css::uno::Reference<css::contain
css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName);
if(aModuleInfo.ModuleType == 1)
{
- exportString(rStrm, OUString(rModuleName + "=25, 25, 1439, 639, \r\n"));
+ exportString(rStrm, OUStringConcatenation(rModuleName + "=25, 25, 1439, 639, \r\n"));
}
else
{
- exportString(rStrm, OUString(rModuleName + "=0, 0, 0, 0, C\r\n"));
+ exportString(rStrm, OUStringConcatenation(rModuleName + "=0, 0, 0, 0, C\r\n"));
}
}
}