cui/source/options/dbregister.cxx              |    6 +++++-
 fpicker/source/office/fileview.cxx             |    3 ++-
 sc/source/core/data/segmenttree.cxx            |    3 ++-
 sc/source/core/tool/interpr1.cxx               |    2 +-
 sc/source/filter/excel/xiescher.cxx            |    3 ++-
 sfx2/source/bastyp/helper.cxx                  |    5 ++++-
 starmath/source/ooxmlimport.cxx                |    6 +++++-
 sw/source/ui/index/cnttab.cxx                  |    6 ++++--
 sw/source/uibase/envelp/labelcfg.cxx           |    3 ++-
 sw/source/uibase/uiview/view.cxx               |    6 +++++-
 ucb/source/ucp/package/pkgcontent.cxx          |    8 ++++++--
 ucb/source/ucp/package/pkguri.cxx              |    8 ++++++--
 unotest/source/cpp/filters-test.cxx            |    3 ++-
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    7 ++++---
 14 files changed, 50 insertions(+), 19 deletions(-)

New commits:
commit f8a30a87a9d0c68dc16d5fa2ca63f687b1d90da1
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Fri Nov 12 09:56:30 2021 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri Nov 12 11:23:14 2021 +0100

    Fix (mis-)uses of temporary O[U]StringLiteral
    
    ...as sub-expressions of ternary operators, which happened to keep compiling
    after 4b9e440c51be3e40326bc90c33ae69885bfb51e4 "Turn OStringLiteral into a
    consteval'ed, static-refcound rtl_String" and
    e6dfaf9f44f9939abc338c83b3024108431d0f69 "Turn OUStringLiteral into a
    consteval'ed, static-refcound rtl_uString" because both branches are of the 
same
    type O[U]StringLiteral<N>, and which didn't cause any issues because no 
dangling
    pointers to those temporary objects escaped the surrounding full 
expressions.
    
    This was found with an experimental build with VS 2022 with
    --enable-latest-c++, which would support HAVE_CPP_CONSTEVAL after some 
linking
    fix in the configure.ac detection code (which is forthcoming in a later 
commit)
    and flagged all these uses in ternary operators as error C7595 "call to
    immediate function is not a constant expression".  That error looks bogus 
(and
    it also caused a false
    
    > sd/source/ui/unoidl/unoobj.cxx(742): error C7595: 'Color::Color': call to 
immediate function is not a constant expression
    
    so HAVE_CPP_CONSTEVAL will need to remain undefined for VS 2022 until that
    compiler bug is fixed), but it nicely found all these cases that should 
arguably
    be cleaned up.
    
    Change-Id: I81de94e8af5a6c50e5fe7dfa1a4b253e0c2a68f3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125082
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/cui/source/options/dbregister.cxx 
b/cui/source/options/dbregister.cxx
index ba61527cdeca..357a4af426c9 100644
--- a/cui/source/options/dbregister.cxx
+++ b/cui/source/options/dbregister.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <dbregister.hxx>
 #include "dbregistersettings.hxx"
 #include <o3tl/safeint.hxx>
@@ -188,7 +192,7 @@ void DbRegistrationOptionsPage::FillUserData()
 {
     OUString aUserData = OUString::number( 
m_xPathBox->get_column_width(COL_TYPE) ) + ";";
     bool bUp = m_xPathBox->get_sort_order();
-    aUserData += (bUp ? OUStringLiteral(u"1") : OUStringLiteral(u"0"));
+    aUserData += (bUp ? std::u16string_view(u"1") : std::u16string_view(u"0"));
     SetUserData( aUserData );
 }
 
diff --git a/fpicker/source/office/fileview.cxx 
b/fpicker/source/office/fileview.cxx
index 203f1d1d27b3..0e13bc0a3b55 100644
--- a/fpicker/source/office/fileview.cxx
+++ b/fpicker/source/office/fileview.cxx
@@ -36,6 +36,7 @@
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 
 #include <algorithm>
+#include <string_view>
 #include <vector>
 #include <tools/debug.hxx>
 #include <tools/urlobj.hxx>
