sw/qa/extras/ooxmlexport/data/tdf121867.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 10 ++++++++ sw/source/filter/ww8/docxexport.cxx | 22 ++++++++++++++++++- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 ++- writerfilter/source/dmapper/SettingsTable.cxx | 25 ++++++++++++++++++++++ writerfilter/source/dmapper/SettingsTable.hxx | 3 ++ 6 files changed, 62 insertions(+), 2 deletions(-)
New commits: commit 209f2fe0304114409434a3bf5f1e08c6613d83c0 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Feb 4 21:35:53 2019 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Feb 5 09:12:09 2019 +0100 tdf#121867 DOCX filter: handle page width zoom And other non-fixed zoom types, similar to how DOC does it. Change-Id: Ie84340b4e662d2329b5d3918900adfd0c3e9b8e9 Reviewed-on: https://gerrit.libreoffice.org/67378 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf121867.odt b/sw/qa/extras/ooxmlexport/data/tdf121867.odt new file mode 100644 index 000000000000..361121d23b61 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf121867.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 3a38655c3781..a67ced7ed730 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -20,6 +20,8 @@ #include <sfx2/docfilt.hxx> #include <svx/xfillit0.hxx> +#include <editsh.hxx> + class Test : public SwModelTestBase { public: @@ -86,6 +88,14 @@ DECLARE_OOXMLEXPORT_TEST(testDateControl, "empty-date-control.odt") assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", u" "); } +DECLARE_OOXMLEXPORT_TEST(testTdf121867, "tdf121867.odt") +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwEditShell* pEditShell = pTextDoc->GetDocShell()->GetEditShell(); + // Without the accompanying fix in place, this test would have failed with + // 'Expected: 3; Actual : 0', i.e. page width zoom was lost on export. + CPPUNIT_ASSERT_EQUAL(SvxZoomType::PAGEWIDTH, pEditShell->GetViewOptions()->GetZoomType()); +} DECLARE_OOXMLEXPORT_TEST(testInputListExport, "tdf122186_input_list.odt") { diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 79717e24761c..3aa8706bed1d 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -932,8 +932,28 @@ void DocxExport::WriteSettings() // Zoom if (pViewShell) { + rtl::Reference<sax_fastparser::FastAttributeList> pAttributeList( + sax_fastparser::FastSerializerHelper::createAttrList()); + + switch (pViewShell->GetViewOptions()->GetZoomType()) + { + case SvxZoomType::WHOLEPAGE: + pAttributeList->add(FSNS(XML_w, XML_val), "fullPage"); + break; + case SvxZoomType::PAGEWIDTH: + pAttributeList->add(FSNS(XML_w, XML_val), "bestFit"); + break; + case SvxZoomType::OPTIMAL: + pAttributeList->add(FSNS(XML_w, XML_val), "textFit"); + break; + default: + break; + } + OString aZoom(OString::number(pViewShell->GetViewOptions()->GetZoom())); - pFS->singleElementNS(XML_w, XML_zoom, FSNS(XML_w, XML_percent), aZoom.getStr(), FSEND); + pAttributeList->add(FSNS(XML_w, XML_percent), aZoom); + sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList.get()); + pFS->singleElementNS(XML_w, XML_zoom, xAttributeList); } // Display Background Shape diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 1361782d9002..5cb18fed76b0 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -5802,7 +5802,9 @@ void DomainMapper_Impl::ApplySettingsTable() { aViewProps.emplace_back("ZoomFactor", -1, uno::makeAny(m_pSettingsTable->GetZoomFactor()), beans::PropertyState_DIRECT_VALUE); aViewProps.emplace_back("VisibleBottom", -1, uno::makeAny(sal_Int32(0)), beans::PropertyState_DIRECT_VALUE); - aViewProps.emplace_back("ZoomType", -1, uno::makeAny(sal_Int16(0)), beans::PropertyState_DIRECT_VALUE); + aViewProps.emplace_back("ZoomType", -1, + uno::makeAny(m_pSettingsTable->GetZoomType()), + beans::PropertyState_DIRECT_VALUE); } uno::Reference<container::XIndexContainer> xBox = document::IndexedPropertyValues::create(m_xComponentContext); xBox->insertByIndex(sal_Int32(0), uno::makeAny(comphelper::containerToSequence(aViewProps))); diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index 12c26049b139..2216e69b78ba 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -22,6 +22,7 @@ #include <vector> #include <rtl/ustring.hxx> +#include <sfx2/zoomitem.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/container/XNameContainer.hpp> @@ -36,6 +37,24 @@ using namespace com::sun::star; namespace writerfilter { +namespace +{ +/// Maps OOXML <w:zoom w:val="..."> to SvxZoomType. +sal_Int16 lcl_GetZoomType(Id nType) +{ + switch (nType) + { + case NS_ooxml::LN_Value_doc_ST_Zoom_fullPage: + return sal_Int16(SvxZoomType::WHOLEPAGE); + case NS_ooxml::LN_Value_doc_ST_Zoom_bestFit: + return sal_Int16(SvxZoomType::PAGEWIDTH); + case NS_ooxml::LN_Value_doc_ST_Zoom_textFit: + return sal_Int16(SvxZoomType::OPTIMAL); + } + + return sal_Int16(SvxZoomType::PERCENT); +} +} namespace dmapper { @@ -221,6 +240,7 @@ struct SettingsTable_Impl bool m_bRecordChanges; bool m_bLinkStyles; sal_Int16 m_nZoomFactor; + sal_Int16 m_nZoomType = 0; Id m_nView; bool m_bEvenAndOddHeaders; bool m_bUsePrinterMetrics; @@ -292,6 +312,9 @@ void SettingsTable::lcl_attribute(Id nName, Value & val) case NS_ooxml::LN_CT_Zoom_percent: m_pImpl->m_nZoomFactor = nIntValue; break; + case NS_ooxml::LN_CT_Zoom_val: + m_pImpl->m_nZoomType = lcl_GetZoomType(nIntValue); + break; case NS_ooxml::LN_CT_Language_val: m_pImpl->m_pThemeFontLangProps[0].Name = "val"; m_pImpl->m_pThemeFontLangProps[0].Value <<= sStringValue; @@ -503,6 +526,8 @@ sal_Int16 SettingsTable::GetZoomFactor() const return m_pImpl->m_nZoomFactor; } +sal_Int16 SettingsTable::GetZoomType() const { return m_pImpl->m_nZoomType; } + Id SettingsTable::GetView() const { return m_pImpl->m_nView; diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx index edffff67cfeb..7d539336f78e 100644 --- a/writerfilter/source/dmapper/SettingsTable.hxx +++ b/writerfilter/source/dmapper/SettingsTable.hxx @@ -57,6 +57,9 @@ class SettingsTable : public LoggedProperties, public LoggedTable /// What's the zoom factor set in percents? sal_Int16 GetZoomFactor() const; + /// Gets the type of the zoom. + sal_Int16 GetZoomType() const; + /// What's the requested view? E.g. "web". Id GetView() const; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits