From 17a416759291426999d5b79eceeeb729ca95bc93 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Thu, 30 Nov 2017 18:26:11 +0100 Subject: tdf#113037 Unify Watermark in DOC & DOCX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use correct font for calculations Change-Id: Idd370678c000bf22c460c3323bd55cd827ba7153 Reviewed-on: https://gerrit.libreoffice.org/45698 Tested-by: Jenkins Reviewed-by: Szymon Kłos (cherry picked from commit 923ca4efe2095998e3da75c372cd7d716db9abb3) Reviewed-on: https://gerrit.libreoffice.org/45824 --- filter/source/msfilter/msdffimp.cxx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'filter') diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index c2f77d7beb2b..38d7e5ed9e8d 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include "viscache.hxx" // SvxItem-Mapping. Is needed to successfully include the SvxItem-Header @@ -4424,16 +4425,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 pDevice = VclPtr::Create(); + vcl::Font aFont = pDevice->GetFont(); aFont.SetFamilyName( aFontName ); - tools::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; -- cgit v1.2.3