filter/inc/filter/msfilter/util.hxx | 7 ++++ filter/source/msfilter/util.cxx | 19 +++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 32 ++++++++++++++++++++++ sw/source/filter/ww8/docxattributeoutput.hxx | 7 ++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 26 ++--------------- 5 files changed, 68 insertions(+), 23 deletions(-)
New commits: commit 2f684f3de4f356bc570d279a392a6afe862314c3 Author: Miklos Vajna <[email protected]> Date: Mon Aug 26 11:35:48 2013 +0200 bnc#834035 DOCX export: fix hyperlinks of illustration index We used to export raw Writer bookmarks, but that's not valid in OOXML. Instead, it has normal bookmarks around the sequence fields, so use them if they are available. Change-Id: I0ef2ff7967c2802b53752c9505ef6db4cc2b8265 (cherry picked from commit e9275c08acc2f4f1c925f78b56a1089515cd9a37) Conflicts: sw/source/filter/ww8/docxattributeoutput.cxx diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 58d6b0a..bb7bd74 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -614,6 +614,7 @@ void DocxAttributeOutput::DoWriteBookmarks() FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( nId ) ).getStr( ), FSNS( XML_w, XML_name ), rName.getStr(), FSEND ); + m_sLastOpenedMark = rName; } m_rMarksStart.clear(); @@ -743,6 +744,12 @@ void DocxAttributeOutput::StartField_Impl( FieldInfos& rInfos, bool bWriteRun ) void DocxAttributeOutput::DoWriteCmd( String& rCmd ) { + OUString sCmd = OUString(rCmd).trim(); + if (sCmd.startsWith("SEQ")) + { + OUString sSeqName = msfilter::util::findQuotedText(sCmd, "SEQ ", '\\').trim(); + m_aSeqMarksNames[sSeqName].push_back(m_sLastOpenedMark); + } // Write the Field command m_pSerializer->startElementNS( XML_w, XML_instrText, FSEND ); m_pSerializer->writeEscaped( OUString( rCmd ) ); @@ -1225,8 +1232,33 @@ bool DocxAttributeOutput::StartURL( const String& rUrl, const String& rTarget ) m_pHyperlinkAttrList->add( FSNS( XML_r, XML_id), sId.getStr()); } else + { + // Is this a link to a sequence? Then try to replace that with a + // normal bookmark, as Word won't understand our special + // <seqname>!<index>|sequence syntax. + OUString aMark(sMark); + if (aMark.endsWith("|sequence")) + { + sal_Int32 nPos = aMark.indexOf('!'); + if (nPos != -1) + { + // Extract <seqname>, the field instruction text has the name quoted. + OUString aSequenceName = OUString('"') + aMark.copy(0, nPos) + OUString('"'); + // Extract <index>. + sal_uInt32 nIndex = aMark.copy(nPos + 1, aMark.getLength() - nPos - sizeof("|sequence")).toInt32(); + std::map<OUString, std::vector<OString> >::iterator it = m_aSeqMarksNames.find(aSequenceName); + if (it != m_aSeqMarksNames.end()) + { + std::vector<OString>& rNames = it->second; + if (rNames.size() > nIndex) + // We know the bookmark name for this sequence and this index, do the replacement. + sMark = OStringToOUString(rNames[nIndex], RTL_TEXTENCODING_UTF8); + } + } + } m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ), OUStringToOString( OUString( sMark ), RTL_TEXTENCODING_UTF8 ).getStr( ) ); + } OUString sTarget( rTarget ); if ( !sTarget.isEmpty() ) diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index ecdc243..cd81387 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -586,6 +586,13 @@ private: /// Maps of the bookmarks ids std::map<rtl::OString, sal_uInt16> m_rOpenedMarksIds; + /// Name of the last opened bookmark. + OString m_sLastOpenedMark; + + /// If there are bookmarks around sequence fields, this map contains the + /// names of these bookmarks for each sequence. + std::map<OUString, std::vector<OString> > m_aSeqMarksNames; + /// The current table helper SwWriteTable *m_pTableWrt; commit 201aa49d9a386844822087362cccd49dbff9d21a Author: Miklos Vajna <[email protected]> Date: Mon Aug 26 11:05:04 2013 +0200 bnc#834035 Introduce msfilter::util::findQuotedText() This was in writerfilter, but we'll need it soon in sw as well, so move it down to msfilter. Change-Id: I8efe02b6bbe8f391d9e14857ed58dbae184d5632 (cherry picked from commit 750f0ebf97d19d1cf305dabe72d52ad6e90adf70) Conflicts: include/filter/msfilter/util.hxx writerfilter/source/dmapper/DomainMapper_Impl.cxx diff --git a/filter/inc/filter/msfilter/util.hxx b/filter/inc/filter/msfilter/util.hxx index dc57627..e14eaf0 100644 --- a/filter/inc/filter/msfilter/util.hxx +++ b/filter/inc/filter/msfilter/util.hxx @@ -103,6 +103,13 @@ public: 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/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index 498d2d5..22c2a25 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -446,6 +446,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/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 57e2aed..8f1af5a 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -75,6 +75,7 @@ #include <comphelper/stlunosequence.hxx> #include <vcl/svapp.hxx> #include <vcl/outdev.hxx> +#include <filter/msfilter/util.hxx> using namespace ::com::sun::star; using namespace ::rtl; @@ -1778,33 +1779,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() ) { @@ -1899,7 +1879,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 _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
