diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-13 09:48:48 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-13 09:53:32 +0100 |
commit | 9ae3ad21422da1ed9693bdc9d14a06b15657c11f (patch) | |
tree | 4d8726d0e76f987ffb1f8c89e7e7209665c4e59b /sw/source | |
parent | 38ab09ecea3a983b315c6a69b1a941e45a933320 (diff) |
DOCX export: fix nested comments
Change-Id: I9e252ab5645de8f88d0d4c6c0023402d86dd2e9e
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 20 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 4 |
2 files changed, 18 insertions, 6 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 4ad9c9b5ba5c..0b04ccb30aba 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4670,18 +4670,28 @@ void DocxAttributeOutput::HiddenField( const SwField& /*rFld*/ ) void DocxAttributeOutput::PostitField( const SwField* pFld ) { assert( dynamic_cast< const SwPostItField* >( pFld )); - m_postitFields.push_back( static_cast< const SwPostItField* >( pFld )); + const SwPostItField* pPostItFld = static_cast<const SwPostItField*>(pFld); + OString aName = OUStringToOString(pPostItFld->GetName(), RTL_TEXTENCODING_UTF8); + sal_Int32 nId = 0; + std::map< OString, sal_uInt16 >::iterator it = m_rOpenedAnnotationMarksIds.find(aName); + if (it != m_rOpenedAnnotationMarksIds.end()) + // If the postit field has an annotation mark associated, we already have an id. + nId = it->second; + else + // Otherwise get a new one. + nId = m_nNextAnnotationMarkId++; + m_postitFields.push_back(std::make_pair(pPostItFld, nId)); } void DocxAttributeOutput::WritePostitFieldReference() { while( m_postitFieldsMaxId < m_postitFields.size()) { - OString idstr = OString::number( m_postitFieldsMaxId); + OString idstr = OString::number(m_postitFields[m_postitFieldsMaxId].second); // In case this file is inside annotation marks, we want to write the // comment reference after the annotation mark is closed, not here. - OString idname = OUStringToOString(m_postitFields[m_postitFieldsMaxId]->GetName(), RTL_TEXTENCODING_UTF8); + OString idname = OUStringToOString(m_postitFields[m_postitFieldsMaxId].first->GetName(), RTL_TEXTENCODING_UTF8); std::map< OString, sal_uInt16 >::iterator it = m_rOpenedAnnotationMarksIds.find( idname ); if ( it == m_rOpenedAnnotationMarksIds.end( ) ) m_pSerializer->singleElementNS( XML_w, XML_commentReference, FSNS( XML_w, XML_id ), idstr.getStr(), FSEND ); @@ -4695,8 +4705,8 @@ void DocxAttributeOutput::WritePostitFields() i < m_postitFields.size(); ++i ) { - OString idstr = OString::number( i); - const SwPostItField* f = m_postitFields[ i ]; + OString idstr = OString::number( m_postitFields[ i ].second); + const SwPostItField* f = m_postitFields[ i ].first; m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr.getStr(), FSNS( XML_w, XML_author ), OUStringToOString( f->GetPar1(), RTL_TEXTENCODING_UTF8 ).getStr(), FSNS( XML_w, XML_date ), DateTimeToOString(f->GetDateTime()).getStr(), diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 3375895d249f..87bafdcde4fe 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -783,7 +783,9 @@ private: const SdrObject* m_postponedChart; Size m_postponedChartSize; const SwField* pendingPlaceholder; - std::vector< const SwPostItField* > m_postitFields; + /// Maps postit fields to ID's, used in commentRangeStart/End, commentReference and comment.xml. + std::vector< std::pair<const SwPostItField*, sal_Int32> > m_postitFields; + /// Number of postit fields which already have a commentReference written. unsigned int m_postitFieldsMaxId; int m_anchorId; int m_nextFontId; |