summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-12-11 17:44:34 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-12-11 21:25:10 +0100
commit35e471bb4d1388cf5afcdcee214cf5111edf44e3 (patch)
treebb78f4f13f131f0cb206a9707cc3cfc495a3876a /oox
parent0c06e77c122f10a1842bc908bd6e25b1110ddbd2 (diff)
Adapt the remaining OUString functions to std string_view
...for LIBO_INTERNAL_ONLY. These had been missed by 1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take std::u16string_view parameters" because they did not match the multi-overload pattern that was addressed there, but they nevertheless benefit from being changed just as well (witness e.g. the various resulting changes from copy() to subView()). This showed a conversion from OStringChar to std::string_view to be missing (while the corresponding conversion form OUStringChar to std::u16string_view was already present). The improvement to loplugin:stringadd became necessary to fix > [CPT] compilerplugins/clang/test/stringadd.cxx > error: 'error' diagnostics expected but not seen: > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd] > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd] > 2 errors generated. Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/xmlfilterbase.cxx6
-rw-r--r--oox/source/docprop/docprophandler.cxx4
-rw-r--r--oox/source/docprop/docprophandler.hxx2
-rw-r--r--oox/source/drawingml/customshapepresetdata.cxx8
-rw-r--r--oox/source/dump/dumperbase.cxx4
-rw-r--r--oox/source/helper/attributelist.cxx2
-rw-r--r--oox/source/helper/binaryoutputstream.cxx2
-rw-r--r--oox/source/ole/vbaexport.cxx57
-rw-r--r--oox/source/token/tokenmap.cxx2
-rw-r--r--oox/source/vml/vmlformatting.cxx4
-rw-r--r--oox/source/vml/vmlshapecontext.cxx8
11 files changed, 53 insertions, 46 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 566e1c4a2909..42bf01bece56 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -20,6 +20,8 @@
#include <oox/core/xmlfilterbase.hxx>
#include <cstdio>
+#include <string_view>
+
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/Pair.hpp>
@@ -554,7 +556,7 @@ OUString XmlFilterBase::addRelation( const Reference< XOutputStream >& rOutputSt
}
static void
-writeElement( const FSHelperPtr& pDoc, sal_Int32 nXmlElement, const OUString& sValue )
+writeElement( const FSHelperPtr& pDoc, sal_Int32 nXmlElement, std::u16string_view sValue )
{
pDoc->startElement(nXmlElement);
pDoc->writeEscaped( sValue );
@@ -761,7 +763,7 @@ writeAppProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties >
// * 14: [Office 2010]
// * 15: [Office 2013/2016/2019] [LO >= 7.0]
// The LibreOffice is application on 2013/2016/2019 level
- writeElement( pAppProps, XML_AppVersion, "15.0000" );
+ writeElement( pAppProps, XML_AppVersion, u"15.0000" );
// OOXTODO Calculate DocSecurity value based on security (password, read-only etc.)
it = aUserDefinedProperties.find("DocSecurity");
diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx
index 07f9b4c0dc72..ebcb87c3cdde 100644
--- a/oox/source/docprop/docprophandler.cxx
+++ b/oox/source/docprop/docprophandler.cxx
@@ -189,9 +189,9 @@ util::DateTime OOXMLDocPropHandler::GetDateTimeFromW3CDTF( const OUString& aChar
aOslDTime.Day, aOslDTime.Month, aOslDTime.Year, false);
}
-uno::Sequence< OUString > OOXMLDocPropHandler::GetKeywordsSet( const OUString& aChars )
+uno::Sequence< OUString > OOXMLDocPropHandler::GetKeywordsSet( std::u16string_view aChars )
{
- if ( !aChars.isEmpty() )
+ if ( !aChars.empty() )
{
std::string aUtf8Chars = OUStringToOString( aChars, RTL_TEXTENCODING_UTF8 ).getStr();
std::vector<std::string> aUtf8Result;
diff --git a/oox/source/docprop/docprophandler.hxx b/oox/source/docprop/docprophandler.hxx
index e9b86e3df4fd..c7e902634543 100644
--- a/oox/source/docprop/docprophandler.hxx
+++ b/oox/source/docprop/docprophandler.hxx
@@ -59,7 +59,7 @@ public:
void AddCustomProperty( const css::uno::Any& aAny );
static css::util::DateTime GetDateTimeFromW3CDTF( const OUString& aChars );
- static css::uno::Sequence< OUString > GetKeywordsSet( const OUString& aChars );
+ static css::uno::Sequence< OUString > GetKeywordsSet( std::u16string_view aChars );
void UpdateDocStatistic( const OUString& aChars );
// com.sun.star.xml.sax.XFastDocumentHandler
diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index 51d5479473da..a80ddeacae21 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -434,8 +434,8 @@ void lcl_parseEquations(std::vector<OUString>& rEquations, const OString& rValue
else if (rValue[i] == '"' && bInString)
{
bInString = false;
- rEquations.push_back(
- OUString::fromUtf8(rValue.copy(nStart + strlen("\""), i - nStart - strlen("\""))));
+ rEquations.push_back(OUString::fromUtf8(
+ rValue.subView(nStart + strlen("\""), i - nStart - strlen("\""))));
}
}
}
@@ -763,8 +763,8 @@ void CustomShapeProperties::initializePresetDataMap()
else
maPresetDataMap[TokenMap::getTokenFromUnicode(aName)] = aPropertyMap;
aName = OUString::fromUtf8(
- aLine.copy(strlen(aCommentPrefix),
- aLine.getLength() - strlen(aCommentPrefix) - strlen(" */")));
+ aLine.subView(strlen(aCommentPrefix),
+ aLine.getLength() - strlen(aCommentPrefix) - strlen(" */")));
}
else
{
diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx
index df18516a0aef..9c36b7ed1d02 100644
--- a/oox/source/dump/dumperbase.cxx
+++ b/oox/source/dump/dumperbase.cxx
@@ -617,7 +617,7 @@ OUString StringHelper::trimTrailingNul( const OUString& rStr )
return rStr;
}
-OString StringHelper::convertToUtf8( const OUString& rStr )
+OString StringHelper::convertToUtf8( std::u16string_view rStr )
{
return OUStringToOString( rStr, RTL_TEXTENCODING_UTF8 );
}
@@ -2153,7 +2153,7 @@ OUString InputObjectBase::dumpCharArray( const String& rName, sal_Int32 nLen, rt
::std::vector< char > aBuffer( static_cast< std::size_t >( nLen ) + 1 );
sal_Int32 nCharsRead = mxStrm->readMemory(aBuffer.data(), nLen);
aBuffer[ nCharsRead ] = 0;
- aString = OStringToOUString(OString(aBuffer.data()), eTextEnc);
+ aString = OStringToOUString(std::string_view(aBuffer.data()), eTextEnc);
}
if( bHideTrailingNul )
aString = StringHelper::trimTrailingNul( aString );
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx
index afc6ebc483c7..6ac3ea872eb4 100644
--- a/oox/source/helper/attributelist.cxx
+++ b/oox/source/helper/attributelist.cxx
@@ -86,7 +86,7 @@ sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName)
return XML_TOKEN_INVALID;
}
-sal_Int32 AttributeConversion::decodeToken( const OUString& rValue )
+sal_Int32 AttributeConversion::decodeToken( std::u16string_view rValue )
{
return TokenMap::getTokenFromUnicode( rValue );
}
diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx
index bac274af1857..50ce7f11ce9e 100644
--- a/oox/source/helper/binaryoutputstream.cxx
+++ b/oox/source/helper/binaryoutputstream.cxx
@@ -99,7 +99,7 @@ void BinaryXOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes, size_
}
void
-BinaryOutputStream::writeCharArrayUC( const OUString& rString, rtl_TextEncoding eTextEnc )
+BinaryOutputStream::writeCharArrayUC( std::u16string_view rString, rtl_TextEncoding eTextEnc )
{
OString sBuf( OUStringToOString( rString, eTextEnc ) );
sBuf = sBuf.replace( '\0', '?' );
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index b699da60697a..9b77a84bea70 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -11,6 +11,7 @@
#include <cassert>
#include <random>
+#include <string_view>
#include <oox/ole/vbaexport.hxx>
@@ -53,7 +54,7 @@
namespace {
-void exportString(SvStream& rStrm, const OUString& rString)
+void exportString(SvStream& rStrm, std::u16string_view rString)
{
OString aStringCorrectCodepage = OUStringToOString(rString, CODEPAGE);
rStrm.WriteOString(aStringCorrectCodepage);
@@ -778,20 +779,20 @@ void exportModuleStream(SvStream& rStrm, const OUString& rSourceCode, const OUSt
{
SvMemoryStream aModuleStream(4096, 4096);
- exportString(aModuleStream, "Attribute VB_Name = \"" + aElementName + "\"\r\n");
+ exportString(aModuleStream, OUString("Attribute VB_Name = \"" + aElementName + "\"\r\n"));
if (rInfo.ModuleType == 4)
{
if (isWorkbook(rInfo.ModuleObject))
- exportString(aModuleStream, "Attribute VB_Base = \"0{00020819-0000-0000-C000-000000000046}\"\r\n");
+ exportString(aModuleStream, u"Attribute VB_Base = \"0{00020819-0000-0000-C000-000000000046}\"\r\n");
else
- exportString(aModuleStream, "Attribute VB_Base = \"0{00020820-0000-0000-C000-000000000046}\"\r\n");
-
- exportString(aModuleStream, "Attribute VB_GlobalNameSpace = False\r\n");
- exportString(aModuleStream, "Attribute VB_Creatable = False\r\n");
- exportString(aModuleStream, "Attribute VB_PredeclaredId = True\r\n");
- exportString(aModuleStream, "Attribute VB_Exposed = True\r\n");
- exportString(aModuleStream, "Attribute VB_TemplateDerived = False\r\n");
- exportString(aModuleStream, "Attribute VB_Customizable = True\r\n");
+ exportString(aModuleStream, u"Attribute VB_Base = \"0{00020820-0000-0000-C000-000000000046}\"\r\n");
+
+ exportString(aModuleStream, u"Attribute VB_GlobalNameSpace = False\r\n");
+ exportString(aModuleStream, u"Attribute VB_Creatable = False\r\n");
+ exportString(aModuleStream, u"Attribute VB_PredeclaredId = True\r\n");
+ exportString(aModuleStream, u"Attribute VB_Exposed = True\r\n");
+ exportString(aModuleStream, u"Attribute VB_TemplateDerived = False\r\n");
+ exportString(aModuleStream, u"Attribute VB_Customizable = True\r\n");
}
OUString aSourceCode = rSourceCode.replaceFirst("Option VBASupport 1\n", "");
const sal_Int32 nPos = aSourceCode.indexOf("Rem Attribute VBA_ModuleType=");
@@ -833,11 +834,11 @@ void exportPROJECTStream(SvStream& rStrm, const css::uno::Reference<css::contain
// section 2.3.1.1ProjectProperties
// section 2.3.1.2 ProjectId
- exportString(rStrm, "ID=\"");
+ exportString(rStrm, u"ID=\"");
OUString aProjectID
= OStringToOUString(comphelper::xml::generateGUIDString(), RTL_TEXTENCODING_UTF8);
exportString(rStrm, aProjectID);
- exportString(rStrm, "\"\r\n");
+ exportString(rStrm, u"\"\r\n");
// section 2.3.1.3 ProjectModule
for (sal_Int32 i = 0; i < n; ++i)
@@ -846,81 +847,81 @@ void exportPROJECTStream(SvStream& rStrm, const css::uno::Reference<css::contain
css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName);
if(aModuleInfo.ModuleType == 1)
{
- exportString(rStrm, "Module=" + rModuleName + "\r\n");
+ exportString(rStrm, OUString("Module=" + rModuleName + "\r\n"));
}
else if(aModuleInfo.ModuleType == 4)
{
- exportString(rStrm, "Document=" + rModuleName + "/&H00000000\r\n");
+ exportString(rStrm, OUString("Document=" + rModuleName + "/&H00000000\r\n"));
}
}
// section 2.3.1.11 ProjectName
- exportString(rStrm, "Name=\"" + projectName + "\"\r\n");
+ exportString(rStrm, OUString("Name=\"" + projectName + "\"\r\n"));
// section 2.3.1.12 ProjectHelpId
- exportString(rStrm, "HelpContextID=\"0\"\r\n");
+ exportString(rStrm, u"HelpContextID=\"0\"\r\n");
// section 2.3.1.14 ProjectVersionCompat32
- exportString(rStrm, "VersionCompatible32=\"393222000\"\r\n");
+ exportString(rStrm, u"VersionCompatible32=\"393222000\"\r\n");
// section 2.3.1.15 ProjectProtectionState
#if VBA_ENCRYPTION
- exportString(rStrm, "CMG=\"");
+ exportString(rStrm, u"CMG=\"");
SvMemoryStream aProtectedStream(4096, 4096);
aProtectedStream.WriteUInt32(0x00000000);
const sal_uInt8* pData = static_cast<const sal_uInt8*>(aProtectedStream.GetData());
sal_uInt8 nProjKey = VBAEncryption::calculateProjKey(aProjectID);
VBAEncryption aProtectionState(pData, 4, rStrm, nProjKey);
aProtectionState.write();
- exportString(rStrm, "\"\r\n");
+ exportString(rStrm, u"\"\r\n");
#else
exportString(rStrm, "CMG=\"BEBC9256EEAAA8AEA8AEA8AEA8AE\"\r\n");
#endif
// section 2.3.1.16 ProjectPassword
#if VBA_ENCRYPTION
- exportString(rStrm, "DPB=\"");
+ exportString(rStrm, u"DPB=\"");
aProtectedStream.Seek(0);
aProtectedStream.WriteUInt8(0x00);
pData = static_cast<const sal_uInt8*>(aProtectedStream.GetData());
VBAEncryption aProjectPassword(pData, 1, rStrm, nProjKey);
aProjectPassword.write();
- exportString(rStrm, "\"\r\n");
+ exportString(rStrm, u"\"\r\n");
#else
exportString(rStrm, "DPB=\"7C7E5014B0D3B1D3B1D3\"\r\n");
#endif
// section 2.3.1.17 ProjectVisibilityState
#if VBA_ENCRYPTION
- exportString(rStrm, "GC=\"");
+ exportString(rStrm, u"GC=\"");
aProtectedStream.Seek(0);
aProtectedStream.WriteUInt8(0xFF);
pData = static_cast<const sal_uInt8*>(aProtectedStream.GetData());
VBAEncryption aVisibilityState(pData, 1, rStrm, nProjKey);
aVisibilityState.write();
- exportString(rStrm, "\"\r\n\r\n");
+ exportString(rStrm, u"\"\r\n\r\n");
#else
exportString(rStrm, "GC=\"3A3816DAD5DBD5DB2A\"\r\n\r\n");
#endif
// section 2.3.1.18 HostExtenders
- exportString(rStrm, "[Host Extender Info]\r\n"
+ exportString(rStrm, u"[Host Extender Info]\r\n"
"&H00000001={3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000\r\n\r\n"
);
// section 2.3.1.19 ProjectWorkspace
- exportString(rStrm, "[Workspace]\r\n");
+ exportString(rStrm, u"[Workspace]\r\n");
for (sal_Int32 i = 0; i < n; ++i)
{
const OUString& rModuleName = aElementNames[rLibraryMap[i]];
css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName);
if(aModuleInfo.ModuleType == 1)
{
- exportString(rStrm, rModuleName + "=25, 25, 1439, 639, \r\n");
+ exportString(rStrm, OUString(rModuleName + "=25, 25, 1439, 639, \r\n"));
}
else
{
- exportString(rStrm, rModuleName + "=0, 0, 0, 0, C\r\n");
+ exportString(rStrm, OUString(rModuleName + "=0, 0, 0, 0, C\r\n"));
}
}
}
diff --git a/oox/source/token/tokenmap.cxx b/oox/source/token/tokenmap.cxx
index 9318971226e7..7cbba35009ae 100644
--- a/oox/source/token/tokenmap.cxx
+++ b/oox/source/token/tokenmap.cxx
@@ -74,7 +74,7 @@ TokenMap::~TokenMap()
{
}
-sal_Int32 TokenMap::getTokenFromUnicode( const OUString& rUnicodeName )
+sal_Int32 TokenMap::getTokenFromUnicode( std::u16string_view rUnicodeName )
{
OString aUtf8Name = OUStringToOString( rUnicodeName, RTL_TEXTENCODING_UTF8 );
const struct xmltoken* pToken = Perfect_Hash::in_word_set( aUtf8Name.getStr(), aUtf8Name.getLength() );
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index d89914e8c3be..62da5dedf10f 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -88,7 +88,7 @@ bool ConversionHelper::separatePair( OUString& orValue1, OUString& orValue2,
return !orValue1.isEmpty() && !orValue2.isEmpty();
}
-bool ConversionHelper::decodeBool( const OUString& rValue )
+bool ConversionHelper::decodeBool( std::u16string_view rValue )
{
sal_Int32 nToken = AttributeConversion::decodeToken( rValue );
// anything else than 't' or 'true' is considered to be false, as specified
@@ -276,7 +276,7 @@ Color ConversionHelper::decodeColor( const GraphicHelper& rGraphicHelper,
if( (2 <= nOpenParen) && (nOpenParen + 1 < nCloseParen) && (nCloseParen + 1 == aColorIndex.getLength()) )
{
sal_Int32 nModToken = XML_TOKEN_INVALID;
- switch( AttributeConversion::decodeToken( aColorIndex.copy( 0, nOpenParen ) ) )
+ switch( AttributeConversion::decodeToken( aColorIndex.subView( 0, nOpenParen ) ) )
{
case XML_darken: nModToken = XML_shade;break;
case XML_lighten: nModToken = XML_tint;
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index e8f1b0b1910e..e1b87a603173 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <string_view>
+
#include <oox/vml/vmlshapecontext.hxx>
#include <oox/core/xmlfilterbase.hxx>
@@ -126,9 +130,9 @@ OptValue< DoublePair > lclDecodePercentPair( const AttributeList& rAttribs, sal_
namespace (VML for spreadsheets). Supported values: f, t, False, True.
@param bDefaultForEmpty Default value for the empty string.
*/
-bool lclDecodeVmlxBool( const OUString& rValue, bool bDefaultForEmpty )
+bool lclDecodeVmlxBool( std::u16string_view rValue, bool bDefaultForEmpty )
{
- if( rValue.isEmpty() ) return bDefaultForEmpty;
+ if( rValue.empty() ) return bDefaultForEmpty;
sal_Int32 nToken = AttributeConversion::decodeToken( rValue );
// anything else than 't' or 'True' is considered to be false, as specified
return (nToken == XML_t) || (nToken == XML_True);