basegfx/source/tools/gradienttools.cxx | 6 +++--- sw/qa/extras/uiwriter/data3/tdf133477.fodt | 21 +++++++++++++++++++++ sw/qa/extras/uiwriter/uiwriter3.cxx | 29 +++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-)
New commits: commit 52f8e0b6f09be0e8e8a068edef2017d45d5a1892 Author: Tünde Tóth <tund...@gmail.com> AuthorDate: Fri May 29 10:51:13 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Fri Aug 7 12:03:01 2020 +0200 tdf#133477 basegfx: fix center of rotated gradients in the case of square and quadratic gradient styles. Change-Id: I2e5522930b472bf2ee702c780f39aa187bd7b64f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95356 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 082f564556a4..3605d8fe0be0 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -244,9 +244,9 @@ namespace basegfx // add defined offsets after rotation if(!fTools::equal(0.5, rOffset.getX()) || !fTools::equal(0.5, rOffset.getY())) { - // use scaled target size - fTargetOffsetX += (rOffset.getX() - 0.5) * fTargetSizeX; - fTargetOffsetY += (rOffset.getY() - 0.5) * fTargetSizeY; + // use original target size + fTargetOffsetX += (rOffset.getX() - 0.5) * rTargetRange.getWidth(); + fTargetOffsetY += (rOffset.getY() - 0.5) * rTargetRange.getHeight(); } // add object translate diff --git a/sw/qa/extras/uiwriter/data3/tdf133477.fodt b/sw/qa/extras/uiwriter/data3/tdf133477.fodt new file mode 100644 index 000000000000..e18a0e458a2d --- /dev/null +++ b/sw/qa/extras/uiwriter/data3/tdf133477.fodt @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:styles> + <draw:gradient draw:name="Gradient_20_1" draw:display-name="Gradient 1" draw:style="rectangular" draw:cx="0%" draw:cy="0%" draw:start-color="#ffff00" draw:end-color="#0066cc" draw:start-intensity="100%" draw:end-intensity="100%" draw:angle="45deg" draw:border="0%"/> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="gr1" style:family="graphic"> + <style:graphic-properties draw:stroke="none" svg:stroke-width="0cm" svg:stroke-color="#000000" draw:marker-start="" draw:marker-start-width="0.3cm" draw:marker-start-center="false" draw:marker-end="" draw:marker-end-width="0.3cm" draw:marker-end-center="false" draw:fill="gradient" draw:fill-color="#00b8ff" draw:fill-gradient-name="Gradient_20_1" draw:gradient-step-count="3" draw:textarea-horizontal-align="center" draw:textarea-vertical-align="middle" draw:shadow="hidden" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:shadow-color="#808080" style:run-through="foreground" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="middle" style:vertical-rel="baseline" style:horizontal-pos="from-left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true" style:flow-with-text="false"/> + </style:style> + </office:automatic-styles> + <office:body> + <office:text> + <text:p text:style-name="Standard"><draw:rect text:anchor-type="as-char" draw:z-index="0" draw:name="Alakzat1" draw:style-name="gr1" svg:width="4cm" svg:height="10cm"> + <text:p/> + </draw:rect></text:p> + <text:p text:style-name="Standard">Top left corner is blue.</text:p> + </office:text> + </office:body> +</office:document> \ No newline at end of file diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 8336544274b4..cd8c7ac359bc 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -10,6 +10,7 @@ #include <swmodeltestbase.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <vcl/scheduler.hxx> +#include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> @@ -22,6 +23,7 @@ #include <fmtanchr.hxx> #include <o3tl/safeint.hxx> #include <tools/json_writer.hxx> +#include <unotools/streamwrap.hxx> #include <wrtsh.hxx> #include <unotxdoc.hxx> @@ -1304,4 +1306,31 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf127652) CPPUNIT_ASSERT_EQUAL_MESSAGE("We are on the wrong page!", assertPage, currentPage); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133477) +{ + load(DATA_DIRECTORY, "tdf133477.fodt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + // Save the shape to a BMP. + uno::Reference<drawing::XGraphicExportFilter> xGraphicExporter + = drawing::GraphicExportFilter::create(mxComponentContext); + uno::Reference<lang::XComponent> xSourceDoc(getShape(1), uno::UNO_QUERY); + xGraphicExporter->setSourceDocument(xSourceDoc); + + SvMemoryStream aStream; + uno::Reference<io::XOutputStream> xOutputStream(new utl::OStreamWrapper(aStream)); + uno::Sequence<beans::PropertyValue> aDescriptor( + comphelper::InitPropertySequence({ { "OutputStream", uno::makeAny(xOutputStream) }, + { "FilterName", uno::makeAny(OUString("BMP")) } })); + xGraphicExporter->filter(aDescriptor); + aStream.Seek(STREAM_SEEK_TO_BEGIN); + + // Read it back and check the color of the first pixel. + Graphic aGraphic; + ReadGraphic(aStream, aGraphic); + BitmapEx aBitmap = aGraphic.GetBitmapEx(); + CPPUNIT_ASSERT_EQUAL(Color(0, 102, 204), aBitmap.GetPixelColor(0, 0)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits