diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-11-30 18:26:11 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-12-07 13:27:39 +0100 |
commit | b66435c3fcff5eb198f0037067294c1203ebcd76 (patch) | |
tree | 4d60d1f4782dc772988cc1b3896b8fdeadb99755 /filter/source | |
parent | 3e4e3ee3dba7fa65263e71da0bc0091d4e950d33 (diff) |
tdf#113037 Unify Watermark in DOC & DOCX
* use correct font for calculations
Reviewed-on: https://gerrit.libreoffice.org/45698
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
(cherry picked from commit 923ca4efe2095998e3da75c372cd7d716db9abb3)
Change-Id: Idd370678c000bf22c460c3323bd55cd827ba7153
Reviewed-on: https://gerrit.libreoffice.org/45996
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'filter/source')
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 36a3f59c3787..b32c3d926f90 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -40,6 +40,7 @@ #include <vcl/cvtgrf.hxx> #include <vcl/wmf.hxx> #include <vcl/settings.hxx> +#include <vcl/vclptr.hxx> #include "viscache.hxx" // SvxItem-Mapping. Is needed to successfully include the SvxItem-Header @@ -4411,16 +4412,18 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r aSet.Put(makeSdrTextAutoGrowWidthItem(false)); double fRatio = 0; - OutputDevice* pOut = Application::GetDefaultDevice(); - vcl::Font aFont( pOut->GetFont() ); + VclPtr<VirtualDevice> pDevice = VclPtr<VirtualDevice>::Create(); + vcl::Font aFont = pDevice->GetFont(); aFont.SetFamilyName( aFontName ); - Rectangle aBoundingRect; - pOut->GetTextBoundRect( aBoundingRect, aObjectText ); + aFont.SetFontSize( Size( 0, 96 ) ); + pDevice->SetFont( aFont ); - OUString aObjName = GetPropertyString(DFF_Prop_wzName, rSt); - if ( aBoundingRect.GetWidth() && aObjData.eShapeType == mso_sptTextPlainText && aObjName.match( "PowerPlusWaterMarkObject" ) ) + auto nTextWidth = pDevice->GetTextWidth( aObjectText ); + OUString aObjName = GetPropertyString( DFF_Prop_wzName, rSt ); + if ( nTextWidth && aObjData.eShapeType == mso_sptTextPlainText + && aObjName.match( "PowerPlusWaterMarkObject" ) ) { - fRatio = (double)aBoundingRect.GetHeight() / aBoundingRect.GetWidth(); + fRatio = (double)pDevice->GetTextHeight() / nTextWidth; sal_Int32 nNewHeight = fRatio * aObjData.aBoundRect.getWidth(); sal_Int32 nPaddingY = aObjData.aBoundRect.getHeight() - nNewHeight; |