summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Co <rattles2013@gmail.com>2013-06-09 19:08:32 +0300
committerMiklos Vajna <vmiklos@suse.cz>2013-06-11 10:21:21 +0000
commitf7595decdfb5f9aac61ccc61ad38de4a1faa402d (patch)
tree145679d431f6b39d3c9e70906df5c0dec2e13575
parent721f82c9bff871cd11c6a7c41ae080375463a690 (diff)
fdo#65265 : fix for DOCX export of formatting data
Change-Id: Iab3c56e5c3e3cf359e42cf7080883d1408cc3304 Reviewed-on: https://gerrit.libreoffice.org/4215 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo65265.docxbin0 -> 14520 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx12
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx64
3 files changed, 73 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo65265.docx b/sw/qa/extras/ooxmlexport/data/fdo65265.docx
new file mode 100644
index 000000000000..6267085fa290
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo65265.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ca6fad612ffa..bcecf95c5ac8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -72,6 +72,7 @@ public:
void testI120928();
void testFdo64826();
void testPageBackground();
+ void testFdo65265();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -121,6 +122,7 @@ void Test::run()
{"i120928.docx", &Test::testI120928},
{"fdo64826.docx", &Test::testFdo64826},
{"page-background.docx", &Test::testPageBackground},
+ {"fdo65265.docx", &Test::testFdo65265},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -688,6 +690,16 @@ void Test::testPageBackground()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
}
+void Test::testFdo65265()
+{
+ // Redline (tracked changes) of text formatting were not exported
+ uno::Reference<text::XTextRange> xParagraph1 = getParagraph(1);
+ uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph1, 3), "RedlineType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph2, 2), "RedlineType"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index bd54f5a06690..7e4f49cd43c5 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1049,8 +1049,12 @@ void DocxAttributeOutput::WriteCollectedRunProperties()
m_pSerializer->mergeTopMarks();
}
-void DocxAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/ )
+void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
{
+ // Call the 'Redline' function. This will add redline (change-tracking) information that regards to run properties.
+ // This includes changes like 'Bold', 'Underline', 'Strikethrough' etc.
+ Redline( pRedlineData );
+
WriteCollectedRunProperties();
m_pSerializer->endElementNS( XML_w, XML_rPr );
@@ -1329,11 +1333,65 @@ void DocxAttributeOutput::FieldVanish( const String& rTxt, ww::eField eType )
WriteField_Impl( NULL, eType, rTxt, WRITEFIELD_ALL );
}
-void DocxAttributeOutput::Redline( const SwRedlineData* /*pRedline*/ )
+// The difference between 'Redline' and 'StartRedline'+'EndRedline' is that:
+// 'Redline' is used for tracked changes of formatting information of a run like Bold, Underline. (the '<w:rPrChange>' is inside the 'run' node)
+// 'StartRedline' is used to output tracked changes of run insertion and deletion (the run is inside the '<w:ins>' node)
+void DocxAttributeOutput::Redline( const SwRedlineData* pRedline)
{
- OSL_TRACE( "TODO DocxAttributeOutput::Redline( const SwRedlineData* pRedline )" );
+ if ( !pRedline )
+ return;
+
+ OString aId( OString::valueOf( sal_Int32(pRedline->GetSeqNo()) ) );
+ const String &rAuthor( SW_MOD()->GetRedlineAuthor( pRedline->GetAuthor() ) );
+ OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
+ OString aDate( msfilter::util::DateTimeToOString( pRedline->GetTimeStamp() ) );
+
+ OUString sVal;
+ OString sOVal;
+
+ switch( pRedline->GetType() )
+ {
+ case nsRedlineType_t::REDLINE_INSERT:
+ break;
+
+ case nsRedlineType_t::REDLINE_DELETE:
+ break;
+
+ case nsRedlineType_t::REDLINE_FORMAT:
+ m_pSerializer->startElementNS( XML_w, XML_rPrChange,
+ FSNS( XML_w, XML_id ), aId.getStr(),
+ FSNS( XML_w, XML_author ), aAuthor.getStr(),
+ FSNS( XML_w, XML_date ), aDate.getStr(),
+ FSEND );
+
+ if ( m_pCharLangAttrList )
+ {
+ if (m_pCharLangAttrList->hasAttribute(FSNS(XML_w, XML_val)))
+ {
+ m_pSerializer->mark();
+ m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND );
+ sVal = m_pCharLangAttrList->getValue(FSNS(XML_w, XML_val));
+ sOVal = OUStringToOString(sVal, RTL_TEXTENCODING_UTF8);
+ m_pSerializer->startElementNS(XML_w, XML_lang,
+ FSNS(XML_w, XML_val), sOVal.getStr(),
+ FSEND);
+ m_pSerializer->endElementNS(XML_w, XML_lang);
+ m_pSerializer->endElementNS( XML_w, XML_rPr );
+ m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
+ }
+ }
+
+ m_pSerializer->endElementNS( XML_w, XML_rPrChange );
+ break;
+ default:
+ SAL_WARN("sw.ww8", "Unhandled redline type for export " << pRedline->GetType());
+ break;
+ }
}
+// The difference between 'Redline' and 'StartRedline'+'EndRedline' is that:
+// 'Redline' is used for tracked changes of formatting information of a run like Bold, Underline. (the '<w:rPrChange>' is inside the 'run' node)
+// 'StartRedline' is used to output tracked changes of run insertion and deletion (the run is inside the '<w:ins>' node)
void DocxAttributeOutput::StartRedline()
{
if ( !m_pRedlineData )