diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/pictureWatermark.docx | bin | 0 -> 798086 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/textWatermark.docx | bin | 0 -> 17870 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 26 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 58 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 2 |
5 files changed, 85 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/pictureWatermark.docx b/sw/qa/extras/ooxmlexport/data/pictureWatermark.docx Binary files differnew file mode 100644 index 000000000000..b526ecf37061 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/pictureWatermark.docx diff --git a/sw/qa/extras/ooxmlexport/data/textWatermark.docx b/sw/qa/extras/ooxmlexport/data/textWatermark.docx Binary files differnew file mode 100644 index 000000000000..c8bff75e028e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/textWatermark.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index 8842cddef690..d46f58351630 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -911,6 +911,32 @@ DECLARE_OOXMLEXPORT_TEST(testDkVert, "dkvert.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<drawing::Hatch>(xShape, "FillHatch").Distance); } +DECLARE_OOXMLEXPORT_TEST(testTextWatermark, "textWatermark.docx") +{ + //The problem was that the watermark ID was not preserved, + //and Word uses the object ID to identify if it is a watermark. + //It has to have the 'PowerPlusWaterMarkObject' string in it + xmlDocPtr pXmlHeader1 = parseExport("word/header1.xml"); + if (!pXmlHeader1) + return; + + assertXPath(pXmlHeader1, "/w:hdr[1]/w:p[1]/w:r[1]/w:pict[1]/v:shape[1]","id","PowerPlusWaterMarkObject93701316"); +} + +DECLARE_OOXMLEXPORT_TEST(testPictureWatermark, "pictureWatermark.docx") +{ + //The problem was that the watermark ID was not preserved, + //and Word uses the object ID to identify if it is a watermark. + //It has to have the 'WordPictureWaterMarkObject' string in it + + xmlDocPtr pXmlHeader1 = parseExport("word/header1.xml"); + if (!pXmlHeader1) + return; + + // Check the watermark ID + assertXPath(pXmlHeader1, "/w:hdr[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Fallback[1]/w:pict[1]/v:rect[1]","id","WordPictureWatermark11962361"); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index b10ece75f92e..abe9360a97e3 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -81,6 +81,7 @@ #include <fmtrowsplt.hxx> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/i18n/WordType.hpp> +#include <oox/export/vmlexport.hxx> #include <filter/msfilter/sprmids.hxx> @@ -103,6 +104,7 @@ using namespace sw::util; using namespace sw::types; using namespace sw::mark; using namespace nsFieldFlags; +using namespace ::oox::vml; static OUString lcl_getFieldCode( const IFieldmark* pFieldmark ) { @@ -518,6 +520,26 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby ) m_rExport.AttrOutput().OutputItem( *pGrabBag ); } +bool SwWW8AttrIter::IsWatermarkFrame() +{ + if (maFlyFrms.size() != 1) + return false; + + while ( maFlyIter != maFlyFrms.end() ) + { + const SdrObject* pSdrObj = maFlyIter->GetFrmFmt().FindRealSdrObject(); + + if (pSdrObj) + { + if (VMLExport::IsWaterMarkShape(pSdrObj->GetName())) + return true; + } + ++maFlyIter; + } + + return false; +} + void SwWW8AttrIter::OutFlys(sal_Int32 nSwPos) { /* @@ -533,7 +555,34 @@ void SwWW8AttrIter::OutFlys(sal_Int32 nSwPos) if ( nPos != nSwPos ) break; - m_rExport.AttrOutput().OutputFlyFrame( *maFlyIter ); + const SdrObject* pSdrObj = maFlyIter->GetFrmFmt().FindRealSdrObject(); + + if (pSdrObj) + { + if (VMLExport::IsWaterMarkShape(pSdrObj->GetName())) + { + // This is a watermark object. Should be written ONLY in the header + if(m_rExport.nTxtTyp == TXT_HDFT) + { + // Should write a watermark in the header + m_rExport.AttrOutput().OutputFlyFrame( *maFlyIter ); + } + else + { + // Should not write watermark object in the main body text + } + } + else + { + // This is not a watermark object - write normally + m_rExport.AttrOutput().OutputFlyFrame( *maFlyIter ); + } + } + else + { + // This is not a watermark object - write normally + m_rExport.AttrOutput().OutputFlyFrame( *maFlyIter ); + } ++maFlyIter; } } @@ -1904,6 +1953,13 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode ) bLastCR = true; } + // In order to make sure watermark is stored in 'header.xml', check nTxtTyp. + // if it is document.xml, don't write the tags (watermark should be only in the 'header') + SwWW8AttrIter aWatermarkAttrIter( *this, rNode ); + if (( TXT_HDFT != nTxtTyp) && aWatermarkAttrIter.IsWatermarkFrame()) + { + return; + } bool bFlyInTable = mpParentFrame && IsInTable(); diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 0dfcfb351683..9a1d7b5d0147 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1539,6 +1539,8 @@ public: OUString GetSnippet(const OUString &rStr, sal_Int32 nAktPos, sal_Int32 nLen) const; const SwFmtDrop& GetSwFmtDrop() const { return mrSwFmtDrop; } + + bool IsWatermarkFrame(); }; /// Class to collect and output the styles table. |