diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index 9501a40ca868..f50ec54c188e 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -427,6 +427,25 @@ const ApiPaperSize& PaperSizeConv::getApiSizeForMSPaperSizeIndex( sal_Int32 nMSO return spPaperSizeTable[ nMSOPaperIndex ]; } +OUString findQuotedText( const OUString& rCommand, + const sal_Char* cStartQuote, const sal_Unicode uEndQuote ) +{ + OUString sRet; + OUString sStartQuote( OUString::createFromAscii(cStartQuote) ); + sal_Int32 nStartIndex = rCommand.indexOf( sStartQuote ); + if( nStartIndex >= 0 ) + { + sal_Int32 nStartLength = sStartQuote.getLength(); + sal_Int32 nEndIndex = rCommand.indexOf( uEndQuote, nStartIndex + nStartLength); + if( nEndIndex > nStartIndex ) + { + sRet = rCommand.copy( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength); + } + } + return sRet; + +} + } } diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx index e13419905a0f..38cdf56e7df2 100644 --- a/include/filter/msfilter/util.hxx +++ b/include/filter/msfilter/util.hxx @@ -88,6 +88,13 @@ public: static sal_Int32 getMSPaperSizeIndex( const com::sun::star::awt::Size& rSize ); static const ApiPaperSize& getApiSizeForMSPaperSizeIndex( sal_Int32 nMSOPaperIndex ); }; + +/** + * Finds the quoted text in a field instruction text. + * + * Example: SEQ "Figure" \someoption -> "Figure" + */ +MSFILTER_DLLPUBLIC OUString findQuotedText( const OUString& rCommand, const sal_Char* cStartQuote, const sal_Unicode uEndQuote ); } } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 6f2a31efed04..7725b86d0604 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -71,6 +71,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::rtl; @@ -1822,33 +1823,12 @@ void DomainMapper_Impl::PopShapeContext() } } - -OUString lcl_FindQuotedText( const OUString& rCommand, - const sal_Char* cStartQuote, const sal_Unicode uEndQuote ) -{ - OUString sRet; - OUString sStartQuote( OUString::createFromAscii(cStartQuote) ); - sal_Int32 nStartIndex = rCommand.indexOf( sStartQuote ); - if( nStartIndex >= 0 ) - { - sal_Int32 nStartLength = sStartQuote.getLength(); - sal_Int32 nEndIndex = rCommand.indexOf( uEndQuote, nStartIndex + nStartLength); - if( nEndIndex > nStartIndex ) - { - sRet = rCommand.copy( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength); - } - } - return sRet; - -} - - sal_Int16 lcl_ParseNumberingType( const OUString& rCommand ) { sal_Int16 nRet = style::NumberingType::PAGE_DESCRIPTOR; // The command looks like: " PAGE \* Arabic " - OUString sNumber = lcl_FindQuotedText(rCommand, "\\* ", ' '); + OUString sNumber = msfilter::util::findQuotedText(rCommand, "\\* ", ' '); if( !sNumber.isEmpty() ) { @@ -1943,7 +1923,7 @@ style::NumberingType:: OUString lcl_ParseFormat( const OUString& rCommand ) { // The command looks like: " DATE \@ "dd MMMM yyyy" - return lcl_FindQuotedText(rCommand, "\\@ \"", '\"'); + return msfilter::util::findQuotedText(rCommand, "\\@ \"", '\"'); } /*------------------------------------------------------------------------- extract a parameter (with or without quotes) between the command and the following backslash @@ -3238,7 +3218,7 @@ void DomainMapper_Impl::CloseFieldCommand() // command looks like: " SEQ Table \* ARABIC " OUString sCmd(pContext->GetCommand()); // find the sequence name, e.g. "SEQ" - OUString sSeqName = lcl_FindQuotedText(sCmd, "SEQ ", '\\'); + OUString sSeqName = msfilter::util::findQuotedText(sCmd, "SEQ ", '\\'); sSeqName = sSeqName.trim(); // create a sequence field master using the sequence name