summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-04-11 11:09:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-04-11 17:18:51 +0200
commit38640d7cb4dd6c19cd9f0c944536dfc1ccec1bf8 (patch)
tree221a7b8fa6aa53b6d69414f821ea128997fa301d
parent8ac1dd864bc535a25caa91c44e7d94b8b8ab9024 (diff)
use more string_view in filter
Change-Id: Icbccd81fd0fa18fc15a32aa2729b1c5f9a3ee542 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150220 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--filter/source/msfilter/rtfutil.cxx7
-rw-r--r--filter/source/msfilter/util.cxx5
-rw-r--r--include/filter/msfilter/rtfutil.hxx4
-rw-r--r--include/filter/msfilter/util.hxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx2
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx12
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx6
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx8
-rw-r--r--sw/source/filter/ww8/rtfexport.hxx6
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx4
10 files changed, 27 insertions, 29 deletions
diff --git a/filter/source/msfilter/rtfutil.cxx b/filter/source/msfilter/rtfutil.cxx
index 71c3e0ff98eb..53f4caea7b98 100644
--- a/filter/source/msfilter/rtfutil.cxx
+++ b/filter/source/msfilter/rtfutil.cxx
@@ -210,12 +210,11 @@ OString OutChar(sal_Unicode c, int* pUCMode, rtl_TextEncoding eDestEnc, bool* pS
return aBuf.makeStringAndClear();
}
-OString OutString(const OUString& rStr, rtl_TextEncoding eDestEnc, bool bUnicode)
+OString OutString(std::u16string_view rStr, rtl_TextEncoding eDestEnc, bool bUnicode)
{
- SAL_INFO("filter.ms", __func__ << ", rStr = '" << rStr << "'");
OStringBuffer aBuf;
int nUCMode = 1;
- for (sal_Int32 n = 0; n < rStr.getLength(); ++n)
+ for (size_t n = 0; n < rStr.size(); ++n)
aBuf.append(OutChar(rStr[n], &nUCMode, eDestEnc, nullptr, bUnicode));
if (nUCMode != 1)
{
@@ -240,7 +239,7 @@ static bool TryOutString(std::u16string_view rStr, rtl_TextEncoding eDestEnc)
return true;
}
-OString OutStringUpr(const char* pToken, const OUString& rStr, rtl_TextEncoding eDestEnc)
+OString OutStringUpr(std::string_view pToken, std::u16string_view rStr, rtl_TextEncoding eDestEnc)
{
if (TryOutString(rStr, eDestEnc))
return OString::Concat("{") + pToken + " " + OutString(rStr, eDestEnc) + "}";
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 32783f2c42f8..18ed0dea22fe 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -331,14 +331,13 @@ OUString CreateDOCXStyleId(std::u16string_view const aName)
}
std::u16string_view findQuotedText( std::u16string_view rCommand,
- const char* cStartQuote, const sal_Unicode uEndQuote )
+ std::u16string_view sStartQuote, const sal_Unicode uEndQuote )
{
std::u16string_view sRet;
- OUString sStartQuote( OUString::createFromAscii(cStartQuote) );
size_t nStartIndex = rCommand.find( sStartQuote );
if( nStartIndex != std::u16string_view::npos )
{
- sal_Int32 nStartLength = sStartQuote.getLength();
+ sal_Int32 nStartLength = sStartQuote.size();
size_t nEndIndex = rCommand.find( uEndQuote, nStartIndex + nStartLength);
if( nEndIndex != std::u16string_view::npos && nEndIndex > nStartIndex )
{
diff --git a/include/filter/msfilter/rtfutil.hxx b/include/filter/msfilter/rtfutil.hxx
index fd7473149df6..7c678402abd9 100644
--- a/include/filter/msfilter/rtfutil.hxx
+++ b/include/filter/msfilter/rtfutil.hxx
@@ -38,7 +38,7 @@ MSFILTER_DLLPUBLIC OString OutChar(sal_Unicode c, int* pUCMode, rtl_TextEncoding
* @param eDestEnc the legacy encoding to use
* @param bUnicode if unicode output is wanted as well, or just legacy
*/
-MSFILTER_DLLPUBLIC OString OutString(const OUString& rStr, rtl_TextEncoding eDestEnc,
+MSFILTER_DLLPUBLIC OString OutString(std::u16string_view rStr, rtl_TextEncoding eDestEnc,
bool bUnicode = true);
/**
@@ -50,7 +50,7 @@ MSFILTER_DLLPUBLIC OString OutString(const OUString& rStr, rtl_TextEncoding eDes
* @param rStr the text to export
* @param eDestEnc the legacy encoding to use
*/
-MSFILTER_DLLPUBLIC OString OutStringUpr(const char* pToken, const OUString& rStr,
+MSFILTER_DLLPUBLIC OString OutStringUpr(std::string_view pToken, std::u16string_view rStr,
rtl_TextEncoding eDestEnc);
/**
diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx
index b9b92ba930ef..495c8ed13581 100644
--- a/include/filter/msfilter/util.hxx
+++ b/include/filter/msfilter/util.hxx
@@ -86,7 +86,7 @@ MSFILTER_DLLPUBLIC OUString CreateDOCXStyleId(std::u16string_view aName);
*
* Example: SEQ "Figure" \someoption -> "Figure"
*/
-MSFILTER_DLLPUBLIC std::u16string_view findQuotedText( std::u16string_view rCommand, const char* cStartQuote, const sal_Unicode uEndQuote );
+MSFILTER_DLLPUBLIC std::u16string_view findQuotedText( std::u16string_view rCommand, std::u16string_view cStartQuote, const sal_Unicode uEndQuote );
class MSFILTER_DLLPUBLIC WW8ReadFieldParams
{
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ce6e28e26407..70e5156644e3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2703,7 +2703,7 @@ void DocxAttributeOutput::DoWriteCmd( std::u16string_view rCmd )
std::u16string_view sCmd = o3tl::trim(rCmd);
if (o3tl::starts_with(sCmd, u"SEQ"))
{
- OUString sSeqName( o3tl::trim(msfilter::util::findQuotedText(sCmd, "SEQ ", '\\')) );
+ OUString sSeqName( o3tl::trim(msfilter::util::findQuotedText(sCmd, u"SEQ ", '\\')) );
m_aSeqBookmarksNames[sSeqName].push_back(m_sLastOpenedBookmark);
}
// Write the Field command
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index f5134d4da2e2..53ba6418a904 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1706,10 +1706,10 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart,
}
void RtfAttributeOutput::WriteField_Impl(const SwField* const pField, ww::eField /*eType*/,
- const OUString& rFieldCmd, FieldFlags nMode)
+ std::u16string_view rFieldCmd, FieldFlags nMode)
{
// If there are no field instructions, don't export it as a field.
- bool bHasInstructions = !rFieldCmd.isEmpty();
+ bool bHasInstructions = !rFieldCmd.empty();
if (FieldFlags::All == nMode)
{
if (bHasInstructions)
@@ -3959,7 +3959,7 @@ MSWordExportBase& RtfAttributeOutput::GetExport() { return m_rExport; }
// These are used by wwFont::WriteRtf()
/// Start the font.
-void RtfAttributeOutput::StartFont(const OUString& rFamilyName) const
+void RtfAttributeOutput::StartFont(std::u16string_view rFamilyName) const
{
// write the font name hex-encoded, but without Unicode - Word at least
// cannot read *both* Unicode and fallback as written by OutString
@@ -3975,7 +3975,7 @@ void RtfAttributeOutput::EndFont() const
}
/// Alternate name for the font.
-void RtfAttributeOutput::FontAlternateName(const OUString& rName) const
+void RtfAttributeOutput::FontAlternateName(std::u16string_view rName) const
{
m_rExport.Strm()
.WriteChar('{')
@@ -4047,7 +4047,7 @@ void RtfAttributeOutput::FontPitchType(FontPitch ePitch) const
m_rExport.Strm().WriteNumberAsString(nVal);
}
-static void lcl_AppendSP(OStringBuffer& rBuffer, const char cName[], const OUString& rValue,
+static void lcl_AppendSP(OStringBuffer& rBuffer, std::string_view cName, std::u16string_view rValue,
const RtfExport& rExport)
{
rBuffer.append("{" OOO_STRING_SVTOOLS_RTF_SP "{"); // "{\sp{"
@@ -4088,7 +4088,7 @@ static OString ExportPICT(const SwFlyFrameFormat* pFlyFrameFormat, const Size& r
MirrorGraph eMirror = pAttrSet->Get(RES_GRFATR_MIRRORGRF).GetValue();
if (eMirror == MirrorGraph::Vertical || eMirror == MirrorGraph::Both)
// Mirror on the vertical axis is a horizontal flip.
- lcl_AppendSP(aRet, "fFlipH", "1", rExport);
+ lcl_AppendSP(aRet, "fFlipH", u"1", rExport);
}
aRet.append("}"); //"}"
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 985df695b2d9..fdd5ed09d3bc 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -226,7 +226,7 @@ public:
const OUString& rNumberingString,
const SvxBrushItem* pBrush) override; //For i120928,to export graphic of bullet
- void WriteField_Impl(const SwField* pField, ww::eField eType, const OUString& rFieldCmd,
+ void WriteField_Impl(const SwField* pField, ww::eField eType, std::u16string_view rFieldCmd,
FieldFlags nMode);
void WriteBookmarks_Impl(std::vector<OUString>& rStarts, std::vector<OUString>& rEnds);
void WriteAnnotationMarks_Impl(std::vector<OUString>& rStarts, std::vector<OUString>& rEnds);
@@ -663,13 +663,13 @@ public:
// These are used by wwFont::WriteRtf()
/// Start the font.
- void StartFont(const OUString& rFamilyName) const;
+ void StartFont(std::u16string_view rFamilyName) const;
/// End the font.
void EndFont() const;
/// Alternate name for the font.
- void FontAlternateName(const OUString& rName) const;
+ void FontAlternateName(std::u16string_view rName) const;
/// Font charset.
void FontCharset(sal_uInt8 nCharSet) const;
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index b59012b857d7..ccde1138c76c 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -575,7 +575,7 @@ void RtfExport::WriteUserPropType(int nType)
Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_PROPTYPE).WriteNumberAsString(nType);
}
-void RtfExport::WriteUserPropValue(const OUString& rValue)
+void RtfExport::WriteUserPropValue(std::u16string_view rValue)
{
Strm().WriteOString("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " ");
Strm().WriteOString(msfilter::rtfutil::OutString(rValue, m_eDefaultEncoding));
@@ -1182,9 +1182,9 @@ OString RtfExport::getStream()
void RtfExport::resetStream() { m_pStream.reset(); }
-void RtfExport::OutUnicode(const char* pToken, const OUString& rContent, bool bUpr)
+void RtfExport::OutUnicode(std::string_view pToken, std::u16string_view rContent, bool bUpr)
{
- if (rContent.isEmpty())
+ if (rContent.empty())
return;
if (!bUpr)
@@ -1197,7 +1197,7 @@ void RtfExport::OutUnicode(const char* pToken, const OUString& rContent, bool bU
Strm().WriteOString(msfilter::rtfutil::OutStringUpr(pToken, rContent, m_eCurrentEncoding));
}
-void RtfExport::OutDateTime(const char* pStr, const util::DateTime& rDT)
+void RtfExport::OutDateTime(std::string_view pStr, const util::DateTime& rDT)
{
Strm().WriteChar('{').WriteOString(pStr).WriteOString(OOO_STRING_SVTOOLS_RTF_YR);
Strm().WriteNumberAsString(rDT.Year).WriteOString(OOO_STRING_SVTOOLS_RTF_MO);
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index ff6ae87bd072..6098ad912e66 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -186,8 +186,8 @@ public:
OString getStream();
/// Return back to the real stream.
void resetStream();
- void OutUnicode(const char* pToken, const OUString& rContent, bool bUpr = false);
- void OutDateTime(const char* pStr, const css::util::DateTime& rDT);
+ void OutUnicode(std::string_view pToken, std::u16string_view rContent, bool bUpr = false);
+ void OutDateTime(std::string_view pStr, const css::util::DateTime& rDT);
void OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirstPage);
sal_uInt16 GetColor(const Color& rColor) const;
@@ -211,7 +211,7 @@ private:
/// Writes a single user property type.
void WriteUserPropType(int nType);
/// Writes a single user property value.
- void WriteUserPropValue(const OUString& rValue);
+ void WriteUserPropValue(std::u16string_view rValue);
/// Writes the userprops group: user defined document properties.
void WriteUserProps();
/// Writes document variables
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f559060704b6..8511417e852c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4637,7 +4637,7 @@ static OUString lcl_ParseFormat( const OUString& rCommand )
// turn date \@ MM into date \@"MM"
command = OUString::Concat(rCommand.subView(0, delimPos + 2)) + "\"" + o3tl::trim(rCommand.subView(delimPos + 2)) + "\"";
}
- return OUString(msfilter::util::findQuotedText(command, "\\@\"", '\"'));
+ return OUString(msfilter::util::findQuotedText(command, u"\\@\"", '\"'));
}
return OUString();
@@ -7317,7 +7317,7 @@ void DomainMapper_Impl::CloseFieldCommand()
// command looks like: " SEQ Table \* ARABIC "
OUString sCmd(pContext->GetCommand());
// find the sequence name, e.g. "SEQ"
- std::u16string_view sSeqName = msfilter::util::findQuotedText(sCmd, "SEQ ", '\\');
+ std::u16string_view sSeqName = msfilter::util::findQuotedText(sCmd, u"SEQ ", '\\');
sSeqName = o3tl::trim(sSeqName);
// create a sequence field master using the sequence name