diff options
author | Vinaya Mandke <vinaya.mandke@synerzip.com> | 2014-01-24 19:29:47 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-13 11:51:50 +0100 |
commit | 8c6ee9360b3ffdc07335da0e3a2c6f05e5438909 (patch) | |
tree | 837b4dc7201ae9c59869673fa8b32450adbfedce | |
parent | a4cd841541a729d7b8126d27d91fa28e30b01403 (diff) |
fdo#73541 "Page Margins : Mirrored" was not preserved on export to DOCX
Mapped Property at import, so Page margins mirrored are imported correctly.
Also exported the mirrorMargins in settings.xml
Added export UT for the same.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7632
Change-Id: I2d90643f55e1dc1d96c809e28ce37dee4653bf57
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo73541.docx | bin | 0 -> 16446 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.hxx | 3 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SettingsTable.cxx | 10 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SettingsTable.hxx | 1 |
7 files changed, 42 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo73541.docx b/sw/qa/extras/ooxmlexport/data/fdo73541.docx Binary files differnew file mode 100644 index 000000000000..469d025209d8 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo73541.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 06b881ccbf3f..818569e52291 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2985,6 +2985,16 @@ DECLARE_OOXMLEXPORT_TEST(testLineStyle_DashType_VML, "LineStyle_DashType_VML.doc assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:stroke", "dashstyle", "dash"); } +DECLARE_OOXMLEXPORT_TEST(testFdo73541,"fdo73541.docx") +{ + // fdo#73541: The mirrored margins were not imported and mapped correctly in Page Layout + // Hence <w:mirrorMargins /> tag was not exported back in settings.xml + xmlDocPtr pXmlDoc = parseExport("word/settings.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:settings/w:mirrorMargins"); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 9a4d32d7e925..e004cc5f3120 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -768,6 +768,10 @@ void DocxExport::WriteSettings() if ( settings.trackRevisions ) pFS->singleElementNS( XML_w, XML_trackRevisions, FSEND ); + // Mirror Margins + if(isMirroredMargin()) + pFS->singleElementNS( XML_w, XML_mirrorMargins, FSEND ); + // Embed Fonts if( pDoc->get( IDocumentSettingAccess::EMBED_FONTS )) pFS->singleElementNS( XML_w, XML_embedTrueTypeFonts, FSEND ); @@ -1176,6 +1180,16 @@ DocxSdrExport& DocxExport::SdrExporter() return *m_pSdrExport; } +bool DocxExport::isMirroredMargin() +{ + bool bMirroredMargins = false; + if ( nsUseOnPage::PD_MIRROR == (nsUseOnPage::PD_MIRROR & pDoc->GetPageDesc(0).ReadUseOn()) ) + { + bMirroredMargins = true; + } + return bMirroredMargins; +} + boost::optional<const SvxBrushItem*> DocxExport::getBackground() { boost::optional<const SvxBrushItem*> oRet; diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 5d370954a1c9..fe303930cbf9 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -236,6 +236,9 @@ private: /// Get background color of the document, if there is one. boost::optional<const SvxBrushItem*> getBackground(); + /// return true if Page Layout is set as Mirrored + bool isMirroredMargin(); + public: /// FIXME this is temporary, remotely reminding the method of the same /// name in WW8Export. diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 8aec430bc963..f90cb204ada1 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1001,6 +1001,10 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) const OUString sTrayIndex = rPropNameSupplier.GetName( PROP_PRINTER_PAPER_TRAY_INDEX ); if( m_nPaperBin >= 0 ) xFollowPageStyle->setPropertyValue( sTrayIndex, uno::makeAny( m_nPaperBin ) ); + if ( rDM_Impl.GetSettingsTable()->GetMirrorMarginSettings() ) + { + Insert(PROP_PAGE_STYLE_LAYOUT, uno::makeAny(style::PageStyleLayout_MIRRORED)); + } uno::Reference< text::XTextColumns > xColumns; if( m_nColumnCount > 0 ) xColumns = ApplyColumnProperties( xFollowPageStyle ); diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index f66a2c2ca9f1..d6ef7211444c 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -72,6 +72,7 @@ struct SettingsTable_Impl bool embedSystemFonts; bool m_bDoNotUseHTMLParagraphAutoSpacing; bool m_bSplitPgBreakAndParaMark; + bool m_bMirrorMargin; uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps; SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) : @@ -97,6 +98,7 @@ struct SettingsTable_Impl , embedSystemFonts(false) , m_bDoNotUseHTMLParagraphAutoSpacing(false) , m_bSplitPgBreakAndParaMark(false) + , m_bMirrorMargin(false) , m_pThemeFontLangProps(3) {} @@ -233,6 +235,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm) case NS_ooxml::LN_CT_Compat_splitPgBreakAndParaMark: m_pImpl->m_bSplitPgBreakAndParaMark = nIntValue; break; + case NS_ooxml::LN_CT_Settings_mirrorMargins: + m_pImpl->m_bMirrorMargin = nIntValue; + break; default: { #ifdef DEBUG_DMAPPER_SETTINGS_TABLE @@ -295,6 +300,11 @@ bool SettingsTable::GetSplitPgBreakAndParaMark() const return m_pImpl->m_bSplitPgBreakAndParaMark; } +bool SettingsTable::GetMirrorMarginSettings() const +{ + return m_pImpl->m_bMirrorMargin; +} + uno::Sequence<beans::PropertyValue> SettingsTable::GetThemeFontLangProperties() const { return m_pImpl->m_pThemeFontLangProps; diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx index 6c619c9f79d6..2014eafab0e7 100644 --- a/writerfilter/source/dmapper/SettingsTable.hxx +++ b/writerfilter/source/dmapper/SettingsTable.hxx @@ -70,6 +70,7 @@ class SettingsTable : public LoggedProperties, public LoggedTable bool GetDoNotUseHTMLParagraphAutoSpacing() const; bool GetSplitPgBreakAndParaMark() const; + bool GetMirrorMarginSettings() const; uno::Sequence<beans::PropertyValue> GetThemeFontLangProperties() const; |