filter/qa/unit/svg.cxx | 49 ++++++++++++++++---------------- filter/source/msfilter/util.cxx | 2 - filter/source/svg/svgexport.cxx | 2 - filter/source/xsltfilter/OleHandler.cxx | 10 +++--- 4 files changed, 33 insertions(+), 30 deletions(-)
New commits: commit 1b19c6b7d03b0f7098f43131358227df28e59d84 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Sun Nov 19 20:42:51 2023 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Mon Nov 20 07:27:05 2023 +0100 Extended loplugin:ostr: filter Change-Id: I1c45cecb97789a3fc229084de1b7b4968d6069c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159699 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx index 4c1ddd10b58a..6297e1856a06 100644 --- a/filter/qa/unit/svg.cxx +++ b/filter/qa/unit/svg.cxx @@ -65,7 +65,7 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testPreserveJpg) // Make sure that the original JPG data is reused and we don't perform a PNG re-compress. xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); - OUString aAttributeValue = getXPath(pXmlDoc, "//svg:image", "href"); + OUString aAttributeValue = getXPath(pXmlDoc, "//svg:image"_ostr, "href"_ostr); // Without the accompanying fix in place, this test would have failed with: // - Expression: aAttributeValue.startsWith("data:image/jpeg") @@ -93,7 +93,7 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentLine) // Get the style of the group around the actual <path> element. xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); OUString aStyle = getXPath( - pXmlDoc, "//svg:g[@class='com.sun.star.drawing.LineShape']/svg:g/svg:g", "style"); + pXmlDoc, "//svg:g[@class='com.sun.star.drawing.LineShape']/svg:g/svg:g"_ostr, "style"_ostr); // Without the accompanying fix in place, this test would have failed, as the style was // "mask:url(#mask1)", not "opacity: <value>". CPPUNIT_ASSERT(aStyle.startsWith("opacity: ", &aStyle)); @@ -119,8 +119,9 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentFillWithTransparentLine) // Get the style of the group around the actual <path> element. xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); - OUString aStyle = getXPath( - pXmlDoc, "//svg:g[@class='com.sun.star.drawing.EllipseShape']/svg:g/svg:g", "style"); + OUString aStyle + = getXPath(pXmlDoc, "//svg:g[@class='com.sun.star.drawing.EllipseShape']/svg:g/svg:g"_ostr, + "style"_ostr); CPPUNIT_ASSERT(aStyle.startsWith("opacity: ", &aStyle)); int nPercent = std::round(aStyle.toDouble() * 100); // Make sure that the line is still 50% opaque @@ -128,7 +129,8 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentFillWithTransparentLine) // Get the stroke of the fill of the EllipseShape (it must be "none") OUString aStroke = getXPath( - pXmlDoc, "//svg:g[@class='com.sun.star.drawing.EllipseShape']/svg:g/svg:path", "stroke"); + pXmlDoc, "//svg:g[@class='com.sun.star.drawing.EllipseShape']/svg:g/svg:path"_ostr, + "stroke"_ostr); // Without the accompanying fix in place, this test would have failed, as the stroke was // "rgb(255,255,255)", not "none". CPPUNIT_ASSERT_EQUAL(OUString("none"), aStroke); @@ -163,13 +165,13 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentText) // - Actual : 1 // i.e. the 2nd shape lots its text. - assertXPath(pXmlDoc, "//svg:g[@class='TextShape']//svg:text", 2); + assertXPath(pXmlDoc, "//svg:g[@class='TextShape']//svg:text"_ostr, 2); // First shape has semi-transparent text. - assertXPath(pXmlDoc, "//svg:text[1]/svg:tspan/svg:tspan/svg:tspan[@fill-opacity='0.8']"); + assertXPath(pXmlDoc, "//svg:text[1]/svg:tspan/svg:tspan/svg:tspan[@fill-opacity='0.8']"_ostr); // Second shape has normal text. - assertXPath(pXmlDoc, "//svg:text[2]/svg:tspan/svg:tspan/svg:tspan[@fill-opacity]", 0); + assertXPath(pXmlDoc, "//svg:text[2]/svg:tspan/svg:tspan/svg:tspan[@fill-opacity]"_ostr, 0); } CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentMultiParaText) @@ -207,20 +209,20 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentMultiParaText) // Then make sure that the two semi-transparent paragraphs have the same X position: xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); - assertXPath(pXmlDoc, "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[1]", "x", - "250"); + assertXPath(pXmlDoc, "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[1]"_ostr, + "x"_ostr, "250"); assertXPath(pXmlDoc, - "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[1]/svg:tspan", - "fill-opacity", "0.8"); + "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[1]/svg:tspan"_ostr, + "fill-opacity"_ostr, "0.8"); // Without the accompanying fix in place, this test would have failed with: // - Expected: 250 // - Actual : 8819 // i.e. the X position of the second paragraph was wrong. - assertXPath(pXmlDoc, "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[2]", "x", - "250"); + assertXPath(pXmlDoc, "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[2]"_ostr, + "x"_ostr, "250"); assertXPath(pXmlDoc, - "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[2]/svg:tspan", - "fill-opacity", "0.8"); + "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[2]/svg:tspan"_ostr, + "fill-opacity"_ostr, "0.8"); } CPPUNIT_TEST_FIXTURE(SvgFilterTest, testShapeNographic) @@ -266,7 +268,8 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testCustomBullet) // i.e. the custom bullet used '<use transform="scale(285,285)" // xlink:href="#bullet-char-template-45"/>', but nobody produced a bullet-char-template-45, // instead we need the path of the glyph inline. - CPPUNIT_ASSERT(!getXPath(pXmlDoc, "//svg:g[@class='BulletChars']//svg:path", "d").isEmpty()); + CPPUNIT_ASSERT( + !getXPath(pXmlDoc, "//svg:g[@class='BulletChars']//svg:path"_ostr, "d"_ostr).isEmpty()); } CPPUNIT_TEST_FIXTURE(SvgFilterTest, attributeRedefinedTest) @@ -298,17 +301,17 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, attributeRedefinedTest) // <tspan id="id14" id="id15" id="id17" class="TextParagraph" font-family="Bahnschrift Light" font-size="1129px" font-weight="400"> OString xPath = "//svg:g[@class='TextShape']//svg:text[@class='SVGTextShape']//" - "svg:tspan[@class='TextParagraph']"; + "svg:tspan[@class='TextParagraph']"_ostr; assertXPath(pXmlDoc, xPath, 4); //assert that each tspan element with TextParagraph class has id and the tspan element of //each empty paragraph does not contain tspan element with class TextPosition - assertXPath(pXmlDoc, xPath + "[1]", "id", "id4"); - assertXPath(pXmlDoc, xPath + "[2]", "id", "id5"); + assertXPath(pXmlDoc, xPath + "[1]", "id"_ostr, "id4"); + assertXPath(pXmlDoc, xPath + "[2]", "id"_ostr, "id5"); assertXPath(pXmlDoc, xPath + "[2]//svg:tspan[@class='TextPosition']", 0); - assertXPath(pXmlDoc, xPath + "[3]", "id", "id6"); + assertXPath(pXmlDoc, xPath + "[3]", "id"_ostr, "id6"); assertXPath(pXmlDoc, xPath + "[3]//svg:tspan[@class='TextPosition']", 0); - assertXPath(pXmlDoc, xPath + "[4]", "id", "id7"); + assertXPath(pXmlDoc, xPath + "[4]", "id"_ostr, "id7"); } CPPUNIT_TEST_FIXTURE(SvgFilterTest, testTab) @@ -343,7 +346,7 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testTab) // - Expected: 2 // - Actual : 1 // i.e. the 2nd text portion was not positioned, which looked as if the tab is lost. - assertXPath(pXmlDoc, "//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition']", 2); + assertXPath(pXmlDoc, "//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition']"_ostr, 2); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index 18ed0dea22fe..4c9a065841b8 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -1019,7 +1019,7 @@ OString GetOOXMLPresetGeometry( std::u16string_view rShapeType ) { u"ooxml-rect", "rect" }, }; auto i(aCustomShapeTypeTranslationHashMap.find(rShapeType)); - return i == aCustomShapeTypeTranslationHashMap.end() ? "rect" : i->second; + return i == aCustomShapeTypeTranslationHashMap.end() ? "rect"_ostr : i->second; } MSO_SPT GETVMLShapeType(std::u16string_view aType) diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index b7b2044cbce1..25a5b66a5753 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -766,7 +766,7 @@ bool SVGFilter::implExportImpressOrDraw( const Reference< XOutputStream >& rxOSt aCodec.BeginCompression( ZCODEC_DEFAULT_COMPRESSION, /*gzLib*/true ); // the inner modify time/filename doesn't really matter in this context because // compressed graphic formats are meant to be opened as is - not to be extracted - aCodec.SetCompressionMetadata( "inner", 0, nUncompressedCRC32 ); + aCodec.SetCompressionMetadata( "inner"_ostr, 0, nUncompressedCRC32 ); aCodec.Compress( aTempStm, aCompressedStm ); sal_uInt32 nTotalIn = static_cast< sal_uInt32 >( aCodec.EndCompression() ); if ( aCompressedStm.GetError() || nTotalIn != aDataSize ) diff --git a/filter/source/xsltfilter/OleHandler.cxx b/filter/source/xsltfilter/OleHandler.cxx index bf1c641186eb..3253c91251a1 100644 --- a/filter/source/xsltfilter/OleHandler.cxx +++ b/filter/source/xsltfilter/OleHandler.cxx @@ -82,13 +82,13 @@ namespace XSLT { if (!m_storage || !m_storage->hasByName(streamName)) { - return "Not Found:";// + streamName; + return "Not Found:"_ostr;// + streamName; } Reference<XInputStream> subStream(m_storage->getByName(streamName), UNO_QUERY); if (!subStream.is()) { - return "Not Found:";// + streamName; + return "Not Found:"_ostr;// + streamName; } //The first four byte are the length of the uncompressed data Sequence<sal_Int8> aLength(4); @@ -98,7 +98,7 @@ namespace XSLT int readbytes = subStream->readBytes(aLength, 4); if (4 != readbytes) { - return "Can not read the length."; + return "Can not read the length."_ostr; } sal_Int32 const oleLength = (static_cast<sal_uInt8>(aLength[0]) << 0U) | (static_cast<sal_uInt8>(aLength[1]) << 8U) @@ -106,14 +106,14 @@ namespace XSLT | (static_cast<sal_uInt8>(aLength[3]) << 24U); if (oleLength < 0) { - return "invalid oleLength"; + return "invalid oleLength"_ostr; } Sequence<sal_Int8> content(oleLength); //Read all bytes. The compressed length should be less than the uncompressed length readbytes = subStream->readBytes(content, oleLength); if (oleLength < readbytes) { - return "oleLength";// +oleLength + readBytes; + return "oleLength"_ostr;// +oleLength + readBytes; } // Decompress the bytes