diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-01-17 09:15:07 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-01-17 12:58:50 +0000 |
commit | 38a1e19ae49ac30757e4020b60adee7c30f3deb9 (patch) | |
tree | cbd3c59ebe6734f99620b1ade0c1075c32d626ff | |
parent | 4fe8a05027ffa664380c2ae42a4a0e2a3bc966c5 (diff) |
tdf#104150 DOCX import: handle <w:displayBackgroundShape/>
Regression from commit 992da0d5cf04497bad55637f6a6ebfcdaec03e16
(bnc#817956 DOCX import of document background color, 2013-05-27),
<w:background> should be ignored when <w:displayBackgroundShape/> is
missing from settings.xml, it turns out.
This also requires generating the
ooxml:CT_Settings_displayBackgroundShape token from the RTF tokenizer.
Change-Id: I6d7986904cedb952998a87e7648919ae34adc360
Reviewed-on: https://gerrit.libreoffice.org/33207
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf104150.docx | bin | 0 -> 12621 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 7 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 3 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SettingsTable.cxx | 10 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SettingsTable.hxx | 1 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchvalue.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 16 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 |
8 files changed, 40 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf104150.docx b/sw/qa/extras/ooxmlexport/data/tdf104150.docx Binary files differnew file mode 100644 index 000000000000..989884642660 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf104150.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 002d0641c54e..89bc9d9429fb 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -197,6 +197,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104162, "tdf104162.docx") CPPUNIT_ASSERT(xTextFields->hasElements()); } +DECLARE_OOXMLEXPORT_TEST(testTdf104150, "tdf104150.docx") +{ + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + // This was 0xff0000, i.e. red: background shape wasn't ignored. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getProperty<sal_Int32>(xPageStyle, "BackColor")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 0a4041cfd495..f2a076c6a3a9 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -987,7 +987,8 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_SdtDate_fullDate", sStringValue); break; case NS_ooxml::LN_CT_Background_color: - m_pImpl->m_oBackgroundColor.reset(nIntValue); + if (m_pImpl->GetSettingsTable()->GetDisplayBackgroundShape()) + m_pImpl->m_oBackgroundColor.reset(nIntValue); break; case NS_ooxml::LN_CT_PageNumber_start: if (pSectionContext != nullptr) diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index 10791f065f5e..8d7bace52257 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -65,6 +65,7 @@ struct SettingsTable_Impl bool m_bSplitPgBreakAndParaMark; bool m_bMirrorMargin; bool m_bProtectForm; + bool m_bDisplayBackgroundShape; uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps; @@ -91,6 +92,7 @@ struct SettingsTable_Impl , m_bSplitPgBreakAndParaMark(false) , m_bMirrorMargin(false) , m_bProtectForm(false) + , m_bDisplayBackgroundShape(false) , m_pThemeFontLangProps(3) , m_pCurrentCompatSetting(3) {} @@ -274,6 +276,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm) case NS_ooxml::LN_CT_Settings_widowControl: m_pImpl->m_bWidowControl = nIntValue; break; + case NS_ooxml::LN_CT_Settings_displayBackgroundShape: + m_pImpl->m_bDisplayBackgroundShape = nIntValue; + break; default: { #ifdef DEBUG_WRITERFILTER @@ -349,6 +354,11 @@ bool SettingsTable::GetMirrorMarginSettings() const return m_pImpl->m_bMirrorMargin; } +bool SettingsTable::GetDisplayBackgroundShape() const +{ + return m_pImpl->m_bDisplayBackgroundShape; +} + bool SettingsTable::GetProtectForm() const { return m_pImpl->m_bProtectForm; diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx index 8328ec2050b5..6ef0a30a788c 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; + bool GetDisplayBackgroundShape() const; bool GetNoColumnBalance() const; bool GetProtectForm() const; diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index 5ca8e0d3a56a..cfef7c665bb2 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -1432,6 +1432,14 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_effect, std::make_shared<RTFValue>(nId)); break; } + case RTF_VIEWBKSP: + { + m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_displayBackgroundShape, pIntValue); + // Send this token immediately, if it only appears before the first + // run, it will be too late, we ignored the background shape already by then. + outputSettingsTable(); + break; + } default: { SAL_INFO("writerfilter", "TODO handle value '" << keywordToString(nKeyword) << "'"); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 9100d368210e..2822ad0ab10d 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -354,16 +354,20 @@ void RTFDocumentImpl::resolveSubstream(std::size_t nPos, Id nId, OUString& rIgno Strm().Seek(nCurrent); } +void RTFDocumentImpl::outputSettingsTable() +{ + writerfilter::Reference<Properties>::Pointer_t pProp = std::make_shared<RTFReferenceProperties>(m_aSettingsTableAttributes, m_aSettingsTableSprms); + RTFReferenceTable::Entries_t aSettingsTableEntries; + aSettingsTableEntries.insert(std::make_pair(0, pProp)); + writerfilter::Reference<Table>::Pointer_t pTable = std::make_shared<RTFReferenceTable>(aSettingsTableEntries); + Mapper().table(NS_ooxml::LN_settings_settings, pTable); +} + void RTFDocumentImpl::checkFirstRun() { if (m_bFirstRun) { - // output settings table - writerfilter::Reference<Properties>::Pointer_t pProp = std::make_shared<RTFReferenceProperties>(m_aSettingsTableAttributes, m_aSettingsTableSprms); - RTFReferenceTable::Entries_t aSettingsTableEntries; - aSettingsTableEntries.insert(std::make_pair(0, pProp)); - writerfilter::Reference<Table>::Pointer_t pTable = std::make_shared<RTFReferenceTable>(aSettingsTableEntries); - Mapper().table(NS_ooxml::LN_settings_settings, pTable); + outputSettingsTable(); // start initial paragraph m_bFirstRun = false; assert(!m_bNeedSect); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 559605a321fa..5b09a5023861 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -424,6 +424,8 @@ public: /// If this is the first run of the document, starts the initial paragraph. void checkFirstRun(); + /// Send NS_ooxml::LN_settings_settings to dmapper. + void outputSettingsTable(); /// If the initial paragraph is started. bool getFirstRun() { |