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

Szymon Kłos szymon.klos at collabora.com
Sat Dec 9 10:59:54 UTC 2017


 filter/source/msfilter/msdffimp.cxx       |   41 +++++++++++++++++++-----------
 sw/qa/extras/ww8export/data/tdf114308.doc |binary
 sw/qa/extras/ww8export/ww8export2.cxx     |    8 +++++
 3 files changed, 34 insertions(+), 15 deletions(-)

New commits:
commit 521d92b39b64f503876ca194d009b29f7188cc87
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Fri Dec 8 19:31:02 2017 +0100

    tdf#114308 DOC import correctly watermark without padding
    
    Change-Id: If44eb4d1354386f66c697206db9ab4d7f2be374d
    Reviewed-on: https://gerrit.libreoffice.org/46110
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 28f151060d30..48ab1aaebca6 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -4424,23 +4424,34 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
                         aSet.Put(makeSdrTextAutoGrowHeightItem(false));
                         aSet.Put(makeSdrTextAutoGrowWidthItem(false));
 
-                        VclPtr<VirtualDevice> pDevice = VclPtr<VirtualDevice>::Create();
-                        vcl::Font aFont = pDevice->GetFont();
-                        aFont.SetFamilyName( aFontName );
-                        aFont.SetFontSize( Size( 0, 96 ) );
-                        pDevice->SetFont( aFont );
-
-                        auto nTextWidth = pDevice->GetTextWidth( aObjectText );
-                        OUString aObjName = GetPropertyString( DFF_Prop_wzName, rSt );
-                        if ( nTextWidth && aObjData.eShapeType == mso_sptTextPlainText
-                            && aObjName.match( "PowerPlusWaterMarkObject" ) )
+                        bool bWithPadding = !( ngtextFStrikethrough & use_gtextFBestFit
+                                            && ngtextFStrikethrough & use_gtextFShrinkFit
+                                            && ngtextFStrikethrough & use_gtextFStretch
+                                            && ngtextFStrikethrough & gtextFBestFit
+                                            && ngtextFStrikethrough & gtextFShrinkFit
+                                            && ngtextFStrikethrough & gtextFStretch );
+
+                        if ( bWithPadding )
                         {
-                            double fRatio = (double)pDevice->GetTextHeight() / nTextWidth;
-                            sal_Int32 nNewHeight = fRatio * aObjData.aBoundRect.getWidth();
-                            sal_Int32 nPaddingY = aObjData.aBoundRect.getHeight() - nNewHeight;
+                            // trim, remove additional space
+                            VclPtr<VirtualDevice> pDevice = VclPtr<VirtualDevice>::Create();
+                            vcl::Font aFont = pDevice->GetFont();
+                            aFont.SetFamilyName( aFontName );
+                            aFont.SetFontSize( Size( 0, 96 ) );
+                            pDevice->SetFont( aFont );
+
+                            auto nTextWidth = pDevice->GetTextWidth( aObjectText );
+                            OUString aObjName = GetPropertyString( DFF_Prop_wzName, rSt );
+                            if ( nTextWidth && aObjData.eShapeType == mso_sptTextPlainText
+                                && aObjName.match( "PowerPlusWaterMarkObject" ) )
+                            {
+                                double fRatio = (double)pDevice->GetTextHeight() / nTextWidth;
+                                sal_Int32 nNewHeight = fRatio * aObjData.aBoundRect.getWidth();
+                                sal_Int32 nPaddingY = aObjData.aBoundRect.getHeight() - nNewHeight;
 
-                            if ( nPaddingY > 0 )
-                                aObjData.aBoundRect.setHeight( nNewHeight );
+                                if ( nPaddingY > 0 )
+                                    aObjData.aBoundRect.setHeight( nNewHeight );
+                            }
                         }
                     }
                     pRet->SetMergedItemSet( aSet );
diff --git a/sw/qa/extras/ww8export/data/tdf114308.doc b/sw/qa/extras/ww8export/data/tdf114308.doc
new file mode 100755
index 000000000000..36e6c7ec6999
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf114308.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 480511334c76..0695c309951b 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -274,6 +274,14 @@ DECLARE_WW8EXPORT_TEST(testTdf91687, "tdf91687.doc")
     CPPUNIT_ASSERT_EQUAL((sal_Int32)18105, xWatermark->getSize().Width);
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf114308, "tdf114308.doc")
+{
+    // Watermark with no additional padding
+    uno::Reference<drawing::XShape> xWatermark = getShape(1);
+
+    CPPUNIT_ASSERT_EQUAL((sal_Int32)8729, xWatermark->getSize().Height);
+}
+
 DECLARE_WW8EXPORT_TEST(testTdf111480, "tdf111480.doc")
 {
     // Circular text was imported horizontally


More information about the Libreoffice-commits mailing list