[Libreoffice-commits] core.git: sw/qa sw/source
Serge Krot
Serge.Krot at cib.de
Mon Oct 23 15:24:11 UTC 2017
sw/qa/extras/ooxmlexport/data/tdf38778_properties_in_run_for_field.doc |binary
sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 67 +++
sw/source/filter/ww8/attributeoutputbase.hxx | 4
sw/source/filter/ww8/docxattributeoutput.cxx | 179 +++++++---
sw/source/filter/ww8/docxattributeoutput.hxx | 12
sw/source/filter/ww8/docxexport.cxx | 4
sw/source/filter/ww8/rtfattributeoutput.cxx | 10
sw/source/filter/ww8/rtfattributeoutput.hxx | 4
sw/source/filter/ww8/wrtw8nds.cxx | 22 -
sw/source/filter/ww8/wrtww8.hxx | 2
sw/source/filter/ww8/ww8attributeoutput.hxx | 4
11 files changed, 237 insertions(+), 71 deletions(-)
New commits:
commit ccf475364881cebc13d50cf2cc9af2040b416bd3
Author: Serge Krot <Serge.Krot at cib.de>
Date: Tue Oct 17 19:03:14 2017 +0200
tdf#38778 fix missing run properties export for fields in docx
Not all runs got their text properties written during field export -
previously only the first run had them. Adds SwTextNode param to EndRun
and EndRuby methods, implementation empty for rtf and doc though.
Change-Id: I77f39b40689feb9664044e61824ad3bb97776638
Reviewed-on: https://gerrit.libreoffice.org/43465
Reviewed-by: Serge Krot (CIB) <Serge.Krot at cib.de>
Tested-by: Serge Krot (CIB) <Serge.Krot at cib.de>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf38778_properties_in_run_for_field.doc b/sw/qa/extras/ooxmlexport/data/tdf38778_properties_in_run_for_field.doc
new file mode 100644
index 000000000000..5f0f7238a153
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf38778_properties_in_run_for_field.doc differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 8858ffd5ade6..52fed19b7dc8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -675,6 +675,73 @@ DECLARE_OOXMLEXPORT_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val","");
}
+// Checks that all runs of the field have text properties.
+// Old behaviour: only first run has text properties of the field
+//
+// There are several runs are used in fields:
+// <w:r>
+// <w:rPr>
+// <!-- properties written with DocxAttributeOutput::StartRunProperties() / DocxAttributeOutput::EndRunProperties().
+// </w:rPr>
+// <w:fldChar w:fldCharType="begin" />
+// </w:r>
+// <w:r>
+// <w:rPr>
+// <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
+// </w:rPr>
+// <w:instrText>TIME \@"HH:mm:ss"</w:instrText>
+// </w:r>
+// <w:r>
+// <w:rPr>
+// <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
+// </w:rPr>
+// <w:fldChar w:fldCharType="separate" />
+// </w:r>
+// <w:r>
+// <w:rPr>
+// <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
+// </w:rPr>
+// <w:t>14:01:13</w:t>
+// </w:r>
+// <w:r>
+// <w:rPr>
+// <!-- properties written with DocxAttributeOutput::DoWriteFieldRunProperties()
+// </w:rPr>
+// <w:fldChar w:fldCharType="end" />
+// </w:r>
+// See, tdf#38778
+DECLARE_OOXMLEXPORT_TEST(testTdf38778, "tdf38778_properties_in_run_for_field.doc")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ const OUString psz("20");
+ const OUString pszCs("20");
+
+ // w:fldCharType="begin"
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[3]/w:rPr/w:sz", "val", psz);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[3]/w:rPr/w:szCs", "val", pszCs);
+
+ // PAGE
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[4]/w:rPr/w:sz", "val", psz);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[4]/w:rPr/w:szCs", "val", pszCs);
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[4]/w:instrText", " PAGE ");
+
+ // w:fldCharType="separate"
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[5]/w:rPr/w:sz", "val", psz);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[5]/w:rPr/w:szCs", "val", pszCs);
+
+ // field result: 1
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[6]/w:rPr/w:sz", "val", psz);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[6]/w:rPr/w:szCs", "val", pszCs);
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[6]/w:t", "1"); // field result
+
+ // w:fldCharType="end"
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[7]/w:rPr/w:sz", "val", psz);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[7]/w:rPr/w:szCs", "val", pszCs);
+}
+
DECLARE_OOXMLEXPORT_TEST(testFDO76312, "FDO76312.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 00ab40dcb88a..1cbe3a1a5376 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -172,7 +172,7 @@ public:
virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false ) = 0;
/// End of the text run.
- virtual void EndRun() = 0;
+ virtual void EndRun( const SwTextNode* pNode, sal_Int32 nPos ) = 0;
/// Called before we start outputting the attributes.
virtual void StartRunProperties() = 0;
@@ -199,7 +199,7 @@ public:
virtual void StartRuby( const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby ) = 0;
/// Output ruby end.
- virtual void EndRuby() = 0;
+ virtual void EndRuby( const SwTextNode& rNode, sal_Int32 nPos ) = 0;
/// Output URL start.
virtual bool StartURL( const OUString& rUrl, const OUString& rTarget ) = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 9f2e11da3a61..0461408b0a67 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1104,7 +1104,7 @@ void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bS
m_pSerializer->mark(Tag_StartRun_3); // let's call it "postponed text"
}
-void DocxAttributeOutput::EndRun()
+void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos)
{
int nFieldsInPrevHyperlink = m_nFieldsInHyperlink;
// Reset m_nFieldsInHyperlink if a new hyperlink is about to start
@@ -1119,7 +1119,7 @@ void DocxAttributeOutput::EndRun()
// Add the fields starts for all but hyperlinks and TOCs
if ( pIt->bOpen && pIt->pField )
{
- StartField_Impl( *pIt );
+ StartField_Impl( pNode, nPos, *pIt );
// Remove the field from the stack if only the start has to be written
// Unknown fields should be removed too
@@ -1167,7 +1167,7 @@ void DocxAttributeOutput::EndRun()
{
// If fields begin before hyperlink then
// it should end before hyperlink close
- EndField_Impl( m_Fields.back( ) );
+ EndField_Impl( pNode, nPos, m_Fields.back( ) );
m_Fields.pop_back();
}
m_pSerializer->endElementNS( XML_w, XML_hyperlink );
@@ -1184,7 +1184,7 @@ void DocxAttributeOutput::EndRun()
// Add the fields starts for hyperlinks, TOCs and index marks
if ( pIt->bOpen && !pIt->pField )
{
- StartField_Impl( *pIt, true );
+ StartField_Impl( pNode, nPos, *pIt, true );
if (m_startedHyperlink)
++m_nFieldsInHyperlink;
@@ -1213,7 +1213,7 @@ void DocxAttributeOutput::EndRun()
{
if (it->bClose && !it->pField)
{
- EndField_Impl(*it);
+ EndField_Impl( pNode, nPos, *it );
it = decltype(m_Fields)::reverse_iterator(m_Fields.erase(it.base() - 1));
}
else
@@ -1356,7 +1356,7 @@ void DocxAttributeOutput::EndRun()
{
// If fields begin after hyperlink start then
// it should end before hyperlink close
- EndField_Impl( m_Fields.back( ) );
+ EndField_Impl( pNode, nPos, m_Fields.back( ) );
m_Fields.pop_back();
}
m_nFieldsInHyperlink = 0;
@@ -1372,7 +1372,7 @@ void DocxAttributeOutput::EndRun()
{
while ( m_Fields.begin() != m_Fields.end() )
{
- EndField_Impl( m_Fields.front( ) );
+ EndField_Impl( pNode, nPos, m_Fields.front( ) );
m_Fields.erase( m_Fields.begin( ) );
}
m_nFieldsInHyperlink = 0;
@@ -1622,7 +1622,7 @@ void DocxAttributeOutput::WriteFFData( const FieldInfos& rInfos )
}
}
-void DocxAttributeOutput::StartField_Impl( FieldInfos const & rInfos, bool bWriteRun )
+void DocxAttributeOutput::StartField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun )
{
if ( rInfos.pField && rInfos.eType == ww::eUNKNOWN )
{
@@ -1655,9 +1655,9 @@ void DocxAttributeOutput::StartField_Impl( FieldInfos const & rInfos, bool bWrit
if ( bWriteRun )
m_pSerializer->endElementNS( XML_w, XML_r );
- if ( !rInfos.pField )
- CmdField_Impl( rInfos );
+ if ( !rInfos.pField )
+ CmdField_Impl( pNode, nPos, rInfos, bWriteRun );
}
else
{
@@ -1687,7 +1687,7 @@ void DocxAttributeOutput::StartField_Impl( FieldInfos const & rInfos, bool bWrit
// The hyperlinks fields can't be expanded: the value is
// normally in the text run
if ( !rInfos.pField )
- CmdField_Impl( rInfos );
+ CmdField_Impl( pNode, nPos, rInfos, bWriteRun );
}
}
}
@@ -1707,48 +1707,130 @@ void DocxAttributeOutput::DoWriteCmd( const OUString& rCmd )
}
-void DocxAttributeOutput::CmdField_Impl( FieldInfos const & rInfos )
+void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun )
{
- m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
- sal_Int32 nNbToken = comphelper::string::getTokenCount(rInfos.sCmd, '\t');
+ // Write the Field instruction
+ {
+ if ( bWriteRun )
+ {
+ m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
+ DoWriteFieldRunProperties( pNode, nPos );
+ }
- for ( sal_Int32 i = 0; i < nNbToken; i++ )
+ sal_Int32 nNbToken = comphelper::string::getTokenCount(rInfos.sCmd, '\t');
+
+ for ( sal_Int32 i = 0; i < nNbToken; i++ )
+ {
+ OUString sToken = rInfos.sCmd.getToken( i, '\t' );
+ if ( rInfos.eType == ww::eCREATEDATE
+ || rInfos.eType == ww::eSAVEDATE
+ || rInfos.eType == ww::ePRINTDATE
+ || rInfos.eType == ww::eDATE
+ || rInfos.eType == ww::eTIME )
+ {
+ sToken = sToken.replaceAll("NNNN", "dddd");
+ sToken = sToken.replaceAll("NN", "ddd");
+ }
+
+ // Write the Field command
+ DoWriteCmd( sToken );
+
+ // Replace tabs by </instrText><tab/><instrText>
+ if ( i < ( nNbToken - 1 ) )
+ RunText( "\t" );
+ }
+
+ if ( bWriteRun )
+ {
+ m_pSerializer->endElementNS( XML_w, XML_r );
+ }
+ }
+
+ // Write the Field separator
{
- OUString sToken = rInfos.sCmd.getToken( i, '\t' );
- if ( rInfos.eType == ww::eCREATEDATE
- || rInfos.eType == ww::eSAVEDATE
- || rInfos.eType == ww::ePRINTDATE
- || rInfos.eType == ww::eDATE
- || rInfos.eType == ww::eTIME )
+ if ( bWriteRun )
{
- sToken = sToken.replaceAll("NNNN", "dddd");
- sToken = sToken.replaceAll("NN", "ddd");
+ m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
+ DoWriteFieldRunProperties( pNode, nPos );
}
- // Write the Field command
- DoWriteCmd( sToken );
+ m_pSerializer->singleElementNS( XML_w, XML_fldChar,
+ FSNS( XML_w, XML_fldCharType ), "separate",
+ FSEND );
- // Replace tabs by </instrText><tab/><instrText>
- if ( i < ( nNbToken - 1 ) )
- RunText( "\t" );
+ if ( bWriteRun )
+ {
+ m_pSerializer->endElementNS( XML_w, XML_r );
+ }
}
+}
- m_pSerializer->endElementNS( XML_w, XML_r );
+/// Writes properties for run that is used to separate field implementation.
+/// There are several runs are used:
+/// <w:r>
+/// <w:rPr>
+/// <!-- properties written with StartRunProperties() / EndRunProperties().
+/// </w:rPr>
+/// <w:fldChar w:fldCharType="begin" />
+/// </w:r>
+/// <w:r>
+/// <w:rPr>
+/// <!-- properties written with DoWriteFieldRunProperties()
+/// </w:rPr>
+/// <w:instrText>TIME \@"HH:mm:ss"</w:instrText>
+/// </w:r>
+/// <w:r>
+/// <w:rPr>
+/// <!-- properties written with DoWriteFieldRunProperties()
+/// </w:rPr>
+/// <w:fldChar w:fldCharType="separate" />
+/// </w:r>
+/// <w:r>
+/// <w:rPr>
+/// <!-- properties written with DoWriteFieldRunProperties()
+/// </w:rPr>
+/// <w:t>14:01:13</w:t>
+/// </w:r>
+/// <w:r>
+/// <w:rPr>
+/// <!-- properties written with DoWriteFieldRunProperties()
+/// </w:rPr>
+/// <w:fldChar w:fldCharType="end" />
+/// </w:r>
+/// See, tdf#38778
+void DocxAttributeOutput::DoWriteFieldRunProperties( const SwTextNode * pNode, sal_Int32 nPos )
+{
+ if (! pNode)
+ {
+ // nothing to do
+ return;
+ }
- // Write the Field separator
- m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
- m_pSerializer->singleElementNS( XML_w, XML_fldChar,
- FSNS( XML_w, XML_fldCharType ), "separate",
- FSEND );
- m_pSerializer->endElementNS( XML_w, XML_r );
+ m_bPreventDoubleFieldsHandling = true;
+
+ {
+ m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
+
+ if(GetExport().m_bHideTabLeaderAndPageNumbers && m_pHyperlinkAttrList.is() )
+ {
+ m_pSerializer->singleElementNS( XML_w, XML_webHidden, FSEND );
+ }
+
+ SwWW8AttrIter aAttrIt( m_rExport, *pNode );
+ aAttrIt.OutAttr( nPos, false );
+
+ m_pSerializer->endElementNS( XML_w, XML_rPr );
+ }
+
+ m_bPreventDoubleFieldsHandling = false;
}
-void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos )
+void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& rInfos )
{
// The command has to be written before for the hyperlinks
if ( rInfos.pField )
{
- CmdField_Impl( rInfos );
+ CmdField_Impl( pNode, nPos, rInfos, true );
}
// Write the bookmark start if any
@@ -1761,6 +1843,8 @@ void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos )
{
// Write the Field latest value
m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
+ DoWriteFieldRunProperties( pNode, nPos );
+
OUString sExpand;
if(rInfos.eType == ww::eCITATION)
{
@@ -1789,6 +1873,7 @@ void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos )
if ( rInfos.bClose )
{
m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
+ DoWriteFieldRunProperties( pNode, nPos );
m_pSerializer->singleElementNS( XML_w, XML_fldChar,
FSNS( XML_w, XML_fldCharType ), "end",
FSEND );
@@ -1820,7 +1905,7 @@ void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos )
m_sFieldBkm = OUString( );
// Write the end of the field
- EndField_Impl( rInfos );
+ EndField_Impl( pNode, nPos, rInfos );
}
}
}
@@ -2339,7 +2424,7 @@ void DocxAttributeOutput::RawText(const OUString& /*rText*/, rtl_TextEncoding /*
void DocxAttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby )
{
SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::StartRuby( const SwTextNode& rNode, const SwFormatRuby& rRuby )" );
- EndRun(); // end run before starting ruby to avoid nested runs, and overlap
+ EndRun( &rNode, nPos ); // end run before starting ruby to avoid nested runs, and overlap
assert(!m_closeHyperlinkInThisRun); // check that no hyperlink overlaps ruby
assert(!m_closeHyperlinkInPreviousRun);
m_pSerializer->startElementNS( XML_w, XML_ruby, FSEND );
@@ -2393,17 +2478,17 @@ void DocxAttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 nPos, co
EndRunProperties( nullptr );
RunText( rRuby.GetText( ) );
- EndRun( );
+ EndRun( &rNode, nPos );
m_pSerializer->endElementNS( XML_w, XML_rt );
m_pSerializer->startElementNS( XML_w, XML_rubyBase, FSEND );
StartRun( nullptr );
}
-void DocxAttributeOutput::EndRuby()
+void DocxAttributeOutput::EndRuby(const SwTextNode& rNode, sal_Int32 nPos)
{
SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::EndRuby()" );
- EndRun( );
+ EndRun( &rNode, nPos );
m_pSerializer->endElementNS( XML_w, XML_rubyBase );
m_pSerializer->endElementNS( XML_w, XML_ruby );
StartRun(nullptr); // open Run again so OutputTextNode loop can close it
@@ -6515,6 +6600,9 @@ void DocxAttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
void DocxAttributeOutput::CharColor( const SvxColorItem& rColor )
{
+ if (m_bPreventDoubleFieldsHandling)
+ return;
+
const Color aColor( rColor.GetValue() );
OString aColorString;
@@ -7066,6 +7154,9 @@ void DocxAttributeOutput::WriteExpand( const SwField* pField )
void DocxAttributeOutput::WriteField_Impl( const SwField* pField, ww::eField eType, const OUString& rFieldCmd, FieldFlags nMode )
{
+ if (m_bPreventDoubleFieldsHandling)
+ return;
+
struct FieldInfos infos;
if (pField)
infos.pField.reset(pField->CopyField());
@@ -8620,6 +8711,9 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem)
void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem )
{
+ if (m_bPreventDoubleFieldsHandling)
+ return;
+
const std::map< OUString, css::uno::Any >& rMap = rItem.GetGrabBag();
// get original values of theme-derived properties to check if they have changed during the edition
@@ -8821,6 +8915,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, const FSHelperPtr
m_bRunTextIsOn( false ),
m_bWritingHeaderFooter( false ),
m_bAnchorLinkedToNode(false),
+ m_bPreventDoubleFieldsHandling( false ),
m_sFieldBkm( ),
m_nNextBookmarkId( 0 ),
m_nNextAnnotationMarkId( 0 ),
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 3fdfd95cd312..2515210fcfb5 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -166,7 +166,7 @@ public:
virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false ) override;
/// End of the text run.
- virtual void EndRun() override;
+ virtual void EndRun(const SwTextNode* pNode, sal_Int32 nPos) override;
/// Called before we start outputting the attributes.
virtual void StartRunProperties() override;
@@ -190,7 +190,7 @@ public:
virtual void StartRuby( const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby ) override;
/// Output ruby end.
- virtual void EndRuby() override;
+ virtual void EndRuby(const SwTextNode& rNode, sal_Int32 nPos) override;
/// Output URL start.
virtual bool StartURL( const OUString& rUrl, const OUString& rTarget ) override;
@@ -725,10 +725,11 @@ private:
/// Closes a currently open SDT block.
void EndSdtBlock();
- void StartField_Impl( FieldInfos const & rInfos, bool bWriteRun = false );
+ void StartField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun = false );
void DoWriteCmd( const OUString& rCmd );
- void CmdField_Impl( FieldInfos const & rInfos );
- void EndField_Impl( FieldInfos& rInfos );
+ void CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun );
+ void EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& rInfos );
+ void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos );
static void AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nAttrName, const sal_Char* sAttrValue );
static void AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nArgs, ... );
@@ -776,6 +777,7 @@ private:
bool m_bAnchorLinkedToNode;
/// Field data to remember in the text run
+ bool m_bPreventDoubleFieldsHandling;
std::vector< FieldInfos > m_Fields;
OUString m_sFieldBkm;
sal_Int32 m_nNextBookmarkId;
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index b57d24acbdb1..fddce24b159d 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1512,7 +1512,9 @@ void DocxExport::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTy
nAktPos = nNextAttr;
eChrSet = eNextChrSet;
aAttrIter.NextPos();
- AttrOutput().EndRun();
+
+ AttrOutput().EndRun( nullptr, 0 );
+
} while( nAktPos < nEnd );
// aAttrIter.OutParaAttr(false);
AttrOutput().EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t());
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 21406ab98fb9..48e004bb7102 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -395,7 +395,7 @@ void RtfAttributeOutput::StartRun(const SwRedlineData* pRedlineData, bool bSingl
OSL_ENSURE(m_aRunText.getLength() == 0, "m_aRunText is not empty");
}
-void RtfAttributeOutput::EndRun()
+void RtfAttributeOutput::EndRun(const SwTextNode* /*pNode*/, sal_Int32 /*nPos*/)
{
m_aRun->append(SAL_NEWLINE_STRING);
m_aRun.appendAndClear(m_aRunText);
@@ -436,7 +436,7 @@ void RtfAttributeOutput::RawText(const OUString& rText, rtl_TextEncoding eCharSe
m_aRunText->append(msfilter::rtfutil::OutString(rText, eCharSet));
}
-void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/, const SwFormatRuby& rRuby)
+void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby)
{
OUString aStr(FieldString(ww::eEQ));
aStr += "\\* jc";
@@ -528,7 +528,7 @@ void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/,
nHeight = (rHeightItem.GetHeight() + 10)/20-1;
aStr += OUString::number(nHeight);
aStr += "(";
- EndRun();
+ EndRun(&rNode, nPos);
m_rExport.OutputField(nullptr, ww::eEQ, aStr, FieldFlags::Start | FieldFlags::CmdStart);
aStr = rRuby.GetText();
aStr += ")";
@@ -536,10 +536,10 @@ void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/,
m_rExport.OutputField(nullptr, ww::eEQ, aStr, FieldFlags::NONE);
}
-void RtfAttributeOutput::EndRuby()
+void RtfAttributeOutput::EndRuby(const SwTextNode& rNode, sal_Int32 nPos)
{
m_rExport.OutputField(nullptr, ww::eEQ, ")", FieldFlags::End | FieldFlags::Close);
- EndRun();
+ EndRun(&rNode, nPos);
}
bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget)
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index f0fbe732ee3c..1520569a7dd3 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -66,7 +66,7 @@ public:
void StartRun(const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false) override;
/// End of the text run.
- void EndRun() override;
+ void EndRun(const SwTextNode* pNode, sal_Int32 nPos) override;
/// Called before we start outputting the attributes.
void StartRunProperties() override;
@@ -92,7 +92,7 @@ public:
void StartRuby(const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby) override;
/// Output ruby end.
- void EndRuby() override;
+ void EndRuby(const SwTextNode& rNode, sal_Int32 nPos) override;
/// Output URL start.
bool StartURL(const OUString& rUrl, const OUString& rTarget) override;
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 3b91af45d4d4..a43db5d01869 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -871,7 +871,7 @@ void WW8AttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 /*nPos*/,
FieldFlags::Start | FieldFlags::CmdStart );
}
-void WW8AttributeOutput::EndRuby()
+void WW8AttributeOutput::EndRuby(const SwTextNode& /*rNode*/, sal_Int32 /*nPos*/)
{
m_rWW8Export.WriteChar( ')' );
m_rWW8Export.OutputField( nullptr, ww::eEQ, OUString(), FieldFlags::End | FieldFlags::Close );
@@ -1219,7 +1219,7 @@ void AttributeOutputBase::TOXMark( const SwTextNode& rNode, const SwTOXMark& rAt
FieldVanish( sText, eType );
}
-int SwWW8AttrIter::OutAttrWithRange(sal_Int32 nPos)
+int SwWW8AttrIter::OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos)
{
int nRet = 0;
if ( const SwpHints* pTextAttrs = rNd.GetpSwpHints() )
@@ -1253,7 +1253,7 @@ int SwWW8AttrIter::OutAttrWithRange(sal_Int32 nPos)
pEnd = pHt->End();
if (nPos == *pEnd && nPos != pHt->GetStart())
{
- m_rExport.AttrOutput().EndRuby();
+ m_rExport.AttrOutput().EndRuby(rNode, nPos);
--nRet;
}
break;
@@ -1307,7 +1307,7 @@ int SwWW8AttrIter::OutAttrWithRange(sal_Int32 nPos)
pEnd = pHt->End();
if (nPos == *pEnd && nPos == pHt->GetStart())
{ // special case: empty must be handled here
- m_rExport.AttrOutput().EndRuby();
+ m_rExport.AttrOutput().EndRuby( rNd, nPos );
--nRet;
}
break;
@@ -2156,7 +2156,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
{
if( AttrOutput().FootnoteEndnoteRefTag() )
{
- AttrOutput().EndRun();
+ AttrOutput().EndRun( &rNode, nAktPos );
AttrOutput().StartRun( pRedlineData, bSingleEmptyRun );
}
}
@@ -2193,7 +2193,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
AppendSmartTags(rNode);
bool bTextAtr = aAttrIter.IsTextAttr( nAktPos );
- nOpenAttrWithRange += aAttrIter.OutAttrWithRange(nAktPos);
+ nOpenAttrWithRange += aAttrIter.OutAttrWithRange( rNode, nAktPos );
sal_Int32 nLen = nNextAttr - nAktPos;
if ( !bTextAtr && nLen )
@@ -2381,7 +2381,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
bool bAttrWithRange = (nOpenAttrWithRange > 0);
if ( nAktPos != nEnd )
{
- nOpenAttrWithRange += aAttrIter.OutAttrWithRange(nEnd);
+ nOpenAttrWithRange += aAttrIter.OutAttrWithRange( rNode, nEnd );
OSL_ENSURE(nOpenAttrWithRange == 0,
"odd to see this happening, expected 0");
}
@@ -2430,7 +2430,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if( bPostponeWritingText && FLY_PROCESSED == nStateOfFlyFrame )
{
- AttrOutput().EndRun();
+ AttrOutput().EndRun(&rNode, nAktPos);
//write the postponed text run
AttrOutput().StartRun( pRedlineData, bSingleEmptyRun );
AttrOutput().SetAnchorIsLinkedToNode( false );
@@ -2442,16 +2442,16 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
AttrOutput().EndRunProperties( pRedlineData );
}
AttrOutput().RunText( aSavedSnippet, eChrSet );
- AttrOutput().EndRun();
+ AttrOutput().EndRun(&rNode, nAktPos);
}
else if( bPostponeWritingText && !aSavedSnippet.isEmpty() )
{
//write the postponed text run
AttrOutput().RunText( aSavedSnippet, eChrSet );
- AttrOutput().EndRun();
+ AttrOutput().EndRun(&rNode, nAktPos);
}
else
- AttrOutput().EndRun();
+ AttrOutput().EndRun(&rNode, nAktPos);
nAktPos = nNextAttr;
UpdatePosition( &aAttrIter, nAktPos );
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index cce3de273005..a835bfca6099 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1492,7 +1492,7 @@ public:
void OutAttr( sal_Int32 nSwPos, bool bRuby = false );
virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const override;
virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const override;
- int OutAttrWithRange(sal_Int32 nPos);
+ int OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos);
const SwRedlineData* GetParagraphLevelRedline( );
const SwRedlineData* GetRunLevelRedline( sal_Int32 nPos );
FlyProcessingState OutFlys(sal_Int32 nSwPos);
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 4136de0ab9f2..84525b6a165d 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -56,7 +56,7 @@ public:
/// End of the text run.
///
/// No-op for binary filters.
- virtual void EndRun() override {}
+ virtual void EndRun(const SwTextNode* , sal_Int32 ) override {}
/// Before we start outputting the attributes.
virtual void StartRunProperties() override;
@@ -74,7 +74,7 @@ public:
virtual void StartRuby( const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby ) override;
/// Output ruby end.
- virtual void EndRuby() override;
+ virtual void EndRuby(const SwTextNode& rNode, sal_Int32 nPos) override;
/// Output URL start.
virtual bool StartURL( const OUString &rUrl, const OUString &rTarget ) override;
More information about the Libreoffice-commits
mailing list