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

Miklos Vajna vmiklos at suse.cz
Mon May 27 12:40:36 PDT 2013


 sw/qa/extras/ooxmlimport/data/page-background.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx           |    9 +++++++++
 writerfilter/source/dmapper/DomainMapper.cxx       |    3 +++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx  |    3 +++
 writerfilter/source/dmapper/PropertyMap.cxx        |    3 +++
 writerfilter/source/ooxml/model.xml                |    2 +-
 6 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 62c705c106bd3c2b87462f30732f162fcb0bde87
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon May 27 17:09:44 2013 +0200

    bnc#817956 DOCX import of document background color
    
    See wwSectionManager::SetSegmentToPageDesc(), this has to be applied to
    every page style.
    
    Change-Id: Iea2707ae665a55eabda3ed7575cf3658f7af5237
    (cherry picked from commit 992da0d5cf04497bad55637f6a6ebfcdaec03e16)

diff --git a/sw/qa/extras/ooxmlimport/data/page-background.docx b/sw/qa/extras/ooxmlimport/data/page-background.docx
new file mode 100644
index 0000000..8c1f2ebd
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/page-background.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index e9f4839..adbe872 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -113,6 +113,7 @@ public:
     void testN592908_Picture();
     void testN779630();
     void testIndentation();
+    void testPageBackground();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -194,6 +195,7 @@ void Test::run()
         {"n592908-picture.docx", &Test::testN592908_Picture},
         {"n779630.docx", &Test::testN779630},
         {"indentation.docx", &Test::testIndentation},
+        {"page-background.docx", &Test::testPageBackground},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1379,6 +1381,13 @@ void Test::testIndentation()
     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>(xPropertySet, "WritingMode"));
 }
 
+void Test::testPageBackground()
+{
+    // The problem was that  <w:background w:color="92D050"/> was ignored.
+    uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 10a018a..7768ddb 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1445,6 +1445,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         case NS_ooxml::LN_CT_SdtListItem_value:
             m_pImpl->m_pSdtHelper->getDropDownItems().push_back(sStringValue);
         break;
+        case NS_ooxml::LN_CT_Background_color:
+            m_pImpl->m_oBackgroundColor.reset(nIntValue);
+        break;
         default:
             {
 #if OSL_DEBUG_LEVEL > 0
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index b7da3a9..fba658a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -684,6 +684,9 @@ public:
     bool m_bInTableStyleRunProps;
 
     SdtHelper* m_pSdtHelper;
+
+    /// Document background color, applied to every page style.
+    boost::optional<sal_Int32> m_oBackgroundColor;
 };
 } //namespace dmapper
 } //namespace writerfilter
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 9e22551..2ab0ff5 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -889,6 +889,9 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
         operator[]( PropertyDefinition( PROP_LEFT_MARGIN, false )) =  uno::makeAny( m_nLeftMargin  );
         operator[]( PropertyDefinition( PROP_RIGHT_MARGIN, false )) = uno::makeAny( m_nRightMargin );
 
+        if (rDM_Impl.m_oBackgroundColor)
+            operator[](PropertyDefinition(PROP_BACK_COLOR, false)) = uno::makeAny(*rDM_Impl.m_oBackgroundColor);
+
         /*** if headers/footers are available then the top/bottom margins of the
             header/footer are copied to the top/bottom margin of the page
           */
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 0e11017..cdafa91 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -14997,7 +14997,7 @@
         <ref name="CT_PictureBase"/>
         <optional>
           <attribute name="color">
-            <text/>
+            <ref name="ST_HexColor"/>
             <xs:documentation>Background Color</xs:documentation>
           </attribute>
         </optional>


More information about the Libreoffice-commits mailing list