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>
This commit is contained in:
@@ -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) + "}";
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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("}"); //"}"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user