diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-12-07 16:09:47 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-12-10 00:20:55 +0100 |
commit | 1aca81256407be27fd4a7e027e27c51486c2dc31 (patch) | |
tree | effdcd60e5bdc971283c4cd8d102e4d2d0f791f1 /sw | |
parent | ffe4d766a0bd9f3b936d6e742d26ca0f1e6554b4 (diff) |
tdf#114308 Export Watermark size as is
* refactoring
* removed size hack
* export/import "trim" attribute
* DOC: export set of parameters to fit shape & frame
Change-Id: Ib00654626ae1e10ac5110d22eada7528e03357e7
Reviewed-on: https://gerrit.libreoffice.org/46036
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/46154
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sw')
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/tdf114308.docx | bin | 0 -> 21487 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 21 | ||||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export2.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 17 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 10 |
5 files changed, 21 insertions, 33 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf114308.docx b/sw/qa/extras/ooxmlexport/data/tdf114308.docx Binary files differnew file mode 100755 index 000000000000..0796200fc5f4 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf114308.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 97a5098d2373..8d125bea4910 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -607,14 +607,25 @@ DECLARE_OOXMLEXPORT_TEST(testWatermarkSize, "watermark.docx") uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); - sal_Int32 nTotalHeight = 0; - xPropertySet->getPropertyValue(UNO_NAME_TEXT_UPPERDIST) >>= nTotalHeight; - nTotalHeight += xShape->getSize().Height; + sal_Int32 nHeight = xShape->getSize().Height; // Rounding errors - sal_Int32 nDifference = 5198 - nTotalHeight; + sal_Int32 nDifference = 5150 - nHeight; std::stringstream ss; - ss << "Difference: " << nDifference << " TotalHeight: " << nTotalHeight; + ss << "Difference: " << nDifference << " TotalHeight: " << nHeight; + CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference <= 4); + CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference >= -4); +} + +DECLARE_OOXMLEXPORT_TEST(testWatermarkTrim, "tdf114308.docx") +{ + uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY); + + // Rounding errors + sal_Int32 nHeight = xShape->getSize().Height; + sal_Int32 nDifference = 8729 - nHeight; + std::stringstream ss; + ss << "Difference: " << nDifference << " TotalHeight: " << nHeight; CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference <= 4); CPPUNIT_ASSERT_MESSAGE(ss.str(), nDifference >= -4); } diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index 5ef42cae4886..0f2ed521d6d0 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -111,12 +111,8 @@ DECLARE_WW8EXPORT_TEST(testTdf91687, "tdf91687.doc") { // Exported Watermarks were resized uno::Reference<drawing::XShape> xWatermark = getShape(1); - uno::Reference<beans::XPropertySet> xWatermarkProperties(xWatermark, uno::UNO_QUERY); - 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)5172, xWatermark->getSize().Height); 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 e8c4c6bc6c04..ce41b3e7a064 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -396,7 +396,6 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, // Calc the ratio. double fRatio = 0; - double fRatioFrame = 0; VclPtr<VirtualDevice> pDevice = VclPtr<VirtualDevice>::Create(); vcl::Font aFont = pDevice->GetFont(); @@ -404,17 +403,11 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, aFont.SetFontSize(Size(0, 96)); pDevice->SetFont(aFont); - Rectangle aBoundingRect; - pDevice->GetTextBoundRect(aBoundingRect, rWatermark.GetText()); - if (aBoundingRect.GetWidth()) - { - fRatio = (double)aBoundingRect.getHeight() / aBoundingRect.getWidth(); - } auto nTextWidth = pDevice->GetTextWidth(rWatermark.GetText()); if (nTextWidth) { - fRatioFrame = pDevice->GetTextHeight(); - fRatioFrame /= nTextWidth; + fRatio = pDevice->GetTextHeight(); + fRatio /= nTextWidth; } // Calc the size. @@ -440,13 +433,12 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, nWidth = aSize.Height - nTopMargin - nBottomMargin; } 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); basegfx::B2DHomMatrix aTransformation; aTransformation.identity(); - aTransformation.scale(nWidth, nFrameHeight); + aTransformation.scale(nWidth, nHeight); aTransformation.rotate(F_PI180 * -1 * nAngle); drawing::HomogenMatrix3 aMatrix; aMatrix.Line1.Column1 = aTransformation.get(0, 0); @@ -473,14 +465,13 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, xPropertySet->setPropertyValue(UNO_NAME_OPAQUE, uno::makeAny(false)); xPropertySet->setPropertyValue(UNO_NAME_TEXT_AUTOGROWHEIGHT, uno::makeAny(false)); xPropertySet->setPropertyValue(UNO_NAME_TEXT_AUTOGROWWIDTH, uno::makeAny(false)); - xPropertySet->setPropertyValue(UNO_NAME_TEXT_MINFRAMEHEIGHT, uno::makeAny(nFrameHeight)); + xPropertySet->setPropertyValue(UNO_NAME_TEXT_MINFRAMEHEIGHT, uno::makeAny(nHeight)); xPropertySet->setPropertyValue(UNO_NAME_TEXT_MINFRAMEWIDTH, uno::makeAny(nWidth)); xPropertySet->setPropertyValue(UNO_NAME_TEXT_WRAP, uno::makeAny(text::WrapTextMode_THROUGHT)); xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION, uno::makeAny(static_cast<sal_Int16>(text::RelOrientation::PAGE_PRINT_AREA))); 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_Int32(nFrameHeight - nHeight))); xPropertySet->setPropertyValue("Transformation", uno::makeAny(aMatrix)); uno::Reference<text::XTextRange> xTextRange(xShape, uno::UNO_QUERY); diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 160616816a0a..9cb319a9ef52 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -690,16 +690,6 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const if (pObj) { aRect = pObj->GetLogicRect(); - - // We have to export Watermark original size with padding - if (pObj->GetName().match("PowerPlusWaterMarkObject")) - { - const SfxItemSet& rSet = pObj->GetMergedItemSet(); - long nHeight = aRect.GetHeight(); - if (const SdrMetricItem* pItem = static_cast<const SdrMetricItem*>(rSet.GetItem(SDRATTR_TEXT_UPPERDIST))) - nHeight += pItem->GetValue(); - aRect.SetSize(Size(aRect.GetWidth(), nHeight)); - } } } |