[Libreoffice-commits] core.git: sw/qa sw/source
Adam Co
rattles2013 at gmail.com
Tue Jun 11 03:21:44 PDT 2013
sw/qa/extras/ooxmlexport/data/fdo65265.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 12 +++++
sw/source/filter/ww8/docxattributeoutput.cxx | 64 +++++++++++++++++++++++++--
3 files changed, 73 insertions(+), 3 deletions(-)
New commits:
commit f7595decdfb5f9aac61ccc61ad38de4a1faa402d
Author: Adam Co <rattles2013 at gmail.com>
Date: Sun Jun 9 19:08:32 2013 +0300
fdo#65265 : fix for DOCX export of formatting data
Change-Id: Iab3c56e5c3e3cf359e42cf7080883d1408cc3304
Reviewed-on: https://gerrit.libreoffice.org/4215
Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
Tested-by: Miklos Vajna <vmiklos at suse.cz>
diff --git a/sw/qa/extras/ooxmlexport/data/fdo65265.docx b/sw/qa/extras/ooxmlexport/data/fdo65265.docx
new file mode 100644
index 0000000..6267085
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo65265.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ca6fad6..bcecf95 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 bd54f5a..7e4f49c 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 )
More information about the Libreoffice-commits
mailing list