filter/source/msfilter/msdffimp.cxx | 8 ++++---- sw/qa/extras/ww8export/ww8export2.cxx | 6 +++++- sw/source/core/edit/edfcol.cxx | 20 +++++++++++++++----- 3 files changed, 24 insertions(+), 10 deletions(-)
New commits: commit fec53ea4c33b012ef76d971d0b154d766c8e5759 Author: Szymon KÅos <szymon.k...@collabora.com> Date: Thu Nov 2 17:22:03 2017 +0100 tdf#113037 create Watermark with correct ratio Reviewed-on: https://gerrit.libreoffice.org/44228 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Szymon KÅos <szymon.k...@collabora.com> (cherry picked from commit 1e6abe31eb8f7c12c725f7e1267a7cedfcd3d157) Change-Id: I17ab8d98a618cff6e38dad344f4096dc520cce43 Reviewed-on: https://gerrit.libreoffice.org/45994 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 98427c6ebab6..36a3f59c3787 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -4414,13 +4414,13 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r OutputDevice* pOut = Application::GetDefaultDevice(); vcl::Font aFont( pOut->GetFont() ); aFont.SetFamilyName( aFontName ); - auto nTextWidth = pOut->GetTextWidth( aObjectText ); + Rectangle aBoundingRect; + pOut->GetTextBoundRect( aBoundingRect, aObjectText ); OUString aObjName = GetPropertyString(DFF_Prop_wzName, rSt); - if ( nTextWidth && aObjData.eShapeType == mso_sptTextPlainText && aObjName.match("PowerPlusWaterMarkObject")) + if ( aBoundingRect.GetWidth() && aObjData.eShapeType == mso_sptTextPlainText && aObjName.match( "PowerPlusWaterMarkObject" ) ) { - fRatio = aFont.GetFontSize().Height(); - fRatio /= nTextWidth; + fRatio = (double)aBoundingRect.GetHeight() / aBoundingRect.GetWidth(); sal_Int32 nNewHeight = fRatio * aObjData.aBoundRect.getWidth(); sal_Int32 nPaddingY = aObjData.aBoundRect.getHeight() - nNewHeight; diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index fb58fbcb47dc..5ef42cae4886 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/text/VertOrientation.hpp> #include <pagedesc.hxx> +#include <editeng/unoprnms.hxx> class Test : public SwModelTestBase { @@ -112,7 +113,10 @@ DECLARE_WW8EXPORT_TEST(testTdf91687, "tdf91687.doc") uno::Reference<drawing::XShape> xWatermark = getShape(1); uno::Reference<beans::XPropertySet> xWatermarkProperties(xWatermark, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL((sal_Int32)5172, xWatermark->getSize().Height); + sal_Int32 nHeight = 0; + xWatermarkProperties->getPropertyValue(UNO_NAME_TEXT_UPPERDIST) >>= nHeight; + + CPPUNIT_ASSERT_EQUAL((sal_Int32)5172, xWatermark->getSize().Height + nHeight); CPPUNIT_ASSERT_EQUAL((sal_Int32)18105, xWatermark->getSize().Width); } diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 2201ada112c3..4df109045209 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -396,14 +396,22 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, // Calc the ratio. double fRatio = 0; + double fRatioFrame = 0; OutputDevice* pOut = Application::GetDefaultDevice(); vcl::Font aFont(pOut->GetFont()); aFont.SetFamilyName(sFont); - auto nTextWidth = pOut->GetTextWidth(rWatermark.GetText()); - if (nTextWidth) + + Rectangle aBoundingRect; + pOut->GetTextBoundRect(aBoundingRect, rWatermark.GetText()); + if (aBoundingRect.GetWidth()) { - fRatio = aFont.GetFontSize().Height(); - fRatio /= nTextWidth; + fRatio = (double)aBoundingRect.GetHeight() / aBoundingRect.GetWidth(); + auto nTextWidth = pOut->GetTextWidth(rWatermark.GetText()); + if (nTextWidth) + { + fRatioFrame = aFont.GetFontSize().Height(); + fRatioFrame /= nTextWidth; + } } // Calc the size. @@ -428,7 +436,8 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, xPageStyle->getPropertyValue(UNO_NAME_BOTTOM_MARGIN) >>= nBottomMargin; nWidth = aSize.Height - nTopMargin - nBottomMargin; } - sal_Int32 nHeight = nWidth * fRatio; + sal_Int32 nHeight = fRatio * nWidth; + sal_Int32 nFrameHeight = fRatioFrame * nWidth; // Create and insert the shape. uno::Reference<drawing::XShape> xShape(xMultiServiceFactory->createInstance(aShapeServiceName), uno::UNO_QUERY); @@ -468,6 +477,7 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT_RELATION, uno::makeAny(static_cast<sal_Int16>(text::RelOrientation::PAGE_PRINT_AREA))); xPropertySet->setPropertyValue(UNO_NAME_CHAR_FONT_NAME, uno::makeAny(sFont)); xPropertySet->setPropertyValue(UNO_NAME_CHAR_HEIGHT, uno::makeAny(WATERMARK_AUTO_SIZE)); + xPropertySet->setPropertyValue(UNO_NAME_TEXT_UPPERDIST, uno::makeAny(sal_uInt32(nFrameHeight - nHeight))); xPropertySet->setPropertyValue("Transformation", uno::makeAny(aMatrix)); xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT, uno::makeAny(static_cast<sal_Int16>(text::HoriOrientation::CENTER))); xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT, uno::makeAny(static_cast<sal_Int16>(text::VertOrientation::CENTER)));
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits