[Libreoffice-commits] core.git: sw/qa writerfilter/source

Justin Luth justin_luth at sil.org
Fri Jan 20 11:58:22 UTC 2017


 sw/qa/extras/ooxmlimport/data/tdf48658_transparentOLEheader.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                         |    7 +++++++
 writerfilter/source/dmapper/OLEHandler.cxx                       |    8 +++++++-
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit c0688e8bf047bb123680806317fe040ba2cde407
Author: Justin Luth <justin_luth at sil.org>
Date:   Mon Jan 16 09:44:32 2017 +0300

    tdf#48658 writerfilter: only set THROUGH wraps as transparent
    
    commit 15c3a08b8b1e8060f9659c7bc98480a39d1802c5 set transparency
    before the wrap type was known (which is good in case wrap type is
    never defined, and the default wrap type IS through, so that fits)
    but transparency was never re-evaluated once the wrap type was known.
    
    In MSWord, the header is at a lower zOrder than the body,
    so objects that are OVER the header text are still UNDER
    the body text. Writer emulates this by insisting that ALL
    through-wrapped header objects are UNDER the header text.
    (This ought to only apply to objects that spill into the
    body text area, but that’s pretty hard to calculate, so
    transparency was applied to any object anchored in the header.)
    
    Change-Id: Ie3916c6b7f3fa80caf5994fd910ba4d4d89ec702
    Reviewed-on: https://gerrit.libreoffice.org/33152
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Tested-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf48658_transparentOLEheader.docx b/sw/qa/extras/ooxmlimport/data/tdf48658_transparentOLEheader.docx
new file mode 100755
index 0000000..5b6649c
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf48658_transparentOLEheader.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 786c686..58d0677 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -817,6 +817,13 @@ DECLARE_OOXMLIMPORT_TEST(testOleAnchor, "ole-anchor.docx")
     CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(getShape(1), "Surround"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf48658_transparentOLEheader, "tdf48658_transparentOLEheader.docx")
+{
+    // The problem was that the shape in the header was hidden in the background.
+    // The round-tripped document was always fine (even before the fix) but the shape numbers change, so import-only test.
+    CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<bool>(getShape(1), "Opaque")));
+}
+
 DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaAdjust, "dml-groupshape-paraadjust.docx")
 {
     // Paragraph adjustment inside a group shape was not imported
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
index 26f12c1..194d1d3 100644
--- a/writerfilter/source/dmapper/OLEHandler.cxx
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -44,6 +44,7 @@
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/WrapTextMode.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
 namespace writerfilter {
@@ -111,7 +112,7 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal)
 
                 try
                 {
-                    // Shapes in the header or footer should be in the background.
+                    // Shapes in the header or footer should be in the background, since the default is WrapTextMode_THROUGH.
                     if (m_rDomainMapper.IsInHeaderFooter())
                         xShapeProps->setPropertyValue("Opaque", uno::makeAny(false));
 
@@ -165,6 +166,11 @@ void OLEHandler::lcl_sprm(Sprm & rSprm)
                     xShapeProps->setPropertyValue(
                         getPropertyName( PROP_SURROUND ),
                         uno::makeAny( m_nWrapMode ) );
+
+                    // Through shapes in the header or footer(that spill into the body) should be in the background.
+                    // It is just assumed that all shapes will spill into the body.
+                    if( m_rDomainMapper.IsInHeaderFooter() )
+                        xShapeProps->setPropertyValue("Opaque", uno::makeAny(m_nWrapMode != text::WrapTextMode_THROUGHT));
                 }
                 catch( const uno::Exception& e )
                 {


More information about the Libreoffice-commits mailing list