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 /oox | |
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 'oox')
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index a9d31b26c82d..d82076315acb 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -22,6 +22,7 @@ #include "oox/vml/vmlshape.hxx" #include <vcl/wmf.hxx> +#include <vcl/virdev.hxx> #include <com/sun/star/beans/PropertyValues.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -1134,15 +1135,17 @@ sal_Int32 lcl_correctWatermarkRect( awt::Rectangle& rShapeRect, const OUString& { sal_Int32 nPaddingY = 0; 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( sFont ); + aFont.SetFontSize( Size( 0, 96 ) ); + pDevice->SetFont( aFont ); - Rectangle aBoundingRect; - pOut->GetTextBoundRect( aBoundingRect, sText ); - if( aBoundingRect.GetWidth() ) + auto nTextWidth = pDevice->GetTextWidth( sText ); + if( nTextWidth ) { - fRatio = (double)aBoundingRect.GetHeight() / aBoundingRect.GetWidth(); + fRatio = pDevice->GetTextHeight(); + fRatio /= nTextWidth; sal_Int32 nNewHeight = fRatio * rShapeRect.Width; nPaddingY = rShapeRect.Height - nNewHeight; |