summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-11-30 18:26:11 +0100
committerAndras Timar <andras.timar@collabora.com>2018-01-17 08:39:44 +0100
commit1eb1ea6814f8118e105de04815a25d14e591aaef (patch)
tree4c37e1cf13fec22ca04ec63b143725b2ef30f2bf /filter
parentecb450de54eb1a757eb1498597c20ec28e37a65d (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> (cherry picked from commit b66435c3fcff5eb198f0037067294c1203ebcd76)
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 6b00faf649d8..7e756a0aa714 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;