summaryrefslogtreecommitdiffstats
path: root/filter/source/msfilter/msdffimp.cxx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-12-08 19:31:02 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2017-12-09 11:57:58 +0100
commit521d92b39b64f503876ca194d009b29f7188cc87 (patch)
treee2811f16560da1af313f48fed62fe5bbf895a747 /filter/source/msfilter/msdffimp.cxx
parenttdf#114338 don't crash on watermark insert w/ existing header (diff)
downloadcore-521d92b39b64f503876ca194d009b29f7188cc87.tar.gz
core-521d92b39b64f503876ca194d009b29f7188cc87.zip
tdf#114308 DOC import correctly watermark without padding
Change-Id: If44eb4d1354386f66c697206db9ab4d7f2be374d Reviewed-on: https://gerrit.libreoffice.org/46110 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'filter/source/msfilter/msdffimp.cxx')
-rw-r--r--filter/source/msfilter/msdffimp.cxx41
1 files changed, 26 insertions, 15 deletions
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 );