@@ -1060,7 +1061,7 @@ OUString SvtFileView::GetConfigString() const
     OUString sRet = OUString::number( mpImpl->mnSortColumn ) + ";";
 
     bool bUp = mpImpl->mbAscending;
-    sRet += (bUp ? OUStringLiteral(u"1") : OUStringLiteral(u"0")) + ";";
+    sRet += OUString::Concat(bUp ? std::u16string_view(u"1") : 
std::u16string_view(u"0")) + ";";
 
     weld::TreeView* pView = mpImpl->mxView->getWidget();
     sal_uInt16 nCount = mpImpl->mxView->TypeColumnVisible() ? 4 : 3;
diff --git a/sc/source/core/data/segmenttree.cxx 
b/sc/source/core/data/segmenttree.cxx
index 60003fb924b3..f57578149e0f 100644
--- a/sc/source/core/data/segmenttree.cxx
+++ b/sc/source/core/data/segmenttree.cxx
@@ -23,6 +23,7 @@
 #include <sal/log.hxx>
 #include <algorithm>
 #include <limits>
+#include <string_view>
 #include <global.hxx>
 
 using ::std::numeric_limits;
@@ -499,7 +500,7 @@ OString ScFlatBoolRowSegments::dumpAsString()
     while (getRangeData(nRow, aRange))
     {
         if (!nRow)
-            aSegment = (aRange.mbValue ? OStringLiteral("1") : 
OStringLiteral("0")) + OString::Concat(":");
+            aSegment = (aRange.mbValue ? std::string_view("1") : 
std::string_view("0")) + OString::Concat(":");
         else
             aSegment.clear();
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index e4e9b1bd5360..bd4a37d85742 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8348,7 +8348,7 @@ void ScInterpreter::ScAddressFunc()
         if (!aDoc.isEmpty())
             sTabStr = aDoc + sTabStr;
         sTabStr += (eConv == FormulaGrammar::CONV_XL_R1C1 || eConv == 
FormulaGrammar::CONV_XL_A1) ?
-            OUStringLiteral(u"!") : OUStringLiteral(u".");
+            std::u16string_view(u"!") : std::u16string_view(u".");
         sTabStr += aRefStr;
         PushString( sTabStr );
     }
diff --git a/sc/source/filter/excel/xiescher.cxx 
b/sc/source/filter/excel/xiescher.cxx
index 02300da7e1fb..c1749c310ab6 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -125,6 +125,7 @@
 #include <sfx2/docfile.hxx>
 #include <memory>
 #include <numeric>
+#include <string_view>
 #include <utility>
 
 using namespace com::sun::star;
@@ -2936,7 +2937,7 @@ OUString XclImpPictureObj::GetOleStorageName() const
     OUStringBuffer aStrgName;
     if( (mbEmbedded || mbLinked) && !mbControl && (mnStorageId > 0) )
     {
-        aStrgName = mbEmbedded ? OUStringLiteral(u"" EXC_STORAGE_OLE_EMBEDDED) 
: OUStringLiteral(u"" EXC_STORAGE_OLE_LINKED);
+        aStrgName = mbEmbedded ? std::u16string_view(u"" 
EXC_STORAGE_OLE_EMBEDDED) : std::u16string_view(u"" EXC_STORAGE_OLE_LINKED);
         static const char spcHexChars[] = "0123456789ABCDEF";
         for( sal_uInt8 nIndex = 32; nIndex > 0; nIndex -= 4 )
             aStrgName.append(OUStringChar( spcHexChars[ ::extract_value< 
sal_uInt8 >( mnStorageId, nIndex - 4, 4 ) ] ));
diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index d9d1a4bb4da4..5138a790e15a 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <string_view>
 
 #include <helper.hxx>
 #include <com/sun/star/sdbc/XResultSet.hpp>
@@ -134,7 +137,7 @@ std::vector< OUString > 
SfxContentHelper::GetHelpTreeViewContents( const OUStrin
                     bool bFolder = xRow->getBoolean(2);
                     OUString aRow = aTitle + "\t" +
                         xContentAccess->queryContentIdentifierString() + "\t" +
-                        (bFolder ? OUStringLiteral(u"1") : 
OUStringLiteral(u"0"));
+                        (bFolder ? std::u16string_view(u"1") : 
std::u16string_view(u"0"));
                     aProperties.push_back( aRow );
                 }
             }
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 5290ad12606c..d14a4d2023b6 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -7,6 +7,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <sal/config.h>
+
+#include <string_view>
 
 #include "ooxmlimport.hxx"
 #include <types.hxx>
