From 0193b284e880a659ab73160e42238e1d5fe5cf8f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 23 Jun 2023 12:34:31 +0200 Subject: new loplugin:constexprliteral OUStringLiteral should be declared constexpr, to enforce that it is initialised at compile-time and not runtime. This seems to make a different at least on Visual Studio Change-Id: I1698f5fa22ddb480347c2f4d444530c2e0e88d92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153499 Tested-by: Jenkins Reviewed-by: Noel Grandin --- test/source/sheet/cellarealink.cxx | 10 +++++----- test/source/sheet/databaserange.cxx | 22 +++++++++++----------- test/source/sheet/datapilotitem.cxx | 4 ++-- test/source/sheet/xarrayformularange.cxx | 2 +- test/source/sheet/xspreadsheets2.cxx | 2 +- test/source/text/textsettings.cxx | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) (limited to 'test') diff --git a/test/source/sheet/cellarealink.cxx b/test/source/sheet/cellarealink.cxx index bfaf4c3fe99b..412d1b6260e3 100644 --- a/test/source/sheet/cellarealink.cxx +++ b/test/source/sheet/cellarealink.cxx @@ -22,7 +22,7 @@ void CellAreaLink::testUrl() { uno::Reference xCellAreaLink(init(), uno::UNO_QUERY_THROW); - static const OUStringLiteral propName(u"Url"); + static constexpr OUStringLiteral propName(u"Url"); OUString aUrl; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aUrl); @@ -39,7 +39,7 @@ void CellAreaLink::testFilter() { uno::Reference xCellAreaLink(init(), uno::UNO_QUERY_THROW); - static const OUStringLiteral propName(u"Filter"); + static constexpr OUStringLiteral propName(u"Filter"); OUString aFilter; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilter); @@ -56,7 +56,7 @@ void CellAreaLink::testFilterOptions() { uno::Reference xCellAreaLink(init(), uno::UNO_QUERY_THROW); - static const OUStringLiteral propName(u"FilterOptions"); + static constexpr OUStringLiteral propName(u"FilterOptions"); OUString aFilterOptions; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilterOptions); @@ -75,7 +75,7 @@ void CellAreaLink::testRefreshDelay() { uno::Reference xCellAreaLink(init(), uno::UNO_QUERY_THROW); - static const OUStringLiteral propName(u"RefreshDelay"); + static constexpr OUStringLiteral propName(u"RefreshDelay"); sal_Int32 aRefreshDelay = 0; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshDelay); @@ -94,7 +94,7 @@ void CellAreaLink::testRefreshPeriod() { uno::Reference xCellAreaLink(init(), uno::UNO_QUERY_THROW); - static const OUStringLiteral propName(u"RefreshPeriod"); + static constexpr OUStringLiteral propName(u"RefreshPeriod"); sal_Int32 aRefreshPeriod = 0; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshPeriod); diff --git a/test/source/sheet/databaserange.cxx b/test/source/sheet/databaserange.cxx index d87e3723ce3b..a9e316be7ce3 100644 --- a/test/source/sheet/databaserange.cxx +++ b/test/source/sheet/databaserange.cxx @@ -26,7 +26,7 @@ void DatabaseRange::testMoveCells() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"MoveCells"); + static constexpr OUStringLiteral propName(u"MoveCells"); bool bMoveCells = true; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bMoveCells); @@ -43,7 +43,7 @@ void DatabaseRange::testKeepFormats() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"KeepFormats"); + static constexpr OUStringLiteral propName(u"KeepFormats"); bool bKeepFormats = true; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bKeepFormats); @@ -60,7 +60,7 @@ void DatabaseRange::testStripData() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"StripData"); + static constexpr OUStringLiteral propName(u"StripData"); bool bStripData = true; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bStripData); @@ -77,7 +77,7 @@ void DatabaseRange::testAutoFilter() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"AutoFilter"); + static constexpr OUStringLiteral propName(u"AutoFilter"); bool bAutoFilter = true; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bAutoFilter); @@ -94,7 +94,7 @@ void DatabaseRange::testUseFilterCriteriaSource() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"UseFilterCriteriaSource"); + static constexpr OUStringLiteral propName(u"UseFilterCriteriaSource"); bool bUseFilterCriteriaSource = true; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bUseFilterCriteriaSource); @@ -113,7 +113,7 @@ void DatabaseRange::testFilterCriteriaSource() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"FilterCriteriaSource"); + static constexpr OUStringLiteral propName(u"FilterCriteriaSource"); table::CellRangeAddress cellRangeAddress; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= cellRangeAddress); @@ -132,7 +132,7 @@ void DatabaseRange::testRefreshPeriod() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"RefreshPeriod"); + static constexpr OUStringLiteral propName(u"RefreshPeriod"); sal_Int32 aRefreshPeriod = 1; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aRefreshPeriod); @@ -151,7 +151,7 @@ void DatabaseRange::testFromSelection() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"FromSelection"); + static constexpr OUStringLiteral propName(u"FromSelection"); bool bFromSelection = true; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bFromSelection); @@ -168,7 +168,7 @@ void DatabaseRange::testTokenIndex() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"TokenIndex"); + static constexpr OUStringLiteral propName(u"TokenIndex"); sal_Int32 aTokenIndex = 0; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aTokenIndex); @@ -185,7 +185,7 @@ void DatabaseRange::testTotalsRow() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"TotalsRow"); + static constexpr OUStringLiteral propName(u"TotalsRow"); bool bTotalsRow = true; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bTotalsRow); @@ -202,7 +202,7 @@ void DatabaseRange::testContainsHeader() { uno::Reference xDatabaseRange(init("DataArea"), UNO_QUERY_THROW); - static const OUStringLiteral propName(u"ContainsHeader"); + static constexpr OUStringLiteral propName(u"ContainsHeader"); bool bContainsHeader = false; CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bContainsHeader); diff --git a/test/source/sheet/datapilotitem.cxx b/test/source/sheet/datapilotitem.cxx index bfbe2110afec..625b1e634807 100644 --- a/test/source/sheet/datapilotitem.cxx +++ b/test/source/sheet/datapilotitem.cxx @@ -24,7 +24,7 @@ void DataPilotItem::testProperties() { uno::Reference xItem(init(), UNO_QUERY_THROW); - static const OUStringLiteral propNameIS(u"IsHidden"); + static constexpr OUStringLiteral propNameIS(u"IsHidden"); bool bIsHidden = true; CPPUNIT_ASSERT(xItem->getPropertyValue(propNameIS) >>= bIsHidden); @@ -36,7 +36,7 @@ void DataPilotItem::testProperties() CPPUNIT_ASSERT(xItem->getPropertyValue(propNameIS) >>= bIsHidden); CPPUNIT_ASSERT_MESSAGE("Value of IsHidden wasn't changed", !bIsHidden); - static const OUStringLiteral propNameSD(u"ShowDetail"); + static constexpr OUStringLiteral propNameSD(u"ShowDetail"); bool bShowDetail = false; CPPUNIT_ASSERT(xItem->getPropertyValue(propNameSD) >>= bShowDetail); diff --git a/test/source/sheet/xarrayformularange.cxx b/test/source/sheet/xarrayformularange.cxx index f7f30a1af73e..55372e18589c 100644 --- a/test/source/sheet/xarrayformularange.cxx +++ b/test/source/sheet/xarrayformularange.cxx @@ -27,7 +27,7 @@ void XArrayFormulaRange::testGetSetArrayFormula() { uno::Reference xAFR(init(), UNO_QUERY_THROW); - static const OUStringLiteral sFormula(u"=1 + 2 * 5"); + static constexpr OUStringLiteral sFormula(u"=1 + 2 * 5"); xAFR->setArrayFormula(sFormula); uno::Reference xCRA(xAFR, UNO_QUERY_THROW); diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx index 3bd539710480..c783d7f6b565 100644 --- a/test/source/sheet/xspreadsheets2.cxx +++ b/test/source/sheet/xspreadsheets2.cxx @@ -243,7 +243,7 @@ void XSpreadsheets2::testImportCellStyle() //new style created in dest uno::Reference< beans::XPropertySet > xSrcCellPropSet (xSrcCell, UNO_QUERY_THROW); - static const OUStringLiteral aCellProperty(u"CellStyle"); + static constexpr OUStringLiteral aCellProperty(u"CellStyle"); OUString aSrcStyleName; CPPUNIT_ASSERT(xSrcCellPropSet->getPropertyValue(aCellProperty) >>= aSrcStyleName); diff --git a/test/source/text/textsettings.cxx b/test/source/text/textsettings.cxx index 112fc939dee9..2003156074b3 100644 --- a/test/source/text/textsettings.cxx +++ b/test/source/text/textsettings.cxx @@ -44,7 +44,7 @@ bool isPropertyReadOnly(css::uno::Reference const& rxP // [property] string PrinterName; void testPrinterName(css::uno::Reference const& rxSettings) { - static const OUStringLiteral rPropertyName(u"PrinterName"); + static constexpr OUStringLiteral rPropertyName(u"PrinterName"); if (!extstsProperty(rxSettings, rPropertyName)) return; // Property is sometimes not set - bug? it is not defined as optional @@ -67,7 +67,7 @@ void testPrinterName(css::uno::Reference const& rxSett // [optional, property] short PrinterIndependentLayout; void testPrinterIndependentLayout(css::uno::Reference const& rxSettings) { - static const OUStringLiteral rPropertyName(u"PrinterIndependentLayout"); + static constexpr OUStringLiteral rPropertyName(u"PrinterIndependentLayout"); if (!extstsProperty(rxSettings, rPropertyName)) return; // Property is optional @@ -91,7 +91,7 @@ void testPrinterIndependentLayout(css::uno::Reference // [optional, property] com::sun::star::i18n::XForbiddenCharacters ForbiddenCharacters; void testForbiddenCharacters(css::uno::Reference const& rxSettings) { - static const OUStringLiteral rPropertyName(u"ForbiddenCharacters"); + static constexpr OUStringLiteral rPropertyName(u"ForbiddenCharacters"); if (!extstsProperty(rxSettings, rPropertyName)) return; // Property is optional -- cgit