diff options
author | Mark Hung <marklh9@gmail.com> | 2017-01-26 23:13:03 +0800 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-02-02 21:11:47 +0000 |
commit | eb9b9c28ed32cacb5ed0410875af2ec03345fbf9 (patch) | |
tree | b1644f10666a1b8c84e893e859627aedf2dba574 /sd | |
parent | 7bee82cac7e90d9b445eed6328a0c1614a62ab39 (diff) |
tdf#91795: prevent default item overwrite actual values.
A few properties of FillProeprties have the same nWID
but have different nMemberId, such as FillGradient,
FillGradientName,FillHatch,FillHatchName, FillBitmap,
FillBitmapName, and FillBitmapURL.
When putting value of an item, the default item was put
first, despite the value of the item might have already
been put.
Move the part of the code that put default item upfront
so that it will not overwrite actual value accidentally.
Change-Id: I54288420abde333e5b3e4cdd31ca9fae0c3ed7ab
Reviewed-on: https://gerrit.libreoffice.org/33594
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index ff95dc91968d..2a1620c28f21 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -20,6 +20,14 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XModel2.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/XDrawPages.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> + #include <vcl/scheduler.hxx> #include <osl/thread.hxx> #include <FactoryIds.hxx> @@ -51,12 +59,14 @@ public: void testTdf96708(); void testTdf99396(); void testTdf99396TextEdit(); + void testFillGradient(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf96206); CPPUNIT_TEST(testTdf96708); CPPUNIT_TEST(testTdf99396); CPPUNIT_TEST(testTdf99396TextEdit); + CPPUNIT_TEST(testFillGradient); CPPUNIT_TEST_SUITE_END(); private: @@ -255,6 +265,39 @@ void SdMiscTest::testTdf99396TextEdit() xDocSh->DoClose(); } +void SdMiscTest::testFillGradient() +{ + ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc( xDocShRef ); + uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages(); + // Insert a new page. + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->insertNewByIndex(0), uno::UNO_QUERY_THROW ); + uno::Reference<drawing::XShapes> xShapes(xDrawPage,uno::UNO_QUERY_THROW); + uno::Reference<lang::XMultiServiceFactory> const xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY); + // Create a rectangle + uno::Reference<drawing::XShape> xShape1(xDoc->createInstance("com.sun.star.drawing.RectangleShape"),uno::UNO_QUERY_THROW ); + uno::Reference<beans::XPropertySet> xPropSet(xShape1, uno::UNO_QUERY_THROW); + // Set FillStyle and FillGradient + awt::Gradient aGradient; + aGradient.StartColor = sal_Int32(RGB_COLORDATA(255, 0, 0)); + aGradient.EndColor = sal_Int32(RGB_COLORDATA(0, 255, 0)); + xPropSet->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_GRADIENT)); + xPropSet->setPropertyValue("FillGradient", uno::makeAny(aGradient)); + // Add the rectangle to the page. + xShapes->add(xShape1); + + // Retrieve the shape and check FillStyle and FillGradient + uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPage, uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet > xPropSet2(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + drawing::FillStyle eFillStyle; + awt::Gradient aGradient2; + CPPUNIT_ASSERT(xPropSet2->getPropertyValue("FillStyle") >>= eFillStyle); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT,eFillStyle); + CPPUNIT_ASSERT(xPropSet2->getPropertyValue("FillGradient") >>= aGradient2); + CPPUNIT_ASSERT_EQUAL(sal_Int32(RGB_COLORDATA(255, 0, 0)),aGradient2.StartColor); + CPPUNIT_ASSERT_EQUAL(sal_Int32(RGB_COLORDATA(0, 255, 0)),aGradient2.EndColor); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest); CPPUNIT_PLUGIN_IMPLEMENT(); |