@@ -439,7 +442,8 @@ OUString SmOoxmlImport::handleLimLowUpp( LimLowUpp_t 
limlowupp )
     if( limlowupp == LimLow && e.endsWith( " underbrace { }" ))
         return e.subView( 0, e.getLength() - 2 ) + lim + "}";
     return e
-        + ( limlowupp == LimLow ? OUStringLiteral( u" csub {" ) : 
OUStringLiteral( u" csup {" ))
+        + ( limlowupp == LimLow
+            ? std::u16string_view( u" csub {" ) : std::u16string_view( u" csup 
{" ))
         + lim + "}";
 }
 
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index dad3312e3d5a..17a360bf522c 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -63,6 +63,7 @@
 
 #include <cmath>
 #include <memory>
+#include <string_view>
 #include <vector>
 #include <numeric>
 
@@ -3844,8 +3845,9 @@ void SwEntryBrowseBox::WriteEntries(SvStream& rOutStr)
                          pEntry->sAlternative + ";" +
                          pEntry->sPrimKey  + ";" +
                          pEntry->sSecKey + ";" +
-                         (pEntry->bCase ? OUStringLiteral(u"1") : 
OUStringLiteral(u"0")) + ";" +
-                         (pEntry->bWord ? OUStringLiteral(u"1") : 
OUStringLiteral(u"0")) );
+                         (pEntry->bCase ? std::u16string_view(u"1") : 
std::u16string_view(u"0")) +
+                         ";" +
+                         (pEntry->bWord ? std::u16string_view(u"1") : 
std::u16string_view(u"0")) );
 
         if( sWrite.getLength() > 5 )
             rOutStr.WriteByteStringLine( sWrite, eTEnc );
diff --git a/sw/source/uibase/envelp/labelcfg.cxx 
b/sw/source/uibase/envelp/labelcfg.cxx
index 413768e030f3..ec943c2ff27c 100644
--- a/sw/source/uibase/envelp/labelcfg.cxx
+++ b/sw/source/uibase/envelp/labelcfg.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <memory>
+#include <string_view>
 #include <config_folders.h>
 
 #include <swtypes.hxx>
@@ -219,7 +220,7 @@ static Sequence<PropertyValue> lcl_CreateProperties(
             case 1:
             {
                 rMeasure.clear();
-                rMeasure += rRec.m_bCont ? OUStringLiteral( u"C" ) : 
OUStringLiteral( u"S" );      rMeasure += sColon;
+                rMeasure += rRec.m_bCont ? std::u16string_view( u"C" ) : 
std::u16string_view( u"S" );      rMeasure += sColon;
                 rMeasure += OUString::number( convertTwipToMm100( 
rRec.m_nHDist ) );   rMeasure += sColon;
                 rMeasure += OUString::number( convertTwipToMm100( 
rRec.m_nVDist ) );   rMeasure += sColon;
                 rMeasure += OUString::number( convertTwipToMm100( 
rRec.m_nWidth ) );   rMeasure += sColon;
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 7755afb107ea..84226f9e2942 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <config_features.h>
 
 #include <stdlib.h>
@@ -1158,7 +1162,7 @@ void SwView::WriteUserData( OUString &rUserData, bool 
bBrowse )
     rUserData += OUString::number(
             
static_cast<sal_uInt16>(m_pWrtShell->GetViewOptions()->GetZoomType()));//eZoom;
     rUserData += ";";
-    rUserData += FrameTypeFlags::NONE == m_pWrtShell->GetSelFrameType() ? 
OUStringLiteral(u"0") : OUStringLiteral(u"1");
+    rUserData += FrameTypeFlags::NONE == m_pWrtShell->GetSelFrameType() ? 
std::u16string_view(u"0") : std::u16string_view(u"1");
 }
 
 // Set CursorPos
diff --git a/ucb/source/ucp/package/pkgcontent.cxx 
b/ucb/source/ucp/package/pkgcontent.cxx
index cf08c8bdfaaf..a22ab7bdaaed 100644
--- a/ucb/source/ucp/package/pkgcontent.cxx
+++ b/ucb/source/ucp/package/pkgcontent.cxx
@@ -22,6 +22,10 @@
                                 TODO
  **************************************************************************
  *************************************************************************/
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <osl/diagnose.h>
 
 #include <rtl/ustring.hxx>
@@ -224,8 +228,8 @@ OUString Content::getContentType(
     return ( OUString::Concat("application/")
              + aScheme
              + ( bFolder
-                 ? OUStringLiteral(u"-folder")
-                 : OUStringLiteral(u"-stream") ) );
+                 ? std::u16string_view(u"-folder")
+                 : std::u16string_view(u"-stream") ) );
 }
 
 
