summaryrefslogtreecommitdiff
path: root/filter
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-05 07:46:01 +0100
commit17a416759291426999d5b79eceeeb729ca95bc93 (patch)
treef46729c8025c16f86ecd1e0fa731aac840defbfb /filter
parent29228e83df009cf76ac819ed024527be1092f065 (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> (cherry picked from commit 923ca4efe2095998e3da75c372cd7d716db9abb3) Reviewed-on: https://gerrit.libreoffice.org/45824
Diffstat (limited to 'filter')
-rw-r--r--filter/source/msfilter/msdffimp.cxx17
1 files changed, 10 insertions, 7 deletions
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 <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
@@ -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<VirtualDevice> pDevice = VclPtr<VirtualDevice>::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;