diff options
author | abdulmajeed ahmed <aalabdulrazzaq@kacst.edu.sa> | 2013-06-15 12:43:29 +0200 |
---|---|---|
committer | abdulmajeed ahmed <aalabdulrazzaq@kacst.edu.sa> | 2013-06-15 12:53:07 +0200 |
commit | 36de708ce421b31beaaddb1048d444de91b2e5e9 (patch) | |
tree | 3ec60b54f937fdc7849c2892a1ae7b144bdec23b | |
parent | 0c0a9c3abbda78e116b6b4920dbdefb06f278261 (diff) |
fix fdo#63053 ampersand in document title causes corrupt docx
FILESAVE, FILEOPEN: ampersand in document title causes corrupt docx when saving; truncates title when loading
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 2 | ||||
-rw-r--r-- | oox/source/docprop/docprophandler.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo63053.docx | bin | 0 -> 5044 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 11 |
4 files changed, 13 insertions, 4 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 9a06b815f890..8a59187f4928 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -450,7 +450,7 @@ writeElement( FSHelperPtr pDoc, sal_Int32 nXmlElement, const OUString& sValue ) if( sValue.isEmpty() ) return; pDoc->startElement( nXmlElement, FSEND ); - pDoc->write( sValue ); + pDoc->writeEscaped( sValue ); pDoc->endElement( nXmlElement ); } diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx index 08cfda0b3ce4..50d5d4c363a4 100644 --- a/oox/source/docprop/docprophandler.cxx +++ b/oox/source/docprop/docprophandler.cxx @@ -453,11 +453,11 @@ void SAL_CALL OOXMLDocPropHandler::characters( const OUString& aChars ) break; case DC_TOKEN( subject ): - m_xDocProp->setSubject( aChars ); + m_xDocProp->setSubject( m_xDocProp->getSubject() + aChars ); break; case DC_TOKEN( title ): - m_xDocProp->setTitle( aChars ); + m_xDocProp->setTitle( m_xDocProp->getTitle() + aChars ); break; default: diff --git a/sw/qa/extras/ooxmlexport/data/fdo63053.docx b/sw/qa/extras/ooxmlexport/data/fdo63053.docx Binary files differnew file mode 100644 index 000000000000..43282b0df717 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo63053.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 494076c0cb50..b832322db64e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -75,7 +75,7 @@ public: void testPageGraphicBackground(); void testFdo65265(); void testFdo65655(); - + void testFDO63053(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) CPPUNIT_TEST(run); @@ -127,6 +127,8 @@ void Test::run() {"page-graphic-background.odt", &Test::testPageGraphicBackground}, {"fdo65265.docx", &Test::testFdo65265}, {"fdo65655.docx", &Test::testFdo65655}, + {"fdo63053.docx" , &Test::testFDO63053}, + }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -725,6 +727,13 @@ void Test::testFdo65655() CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); xPropertySet->getPropertyValue("FooterIsShared") >>= bValue; CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); + +void Test::testFDO63053() +{ + uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties(); + CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties->getTitle()); + CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties->getSubject()); } CPPUNIT_TEST_SUITE_REGISTRATION(Test); |