diff --git a/ucb/source/ucp/package/pkguri.cxx 
b/ucb/source/ucp/package/pkguri.cxx
index dfcde478938b..9796ecc34c73 100644
--- a/ucb/source/ucp/package/pkguri.cxx
+++ b/ucb/source/ucp/package/pkguri.cxx
@@ -24,6 +24,10 @@
 
  *************************************************************************/
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <comphelper/storagehelper.hxx>
 
 #include "../inc/urihelper.hxx"
@@ -109,8 +113,8 @@ void PackageUri::init() const
         {
             m_aParam +=
                 ( !m_aParam.isEmpty()
-                  ? OUStringLiteral( u"&purezip" )
-                  : OUStringLiteral( u"?purezip" ) );
+                  ? std::u16string_view( u"&purezip" )
+                  : std::u16string_view( u"?purezip" ) );
         }
 
         aPureUri = aPureUri.replaceAt( 0,
diff --git a/unotest/source/cpp/filters-test.cxx 
b/unotest/source/cpp/filters-test.cxx
index a642c2176678..7adbd9ca4d4d 100644
--- a/unotest/source/cpp/filters-test.cxx
+++ b/unotest/source/cpp/filters-test.cxx
@@ -10,6 +10,7 @@
 #include <sal/config.h>
 
 #include <set>
+#include <string_view>
 
 #include <unotest/filters-test.hxx>
 #include <osl/file.hxx>
@@ -107,7 +108,7 @@ void FiltersTest::recursiveScan(filterStatus nExpected,
         }
 
         OString aRes(
-            (bExport ? OStringLiteral("save") : OStringLiteral("load")) + " "
+            OString::Concat(bExport ? std::string_view("save") : 
std::string_view("load")) + " "
             + OUStringToOString(sURL, osl_getThreadTextEncoding()));
 
         OUString realUrl;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index d9d15551a4d0..663ac935047d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -10,6 +10,7 @@
 #include "rtfdocumentimpl.hxx"
 #include <algorithm>
 #include <memory>
+#include <string_view>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/io/WrongFormatException.hpp>
@@ -2454,9 +2455,9 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& 
rState)
             OUString 
str(m_aStates.top().getCurrentDestinationText()->makeStringAndClear());
             // dmapper expects this as a field, so let's fake something...
             auto const field((Destination::INDEXENTRY == 
rState.getDestination())
-                                 ? OUStringLiteral(u"XE")
-                                 : OUStringLiteral(u"TC"));
-            str = field + " \"" + str.replaceAll("\"", "\\\"") + "\"";
+                                 ? std::u16string_view(u"XE")
+                                 : std::u16string_view(u"TC"));
+            str = OUString::Concat(field) + " \"" + str.replaceAll("\"", 
"\\\"") + "\"";
             singleChar(cFieldStart);
             Mapper().utext(reinterpret_cast<sal_uInt8 const*>(str.getStr()), 
str.getLength());
             singleChar(cFieldSep);

Reply via email to