diff options
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 43 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 17 |
2 files changed, 56 insertions, 4 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(); diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index d20eaef09261..bb6e8fad528f 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -95,7 +95,7 @@ #include <memory> #include <vector> - +#include <iostream> using namespace ::osl; using namespace ::cppu; using namespace ::com::sun::star; @@ -598,6 +598,18 @@ void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& const SfxItemPropertyMap& rSrc = rPropSet.getPropertyMap(); PropertyEntryVector_t aSrcPropVector = rSrc.getPropertyEntries(); PropertyEntryVector_t::const_iterator aSrcIt = aSrcPropVector.begin(); + + while(aSrcIt != aSrcPropVector.end()) + { + const sal_uInt16 nWID = aSrcIt->nWID; + if(SfxItemPool::IsWhich(nWID) + && (nWID < OWN_ATTR_VALUE_START || nWID > OWN_ATTR_VALUE_END) + && rPropSet.GetUsrAnyForID(nWID)) + rSet.Put(rSet.GetPool()->GetDefaultItem(nWID)); + ++aSrcIt; + } + + aSrcIt = aSrcPropVector.begin(); while(aSrcIt != aSrcPropVector.end()) { if(aSrcIt->nWID) @@ -618,9 +630,6 @@ void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& } else { - if(SfxItemPool::IsWhich(pEntry->nWID)) - rSet.Put(rSet.GetPool()->GetDefaultItem(pEntry->nWID)); - // set SvxItemPropertySet_setPropertyValue(pEntry, *pUsrAny, rSet); } } |