svx/source/customshapes/EnhancedCustomShape2d.cxx | 12 ++++-- sw/CppunitTest_sw_uiwriter.mk | 35 ----------------- sw/qa/extras/uiwriter/data/fdo87448.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx | 44 ++++++++++++++++++++++ 4 files changed, 53 insertions(+), 38 deletions(-)
New commits: commit 20f8006e21943b08f1f152e4a0359c9ebe4786f2 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Dec 18 19:17:25 2014 +0100 fdo#87448 EnhancedCustomShape2d: fix handling of scaled ARCANGLETO commands Change-Id: I7daf52a60e3fac8d9f86b464e86af60e0495fcb1 diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 225ec26..9a66921 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -52,6 +52,7 @@ #include <basegfx/color/bcolortools.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <rtl/strbuf.hxx> #include <math.h> @@ -1770,8 +1771,7 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm GetParameter ( fStartAngle, seqCoordinates[ (sal_uInt16)( rSrcPt + 1) ].First, false, false ); GetParameter ( fSwingAngle, seqCoordinates[ (sal_uInt16)( rSrcPt + 1 ) ].Second, false, false ); - fWR *= fXScale; - fHR *= fYScale; + // Convert angles to radians, but don't do any scaling / translation yet. fStartAngle *= F_PI180; fSwingAngle *= F_PI180; @@ -1783,7 +1783,7 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm if (aNewB2DPolygon.count() > 0) { basegfx::B2DPoint aStartPointB2D( aNewB2DPolygon.getB2DPoint(aNewB2DPolygon.count() - 1 ) ); - Point aStartPoint( aStartPointB2D.getX(), aStartPointB2D.getY() ); + Point aStartPoint( 0, 0 ); double fT = atan2((fWR*sin(fStartAngle)), (fHR*cos(fStartAngle))); double fTE = atan2((fWR*sin(fStartAngle + fSwingAngle)), fHR*cos(fStartAngle + fSwingAngle)); @@ -1798,7 +1798,11 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm OSL_TRACE("ARCANGLETO rect: %d, %d x %d, %d start: %d, %d end: %d, %d clockwise: %d", aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom(), aStartPoint.X(), aStartPoint.Y(), aEndPoint.X(), aEndPoint.Y(), bClockwise); - aNewB2DPolygon.append(CreateArc( aRect, bClockwise ? aEndPoint : aStartPoint, bClockwise ? aStartPoint : aEndPoint, bClockwise, aStartPoint == aEndPoint && fSwingAngle > F_PI)); + basegfx::B2DPolygon aArc = CreateArc( aRect, bClockwise ? aEndPoint : aStartPoint, bClockwise ? aStartPoint : aEndPoint, bClockwise, aStartPoint == aEndPoint && fSwingAngle > F_PI); + // Now that we have the arc, move it to aStartPointB2D and also scale it. + basegfx::B2DHomMatrix aMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(fXScale, fYScale, aStartPointB2D.getX(), aStartPointB2D.getY()); + aArc.transform(aMatrix); + aNewB2DPolygon.append(aArc); } rSrcPt += 2; diff --git a/sw/qa/extras/uiwriter/data/fdo87448.odt b/sw/qa/extras/uiwriter/data/fdo87448.odt new file mode 100644 index 0000000..3618dcd Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo87448.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index c840b44..8073a43 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -8,6 +8,7 @@ */ #include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <swmodeltestbase.hxx> #include <ndtxt.hxx> @@ -26,6 +27,8 @@ #include <hhcwrp.hxx> #include <swacorr.hxx> #include <editeng/acorrcfg.hxx> +#include <unotools/streamwrap.hxx> +#include <test/mtfxmldump.hxx> #include <svx/svdpage.hxx> #include <svx/svdview.hxx> @@ -72,6 +75,7 @@ public: void testCreatePortions(); void testBookmarkUndo(); void testFdo85876(); + void testFdo87448(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -101,6 +105,7 @@ public: CPPUNIT_TEST(testCreatePortions); CPPUNIT_TEST(testBookmarkUndo); CPPUNIT_TEST(testFdo85876); + CPPUNIT_TEST(testFdo87448); CPPUNIT_TEST_SUITE_END(); @@ -760,6 +765,45 @@ void SwUiWriterTest::testFdo85876() } } +void SwUiWriterTest::testFdo87448() +{ + createDoc("fdo87448.odt"); + + // Save the first shape to a metafile. + uno::Reference<drawing::XGraphicExportFilter> xGraphicExporter = drawing::GraphicExportFilter::create(comphelper::getProcessComponentContext()); + 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 = + { + beans::PropertyValue("OutputStream", sal_Int32(0), uno::makeAny(xOutputStream), beans::PropertyState_DIRECT_VALUE), + beans::PropertyValue("FilterName", sal_Int32(0), uno::makeAny(OUString("SVM")), beans::PropertyState_DIRECT_VALUE) + }; + xGraphicExporter->filter(aDescriptor); + aStream.Seek(STREAM_SEEK_TO_BEGIN); + + // Read it back and dump it as an XML file. + Graphic aGraphic; + ReadGraphic(aStream, aGraphic); + const GDIMetaFile& rMetaFile = aGraphic.GetGDIMetaFile(); + MetafileXmlDump dumper; + xmlDocPtr pXmlDoc = dumper.dumpAndParse(const_cast<GDIMetaFile&>(rMetaFile)); + + // The first polyline in the document has a number of points to draw arcs, + // the last one jumps back to the start, so we call "end" the last but one. + sal_Int32 nFirstEnd = getXPath(pXmlDoc, "/metafile/polyline[1]/point[last()-1]", "x").toInt32(); + // The second polyline has a different start point, but the arc it draws + // should end at the ~same position as the first polyline. + sal_Int32 nSecondEnd = getXPath(pXmlDoc, "/metafile/polyline[2]/point[last()]", "x").toInt32(); + + // nFirstEnd was 6023 and nSecondEnd was 6648, now they should be much closer, e.g. nFirstEnd = 6550, nSecondEnd = 6548 + OString aMsg = "nFirstEnd is " + OString::number(nFirstEnd) + ", nSecondEnd is " + OString::number(nSecondEnd); + // Assert that the difference is less than half point. + CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), abs(nFirstEnd - nSecondEnd) < 10); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit 4423637d4e9c949b22109f7db029c9afaccc7d7e Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Dec 18 18:40:12 2014 +0100 CppunitTest_sw_uiwriter: use gb_CppunitTest_use_rdb I can't easily see what component is missing for SVM saving, and we do the same in CppunitTest_sw_htmlimport already, so why bother. Change-Id: Iba917e211fc721f8e275b3ce04a0e02c0759485b diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk index 589421d..a34093b 100644 --- a/sw/CppunitTest_sw_uiwriter.mk +++ b/sw/CppunitTest_sw_uiwriter.mk @@ -55,40 +55,7 @@ $(eval $(call gb_CppunitTest_use_api,sw_uiwriter,\ $(eval $(call gb_CppunitTest_use_ure,sw_uiwriter)) $(eval $(call gb_CppunitTest_use_vcl,sw_uiwriter)) -$(eval $(call gb_CppunitTest_use_components,sw_uiwriter,\ - basic/util/sb \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - embeddedobj/util/embobj \ - filter/source/config/cache/filterconfig1 \ - filter/source/storagefilterdetect/storagefd \ - framework/util/fwk \ - i18npool/util/i18npool \ - linguistic/source/lng \ - package/util/package2 \ - package/source/xstor/xstor \ - sw/util/msword \ - sw/util/sw \ - sw/util/swd \ - sax/source/expatwrap/expwrap \ - sfx2/util/sfx \ - svl/source/fsstor/fsstorage \ - svtools/util/svt \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - unotools/util/utl \ - unoxml/source/service/unoxml \ - uui/util/uui \ - $(if $(filter-out MACOSX WNT,$(OS)), \ - $(if $(ENABLE_HEADLESS),, \ - vcl/vcl.unx \ - ) \ - ) \ - $(if $(filter DESKTOP,$(BUILD_TYPE)),xmlhelp/util/ucpchelp1) \ - writerfilter/util/writerfilter \ - xmloff/util/xo \ -)) +$(eval $(call gb_CppunitTest_use_rdb,sw_uiwriter,services)) $(eval $(call gb_CppunitTest_use_configuration,sw_uiwriter)) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits