[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Jan 17 20:12:39 UTC 2017


 sw/qa/extras/ooxmlexport/data/tdf104150.docx    |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx       |    7 +++++++
 writerfilter/source/dmapper/DomainMapper.cxx    |    3 ++-
 writerfilter/source/dmapper/SettingsTable.cxx   |   10 ++++++++++
 writerfilter/source/dmapper/SettingsTable.hxx   |    1 +
 writerfilter/source/rtftok/rtfdispatchvalue.cxx |    8 ++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx  |   16 ++++++++++------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx  |    2 ++
 8 files changed, 40 insertions(+), 7 deletions(-)

New commits:
commit 9093bd7295c677fa1888d3d805fccbc07e85f1f4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 17 09:15:07 2017 +0100

    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.
    
    (cherry picked from commit 38a1e19ae49ac30757e4020b60adee7c30f3deb9)
    
    Change-Id: I6d7986904cedb952998a87e7648919ae34adc360
    Reviewed-on: https://gerrit.libreoffice.org/33224
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf104150.docx b/sw/qa/extras/ooxmlexport/data/tdf104150.docx
new file mode 100644
index 0000000..9898846
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf104150.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 2668d34..0f05214 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -184,6 +184,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 0a4041c..f2a076c 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 10791f0..8d7bace 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 8328ec2..6ef0a30 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 4c1d217..9de22b7 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1420,6 +1420,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 a65d7b6..ddede57 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -349,16 +349,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 0a21bbf..09905dc 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()
     {


More information about the Libreoffice-commits mailing list