summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-07-19 13:56:30 +0200
committerLuboš Luňák <l.lunak@suse.cz>2011-07-19 13:57:04 +0200
commit17651a5b8aab1a64fcefde3067422509a3221e34 (patch)
tree7b840c1255c2b4f349461d1d5b5c8ebebe20b2e9
parent51dae8c127e4d9d3d864947f239ceec6bebd0ae8 (diff)
skeleton for writting .docx comments
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx3
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx37
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx7
-rw-r--r--sw/source/filter/ww8/docxexport.cxx22
-rw-r--r--sw/source/filter/ww8/docxexport.hxx3
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx2
6 files changed, 71 insertions, 3 deletions
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index c002488ea9..1562a759d8 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -176,6 +176,9 @@ public:
/// for docx footnotePr/endnotePr inside sectPr
virtual void SectFootnoteEndnotePr() {};
+ /// for docx w:commentReference
+ virtual void WritePostitFieldReference() {};
+
/// Output text (inside a run).
virtual void RunText( const String& rText, rtl_TextEncoding eCharSet ) = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8b7f0950ad..e5bac975f6 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3302,9 +3302,34 @@ void DocxAttributeOutput::HiddenField( const SwField& /*rFld*/ )
OSL_TRACE( "TODO DocxAttributeOutput::HiddenField()\n" );
}
-void DocxAttributeOutput::PostitField( const SwField* /* pFld*/ )
+void DocxAttributeOutput::PostitField( const SwField* pFld )
{
- OSL_TRACE( "TODO DocxAttributeOutput::PostitField()\n" );
+ assert( dynamic_cast< const SwPostItField* >( pFld ));
+ m_postitFields.push_back( static_cast< const SwPostItField* >( pFld ));
+}
+
+void DocxAttributeOutput::WritePostitFieldReference()
+{
+ while( m_postitFieldsMaxId < m_postitFields.size())
+ {
+ OString idstr = OString::valueOf( sal_Int32( m_postitFieldsMaxId ));
+ m_pSerializer->singleElementNS( XML_w, XML_commentReference, FSNS( XML_w, XML_id ), idstr.getStr(), FSEND );
+ ++m_postitFieldsMaxId;
+ }
+}
+
+void DocxAttributeOutput::WritePostitFields()
+{
+ for( unsigned int i = 0;
+ i < m_postitFields.size();
+ ++i )
+ {
+ OString idstr = OString::valueOf( sal_Int32( i ));
+ const SwPostItField* f = m_postitFields[ i ];
+ m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr.getStr(),
+ /*TODO*/ FSEND );
+ m_pSerializer->endElementNS( XML_w, XML_comment );
+ }
}
bool DocxAttributeOutput::DropdownField( const SwField* pFld )
@@ -4283,7 +4308,8 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
m_nColBreakStatus( COLBRK_NONE ),
m_pParentFrame( NULL ),
m_nCloseHyperlinkStatus( Undetected ),
- m_postponedGraphic( NULL )
+ m_postponedGraphic( NULL ),
+ m_postitFieldsMaxId( 0 )
{
}
@@ -4319,4 +4345,9 @@ bool DocxAttributeOutput::HasEndnotes() const
return !m_pEndnotesList->isEmpty();
}
+bool DocxAttributeOutput::HasPostitFields() const
+{
+ return !m_postitFields.empty();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index a476cc5378..cc67549de3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -105,6 +105,8 @@ public:
virtual void SectFootnoteEndnotePr();
+ virtual void WritePostitFieldReference();
+
/// Output text (inside a run).
virtual void RunText( const String& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8 );
@@ -599,6 +601,8 @@ private:
Size size;
};
std::list< PostponedGraphic >* m_postponedGraphic;
+ std::vector< const SwPostItField* > m_postitFields;
+ unsigned int m_postitFieldsMaxId;
public:
DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML );
@@ -626,6 +630,9 @@ public:
/// writes the footnotePr/endnotePr (depending on tag) section
void WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr fs, int tag, const SwEndNoteInfo& info, int listtag );
+
+ bool HasPostitFields() const;
+ void WritePostitFields();
};
#endif // _DOCXATTRIBUTEOUTPUT_HXX_
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 12ab4a841d..dd77d7bbcc 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -339,6 +339,8 @@ void DocxExport::ExportDocument_Impl()
WriteFootnotesEndnotes();
+ WritePostitFields();
+
WriteNumbering();
WriteFonts();
@@ -516,6 +518,26 @@ void DocxExport::WriteFootnotesEndnotes()
}
}
+void DocxExport::WritePostitFields()
+{
+ if ( m_pAttrOutput->HasPostitFields() )
+ {
+ m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
+ S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" ),
+ S( "comments.xml" ) );
+
+ ::sax_fastparser::FSHelperPtr pPostitFS =
+ m_pFilter->openFragmentStreamWithSerializer( S( "word/comments.xml" ),
+ S( "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" ) );
+
+ pPostitFS->startElementNS( XML_w, XML_comments, MainXmlNamespaces( pPostitFS ));
+ m_pAttrOutput->SetSerializer( pPostitFS );
+ m_pAttrOutput->WritePostitFields();
+ m_pAttrOutput->SetSerializer( m_pDocumentFS );
+ pPostitFS->endElementNS( XML_w, XML_comments );
+ }
+}
+
void DocxExport::WriteNumbering()
{
if ( !pUsedNumTbl )
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index ee84dcd33b..faed1e0cf7 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -190,6 +190,9 @@ private:
/// Write footnotes.xml and endnotes.xml.
void WriteFootnotesEndnotes();
+ /// Write comments.xml
+ void WritePostitFields();
+
/// Write the numbering table.
virtual void WriteNumbering();
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 72ae0fd96c..8dcd8b8f0c 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2030,6 +2030,8 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
}
}
+ AttrOutput().WritePostitFieldReference();
+
AttrOutput().EndRun();
nAktPos = nNextAttr;