diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-15 13:12:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-15 20:37:38 +0200 |
commit | 12008e10549aa3fe23063eb1af38fb3e86064d3e (patch) | |
tree | b07bad8a2cc8f83bb69d3c5fe983d1b163f0ffc4 /xmloff/qa/unit | |
parent | ffd199021ec24e3fb2028708a6a191bf5dd49e41 (diff) |
loplugin:ostr in xmloff
Change-Id: I24f5626e57e03217e4bcf77289c785e255b9f904
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167667
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'xmloff/qa/unit')
-rw-r--r-- | xmloff/qa/unit/draw.cxx | 202 | ||||
-rw-r--r-- | xmloff/qa/unit/style.cxx | 198 | ||||
-rw-r--r-- | xmloff/qa/unit/text.cxx | 631 | ||||
-rw-r--r-- | xmloff/qa/unit/text/txtprmap.cxx | 32 | ||||
-rw-r--r-- | xmloff/qa/unit/uxmloff.cxx | 20 |
5 files changed, 546 insertions, 537 deletions
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index 985af4f1ad5e..05d5a756d6e9 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -70,7 +70,7 @@ public: }; XmloffDrawTest::XmloffDrawTest() - : UnoApiXmlTest("/xmloff/qa/unit/data/") + : UnoApiXmlTest(u"/xmloff/qa/unit/data/"_ustr) { } @@ -89,14 +89,14 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextBoxLoss) { // Load a document that has a shape with a textbox in it. Save it to ODF and reload. loadFromFile(u"textbox-loss.docx"); - saveAndReload("impress8"); + saveAndReload(u"impress8"_ustr); // Make sure that the shape is still a textbox. uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); bool bTextBox = false; - xShape->getPropertyValue("TextBox") >>= bTextBox; + xShape->getPropertyValue(u"TextBox"_ustr) >>= bTextBox; // Without the accompanying fix in place, this test would have failed, as the shape only had // editeng text, losing the image part of the shape text. @@ -109,18 +109,18 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf141301_Extrusion_Angle) loadFromFile(u"tdf141301_Extrusion_Skew.odg"); // Prepare use of XPath - save("draw8"); - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + save(u"draw8"_ustr); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without fix draw:extrusion-skew="50 -135" was not written to file although "50 -135" is not // default in ODF, but only default inside LO. - assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-skew"_ostr, "50 -135"); + assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-skew"_ostr, u"50 -135"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeExport) { // Create an Impress document which has a master page which has a theme associated with it. - mxComponent = loadFromDesktop("private:factory/simpress"); + mxComponent = loadFromDesktop(u"private:factory/simpress"_ustr); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XMasterPageTarget> xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); @@ -143,13 +143,13 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeExport) pTheme->setColorSet(pColorSet); uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(pTheme); - xMasterPage->setPropertyValue("Theme", uno::Any(xTheme)); + xMasterPage->setPropertyValue(u"Theme"_ustr, uno::Any(xTheme)); // Export to ODP: - save("impress8"); + save(u"impress8"_ustr); // Check if the 12 colors are written in the XML: - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - Expected: 12 // - Actual : 0 @@ -185,9 +185,9 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testVideoSnapshot) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1356), rCrop.Right); // Execute ODP export: - save("impress8"); + save(u"impress8"_ustr); - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Check that the preview was exported: // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 @@ -195,10 +195,10 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testVideoSnapshot) // - XPath '//draw:frame[@draw:style-name='gr1']/draw:image' number of nodes is incorrect // i.e. the preview wasn't exported to ODP. assertXPath(pXmlDoc, "//draw:frame[@draw:style-name='gr1']/draw:image"_ostr, "href"_ostr, - "Pictures/MediaPreview1.png"); + u"Pictures/MediaPreview1.png"_ustr); // Check that the crop was exported: assertXPath(pXmlDoc, "//style:style[@style:name='gr1']/style:graphic-properties"_ostr, - "clip"_ostr, "rect(0cm, 1.356cm, 0cm, 1.356cm)"); + "clip"_ostr, u"rect(0cm, 1.356cm, 0cm, 1.356cm)"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport) @@ -213,7 +213,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport) uno::Reference<beans::XPropertySet> xMasterpage(xDrawPage->getMasterPage(), uno::UNO_QUERY); uno::Reference<util::XTheme> xTheme; - xMasterpage->getPropertyValue("Theme") >>= xTheme; + xMasterpage->getPropertyValue(u"Theme"_ustr) >>= xTheme; // We expect the theme to be set on the master page CPPUNIT_ASSERT(xTheme.is()); @@ -222,10 +222,10 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport) auto pTheme = pUnoTheme->getTheme(); CPPUNIT_ASSERT(pTheme); - CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), pTheme->GetName()); + CPPUNIT_ASSERT_EQUAL(u"Office Theme"_ustr, pTheme->GetName()); auto pColorSet = pTheme->getColorSet(); CPPUNIT_ASSERT(pColorSet); - CPPUNIT_ASSERT_EQUAL(OUString("Office"), pColorSet->getName()); + CPPUNIT_ASSERT_EQUAL(u"Office"_ustr, pColorSet->getName()); CPPUNIT_ASSERT_EQUAL(Color(0x954F72), pColorSet->getColor(model::ThemeColorType::FollowedHyperlink)); @@ -239,7 +239,7 @@ void checkFillAndLineComplexColors(uno::Reference<drawing::XShape> const& xShape uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); { uno::Reference<util::XComplexColor> xComplexColor; - xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor; + xShapeProperties->getPropertyValue(u"FillComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType()); @@ -253,7 +253,7 @@ void checkFillAndLineComplexColors(uno::Reference<drawing::XShape> const& xShape } { uno::Reference<util::XComplexColor> xComplexColor; - xShapeProperties->getPropertyValue("LineComplexColor") >>= xComplexColor; + xShapeProperties->getPropertyValue(u"LineComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType()); @@ -275,7 +275,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testFillAndLineThemeColorExportImport) checkFillAndLineComplexColors(getShape(0)); - save("impress8"); + save(u"impress8"_ustr); load(maTempFile.GetURL()); @@ -286,62 +286,62 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport) { // Given a document that refers to a theme color: loadFromFile(u"Reference-ThemeColors-TextAndFill.pptx"); - save("impress8"); + save(u"impress8"_ustr); // Make sure the export result has the theme reference: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Text color OString aStyle1( "//style:style[@style:name='T2']/style:text-properties/loext:char-complex-color"_ostr); - assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme"); - assertXPath(pXmlDoc, aStyle1, "theme-type"_ostr, "accent3"); - assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "type"_ostr, "lummod"); - assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "value"_ostr, "2000"); - assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[2]", "type"_ostr, "lumoff"); - assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[2]", "value"_ostr, "8000"); + assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, u"theme"_ustr); + assertXPath(pXmlDoc, aStyle1, "theme-type"_ostr, u"accent3"_ustr); + assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "type"_ostr, u"lummod"_ustr); + assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "value"_ostr, u"2000"_ustr); + assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[2]", "type"_ostr, u"lumoff"_ustr); + assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[2]", "value"_ostr, u"8000"_ustr); OString aStyle2( "//style:style[@style:name='T3']/style:text-properties/loext:char-complex-color"_ostr); - assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme"); - assertXPath(pXmlDoc, aStyle2, "theme-type"_ostr, "accent3"); - assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "type"_ostr, "lummod"); - assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "value"_ostr, "6000"); - assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[2]", "type"_ostr, "lumoff"); - assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[2]", "value"_ostr, "4000"); + assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, u"theme"_ustr); + assertXPath(pXmlDoc, aStyle2, "theme-type"_ostr, u"accent3"_ustr); + assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "type"_ostr, u"lummod"_ustr); + assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "value"_ostr, u"6000"_ustr); + assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[2]", "type"_ostr, u"lumoff"_ustr); + assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[2]", "value"_ostr, u"4000"_ustr); OString aStyle3( "//style:style[@style:name='T4']/style:text-properties/loext:char-complex-color"_ostr); - assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme"); - assertXPath(pXmlDoc, aStyle3, "theme-type"_ostr, "accent3"); - assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "type"_ostr, "lummod"); - assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "value"_ostr, "5000"); + assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, u"theme"_ustr); + assertXPath(pXmlDoc, aStyle3, "theme-type"_ostr, u"accent3"_ustr); + assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "type"_ostr, u"lummod"_ustr); + assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "value"_ostr, u"5000"_ustr); // Shapes fill color OString aShape1("//style:style[@style:name='gr1']/style:graphic-properties/" "loext:fill-complex-color"_ostr); - assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme"); - assertXPath(pXmlDoc, aShape1, "theme-type"_ostr, "accent2"); - assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "type"_ostr, "lummod"); - assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "value"_ostr, "2000"); - assertXPath(pXmlDoc, aShape1 + "/loext:transformation[2]", "type"_ostr, "lumoff"); - assertXPath(pXmlDoc, aShape1 + "/loext:transformation[2]", "value"_ostr, "8000"); + assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, u"theme"_ustr); + assertXPath(pXmlDoc, aShape1, "theme-type"_ostr, u"accent2"_ustr); + assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "type"_ostr, u"lummod"_ustr); + assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "value"_ostr, u"2000"_ustr); + assertXPath(pXmlDoc, aShape1 + "/loext:transformation[2]", "type"_ostr, u"lumoff"_ustr); + assertXPath(pXmlDoc, aShape1 + "/loext:transformation[2]", "value"_ostr, u"8000"_ustr); OString aShape2("//style:style[@style:name='gr2']/style:graphic-properties/" "loext:fill-complex-color"_ostr); - assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme"); - assertXPath(pXmlDoc, aShape2, "theme-type"_ostr, "accent2"); - assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "type"_ostr, "lummod"); - assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "value"_ostr, "6000"); - assertXPath(pXmlDoc, aShape2 + "/loext:transformation[2]", "type"_ostr, "lumoff"); - assertXPath(pXmlDoc, aShape2 + "/loext:transformation[2]", "value"_ostr, "4000"); + assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, u"theme"_ustr); + assertXPath(pXmlDoc, aShape2, "theme-type"_ostr, u"accent2"_ustr); + assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "type"_ostr, u"lummod"_ustr); + assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "value"_ostr, u"6000"_ustr); + assertXPath(pXmlDoc, aShape2 + "/loext:transformation[2]", "type"_ostr, u"lumoff"_ustr); + assertXPath(pXmlDoc, aShape2 + "/loext:transformation[2]", "value"_ostr, u"4000"_ustr); OString aShape3("//style:style[@style:name='gr3']/style:graphic-properties/" "loext:fill-complex-color"_ostr); - assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, "theme"); - assertXPath(pXmlDoc, aShape3, "theme-type"_ostr, "accent2"); - assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "type"_ostr, "lummod"); - assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "value"_ostr, "5000"); + assertXPath(pXmlDoc, aStyle1, "color-type"_ostr, u"theme"_ustr); + assertXPath(pXmlDoc, aShape3, "theme-type"_ostr, u"accent2"_ustr); + assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "type"_ostr, u"lummod"_ustr); + assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "value"_ostr, u"5000"_ustr); // reload load(maTempFile.GetURL()); @@ -352,7 +352,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport) CPPUNIT_ASSERT(xShape.is()); uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); uno::Reference<util::XComplexColor> xComplexColor; - xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor; + xShapeProperties->getPropertyValue(u"FillComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType()); @@ -369,7 +369,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport) CPPUNIT_ASSERT(xShape.is()); uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); uno::Reference<util::XComplexColor> xComplexColor; - xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor; + xShapeProperties->getPropertyValue(u"FillComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType()); @@ -386,7 +386,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport) CPPUNIT_ASSERT(xShape.is()); uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); uno::Reference<util::XComplexColor> xComplexColor; - xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor; + xShapeProperties->getPropertyValue(u"FillComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getThemeColorType()); @@ -405,7 +405,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport) uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape); CPPUNIT_ASSERT(xPortion.is()); uno::Reference<util::XComplexColor> xComplexColor; - xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor; + xPortion->getPropertyValue(u"CharComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType()); @@ -426,7 +426,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport) uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape); CPPUNIT_ASSERT(xPortion.is()); uno::Reference<util::XComplexColor> xComplexColor; - xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor; + xPortion->getPropertyValue(u"CharComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType()); @@ -447,7 +447,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport) uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape); CPPUNIT_ASSERT(xPortion.is()); uno::Reference<util::XComplexColor> xComplexColor; - xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor; + xPortion->getPropertyValue(u"CharComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getThemeColorType()); @@ -461,7 +461,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextAndFillThemeColorExportImport) CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColor_ShapeFill) { loadFromFile(u"ReferenceShapeFill.pptx"); - save("impress8"); + save(u"impress8"_ustr); // reload load(maTempFile.GetURL()); @@ -470,7 +470,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColor_ShapeFill) CPPUNIT_ASSERT(xShape.is()); uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); uno::Reference<util::XComplexColor> xComplexColor; - xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor; + xShapeProperties->getPropertyValue(u"FillComplexColor"_ustr) >>= xComplexColor; CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getThemeColorType()); @@ -495,8 +495,8 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTableInShape) uno::Reference<text::XTextTable> xTable(xEnum->nextElement(), uno::UNO_QUERY); // Without the accompanying fix in place, this test would have crashed, as xTable was an empty // reference, i.e. the table inside the shape was lost. - uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("A1"), xCell->getString()); + uno::Reference<text::XTextRange> xCell(xTable->getCellByName(u"A1"_ustr), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(u"A1"_ustr, xCell->getString()); } // Tests for save/load of new (LO 7.4) attribute loext:extrusion-metal-type @@ -506,19 +506,19 @@ void lcl_assertMetalProperties(std::string_view sInfo, uno::Reference<drawing::X { uno::Reference<beans::XPropertySet> xShapeProps(rxShape, uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aGeoPropSeq; - xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq; + xShapeProps->getPropertyValue(u"CustomShapeGeometry"_ustr) >>= aGeoPropSeq; comphelper::SequenceAsHashMap aGeoPropMap(aGeoPropSeq); uno::Sequence<beans::PropertyValue> aExtrusionSeq; - aGeoPropMap.getValue("Extrusion") >>= aExtrusionSeq; + aGeoPropMap.getValue(u"Extrusion"_ustr) >>= aExtrusionSeq; comphelper::SequenceAsHashMap aExtrusionPropMap(aExtrusionSeq); bool bIsMetal(false); - aExtrusionPropMap.getValue("Metal") >>= bIsMetal; + aExtrusionPropMap.getValue(u"Metal"_ustr) >>= bIsMetal; OString sMsg = OString::Concat(sInfo) + " Metal"; CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), bIsMetal); sal_Int16 nMetalType(-1); - aExtrusionPropMap.getValue("MetalType") >>= nMetalType; + aExtrusionPropMap.getValue(u"MetalType"_ustr) >>= nMetalType; sMsg = OString::Concat(sInfo) + " MetalType"; CPPUNIT_ASSERT_EQUAL_MESSAGE( sMsg.getStr(), css::drawing::EnhancedCustomShapeMetalType::MetalMSCompatible, nMetalType); @@ -533,17 +533,17 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeExtended) lcl_assertMetalProperties("from doc", xShape); // Test, that new attribute is written with loext namespace. Adapt when attribute is added to ODF. - save("writer8"); + save(u"writer8"_ustr); // assert XML. - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); - assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-metal"_ostr, "true"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-metal"_ostr, u"true"_ustr); assertXPath( pXmlDoc, "//draw:enhanced-geometry[@loext:extrusion-metal-type='loext:MetalMSCompatible']"_ostr); // reload - mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument"); + mxComponent = loadFromDesktop(maTempFile.GetURL(), u"com.sun.star.text.TextDocument"_ustr); // verify properties uno::Reference<drawing::XShape> xShapeReload(getShape(0)); lcl_assertMetalProperties("from ODF 1.3 extended", xShapeReload); @@ -557,11 +557,11 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeStrict) // added to ODF. const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); SetODFDefaultVersion(SvtSaveOptions::ODFVER_013); - save("writer8"); + save(u"writer8"_ustr); // assert XML. - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); - assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-metal"_ostr, "true"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, "//draw:enhanced-geometry"_ostr, "extrusion-metal"_ostr, u"true"_ustr); assertXPath(pXmlDoc, "//draw:enhanced-geometry[@loext:extrusion-metal-type]"_ostr, 0); SetODFDefaultVersion(nCurrentODFVersion); @@ -573,14 +573,14 @@ void lcl_assertSpecularityProperty(std::string_view sInfo, uno::Reference<drawin { uno::Reference<beans::XPropertySet> xShapeProps(rxShape, uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aGeoPropSeq; - xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq; + xShapeProps->getPropertyValue(u"CustomShapeGeometry"_ustr) >>= aGeoPropSeq; comphelper::SequenceAsHashMap aGeoPropMap(aGeoPropSeq); uno::Sequence<beans::PropertyValue> aExtrusionSeq; - aGeoPropMap.getValue("Extrusion") >>= aExtrusionSeq; + aGeoPropMap.getValue(u"Extrusion"_ustr) >>= aExtrusionSeq; comphelper::SequenceAsHashMap aExtrusionPropMap(aExtrusionSeq); double fSpecularity(-1.0); - aExtrusionPropMap.getValue("Specularity") >>= fSpecularity; + aExtrusionPropMap.getValue(u"Specularity"_ustr) >>= fSpecularity; OString sMsg = OString::Concat(sInfo) + "Specularity"; CPPUNIT_ASSERT_EQUAL_MESSAGE(sMsg.getStr(), 122.0703125, fSpecularity); } @@ -595,16 +595,16 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularityExtended) // Test, that attribute is written in draw namespace with value 100% and in loext namespace with // value 122.0703125%. - save("writer8"); + save(u"writer8"_ustr); // assert XML. - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); assertXPath(pXmlDoc, "//draw:enhanced-geometry[@draw:extrusion-specularity='100%']"_ostr); assertXPath(pXmlDoc, "//draw:enhanced-geometry[@loext:extrusion-specularity-loext='122.0703125%']"_ostr); // reload and verify, that the loext value is used - mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument"); + mxComponent = loadFromDesktop(maTempFile.GetURL(), u"com.sun.star.text.TextDocument"_ustr); // verify properties uno::Reference<drawing::XShape> xShapeReload(getShape(0)); lcl_assertSpecularityProperty("from ODF 1.3 extended", xShapeReload); @@ -618,7 +618,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularity) // Save to ODF 1.3 strict and make sure it does not produce a validation error. const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); SetODFDefaultVersion(SvtSaveOptions::ODFVER_013); - save("writer8"); + save(u"writer8"_ustr); SetODFDefaultVersion(nCurrentODFVersion); } @@ -629,7 +629,7 @@ bool lcl_getShapeSegments(uno::Sequence<drawing::EnhancedCustomShapeSegment>& rS const uno::Reference<drawing::XShape>& xShape) { uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY_THROW); - uno::Any anotherAny = xShapeProps->getPropertyValue("CustomShapeGeometry"); + uno::Any anotherAny = xShapeProps->getPropertyValue(u"CustomShapeGeometry"_ustr); uno::Sequence<beans::PropertyValue> aCustomShapeGeometry; if (!(anotherAny >>= aCustomShapeGeometry)) return false; @@ -707,18 +707,18 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextRotationPlusPre) uno::Reference<drawing::XShape> xShape(getShape(0)); uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aGeomSeq; - xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeomSeq; + xShapeProps->getPropertyValue(u"CustomShapeGeometry"_ustr) >>= aGeomSeq; auto aGeomVec(comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aGeomSeq)); - aGeomVec.push_back(comphelper::makePropertyValue("TextRotateAngle", sal_Int32(45))); + aGeomVec.push_back(comphelper::makePropertyValue(u"TextRotateAngle"_ustr, sal_Int32(45))); aGeomSeq = comphelper::containerToSequence(aGeomVec); - xShapeProps->setPropertyValue("CustomShapeGeometry", uno::Any(aGeomSeq)); + xShapeProps->setPropertyValue(u"CustomShapeGeometry"_ustr, uno::Any(aGeomSeq)); // Save to ODF. Without the fix, a file format error was produced, because attribute // draw:text-rotate-angle was written twice, one from TextPreRotateAngle and the other from // TextRotateAngle. // This should already catch the format error, but does not, see tdf#149567 // But reload catches it. - saveAndReload("writer8"); + saveAndReload(u"writer8"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf156975_ThemeExport) @@ -727,7 +727,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf156975_ThemeExport) // Without fix for tdf#156975 it was not written at all. // The test needs to be adapted, when themes are available in ODF. - mxComponent = loadFromDesktop("private:factory/sdraw"); + mxComponent = loadFromDesktop(u"private:factory/sdraw"_ustr); // generate a theme to be sure we have got one and know the values uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XMasterPageTarget> xDrawPage( @@ -752,13 +752,13 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf156975_ThemeExport) pTheme->setColorSet(pColorSet); uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(pTheme); - xMasterPageProps->setPropertyValue("Theme", uno::Any(xTheme)); + xMasterPageProps->setPropertyValue(u"Theme"_ustr, uno::Any(xTheme)); // save as odg - save("draw8"); + save(u"draw8"_ustr); // and check the markup. - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); static constexpr OString sThemePath = "//office:master-styles/style:master-page/loext:theme"_ostr; assertXPath(pXmlDoc, sThemePath, 1); @@ -770,12 +770,12 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf156975_ThemeExport) const OString sThemeColorPath = sThemeColorsPath + "/loext:color"; assertXPath(pXmlDoc, sThemeColorPath, 12); - assertXPath(pXmlDoc, sThemeColorPath + "[3]", "name"_ostr, "dark2"); - assertXPath(pXmlDoc, sThemeColorPath + "[3]", "color"_ostr, "#002200"); - assertXPath(pXmlDoc, sThemeColorPath + "[9]", "name"_ostr, "accent5"); - assertXPath(pXmlDoc, sThemeColorPath + "[9]", "color"_ostr, "#880088"); - assertXPath(pXmlDoc, sThemeColorPath + "[12]", "name"_ostr, "followed-hyperlink"); - assertXPath(pXmlDoc, sThemeColorPath + "[12]", "color"_ostr, "#b0b0b0"); + assertXPath(pXmlDoc, sThemeColorPath + "[3]", "name"_ostr, u"dark2"_ustr); + assertXPath(pXmlDoc, sThemeColorPath + "[3]", "color"_ostr, u"#002200"_ustr); + assertXPath(pXmlDoc, sThemeColorPath + "[9]", "name"_ostr, u"accent5"_ustr); + assertXPath(pXmlDoc, sThemeColorPath + "[9]", "color"_ostr, u"#880088"_ustr); + assertXPath(pXmlDoc, sThemeColorPath + "[12]", "name"_ostr, u"followed-hyperlink"_ustr); + assertXPath(pXmlDoc, sThemeColorPath + "[12]", "color"_ostr, u"#b0b0b0"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf157018_ThemeImportDraw) @@ -791,7 +791,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf157018_ThemeImportDraw) uno::Reference<beans::XPropertySet> xMasterpage(xDrawPage->getMasterPage(), uno::UNO_QUERY); uno::Reference<util::XTheme> xTheme; - xMasterpage->getPropertyValue("Theme") >>= xTheme; + xMasterpage->getPropertyValue(u"Theme"_ustr) >>= xTheme; CPPUNIT_ASSERT(xTheme.is()); // Then make sure it is the custom color theme @@ -800,10 +800,10 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf157018_ThemeImportDraw) auto pTheme = pUnoTheme->getTheme(); CPPUNIT_ASSERT(pTheme); - CPPUNIT_ASSERT_EQUAL(OUString("Custom"), pTheme->GetName()); + CPPUNIT_ASSERT_EQUAL(u"Custom"_ustr, pTheme->GetName()); auto pColorSet = pTheme->getColorSet(); CPPUNIT_ASSERT(pColorSet); - CPPUNIT_ASSERT_EQUAL(OUString("My Colors"), pColorSet->getName()); + CPPUNIT_ASSERT_EQUAL(u"My Colors"_ustr, pColorSet->getName()); // and test some colors CPPUNIT_ASSERT_EQUAL(Color(0xFFFF11), pColorSet->getColor(model::ThemeColorType::Light1)); @@ -819,7 +819,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, test_scene3d_ooxml_light) loadFromFile(u"Scene3d_LightRig_threePt.pptx"); // Without fix this would have failed with validation error. - save("impress8"); + save(u"impress8"_ustr); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index 5da0c51d73ea..e3ee10a5c1d3 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -35,7 +35,7 @@ public: }; XmloffStyleTest::XmloffStyleTest() - : UnoApiXmlTest("/xmloff/qa/unit/data/") + : UnoApiXmlTest(u"/xmloff/qa/unit/data/"_ustr) { } @@ -56,11 +56,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFillImageBase64) loadFromFile(u"fill-image-base64.fodg"); uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); uno::Reference<container::XNameContainer> xBitmaps( - xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY); + xFactory->createInstance(u"com.sun.star.drawing.BitmapTable"_ustr), uno::UNO_QUERY); // Without the accompanying fix in place, this test would have failed, as the base64 stream was // not considered when parsing the fill-image style. - CPPUNIT_ASSERT(xBitmaps->hasByName("libreoffice_0")); + CPPUNIT_ASSERT(xBitmaps->hasByName(u"libreoffice_0"_ustr)); } namespace @@ -91,13 +91,13 @@ Color asColor(com::sun::star::rendering::RGBColor const& rRGBColor) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFontSorting) { // Given an empty document with default fonts (Liberation Sans, Lucida Sans, etc): - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); // When saving that document to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure <style:font-face> elements are sorted (by style:name="..."): - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); xmlXPathObjectPtr pXPath = getXPathNode( pXmlDoc, "/office:document-content/office:font-face-decls/style:font-face"_ostr); xmlNodeSetPtr pXmlNodes = pXPath->nodesetval; @@ -158,12 +158,12 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testRtlGutter) uno::UNO_QUERY); uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); - uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), - uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xStandard(xStyleFamily->getByName("Standard"), + uno::Reference<container::XNameAccess> xStyleFamily( + xStyleFamilies->getByName(u"PageStyles"_ustr), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xStandard(xStyleFamily->getByName(u"Standard"_ustr), uno::UNO_QUERY); bool bRtlGutter{}; - xStandard->getPropertyValue("RtlGutter") >>= bRtlGutter; + xStandard->getPropertyValue(u"RtlGutter"_ustr) >>= bRtlGutter; // Without the accompanying fix in place, this test would have failed as // <style:page-layout-properties>'s style:writing-mode="..." did not affect RtlGutter. CPPUNIT_ASSERT(bRtlGutter); @@ -190,17 +190,17 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); pBatch->commit(); - save("writer8"); + save(u"writer8"_ustr); // With applied fix for tdf150407 still loext:writing-mode="bt-lr" has to be written. - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); assertXPath(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:name='FrameBTLR']/" "style:graphic-properties[@loext:writing-mode]"_ostr); assertXPath(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:name='FrameBTLR']/" "style:graphic-properties"_ostr, - "writing-mode"_ostr, "bt-lr"); + "writing-mode"_ostr, u"bt-lr"_ustr); } loadFromFile(u"tdf150407_WritingModeBTLR_style.odt"); @@ -210,11 +210,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); pBatch->commit(); - save("writer8"); + save(u"writer8"_ustr); // Without the fix an faulty 'writing-mode="bt-lr"' attribute was written in productive build. // A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/" "style:style[@style:name='FrameBTLR']/style:graphic-properties"_ostr, @@ -243,11 +243,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); pBatch->commit(); - save("writer8"); + save(u"writer8"_ustr); // With applied fix for tdf150407 still loext:vertical-rel="page-content-bottom" has to be // written. - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); assertXPath( pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" @@ -256,7 +256,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" "style:graphic-properties"_ostr, - "vertical-rel"_ostr, "page-content-bottom"); + "vertical-rel"_ostr, u"page-content-bottom"_ustr); } loadFromFile(u"tdf150407_PosRelBottomMargin.docx"); @@ -266,11 +266,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); pBatch->commit(); - save("writer8"); + save(u"writer8"_ustr); // Without the fix an faulty 'vertical-rel="page-content-bottom"' attribute was written in // productive build. A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); assertXPathNoAttribute(pXmlDoc, "/office:document-content/office:automatic-styles/" "style:style[@style:name='gr1']/style:graphic-properties"_ostr, @@ -299,11 +299,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); pBatch->commit(); - save("writer8"); + save(u"writer8"_ustr); // With applied fix for tdf150407 still loext:vertical-rel="page-content-top has to be // written. - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); assertXPath( pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" @@ -312,7 +312,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" "style:graphic-properties"_ostr, - "vertical-rel"_ostr, "page-content-top"); + "vertical-rel"_ostr, u"page-content-top"_ustr); } loadFromFile(u"tdf150407_PosRelTopMargin.docx"); @@ -322,11 +322,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); pBatch->commit(); - save("writer8"); + save(u"writer8"_ustr); // Without the fix an faulty 'vertical-rel="page-content-top"' attribute was written in // productive build. A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); assertXPathNoAttribute(pXmlDoc, "/office:document-content/office:automatic-styles/" "style:style[@style:name='gr1']/style:graphic-properties"_ostr, @@ -341,24 +341,24 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew) loadFromFile(u"MCGR_OldToNew.odg"); // saveAndReload includes validation and must not fail with the new elements and attributes. - saveAndReload("draw8"); + saveAndReload(u"draw8"_ustr); // Examine file markup // For compatibility the file should still have the old attributes 'start-color' and 'end-color' - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); OString sPath = "/office:document-styles/office:styles/draw:gradient[@draw:name='red2yellow']"_ostr; - assertXPath(pXmlDoc, sPath, "start-color"_ostr, "#ff0000"); - assertXPath(pXmlDoc, sPath, "end-color"_ostr, "#ffff00"); + assertXPath(pXmlDoc, sPath, "start-color"_ostr, u"#ff0000"_ustr); + assertXPath(pXmlDoc, sPath, "end-color"_ostr, u"#ffff00"_ustr); // And it must have the new 'gradient-stop' elements. // The prefix 'loext' needs to be adapted, when the element is available in ODF strict. - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset"_ostr, "0"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-type"_ostr, "rgb"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value"_ostr, "#ff0000"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset"_ostr, "1"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-type"_ostr, "rgb"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value"_ostr, "#ffff00"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset"_ostr, u"0"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-type"_ostr, u"rgb"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value"_ostr, u"#ff0000"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset"_ostr, u"1"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-type"_ostr, u"rgb"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value"_ostr, u"#ffff00"_ustr); // Examine reloaded file uno::Reference<drawing::XShape> xShape(getShape(0)); @@ -367,10 +367,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew) // The old properties need to be still available, as they might be used in macros. OUString sGradientName; - xShapeProperties->getPropertyValue("FillGradientName") >>= sGradientName; + xShapeProperties->getPropertyValue(u"FillGradientName"_ustr) >>= sGradientName; CPPUNIT_ASSERT_EQUAL(u"red2yellow"_ustr, sGradientName); awt::Gradient2 aGradient; - xShapeProperties->getPropertyValue("FillGradient") >>= aGradient; + xShapeProperties->getPropertyValue(u"FillGradient"_ustr) >>= aGradient; CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, Color(ColorTransparency, aGradient.StartColor)); CPPUNIT_ASSERT_EQUAL(COL_YELLOW, Color(ColorTransparency, aGradient.EndColor)); @@ -395,29 +395,29 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew_opacity) loadFromFile(u"MCGR_OldToNew_opacity.odg"); // saveAndReload includes validation and must not fail with the new elements and attributes. - saveAndReload("draw8"); + saveAndReload(u"draw8"_ustr); // Examine file markup // For compatibility the file should still have the old attributes. - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); OString sPath = "/office:document-styles/office:styles/draw:opacity"_ostr; - assertXPath(pXmlDoc, sPath, "start"_ostr, "10%"); // UI 90% transparency - assertXPath(pXmlDoc, sPath, "end"_ostr, "100%"); // UI 0% transparency - assertXPath(pXmlDoc, sPath, "border"_ostr, "20%"); - assertXPath(pXmlDoc, sPath, "cx"_ostr, "50%"); - assertXPath(pXmlDoc, sPath, "cy"_ostr, "50%"); - assertXPath(pXmlDoc, sPath, "style"_ostr, "radial"); + assertXPath(pXmlDoc, sPath, "start"_ostr, u"10%"_ustr); // UI 90% transparency + assertXPath(pXmlDoc, sPath, "end"_ostr, u"100%"_ustr); // UI 0% transparency + assertXPath(pXmlDoc, sPath, "border"_ostr, u"20%"_ustr); + assertXPath(pXmlDoc, sPath, "cx"_ostr, u"50%"_ustr); + assertXPath(pXmlDoc, sPath, "cy"_ostr, u"50%"_ustr); + assertXPath(pXmlDoc, sPath, "style"_ostr, u"radial"_ustr); // And it must have the new 'opacity-stop' elements. // The prefix 'loext' needs to be adapted, when the element is available in ODF strict. OString sFirstStop = sPath + "/loext:opacity-stop[1]"; - assertXPath(pXmlDoc, sFirstStop, "offset"_ostr, "0"); + assertXPath(pXmlDoc, sFirstStop, "offset"_ostr, u"0"_ustr); // Because of converting through color, the grade of opacity is not exact "0.1" double fOpacity = getXPathContent(pXmlDoc, sFirstStop + "/@svg:stop-opacity").toDouble(); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, fOpacity, 0.002); - assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "offset"_ostr, "1"); - assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "stop-opacity"_ostr, "1"); + assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "offset"_ostr, u"1"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "stop-opacity"_ostr, u"1"_ustr); // Examine reloaded file uno::Reference<drawing::XShape> xShape(getShape(0)); @@ -426,7 +426,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew_opacity) // The old properties need to be still available, as they might be used in macros. awt::Gradient2 aGradient; - xShapeProperties->getPropertyValue("FillTransparenceGradient") >>= aGradient; + xShapeProperties->getPropertyValue(u"FillTransparenceGradient"_ustr) >>= aGradient; CPPUNIT_ASSERT_EQUAL(Color(0xE5E5E5), Color(ColorTransparency, aGradient.StartColor)); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, aGradient.EndColor)); CPPUNIT_ASSERT_EQUAL(sal_Int16(20), aGradient.Border); @@ -455,32 +455,32 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_threeStops) loadFromFile(u"MCGR_threeStops.fodt"); // saveAndReload includes validation and must not fail with the new elements and attributes. - saveAndReload("draw8"); + saveAndReload(u"draw8"_ustr); // Examine file markup // For compatibility the file should still have the old attributes 'start-color' and 'end-color' - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); OString sPath = "/office:document-styles/office:styles/draw:gradient[@draw:name='threeStops']"_ostr; - assertXPath(pXmlDoc, sPath, "start-color"_ostr, "#ff0000"); - assertXPath(pXmlDoc, sPath, "end-color"_ostr, "#ffff00"); - assertXPath(pXmlDoc, sPath, "style"_ostr, "square"); - assertXPath(pXmlDoc, sPath, "cx"_ostr, "0%"); - assertXPath(pXmlDoc, sPath, "cy"_ostr, "50%"); - assertXPath(pXmlDoc, sPath, "angle"_ostr, "45deg"); - assertXPath(pXmlDoc, sPath, "border"_ostr, "10%"); + assertXPath(pXmlDoc, sPath, "start-color"_ostr, u"#ff0000"_ustr); + assertXPath(pXmlDoc, sPath, "end-color"_ostr, u"#ffff00"_ustr); + assertXPath(pXmlDoc, sPath, "style"_ostr, u"square"_ustr); + assertXPath(pXmlDoc, sPath, "cx"_ostr, u"0%"_ustr); + assertXPath(pXmlDoc, sPath, "cy"_ostr, u"50%"_ustr); + assertXPath(pXmlDoc, sPath, "angle"_ostr, u"45deg"_ustr); + assertXPath(pXmlDoc, sPath, "border"_ostr, u"10%"_ustr); // And it must have the new 'gradient-stop' elements. // The prefix 'loext' needs to be adapted, when the element is available in ODF strict. - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset"_ostr, "0"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-type"_ostr, "rgb"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value"_ostr, "#ff0000"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset"_ostr, "0.3"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-type"_ostr, "rgb"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value"_ostr, "#0099bb"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "offset"_ostr, "1"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "color-type"_ostr, "rgb"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "color-value"_ostr, "#ffff00"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset"_ostr, u"0"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-type"_ostr, u"rgb"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value"_ostr, u"#ff0000"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset"_ostr, u"0.3"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-type"_ostr, u"rgb"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value"_ostr, u"#0099bb"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "offset"_ostr, u"1"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "color-type"_ostr, u"rgb"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[3]", "color-value"_ostr, u"#ffff00"_ustr); // Examine reloaded file uno::Reference<drawing::XShape> xShape(getShape(0)); @@ -489,10 +489,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_threeStops) // The old properties need to be still available, as they might be used in macros. OUString sGradientName; - xShapeProperties->getPropertyValue("FillGradientName") >>= sGradientName; + xShapeProperties->getPropertyValue(u"FillGradientName"_ustr) >>= sGradientName; CPPUNIT_ASSERT_EQUAL(u"threeStops"_ustr, sGradientName); awt::Gradient2 aGradient; - xShapeProperties->getPropertyValue("FillGradient") >>= aGradient; + xShapeProperties->getPropertyValue(u"FillGradient"_ustr) >>= aGradient; CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, Color(ColorTransparency, aGradient.StartColor)); CPPUNIT_ASSERT_EQUAL(COL_YELLOW, Color(ColorTransparency, aGradient.EndColor)); CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_SQUARE, aGradient.Style); @@ -535,24 +535,24 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBorderRestoration) // Save to ODF_LATEST which is currently ODF 1.3 extended. Make sure gradient-stop elements have // offsets 0 and 1, and border is written as 50%. SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_LATEST); - save("impress8"); - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + save(u"impress8"_ustr); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); OString sPath = "/office:document-styles/office:styles/draw:gradient[@draw:name='Gradient_20_1']"_ostr; - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value"_ostr, "#ff0000"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset"_ostr, "1"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value"_ostr, "#ffff00"); - assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset"_ostr, "0"); - assertXPath(pXmlDoc, sPath, "border"_ostr, "50%"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value"_ostr, u"#ff0000"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset"_ostr, u"1"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value"_ostr, u"#ffff00"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset"_ostr, u"0"_ustr); + assertXPath(pXmlDoc, sPath, "border"_ostr, u"50%"_ustr); // Save to ODF 1.3 strict and make sure border, start-color and end-color are suitable set. SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); - save("impress8"); - pXmlDoc = parseExport("styles.xml"); + save(u"impress8"_ustr); + pXmlDoc = parseExport(u"styles.xml"_ustr); assertXPath(pXmlDoc, sPath + "/loext:gradient-stop", 0); - assertXPath(pXmlDoc, sPath, "start-color"_ostr, "#ffff00"); - assertXPath(pXmlDoc, sPath, "end-color"_ostr, "#ff0000"); - assertXPath(pXmlDoc, sPath, "border"_ostr, "50%"); + assertXPath(pXmlDoc, sPath, "start-color"_ostr, u"#ffff00"_ustr); + assertXPath(pXmlDoc, sPath, "end-color"_ostr, u"#ff0000"_ustr); + assertXPath(pXmlDoc, sPath, "border"_ostr, u"50%"_ustr); // Set back to original ODF default version. SetODFDefaultVersion(nCurrentODFVersion); @@ -573,23 +573,23 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testTransparencyBorderRestoration) // Save to ODF_LATEST which is currently ODF 1.3 extended. Make sure transparency gradient-stop //elements are written with offset 0 and 1, and border is written as 40%. SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_LATEST); - save("impress8"); - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + save(u"impress8"_ustr); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); OString sPath = "/office:document-styles/office:styles/draw:opacity[1]"_ostr; - assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "stop-opacity"_ostr, "0.9"); - assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "offset"_ostr, "1"); - assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[1]", "stop-opacity"_ostr, "0"); - assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[1]", "offset"_ostr, "0"); - assertXPath(pXmlDoc, sPath, "border"_ostr, "40%"); + assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "stop-opacity"_ostr, u"0.9"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[2]", "offset"_ostr, u"1"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[1]", "stop-opacity"_ostr, u"0"_ustr); + assertXPath(pXmlDoc, sPath + "/loext:opacity-stop[1]", "offset"_ostr, u"0"_ustr); + assertXPath(pXmlDoc, sPath, "border"_ostr, u"40%"_ustr); // Save to ODF 1.3 strict and make sure border, start and end opacity are suitable set. SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); - save("impress8"); - pXmlDoc = parseExport("styles.xml"); + save(u"impress8"_ustr); + pXmlDoc = parseExport(u"styles.xml"_ustr); assertXPath(pXmlDoc, sPath + "/loext:opacity-stop", 0); - assertXPath(pXmlDoc, sPath, "start"_ostr, "0%"); - assertXPath(pXmlDoc, sPath, "end"_ostr, "90%"); - assertXPath(pXmlDoc, sPath, "border"_ostr, "40%"); + assertXPath(pXmlDoc, sPath, "start"_ostr, u"0%"_ustr); + assertXPath(pXmlDoc, sPath, "end"_ostr, u"90%"_ustr); + assertXPath(pXmlDoc, sPath, "border"_ostr, u"40%"_ustr); // Set back to original ODF default version. SetODFDefaultVersion(nCurrentODFVersion); @@ -609,8 +609,8 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAxialGradientCompatible) //Round-trip through OOXML. // FixMe tdf#153183. Here "Attribute 'ID' is not allowed to appear in element 'v:rect'". skipValidation(); - saveAndReload("Office Open XML Text"); - saveAndReload("writer8"); + saveAndReload(u"Office Open XML Text"_ustr); + saveAndReload(u"writer8"_ustr); // Examine reloaded file uno::Reference<drawing::XShape> xShape(getShape(0)); @@ -619,7 +619,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAxialGradientCompatible) // Without fix these would have failed with Style=0 (=LINEAR), StartColor=0xFFFF00 and Border=0. awt::Gradient2 aGradient; - xShapeProperties->getPropertyValue("FillGradient") >>= aGradient; + xShapeProperties->getPropertyValue(u"FillGradient"_ustr) >>= aGradient; CPPUNIT_ASSERT_EQUAL_MESSAGE("gradient style", awt::GradientStyle_AXIAL, aGradient.Style); CPPUNIT_ASSERT_EQUAL_MESSAGE("EndColor", sal_Int32(0xFFFF00), aGradient.EndColor); CPPUNIT_ASSERT_EQUAL_MESSAGE("StartColor", sal_Int32(0x1E90FF), aGradient.StartColor); @@ -641,8 +641,8 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAxialTransparencyCompatible) //Round-trip through OOXML. // FixMe tdf#153183, and error in charSpace and in CharacterSet //skipValidation(); - saveAndReload("Office Open XML Text"); - saveAndReload("writer8"); + saveAndReload(u"Office Open XML Text"_ustr); + saveAndReload(u"writer8"_ustr); // Examine reloaded file uno::Reference<drawing::XShape> xShape(getShape(0)); @@ -651,7 +651,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAxialTransparencyCompatible) // Without fix these would have failed with Style=LINEAR, StartColor=0xCCCCCC and wrong Border. awt::Gradient2 aTransGradient; - xShapeProperties->getPropertyValue("FillTransparenceGradient") >>= aTransGradient; + xShapeProperties->getPropertyValue(u"FillTransparenceGradient"_ustr) >>= aTransGradient; CPPUNIT_ASSERT_EQUAL_MESSAGE("gradient style", awt::GradientStyle_AXIAL, aTransGradient.Style); CPPUNIT_ASSERT_EQUAL_MESSAGE("EndColor", sal_Int32(0xCCCCCC), aTransGradient.EndColor); CPPUNIT_ASSERT_EQUAL_MESSAGE("StartColor", sal_Int32(0x191919), aTransGradient.StartColor); diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index e6433b2b70f9..1679af04bc1f 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -39,7 +39,7 @@ public: }; XmloffStyleTest::XmloffStyleTest() - : UnoApiXmlTest("/xmloff/qa/unit/data/") + : UnoApiXmlTest(u"/xmloff/qa/unit/data/"_ustr) { } @@ -52,11 +52,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMailMergeInEditeng) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentProperty) { - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Sequence<beans::PropertyValue> aCommentProps = comphelper::InitPropertySequence({ - { "Text", uno::Any(OUString("comment")) }, + { "Text", uno::Any(u"comment"_ustr) }, }); - dispatchCommand(mxComponent, ".uno:InsertAnnotation", aCommentProps); + dispatchCommand(mxComponent, u".uno:InsertAnnotation"_ustr, aCommentProps); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); @@ -64,25 +64,25 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentProperty) uno::Reference<container::XEnumerationAccess> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xPortionEnum = xPara->createEnumeration(); uno::Reference<beans::XPropertySet> xPortion(xPortionEnum->nextElement(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xField(xPortion->getPropertyValue("TextField"), + uno::Reference<beans::XPropertySet> xField(xPortion->getPropertyValue(u"TextField"_ustr), uno::UNO_QUERY); - xField->setPropertyValue("Resolved", uno::Any(true)); - xField->setPropertyValue("ParentName", uno::Any(OUString("parent_comment_name"))); + xField->setPropertyValue(u"Resolved"_ustr, uno::Any(true)); + xField->setPropertyValue(u"ParentName"_ustr, uno::Any(u"parent_comment_name"_ustr)); - saveAndReload("writer8"); + saveAndReload(u"writer8"_ustr); xTextDocument.set(mxComponent, uno::UNO_QUERY); xParaEnumAccess.set(xTextDocument->getText(), uno::UNO_QUERY); xParaEnum = xParaEnumAccess->createEnumeration(); xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); xPortionEnum = xPara->createEnumeration(); xPortion.set(xPortionEnum->nextElement(), uno::UNO_QUERY); - xField.set(xPortion->getPropertyValue("TextField"), uno::UNO_QUERY); + xField.set(xPortion->getPropertyValue(u"TextField"_ustr), uno::UNO_QUERY); bool bResolved = false; - xField->getPropertyValue("Resolved") >>= bResolved; + xField->getPropertyValue(u"Resolved"_ustr) >>= bResolved; OUString parentName; - xField->getPropertyValue("ParentName") >>= parentName; + xField->getPropertyValue(u"ParentName"_ustr) >>= parentName; CPPUNIT_ASSERT_EQUAL( - OUString("parent_comment_name"), + u"parent_comment_name"_ustr, parentName); // Check if the parent comment name is written and read correctly. // Without the accompanying fix in place, this test would have failed, as the resolved state was // not saved for non-range comments. @@ -92,19 +92,19 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentProperty) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyLocalUrl) { // Given a document with a biblio field, with non-empty LocalURL: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xField( - xFactory->createInstance("com.sun.star.text.TextField.Bibliography"), uno::UNO_QUERY); + xFactory->createInstance(u"com.sun.star.text.TextField.Bibliography"_ustr), uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aFields = { - comphelper::makePropertyValue("BibiliographicType", text::BibliographyDataType::WWW), - comphelper::makePropertyValue("Identifier", OUString("AT")), - comphelper::makePropertyValue("Author", OUString("Author")), - comphelper::makePropertyValue("Title", OUString("Title")), - comphelper::makePropertyValue("URL", OUString("http://www.example.com/test.pdf#page=1")), - comphelper::makePropertyValue("LocalURL", OUString("file:///home/me/test.pdf")), + comphelper::makePropertyValue(u"BibiliographicType"_ustr, text::BibliographyDataType::WWW), + comphelper::makePropertyValue(u"Identifier"_ustr, u"AT"_ustr), + comphelper::makePropertyValue(u"Author"_ustr, u"Author"_ustr), + comphelper::makePropertyValue(u"Title"_ustr, u"Title"_ustr), + comphelper::makePropertyValue(u"URL"_ustr, u"http://www.example.com/test.pdf#page=1"_ustr), + comphelper::makePropertyValue(u"LocalURL"_ustr, u"file:///home/me/test.pdf"_ustr), }; - xField->setPropertyValue("Fields", uno::Any(aFields)); + xField->setPropertyValue(u"Fields"_ustr, uno::Any(aFields)); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); @@ -112,7 +112,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyLocalUrl) xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false); // When invoking ODT export + import on it: - saveAndReload("writer8"); + saveAndReload(u"writer8"_ustr); // Without the accompanying fix in place, this test would have resulted in an assertion failure, // as LocalURL was mapped to XML_TOKEN_INVALID. @@ -124,27 +124,28 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyLocalUrl) uno::Reference<container::XEnumerationAccess> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xPortionEnum = xPara->createEnumeration(); uno::Reference<beans::XPropertySet> xPortion(xPortionEnum->nextElement(), uno::UNO_QUERY); - xField.set(xPortion->getPropertyValue("TextField"), uno::UNO_QUERY); - comphelper::SequenceAsHashMap aMap(xField->getPropertyValue("Fields")); - CPPUNIT_ASSERT(aMap.contains("LocalURL")); - auto aActual = aMap["LocalURL"].get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("file:///home/me/test.pdf"), aActual); + xField.set(xPortion->getPropertyValue(u"TextField"_ustr), uno::UNO_QUERY); + comphelper::SequenceAsHashMap aMap(xField->getPropertyValue(u"Fields"_ustr)); + CPPUNIT_ASSERT(aMap.contains(u"LocalURL"_ustr)); + auto aActual = aMap[u"LocalURL"_ustr].get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"file:///home/me/test.pdf"_ustr, aActual); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyTargetURL1) { // Given a document with a biblio field, with non-empty LocalURL: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xField( - xFactory->createInstance("com.sun.star.text.TextField.Bibliography"), uno::UNO_QUERY); + xFactory->createInstance(u"com.sun.star.text.TextField.Bibliography"_ustr), uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aFields = { - comphelper::makePropertyValue("Identifier", OUString("AT")), - comphelper::makePropertyValue("URL", OUString("https://display.url/test1.pdf#page=1")), - comphelper::makePropertyValue("TargetType", OUString("1")), - comphelper::makePropertyValue("TargetURL", OUString("https://target.url/test2.pdf#page=2")), + comphelper::makePropertyValue(u"Identifier"_ustr, u"AT"_ustr), + comphelper::makePropertyValue(u"URL"_ustr, u"https://display.url/test1.pdf#page=1"_ustr), + comphelper::makePropertyValue(u"TargetType"_ustr, u"1"_ustr), + comphelper::makePropertyValue(u"TargetURL"_ustr, + u"https://target.url/test2.pdf#page=2"_ustr), }; - xField->setPropertyValue("Fields", uno::Any(aFields)); + xField->setPropertyValue(u"Fields"_ustr, uno::Any(aFields)); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); @@ -152,7 +153,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyTargetURL1) xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false); // When invoking ODT export + import on it: - saveAndReload("writer8"); + saveAndReload(u"writer8"_ustr); // Then make sure that URL, TargetURL and UseTargetURL are preserved and independent: xTextDocument.set(mxComponent, uno::UNO_QUERY); @@ -162,19 +163,19 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyTargetURL1) uno::Reference<container::XEnumerationAccess> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xPortionEnum = xPara->createEnumeration(); uno::Reference<beans::XPropertySet> xPortion(xPortionEnum->nextElement(), uno::UNO_QUERY); - xField.set(xPortion->getPropertyValue("TextField"), uno::UNO_QUERY); - comphelper::SequenceAsHashMap aMap(xField->getPropertyValue("Fields")); + xField.set(xPortion->getPropertyValue(u"TextField"_ustr), uno::UNO_QUERY); + comphelper::SequenceAsHashMap aMap(xField->getPropertyValue(u"Fields"_ustr)); - CPPUNIT_ASSERT(aMap.contains("URL")); - CPPUNIT_ASSERT_EQUAL(OUString("https://display.url/test1.pdf#page=1"), - aMap["URL"].get<OUString>()); + CPPUNIT_ASSERT(aMap.contains(u"URL"_ustr)); + CPPUNIT_ASSERT_EQUAL(u"https://display.url/test1.pdf#page=1"_ustr, + aMap[u"URL"_ustr].get<OUString>()); - CPPUNIT_ASSERT(aMap.contains("TargetURL")); - CPPUNIT_ASSERT_EQUAL(OUString("https://target.url/test2.pdf#page=2"), - aMap["TargetURL"].get<OUString>()); + CPPUNIT_ASSERT(aMap.contains(u"TargetURL"_ustr)); + CPPUNIT_ASSERT_EQUAL(u"https://target.url/test2.pdf#page=2"_ustr, + aMap[u"TargetURL"_ustr].get<OUString>()); - CPPUNIT_ASSERT(aMap.contains("TargetType")); - CPPUNIT_ASSERT_EQUAL(OUString("1"), aMap["TargetType"].get<OUString>()); + CPPUNIT_ASSERT(aMap.contains(u"TargetType"_ustr)); + CPPUNIT_ASSERT_EQUAL(u"1"_ustr, aMap[u"TargetType"_ustr].get<OUString>()); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentTableBorder) @@ -195,23 +196,24 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testParaStyleListLevel) uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); uno::Reference<container::XNameAccess> xStyleFamily( - xStyleFamilies->getByName("ParagraphStyles"), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xStyle(xStyleFamily->getByName("mystyle"), uno::UNO_QUERY); + xStyleFamilies->getByName(u"ParagraphStyles"_ustr), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xStyle(xStyleFamily->getByName(u"mystyle"_ustr), + uno::UNO_QUERY); sal_Int16 nNumberingLevel{}; - CPPUNIT_ASSERT(xStyle->getPropertyValue("NumberingLevel") >>= nNumberingLevel); + CPPUNIT_ASSERT(xStyle->getPropertyValue(u"NumberingLevel"_ustr) >>= nNumberingLevel); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), nNumberingLevel); // Test the export as well: - save("writer8"); + save(u"writer8"_ustr); // Then make sure we save the style's numbering level: - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); // Without the accompanying fix in place, this failed with: // - XPath '/office:document-styles/office:styles/style:style[@style:name='mystyle']' no attribute 'list-level' exist // i.e. a custom NumberingLevel was lost on save. assertXPath(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:name='mystyle']"_ostr, - "list-level"_ostr, "2"); + "list-level"_ostr, u"2"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testContinueNumberingWord) @@ -228,12 +230,12 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testContinueNumberingWord) xParaEnum->nextElement(); xParaEnum->nextElement(); uno::Reference<beans::XPropertySet> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); - auto aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); + auto aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); // Without the accompanying fix in place, this failed with: // - Expected: 2. // - Actual : 1. // i.e. the numbering was not continued, like in Word. - CPPUNIT_ASSERT_EQUAL(OUString("2."), aActual); + CPPUNIT_ASSERT_EQUAL(u"2."_ustr, aActual); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListId) @@ -242,10 +244,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListId) loadFromFile(u"list-id.fodt"); // When storing that document as ODF: - save("writer8"); + save(u"writer8"_ustr); // Then make sure that unreferenced xml:id="..." attributes are not written: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this failed with: // - XPath '//text:list' unexpected 'id' attribute // i.e. xml:id="..." was written unconditionally, even when no other list needed it. @@ -262,55 +264,55 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListId2) auto xParaEnum(xParaEnumAccess->createEnumeration()); auto xPara(xParaEnum->nextElement().queryThrow<beans::XPropertySet>()); - auto aActual(xPara->getPropertyValue("ListLabelString").get<OUString>()); - CPPUNIT_ASSERT_EQUAL(OUString("1."), aActual); + auto aActual(xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"1."_ustr, aActual); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("2."), aActual); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"2."_ustr, aActual); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("3."), aActual); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"3."_ustr, aActual); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("4."), aActual); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"4."_ustr, aActual); // When storing that document as ODF: // Without the fix in place, automatic validation would fail with: // Error: "list123456789012345" is referenced by an IDREF, but not defined. - saveAndReload("writer8"); + saveAndReload(u"writer8"_ustr); xTextDocument.set(mxComponent.queryThrow<css::text::XTextDocument>()); xParaEnumAccess.set(xTextDocument->getText().queryThrow<css::container::XEnumerationAccess>()); xParaEnum.set(xParaEnumAccess->createEnumeration()); xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("1."), aActual); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"1."_ustr, aActual); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("2."), aActual); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"2."_ustr, aActual); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("3."), aActual); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"3."_ustr, aActual); xParaEnum->nextElement(); // Skip empty intermediate paragraph // Check that the last item number is correct xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); // Without the fix in place, this would fail with: // - Expected: 4. // - Actual : 1. // i.e. the numbering was not continued. - CPPUNIT_ASSERT_EQUAL(OUString("4."), aActual); + CPPUNIT_ASSERT_EQUAL(u"4."_ustr, aActual); // Then make sure that required xml:id="..." attributes is written when the style changes: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); CPPUNIT_ASSERT(pXmlDoc); // Without the fix in place, this would fail, // i.e. xml:id="..." was omitted, even though it was needed for the next item. @@ -325,7 +327,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListIdState) { // tdf#149668: given a document with 3 paragraphs: an outer numbering on para 1 & 3, an inner // numbering on para 2: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); auto xTextDocument(mxComponent.queryThrow<text::XTextDocument>()); auto xText(xTextDocument->getText()); xText->insertControlCharacter(xText->getEnd(), css::text::ControlCharacter::PARAGRAPH_BREAK, @@ -336,15 +338,15 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListIdState) auto paraEnumAccess(xText.queryThrow<container::XEnumerationAccess>()); auto paraEnum(paraEnumAccess->createEnumeration()); auto xParaProps(paraEnum->nextElement().queryThrow<beans::XPropertySet>()); - xParaProps->setPropertyValue("NumberingStyleName", css::uno::Any(OUString("Numbering ABC"))); + xParaProps->setPropertyValue(u"NumberingStyleName"_ustr, css::uno::Any(u"Numbering ABC"_ustr)); xParaProps.set(paraEnum->nextElement().queryThrow<beans::XPropertySet>()); - xParaProps->setPropertyValue("NumberingStyleName", css::uno::Any(OUString("Numbering 123"))); + xParaProps->setPropertyValue(u"NumberingStyleName"_ustr, css::uno::Any(u"Numbering 123"_ustr)); xParaProps.set(paraEnum->nextElement().queryThrow<beans::XPropertySet>()); - xParaProps->setPropertyValue("NumberingStyleName", css::uno::Any(OUString("Numbering ABC"))); + xParaProps->setPropertyValue(u"NumberingStyleName"_ustr, css::uno::Any(u"Numbering ABC"_ustr)); // When storing that document as ODF: - save("writer8"); - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + save(u"writer8"_ustr); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Make sure that xml:id="..." gets written for para 1, as it'll be continued in para 3. // Without the accompanying fix in place, this test would have failed, @@ -368,79 +370,79 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListIdOnRestart) auto xParaEnum(xParaEnumAccess->createEnumeration()); auto xPara(xParaEnum->nextElement().queryThrow<beans::XPropertySet>()); - auto aActual(xPara->getPropertyValue("ListLabelString").get<OUString>()); - CPPUNIT_ASSERT_EQUAL(OUString("1."), aActual); - OUString list_id = xPara->getPropertyValue("ListId").get<OUString>(); + auto aActual(xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"1."_ustr, aActual); + OUString list_id = xPara->getPropertyValue(u"ListId"_ustr).get<OUString>(); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY_THROW); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("2."), aActual); - CPPUNIT_ASSERT_EQUAL(list_id, xPara->getPropertyValue("ListId").get<OUString>()); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"2."_ustr, aActual); + CPPUNIT_ASSERT_EQUAL(list_id, xPara->getPropertyValue(u"ListId"_ustr).get<OUString>()); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); // Check that restart was applied correctly, with simple 'text:continue-numbering="true"' - CPPUNIT_ASSERT_EQUAL(OUString("1."), aActual); - CPPUNIT_ASSERT_EQUAL(list_id, xPara->getPropertyValue("ListId").get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"1."_ustr, aActual); + CPPUNIT_ASSERT_EQUAL(list_id, xPara->getPropertyValue(u"ListId"_ustr).get<OUString>()); // When storing that document as ODF: - saveAndReload("writer8"); + saveAndReload(u"writer8"_ustr); xTextDocument.set(mxComponent, uno::UNO_QUERY_THROW); xParaEnumAccess.set(xTextDocument->getText(), uno::UNO_QUERY_THROW); xParaEnum.set(xParaEnumAccess->createEnumeration()); xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY_THROW); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("1."), aActual); - list_id = xPara->getPropertyValue("ListId").get<OUString>(); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"1."_ustr, aActual); + list_id = xPara->getPropertyValue(u"ListId"_ustr).get<OUString>(); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY_THROW); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("2."), aActual); - CPPUNIT_ASSERT_EQUAL(list_id, xPara->getPropertyValue("ListId").get<OUString>()); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"2."_ustr, aActual); + CPPUNIT_ASSERT_EQUAL(list_id, xPara->getPropertyValue(u"ListId"_ustr).get<OUString>()); xParaEnum->nextElement(); // Skip empty intermediate paragraph xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY_THROW); - aActual = xPara->getPropertyValue("ListLabelString").get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("1."), aActual); - CPPUNIT_ASSERT_EQUAL(list_id, xPara->getPropertyValue("ListId").get<OUString>()); + aActual = xPara->getPropertyValue(u"ListLabelString"_ustr).get<OUString>(); + CPPUNIT_ASSERT_EQUAL(u"1."_ustr, aActual); + CPPUNIT_ASSERT_EQUAL(list_id, xPara->getPropertyValue(u"ListId"_ustr).get<OUString>()); // Then make sure that no xml:id="..." attribute is written, even in restarted case: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); CPPUNIT_ASSERT(pXmlDoc); assertXPath(pXmlDoc, "//text:list"_ostr, 3); assertXPathNoAttribute(pXmlDoc, "//text:list[1]"_ostr, "id"_ostr); assertXPathNoAttribute(pXmlDoc, "//text:list[2]"_ostr, "id"_ostr); assertXPathNoAttribute(pXmlDoc, "//text:list[3]"_ostr, "id"_ostr); assertXPathNoAttribute(pXmlDoc, "//text:list[3]"_ostr, "continue-list"_ostr); - assertXPath(pXmlDoc, "//text:list[3]"_ostr, "continue-numbering"_ostr, "true"); + assertXPath(pXmlDoc, "//text:list[3]"_ostr, "continue-numbering"_ostr, u"true"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testClearingBreakExport) { // Given a document with a clearing break: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextContent> xLineBreak( - xMSF->createInstance("com.sun.star.text.LineBreak"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.LineBreak"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY); // SwLineBreakClear::ALL; sal_Int16 eClear = 3; - xLineBreakProps->setPropertyValue("Clear", uno::Any(eClear)); + xLineBreakProps->setPropertyValue(u"Clear"_ustr, uno::Any(eClear)); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this failed with: // - XPath '//text:line-break' number of nodes is incorrect // i.e. the clearing break was lost on export. - assertXPath(pXmlDoc, "//text:line-break"_ostr, "clear"_ostr, "all"); + assertXPath(pXmlDoc, "//text:line-break"_ostr, "clear"_ostr, u"all"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testClearingBreakImport) @@ -466,108 +468,109 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testClearingBreakImport) // linebreak, text). uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aTextPortionType; - xPortion->getPropertyValue("TextPortionType") >>= aTextPortionType; - CPPUNIT_ASSERT_EQUAL(OUString("LineBreak"), aTextPortionType); + xPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aTextPortionType; + CPPUNIT_ASSERT_EQUAL(u"LineBreak"_ustr, aTextPortionType); uno::Reference<text::XTextContent> xLineBreak; - xPortion->getPropertyValue("LineBreak") >>= xLineBreak; + xPortion->getPropertyValue(u"LineBreak"_ustr) >>= xLineBreak; uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY); sal_Int16 eClear{}; - xLineBreakProps->getPropertyValue("Clear") >>= eClear; + xLineBreakProps->getPropertyValue(u"Clear"_ustr) >>= eClear; CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(3), eClear); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testRelativeWidth) { // Given a document with an 50% wide text frame: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); - uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), - uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xStyle(xStyleFamily->getByName("Standard"), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamily( + xStyleFamilies->getByName(u"PageStyles"_ustr), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xStyle(xStyleFamily->getByName(u"Standard"_ustr), + uno::UNO_QUERY); // Body frame width is 6cm (2+2cm margin). - xStyle->setPropertyValue("Width", uno::Any(static_cast<sal_Int32>(10000))); + xStyle->setPropertyValue(u"Width"_ustr, uno::Any(static_cast<sal_Int32>(10000))); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextContent> xTextFrame( - xMSF->createInstance("com.sun.star.text.TextFrame"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.TextFrame"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xTextFrameProps(xTextFrame, uno::UNO_QUERY); - xTextFrameProps->setPropertyValue("RelativeWidth", uno::Any(static_cast<sal_Int16>(50))); + xTextFrameProps->setPropertyValue(u"RelativeWidth"_ustr, uno::Any(static_cast<sal_Int16>(50))); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); xText->insertTextContent(xCursor, xTextFrame, /*bAbsorb=*/false); // Body frame width is 16cm. - xStyle->setPropertyValue("Width", uno::Any(static_cast<sal_Int32>(20000))); + xStyle->setPropertyValue(u"Width"_ustr, uno::Any(static_cast<sal_Int32>(20000))); - save("writer8"); + save(u"writer8"_ustr); - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this failed with: // - Expected: 3.1492in (8cm) // - Actual : 0.0161in (0.04 cm) // i.e. the fallback width value wasn't the expected half of the body frame width, but a smaller // value. - assertXPath(pXmlDoc, "//draw:frame"_ostr, "width"_ostr, "3.1492in"); + assertXPath(pXmlDoc, "//draw:frame"_ostr, "width"_ostr, u"3.1492in"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testScaleWidthAndHeight) { // Given a broken document where both IsSyncHeightToWidth and IsSyncWidthToHeight are set to // true: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextContent> xTextFrame( - xMSF->createInstance("com.sun.star.text.TextFrame"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.TextFrame"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xTextFrameProps(xTextFrame, uno::UNO_QUERY); - xTextFrameProps->setPropertyValue("Width", uno::Any(static_cast<sal_Int16>(2000))); - xTextFrameProps->setPropertyValue("Height", uno::Any(static_cast<sal_Int16>(1000))); - xTextFrameProps->setPropertyValue("IsSyncHeightToWidth", uno::Any(true)); - xTextFrameProps->setPropertyValue("IsSyncWidthToHeight", uno::Any(true)); + xTextFrameProps->setPropertyValue(u"Width"_ustr, uno::Any(static_cast<sal_Int16>(2000))); + xTextFrameProps->setPropertyValue(u"Height"_ustr, uno::Any(static_cast<sal_Int16>(1000))); + xTextFrameProps->setPropertyValue(u"IsSyncHeightToWidth"_ustr, uno::Any(true)); + xTextFrameProps->setPropertyValue(u"IsSyncWidthToHeight"_ustr, uno::Any(true)); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); xText->insertTextContent(xCursor, xTextFrame, /*bAbsorb=*/false); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure that we still export a non-zero size: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this failed with: // - Expected: 0.7874in // - Actual : 0in // i.e. the exported size was 0, not 2000 mm100 in inches. - assertXPath(pXmlDoc, "//draw:frame"_ostr, "width"_ostr, "0.7874in"); + assertXPath(pXmlDoc, "//draw:frame"_ostr, "width"_ostr, u"0.7874in"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testContentControlExport) { // Given a document with a content control around one or more text portions: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); - xText->insertString(xCursor, "test", /*bAbsorb=*/false); + xText->insertString(xCursor, u"test"_ustr, /*bAbsorb=*/false); xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<text::XTextContent> xContentControl( - xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.ContentControl"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); - xContentControlProps->setPropertyValue("ShowingPlaceHolder", uno::Any(true)); + xContentControlProps->setPropertyValue(u"ShowingPlaceHolder"_ustr, uno::Any(true)); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this failed with: // - XPath '//loext:content-control' number of nodes is incorrect // i.e. the content control was lost on export. - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "showing-place-holder"_ostr, "true"); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "showing-place-holder"_ostr, u"true"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testContentControlImport) @@ -585,26 +588,26 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testContentControlImport) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aPortionType; - xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; + xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType; // Without the accompanying fix in place, this failed with: // - Expected: ContentControl // - Actual : Text // i.e. the content control was lost on import. - CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + CPPUNIT_ASSERT_EQUAL(u"ContentControl"_ustr, aPortionType); uno::Reference<text::XTextContent> xContentControl; - xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + xTextPortion->getPropertyValue(u"ContentControl"_ustr) >>= xContentControl; uno::Reference<text::XTextRange> xContentControlRange(xContentControl, uno::UNO_QUERY); uno::Reference<text::XText> xText = xContentControlRange->getText(); uno::Reference<container::XEnumerationAccess> xContentEnumAccess(xText, uno::UNO_QUERY); uno::Reference<container::XEnumeration> xContentEnum = xContentEnumAccess->createEnumeration(); uno::Reference<text::XTextRange> xContent(xContentEnum->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("test"), xContent->getString()); + CPPUNIT_ASSERT_EQUAL(u"test"_ustr, xContent->getString()); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCheckboxContentControlExport) { // Given a document with a checkbox content control around a text portion: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); @@ -613,21 +616,21 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCheckboxContentControlExport) xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<text::XTextContent> xContentControl( - xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.ContentControl"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); - xContentControlProps->setPropertyValue("Checkbox", uno::Any(true)); - xContentControlProps->setPropertyValue("Checked", uno::Any(true)); - xContentControlProps->setPropertyValue("CheckedState", uno::Any(u"☒"_ustr)); - xContentControlProps->setPropertyValue("UncheckedState", uno::Any(u"☐"_ustr)); + xContentControlProps->setPropertyValue(u"Checkbox"_ustr, uno::Any(true)); + xContentControlProps->setPropertyValue(u"Checked"_ustr, uno::Any(true)); + xContentControlProps->setPropertyValue(u"CheckedState"_ustr, uno::Any(u"☒"_ustr)); + xContentControlProps->setPropertyValue(u"UncheckedState"_ustr, uno::Any(u"☐"_ustr)); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "checkbox"_ostr, "true"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "checked"_ostr, "true"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "checkbox"_ostr, u"true"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "checked"_ostr, u"true"_ustr); assertXPath(pXmlDoc, "//loext:content-control"_ostr, "checked-state"_ostr, u"☒"_ustr); assertXPath(pXmlDoc, "//loext:content-control"_ostr, "unchecked-state"_ostr, u"☐"_ustr); } @@ -647,24 +650,24 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCheckboxContentControlImport) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aPortionType; - xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; - CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(u"ContentControl"_ustr, aPortionType); uno::Reference<text::XTextContent> xContentControl; - xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + xTextPortion->getPropertyValue(u"ContentControl"_ustr) >>= xContentControl; uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); bool bCheckbox{}; - xContentControlProps->getPropertyValue("Checkbox") >>= bCheckbox; + xContentControlProps->getPropertyValue(u"Checkbox"_ustr) >>= bCheckbox; // Without the accompanying fix in place, this failed, as the checkbox-related attributes were // ignored on import. CPPUNIT_ASSERT(bCheckbox); bool bChecked{}; - xContentControlProps->getPropertyValue("Checked") >>= bChecked; + xContentControlProps->getPropertyValue(u"Checked"_ustr) >>= bChecked; CPPUNIT_ASSERT(bChecked); OUString aCheckedState; - xContentControlProps->getPropertyValue("CheckedState") >>= aCheckedState; + xContentControlProps->getPropertyValue(u"CheckedState"_ustr) >>= aCheckedState; CPPUNIT_ASSERT_EQUAL(u"☒"_ustr, aCheckedState); OUString aUncheckedState; - xContentControlProps->getPropertyValue("UncheckedState") >>= aUncheckedState; + xContentControlProps->getPropertyValue(u"UncheckedState"_ustr) >>= aUncheckedState; CPPUNIT_ASSERT_EQUAL(u"☐"_ustr, aUncheckedState); uno::Reference<text::XTextRange> xContentControlRange(xContentControl, uno::UNO_QUERY); uno::Reference<text::XText> xText = xContentControlRange->getText(); @@ -677,57 +680,60 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCheckboxContentControlImport) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlExport) { // Given a document with a dropdown content control around a text portion: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); - xText->insertString(xCursor, "choose an item", /*bAbsorb=*/false); + xText->insertString(xCursor, u"choose an item"_ustr, /*bAbsorb=*/false); xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<text::XTextContent> xContentControl( - xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.ContentControl"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); { - xContentControlProps->setPropertyValue("DropDown", uno::Any(true)); + xContentControlProps->setPropertyValue(u"DropDown"_ustr, uno::Any(true)); uno::Sequence<beans::PropertyValues> aListItems = { { - comphelper::makePropertyValue("DisplayText", uno::Any(OUString("red"))), - comphelper::makePropertyValue("Value", uno::Any(OUString("R"))), + comphelper::makePropertyValue(u"DisplayText"_ustr, uno::Any(u"red"_ustr)), + comphelper::makePropertyValue(u"Value"_ustr, uno::Any(u"R"_ustr)), }, { - comphelper::makePropertyValue("DisplayText", uno::Any(OUString("green"))), - comphelper::makePropertyValue("Value", uno::Any(OUString("G"))), + comphelper::makePropertyValue(u"DisplayText"_ustr, uno::Any(u"green"_ustr)), + comphelper::makePropertyValue(u"Value"_ustr, uno::Any(u"G"_ustr)), }, { - comphelper::makePropertyValue("DisplayText", uno::Any(OUString("blue"))), - comphelper::makePropertyValue("Value", uno::Any(OUString("B"))), + comphelper::makePropertyValue(u"DisplayText"_ustr, uno::Any(u"blue"_ustr)), + comphelper::makePropertyValue(u"Value"_ustr, uno::Any(u"B"_ustr)), }, }; - xContentControlProps->setPropertyValue("ListItems", uno::Any(aListItems)); + xContentControlProps->setPropertyValue(u"ListItems"_ustr, uno::Any(aListItems)); } xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "dropdown"_ostr, "true"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "dropdown"_ostr, u"true"_ustr); // Without the accompanying fix in place, this failed with: // - Expected: 1 // - Actual : 0 // - XPath '//loext:content-control/loext:list-item[1]' number of nodes is incorrect // i.e. the list items were lost on export. assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[1]"_ostr, "display-text"_ostr, - "red"); - assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[1]"_ostr, "value"_ostr, "R"); + u"red"_ustr); + assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[1]"_ostr, "value"_ostr, + u"R"_ustr); assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[2]"_ostr, "display-text"_ostr, - "green"); - assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[2]"_ostr, "value"_ostr, "G"); + u"green"_ustr); + assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[2]"_ostr, "value"_ostr, + u"G"_ustr); assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[3]"_ostr, "display-text"_ostr, - "blue"); - assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[3]"_ostr, "value"_ostr, "B"); + u"blue"_ustr); + assertXPath(pXmlDoc, "//loext:content-control/loext:list-item[3]"_ostr, "value"_ostr, + u"B"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlImport) @@ -745,65 +751,65 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlImport) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aPortionType; - xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; - CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(u"ContentControl"_ustr, aPortionType); uno::Reference<text::XTextContent> xContentControl; - xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + xTextPortion->getPropertyValue(u"ContentControl"_ustr) >>= xContentControl; uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); uno::Sequence<beans::PropertyValues> aListItems; - xContentControlProps->getPropertyValue("ListItems") >>= aListItems; + xContentControlProps->getPropertyValue(u"ListItems"_ustr) >>= aListItems; // Without the accompanying fix in place, this failed with: // - Expected: 3 // - Actual : 0 // i.e. the list items were lost on import. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), aListItems.getLength()); comphelper::SequenceAsHashMap aMap0(aListItems[0]); - CPPUNIT_ASSERT_EQUAL(OUString("red"), aMap0["DisplayText"].get<OUString>()); - CPPUNIT_ASSERT_EQUAL(OUString("R"), aMap0["Value"].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"red"_ustr, aMap0[u"DisplayText"_ustr].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"R"_ustr, aMap0[u"Value"_ustr].get<OUString>()); comphelper::SequenceAsHashMap aMap1(aListItems[1]); - CPPUNIT_ASSERT_EQUAL(OUString("green"), aMap1["DisplayText"].get<OUString>()); - CPPUNIT_ASSERT_EQUAL(OUString("G"), aMap1["Value"].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"green"_ustr, aMap1[u"DisplayText"_ustr].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"G"_ustr, aMap1[u"Value"_ustr].get<OUString>()); comphelper::SequenceAsHashMap aMap2(aListItems[2]); - CPPUNIT_ASSERT_EQUAL(OUString("blue"), aMap2["DisplayText"].get<OUString>()); - CPPUNIT_ASSERT_EQUAL(OUString("B"), aMap2["Value"].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"blue"_ustr, aMap2[u"DisplayText"_ustr].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(u"B"_ustr, aMap2[u"Value"_ustr].get<OUString>()); uno::Reference<text::XTextRange> xContentControlRange(xContentControl, uno::UNO_QUERY); uno::Reference<text::XText> xText = xContentControlRange->getText(); uno::Reference<container::XEnumerationAccess> xContentEnumAccess(xText, uno::UNO_QUERY); uno::Reference<container::XEnumeration> xContentEnum = xContentEnumAccess->createEnumeration(); uno::Reference<text::XTextRange> xContent(xContentEnum->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("choose a color"), xContent->getString()); + CPPUNIT_ASSERT_EQUAL(u"choose a color"_ustr, xContent->getString()); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPictureContentControlExport) { // Given a document with a picture content control around an as-char image: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); uno::Reference<beans::XPropertySet> xTextGraphic( - xMSF->createInstance("com.sun.star.text.TextGraphicObject"), uno::UNO_QUERY); - xTextGraphic->setPropertyValue("AnchorType", + xMSF->createInstance(u"com.sun.star.text.TextGraphicObject"_ustr), uno::UNO_QUERY); + xTextGraphic->setPropertyValue(u"AnchorType"_ustr, uno::Any(text::TextContentAnchorType_AS_CHARACTER)); uno::Reference<text::XTextContent> xTextContent(xTextGraphic, uno::UNO_QUERY); xText->insertTextContent(xCursor, xTextContent, false); xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<text::XTextContent> xContentControl( - xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.ContentControl"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); - xContentControlProps->setPropertyValue("Picture", uno::Any(true)); + xContentControlProps->setPropertyValue(u"Picture"_ustr, uno::Any(true)); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - XPath '//loext:content-control' no attribute 'picture' exist - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "picture"_ostr, "true"); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "picture"_ostr, u"true"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPictureContentControlImport) @@ -821,13 +827,13 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPictureContentControlImport) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aPortionType; - xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; - CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(u"ContentControl"_ustr, aPortionType); uno::Reference<text::XTextContent> xContentControl; - xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + xTextPortion->getPropertyValue(u"ContentControl"_ustr) >>= xContentControl; uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); bool bPicture{}; - xContentControlProps->getPropertyValue("Picture") >>= bPicture; + xContentControlProps->getPropertyValue(u"Picture"_ustr) >>= bPicture; // Without the accompanying fix in place, this failed, as the picture attribute was ignored on // import. CPPUNIT_ASSERT(bPicture); @@ -836,36 +842,37 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPictureContentControlImport) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlExport) { // Given a document with a date content control around a text portion: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); - xText->insertString(xCursor, "choose a date", /*bAbsorb=*/false); + xText->insertString(xCursor, u"choose a date"_ustr, /*bAbsorb=*/false); xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<text::XTextContent> xContentControl( - xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.ContentControl"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); - xContentControlProps->setPropertyValue("Date", uno::Any(true)); - xContentControlProps->setPropertyValue("DateFormat", uno::Any(OUString("YYYY-MM-DD"))); - xContentControlProps->setPropertyValue("DateLanguage", uno::Any(OUString("en-US"))); - xContentControlProps->setPropertyValue("CurrentDate", - uno::Any(OUString("2022-05-25T00:00:00Z"))); + xContentControlProps->setPropertyValue(u"Date"_ustr, uno::Any(true)); + xContentControlProps->setPropertyValue(u"DateFormat"_ustr, uno::Any(u"YYYY-MM-DD"_ustr)); + xContentControlProps->setPropertyValue(u"DateLanguage"_ustr, uno::Any(u"en-US"_ustr)); + xContentControlProps->setPropertyValue(u"CurrentDate"_ustr, + uno::Any(u"2022-05-25T00:00:00Z"_ustr)); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - XPath '//loext:content-control' no attribute 'date' exist - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "date"_ostr, "true"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "date-format"_ostr, "YYYY-MM-DD"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "date-rfc-language-tag"_ostr, "en-US"); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "date"_ostr, u"true"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "date-format"_ostr, u"YYYY-MM-DD"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "date-rfc-language-tag"_ostr, + u"en-US"_ustr); assertXPath(pXmlDoc, "//loext:content-control"_ostr, "current-date"_ostr, - "2022-05-25T00:00:00Z"); + u"2022-05-25T00:00:00Z"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlImport) @@ -883,53 +890,53 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlImport) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aPortionType; - xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; - CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(u"ContentControl"_ustr, aPortionType); uno::Reference<text::XTextContent> xContentControl; - xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + xTextPortion->getPropertyValue(u"ContentControl"_ustr) >>= xContentControl; uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); bool bDate{}; - xContentControlProps->getPropertyValue("Date") >>= bDate; + xContentControlProps->getPropertyValue(u"Date"_ustr) >>= bDate; // Without the accompanying fix in place, this test would have failed, the content control was // imported as a default rich text one. CPPUNIT_ASSERT(bDate); OUString aDateFormat; - xContentControlProps->getPropertyValue("DateFormat") >>= aDateFormat; - CPPUNIT_ASSERT_EQUAL(OUString("YYYY-MM-DD"), aDateFormat); + xContentControlProps->getPropertyValue(u"DateFormat"_ustr) >>= aDateFormat; + CPPUNIT_ASSERT_EQUAL(u"YYYY-MM-DD"_ustr, aDateFormat); OUString aDateLanguage; - xContentControlProps->getPropertyValue("DateLanguage") >>= aDateLanguage; - CPPUNIT_ASSERT_EQUAL(OUString("en-US"), aDateLanguage); + xContentControlProps->getPropertyValue(u"DateLanguage"_ustr) >>= aDateLanguage; + CPPUNIT_ASSERT_EQUAL(u"en-US"_ustr, aDateLanguage); OUString aCurrentDate; - xContentControlProps->getPropertyValue("CurrentDate") >>= aCurrentDate; - CPPUNIT_ASSERT_EQUAL(OUString("2022-05-25T00:00:00Z"), aCurrentDate); + xContentControlProps->getPropertyValue(u"CurrentDate"_ustr) >>= aCurrentDate; + CPPUNIT_ASSERT_EQUAL(u"2022-05-25T00:00:00Z"_ustr, aCurrentDate); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPlainTextContentControlExport) { // Given a document with a plain text content control around a text portion: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); - xText->insertString(xCursor, "test", /*bAbsorb=*/false); + xText->insertString(xCursor, u"test"_ustr, /*bAbsorb=*/false); xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<text::XTextContent> xContentControl( - xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.ContentControl"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); - xContentControlProps->setPropertyValue("PlainText", uno::Any(true)); + xContentControlProps->setPropertyValue(u"PlainText"_ustr, uno::Any(true)); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - XPath '//loext:content-control' no attribute 'plain-text' exist // i.e. the plain text content control was turned into a rich text one on export. - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "plain-text"_ostr, "true"); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "plain-text"_ostr, u"true"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPlainTextContentControlImport) @@ -947,13 +954,13 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPlainTextContentControlImport) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aPortionType; - xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; - CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(u"ContentControl"_ustr, aPortionType); uno::Reference<text::XTextContent> xContentControl; - xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + xTextPortion->getPropertyValue(u"ContentControl"_ustr) >>= xContentControl; uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); bool bPlainText{}; - xContentControlProps->getPropertyValue("PlainText") >>= bPlainText; + xContentControlProps->getPropertyValue(u"PlainText"_ustr) >>= bPlainText; // Without the accompanying fix in place, this test would have failed, the import result was a // rich text content control (not a plain text one). CPPUNIT_ASSERT(bPlainText); @@ -962,66 +969,67 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPlainTextContentControlImport) CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testComboBoxContentControlExport) { // Given a document with a combo box content control around a text portion: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); - xText->insertString(xCursor, "test", /*bAbsorb=*/false); + xText->insertString(xCursor, u"test"_ustr, /*bAbsorb=*/false); xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<text::XTextContent> xContentControl( - xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.ContentControl"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); - xContentControlProps->setPropertyValue("ComboBox", uno::Any(true)); + xContentControlProps->setPropertyValue(u"ComboBox"_ustr, uno::Any(true)); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - XPath '//loext:content-control' no attribute 'combobox' exist // i.e. the combo box content control was turned into a drop-down one on export. - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "combobox"_ostr, "true"); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "combobox"_ostr, u"true"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAliasContentControlExport) { // Given a document with a content control and its alias around a text portion: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextDocument->getText(); uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); - xText->insertString(xCursor, "test", /*bAbsorb=*/false); + xText->insertString(xCursor, u"test"_ustr, /*bAbsorb=*/false); xCursor->gotoStart(/*bExpand=*/false); xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<text::XTextContent> xContentControl( - xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xMSF->createInstance(u"com.sun.star.text.ContentControl"_ustr), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); - xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("my alias"))); - xContentControlProps->setPropertyValue("Tag", uno::Any(OUString("my tag"))); - xContentControlProps->setPropertyValue("Id", uno::Any(static_cast<sal_Int32>(-2147483648))); - xContentControlProps->setPropertyValue("TabIndex", uno::Any(sal_uInt32(3))); - xContentControlProps->setPropertyValue("Lock", uno::Any(OUString("unlocked"))); + xContentControlProps->setPropertyValue(u"Alias"_ustr, uno::Any(u"my alias"_ustr)); + xContentControlProps->setPropertyValue(u"Tag"_ustr, uno::Any(u"my tag"_ustr)); + xContentControlProps->setPropertyValue(u"Id"_ustr, + uno::Any(static_cast<sal_Int32>(-2147483648))); + xContentControlProps->setPropertyValue(u"TabIndex"_ustr, uno::Any(sal_uInt32(3))); + xContentControlProps->setPropertyValue(u"Lock"_ustr, uno::Any(u"unlocked"_ustr)); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - Expression: prop // - XPath '//loext:content-control' no attribute 'alias' exist // i.e. alias was lost on export. - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "alias"_ostr, "my alias"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "tag"_ostr, "my tag"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "id"_ostr, "-2147483648"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "tab-index"_ostr, "3"); - assertXPath(pXmlDoc, "//loext:content-control"_ostr, "lock"_ostr, "unlocked"); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "alias"_ostr, u"my alias"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "tag"_ostr, u"my tag"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "id"_ostr, u"-2147483648"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "tab-index"_ostr, u"3"_ustr); + assertXPath(pXmlDoc, "//loext:content-control"_ostr, "lock"_ostr, u"unlocked"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testComboBoxContentControlImport) @@ -1039,13 +1047,13 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testComboBoxContentControlImport) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aPortionType; - xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; - CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(u"ContentControl"_ustr, aPortionType); uno::Reference<text::XTextContent> xContentControl; - xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + xTextPortion->getPropertyValue(u"ContentControl"_ustr) >>= xContentControl; uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); bool bComboBox{}; - xContentControlProps->getPropertyValue("ComboBox") >>= bComboBox; + xContentControlProps->getPropertyValue(u"ComboBox"_ustr) >>= bComboBox; // Without the accompanying fix in place, this test would have failed, the import result was a // drop-down content control (not a combo box one). CPPUNIT_ASSERT(bComboBox); @@ -1066,30 +1074,30 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAliasContentControlImport) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); OUString aPortionType; - xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType; - CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); + xTextPortion->getPropertyValue(u"TextPortionType"_ustr) >>= aPortionType; + CPPUNIT_ASSERT_EQUAL(u"ContentControl"_ustr, aPortionType); uno::Reference<text::XTextContent> xContentControl; - xTextPortion->getPropertyValue("ContentControl") >>= xContentControl; + xTextPortion->getPropertyValue(u"ContentControl"_ustr) >>= xContentControl; uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); OUString aAlias; - xContentControlProps->getPropertyValue("Alias") >>= aAlias; + xContentControlProps->getPropertyValue(u"Alias"_ustr) >>= aAlias; // Without the accompanying fix in place, this test would have failed with: // - Expected: my alias // - Actual : // i.e. the alias was lost on import. - CPPUNIT_ASSERT_EQUAL(OUString("my alias"), aAlias); + CPPUNIT_ASSERT_EQUAL(u"my alias"_ustr, aAlias); OUString aTag; - xContentControlProps->getPropertyValue("Tag") >>= aTag; - CPPUNIT_ASSERT_EQUAL(OUString("my tag"), aTag); + xContentControlProps->getPropertyValue(u"Tag"_ustr) >>= aTag; + CPPUNIT_ASSERT_EQUAL(u"my tag"_ustr, aTag); sal_Int32 nId = 0; - xContentControlProps->getPropertyValue("Id") >>= nId; + xContentControlProps->getPropertyValue(u"Id"_ustr) >>= nId; CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2147483647), nId); sal_uInt32 nTabIndex; - xContentControlProps->getPropertyValue("TabIndex") >>= nTabIndex; + xContentControlProps->getPropertyValue(u"TabIndex"_ustr) >>= nTabIndex; CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(4), nTabIndex); OUString aLock; - xContentControlProps->getPropertyValue("Lock") >>= aLock; - CPPUNIT_ASSERT_EQUAL(OUString("sdtContentLocked"), aLock); + xContentControlProps->getPropertyValue(u"Lock"_ustr) >>= aLock; + CPPUNIT_ASSERT_EQUAL(u"sdtContentLocked"_ustr, aLock); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlAutostyleExport) @@ -1101,7 +1109,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlAutostyleExport) // When saving that document to ODT, then make sure no assertion failure happens: uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aStoreProps = comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, + { "FilterName", uno::Any(u"writer8"_ustr) }, }); // Without the accompanying fix in place, this test would have failed, we had duplicated XML // attributes. @@ -1112,26 +1120,26 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testScaleWidthRedline) { // Given a document with change tracking enabled, one image is part of a delete redline: loadFromFile(u"scale-width-redline.fodt"); - dispatchCommand(mxComponent, ".uno:TrackChanges", {}); - dispatchCommand(mxComponent, ".uno:GoToEndOfLine", {}); - dispatchCommand(mxComponent, ".uno:EndOfParaSel", {}); - dispatchCommand(mxComponent, ".uno:Delete", {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + dispatchCommand(mxComponent, u".uno:GoToEndOfLine"_ustr, {}); + dispatchCommand(mxComponent, u".uno:EndOfParaSel"_ustr, {}); + dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); // When saving to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure that a non-zero size is written to the output: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - Expected: 6.1728in // - Actual : 0in // i.e. the deleted image had zero size, which is incorrect. - assertXPath(pXmlDoc, "//draw:frame[@draw:name='Image45']"_ostr, "width"_ostr, "6.1728in"); + assertXPath(pXmlDoc, "//draw:frame[@draw:name='Image45']"_ostr, "width"_ostr, u"6.1728in"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testThemeExport) { - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); @@ -1154,55 +1162,55 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testThemeExport) pTheme->setColorSet(pColorSet); uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(pTheme); - xPageProps->setPropertyValue("Theme", uno::Any(xTheme)); + xPageProps->setPropertyValue(u"Theme"_ustr, uno::Any(xTheme)); // Export to ODT: - save("writer8"); + save(u"writer8"_ustr); // Check if the 12 colors are written in the XML: - xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"styles.xml"_ustr); OString aThemePath = "//office:styles/loext:theme/loext:theme-colors/loext:color"_ostr; assertXPath(pXmlDoc, aThemePath, 12); - assertXPath(pXmlDoc, aThemePath + "[1]", "name"_ostr, "dark1"); - assertXPath(pXmlDoc, aThemePath + "[1]", "color"_ostr, "#101010"); - assertXPath(pXmlDoc, aThemePath + "[2]", "name"_ostr, "light1"); - assertXPath(pXmlDoc, aThemePath + "[2]", "color"_ostr, "#202020"); - assertXPath(pXmlDoc, aThemePath + "[12]", "name"_ostr, "followed-hyperlink"); - assertXPath(pXmlDoc, aThemePath + "[12]", "color"_ostr, "#c0c0c0"); + assertXPath(pXmlDoc, aThemePath + "[1]", "name"_ostr, u"dark1"_ustr); + assertXPath(pXmlDoc, aThemePath + "[1]", "color"_ostr, u"#101010"_ustr); + assertXPath(pXmlDoc, aThemePath + "[2]", "name"_ostr, u"light1"_ustr); + assertXPath(pXmlDoc, aThemePath + "[2]", "color"_ostr, u"#202020"_ustr); + assertXPath(pXmlDoc, aThemePath + "[12]", "name"_ostr, u"followed-hyperlink"_ustr); + assertXPath(pXmlDoc, aThemePath + "[12]", "color"_ostr, u"#c0c0c0"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFloatingTableExport) { // Given a document with a floating table: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); // Insert a table: uno::Sequence<beans::PropertyValue> aArgs = { - comphelper::makePropertyValue("Rows", static_cast<sal_Int32>(1)), - comphelper::makePropertyValue("Columns", static_cast<sal_Int32>(1)), + comphelper::makePropertyValue(u"Rows"_ustr, static_cast<sal_Int32>(1)), + comphelper::makePropertyValue(u"Columns"_ustr, static_cast<sal_Int32>(1)), }; - dispatchCommand(mxComponent, ".uno:InsertTable", aArgs); + dispatchCommand(mxComponent, u".uno:InsertTable"_ustr, aArgs); // Select it: - dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); // Wrap in a fly: aArgs = { - comphelper::makePropertyValue("AnchorType", static_cast<sal_uInt16>(0)), + comphelper::makePropertyValue(u"AnchorType"_ustr, static_cast<sal_uInt16>(0)), }; - dispatchCommand(mxComponent, ".uno:InsertFrame", aArgs); + dispatchCommand(mxComponent, u".uno:InsertFrame"_ustr, aArgs); // Mark it as a floating table: uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xFrame( - xTextFramesSupplier->getTextFrames()->getByName("Frame1"), uno::UNO_QUERY); - xFrame->setPropertyValue("IsSplitAllowed", uno::Any(true)); + xTextFramesSupplier->getTextFrames()->getByName(u"Frame1"_ustr), uno::UNO_QUERY); + xFrame->setPropertyValue(u"IsSplitAllowed"_ustr, uno::Any(true)); // When saving to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure we write a floating table, not a textframe containing a table: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - XPath '//draw:frame' no attribute 'may-break-between-pages' exist // i.e. no floating table was exported. - assertXPath(pXmlDoc, "//draw:frame"_ostr, "may-break-between-pages"_ostr, "true"); + assertXPath(pXmlDoc, "//draw:frame"_ostr, "may-break-between-pages"_ostr, u"true"_ustr); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFloatingTableImport) @@ -1214,10 +1222,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFloatingTableImport) // Then make sure that the matching text frame property is set: uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xFrame( - xTextFramesSupplier->getTextFrames()->getByName("Frame1"), uno::UNO_QUERY); + xTextFramesSupplier->getTextFrames()->getByName(u"Frame1"_ustr), uno::UNO_QUERY); bool bIsSplitAllowed = false; // Without the accompanying fix in place, this test would have failed, the property was false. - xFrame->getPropertyValue("IsSplitAllowed") >>= bIsSplitAllowed; + xFrame->getPropertyValue(u"IsSplitAllowed"_ustr) >>= bIsSplitAllowed; CPPUNIT_ASSERT(bIsSplitAllowed); } @@ -1247,16 +1255,17 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testParagraphScopedTabDistance) // Without the accompanying fix in place, this test would have failed with: // - Expected: 10000 // - Actual : 0 - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(10000), - xPropSet->getPropertyValue("ParaTabStopDefaultDistance").get<sal_Int32>()); + CPPUNIT_ASSERT_EQUAL( + static_cast<sal_Int32>(10000), + xPropSet->getPropertyValue(u"ParaTabStopDefaultDistance"_ustr).get<sal_Int32>()); // Save the imported file to test the export too - save("impress8"); + save(u"impress8"_ustr); // Then make sure we write the tab-stop-distance - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); assertXPath(pXmlDoc, "//style:style[@style:name='P1']/style:paragraph-properties"_ostr, - "tab-stop-distance"_ostr, "10cm"); + "tab-stop-distance"_ostr, u"10cm"_ustr); assertXPath(pXmlDoc, "//text:p[@text:style-name='P1']"_ostr); } @@ -1278,7 +1287,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testNestedSpans) uno::Reference<container::XEnumeration> xPortions = xParagraph->createEnumeration(); uno::Reference<beans::XPropertySet> xTextPortion(xPortions->nextElement(), uno::UNO_QUERY); float fWeight{}; - xTextPortion->getPropertyValue("CharWeight") >>= fWeight; + xTextPortion->getPropertyValue(u"CharWeight"_ustr) >>= fWeight; // Without the accompanying fix in place, this test would have failed with: // - Expected: 150 (awt::FontWeight::BOLD) // - Actual : 100 (awt::FontWeight::NORMAL) diff --git a/xmloff/qa/unit/text/txtprmap.cxx b/xmloff/qa/unit/text/txtprmap.cxx index 08c91c4c1a78..f2f737214dd0 100644 --- a/xmloff/qa/unit/text/txtprmap.cxx +++ b/xmloff/qa/unit/text/txtprmap.cxx @@ -27,44 +27,44 @@ public: } Test::Test() - : UnoApiXmlTest("/xmloff/qa/unit/data/") + : UnoApiXmlTest(u"/xmloff/qa/unit/data/"_ustr) { } CPPUNIT_TEST_FIXTURE(Test, testFloatingTableWrapTextAtFlyStartExport) { // Given a document with a floating table: - mxComponent = loadFromDesktop("private:factory/swriter"); + mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr); // Insert a table: uno::Sequence<beans::PropertyValue> aArgs = { - comphelper::makePropertyValue("Rows", static_cast<sal_Int32>(1)), - comphelper::makePropertyValue("Columns", static_cast<sal_Int32>(1)), + comphelper::makePropertyValue(u"Rows"_ustr, static_cast<sal_Int32>(1)), + comphelper::makePropertyValue(u"Columns"_ustr, static_cast<sal_Int32>(1)), }; - dispatchCommand(mxComponent, ".uno:InsertTable", aArgs); + dispatchCommand(mxComponent, u".uno:InsertTable"_ustr, aArgs); // Select it: - dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); // Wrap in a fly: aArgs = { - comphelper::makePropertyValue("AnchorType", static_cast<sal_uInt16>(0)), + comphelper::makePropertyValue(u"AnchorType"_ustr, static_cast<sal_uInt16>(0)), }; - dispatchCommand(mxComponent, ".uno:InsertFrame", aArgs); + dispatchCommand(mxComponent, u".uno:InsertFrame"_ustr, aArgs); // Mark it as a floating table that wraps on all pages: uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xFrame( - xTextFramesSupplier->getTextFrames()->getByName("Frame1"), uno::UNO_QUERY); - xFrame->setPropertyValue("IsSplitAllowed", uno::Any(true)); - xFrame->setPropertyValue("WrapTextAtFlyStart", uno::Any(true)); + xTextFramesSupplier->getTextFrames()->getByName(u"Frame1"_ustr), uno::UNO_QUERY); + xFrame->setPropertyValue(u"IsSplitAllowed"_ustr, uno::Any(true)); + xFrame->setPropertyValue(u"WrapTextAtFlyStart"_ustr, uno::Any(true)); // When saving to ODT: - save("writer8"); + save(u"writer8"_ustr); // Then make sure we write a floating table, that wraps on all pages: - xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); // Without the accompanying fix in place, this test would have failed with: // - XPath '//style:graphic-properties' no attribute 'wrap-text-at-frame-start' exist // i.e. no floating table was exported. assertXPath(pXmlDoc, "//style:graphic-properties"_ostr, "wrap-text-at-frame-start"_ostr, - "true"); + u"true"_ustr); } CPPUNIT_TEST_FIXTURE(Test, testFloatingTableWrapTextAtFlyStartImport) @@ -77,10 +77,10 @@ CPPUNIT_TEST_FIXTURE(Test, testFloatingTableWrapTextAtFlyStartImport) // Then make sure that the matching text frame property is set: uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xFrame( - xTextFramesSupplier->getTextFrames()->getByName("Frame1"), uno::UNO_QUERY); + xTextFramesSupplier->getTextFrames()->getByName(u"Frame1"_ustr), uno::UNO_QUERY); bool bWrapTextAtFlyStart = false; // Without the accompanying fix in place, this test would have failed, the property was false. - xFrame->getPropertyValue("WrapTextAtFlyStart") >>= bWrapTextAtFlyStart; + xFrame->getPropertyValue(u"WrapTextAtFlyStart"_ustr) >>= bWrapTextAtFlyStart; CPPUNIT_ASSERT(bWrapTextAtFlyStart); } diff --git a/xmloff/qa/unit/uxmloff.cxx b/xmloff/qa/unit/uxmloff.cxx index d87a3e86eeec..7fb1004bf612 100644 --- a/xmloff/qa/unit/uxmloff.cxx +++ b/xmloff/qa/unit/uxmloff.cxx @@ -56,7 +56,7 @@ void Test::setUp() BootstrapFixture::setUp(); pExport = new SchXMLExport( - comphelper::getProcessComponentContext(), "SchXMLExport.Compact", + comphelper::getProcessComponentContext(), u"SchXMLExport.Compact"_ustr, SvXMLExportFlags::ALL); } @@ -78,26 +78,26 @@ void Test::testAutoStylePool() xPool->AddFamily( XmlStyleFamily::TEXT_PARAGRAPH, GetXMLToken( XML_PARAGRAPH ), xExportPropMapper.get(), - OUString( "Bob" ) ); + u"Bob"_ustr ); - OUString aName = xPool->Add( XmlStyleFamily::TEXT_PARAGRAPH, "", {} ); + OUString aName = xPool->Add( XmlStyleFamily::TEXT_PARAGRAPH, u""_ustr, {} ); // not that interesting but worth checking bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != nullptr); if (bHack) - CPPUNIT_ASSERT_EQUAL_MESSAGE( "style / naming changed", OUString("Bob"), aName ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "style / naming changed", u"Bob"_ustr, aName ); else - CPPUNIT_ASSERT_EQUAL_MESSAGE( "style / naming changed", OUString("Bob1"), aName ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "style / naming changed", u"Bob1"_ustr, aName ); // find ourselves again: - OUString aSameName = xPool->Find( XmlStyleFamily::TEXT_PARAGRAPH, "", {} ); + OUString aSameName = xPool->Find( XmlStyleFamily::TEXT_PARAGRAPH, u""_ustr, {} ); CPPUNIT_ASSERT_EQUAL_MESSAGE( "same style not found", aName, aSameName ); } void Test::testMetaGenerator() { comphelper::PropertyMapEntry const aInfoMap[] = { - { OUString("BuildId"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, + { u"BuildId"_ustr, 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, }; uno::Reference<beans::XPropertySet> const xInfoSet( comphelper::GenericPropertySet_CreateInstance( @@ -206,7 +206,7 @@ void Test::testMetaGenerator() { // the DocumentInfo instance is cached so need fresh SvXMLImport rtl::Reference<SvXMLImport> const pImport(new SvXMLImport( - comphelper::getProcessComponentContext(), "testdummy", + comphelper::getProcessComponentContext(), u"testdummy"_ustr, SvXMLImportFlags::ALL)); pImport->initialize(uno::Sequence<uno::Any>{ uno::Any(xInfoSet) }); @@ -216,11 +216,11 @@ void Test::testMetaGenerator() { CPPUNIT_ASSERT_EQUAL_MESSAGE(pGenerator, OUString::createFromAscii(pBuildId), - xInfoSet->getPropertyValue("BuildId").get<OUString>()); + xInfoSet->getPropertyValue(u"BuildId"_ustr).get<OUString>()); } else { - CPPUNIT_ASSERT_MESSAGE(pGenerator, !xInfoSet->getPropertyValue("BuildId").hasValue()); + CPPUNIT_ASSERT_MESSAGE(pGenerator, !xInfoSet->getPropertyValue(u"BuildId"_ustr).hasValue()); } CPPUNIT_ASSERT_EQUAL_MESSAGE(pGenerator, nResult, pImport->getGeneratorVersion()); } |