summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-11-30 18:26:11 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2017-12-02 18:44:16 +0100
commit923ca4efe2095998e3da75c372cd7d716db9abb3 (patch)
tree9dcc6d326fe3183562b45675c543c288d0fcd386 /oox
parent0cb20da5fddbfbeb06f51aef9cd5addb669bb2ad (diff)
tdf#113037 Unify Watermark in DOC & DOCX
* use correct font for calculations Change-Id: Idd370678c000bf22c460c3323bd55cd827ba7153 Reviewed-on: https://gerrit.libreoffice.org/45698 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/vml/vmlshape.cxx15
1 files changed, 9 insertions, 6 deletions
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index ea111d4c93cb..6e792d93157e 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -24,6 +24,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>
@@ -1174,15 +1175,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 );
- tools::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;