sc/qa/unit/subsequent_export_test4.cxx | 7 +++++-- sc/source/ui/unoobj/styleuno.cxx | 7 +++++++ sc/source/ui/view/tabvwsha.cxx | 25 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-)
New commits: commit 0f6e6e82a4a693a6970540db6e98d0302f3fefa6 Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Wed Apr 19 01:47:10 2023 +0300 Commit: Maxim Monastirsky <momonas...@gmail.com> CommitDate: Wed Apr 19 13:31:17 2023 +0200 sc drawstyles: Fix export of transparency Change-Id: I1abf277223718ae2d650728e5bd141372a771a87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150590 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index eb3af3a2b2bf..25eb30e19245 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -1499,8 +1499,9 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testShapeStyles) uno::Reference<style::XStyle> xStyle( xMSF->createInstance("com.sun.star.style.GraphicStyle"), uno::UNO_QUERY_THROW); xGraphicStyles->insertByName("MyStyle1", Any(xStyle)); - uno::Reference<beans::XPropertySet>(xStyle, uno::UNO_QUERY_THROW) - ->setPropertyValue("FillColor", Any(COL_RED)); + uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY_THROW); + xPropertySet->setPropertyValue("FillColor", Any(COL_RED)); + xPropertySet->setPropertyValue("FillTransparence", Any(sal_Int16(40))); xStyle.set(xMSF->createInstance("com.sun.star.style.GraphicStyle"), uno::UNO_QUERY_THROW); xGraphicStyles->insertByName("MyStyle2", Any(xStyle)); @@ -1540,6 +1541,8 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testShapeStyles) Color nColor; xShape->getPropertyValue("FillColor") >>= nColor; CPPUNIT_ASSERT_EQUAL(COL_RED, nColor); + CPPUNIT_ASSERT_EQUAL(sal_Int16(40), + xShape->getPropertyValue("FillTransparence").get<sal_Int16>()); } } diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index f4280dd2a679..a97c12e3dec5 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -2025,6 +2025,13 @@ uno::Any ScStyleObj::getPropertyValue_Impl( std::u16string_view aPropertyName ) { if (!SvxUnoTextRangeBase::GetPropertyValueHelper(*pItemSet, pResultEntry, aAny)) aAny = SvxItemPropertySet_getPropertyValue(pResultEntry, *pItemSet); + + // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here + if (pResultEntry->aType == ::cppu::UnoType<sal_Int16>::get() && + aAny.getValueType() == ::cppu::UnoType<sal_Int32>::get()) + { + aAny <<= static_cast<sal_Int16>(aAny.get<sal_Int32>()); + } } } } diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index a3eb7bd5403d..b309ac6156d5 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -40,6 +40,13 @@ #include <svl/stritem.hxx> #include <svl/whiter.hxx> #include <svx/numinf.hxx> +#include <svx/xbtmpit.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xlnstit.hxx> +#include <svx/xlnedit.hxx> +#include <svx/xflgrit.hxx> +#include <svx/xflftrit.hxx> +#include <svx/xflhtit.hxx> #include <svx/zoomslideritem.hxx> #include <global.hxx> @@ -1587,6 +1594,24 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq ) SfxItemSet& rAttr = pStyleSheet->GetItemSet(); sdr::properties::CleanupFillProperties(rAttr); + // check for unique names of named items for xml + auto checkForUniqueItem = [&] (auto nWhichId) + { + if (auto pOldItem = rAttr.GetItemIfSet(nWhichId, false)) + { + if (auto pNewItem = pOldItem->checkForUniqueItem(&GetDrawView()->GetModel())) + rAttr.Put(std::move(pNewItem)); + } + }; + + checkForUniqueItem(XATTR_FILLBITMAP); + checkForUniqueItem(XATTR_LINEDASH); + checkForUniqueItem(XATTR_LINESTART); + checkForUniqueItem(XATTR_LINEEND); + checkForUniqueItem(XATTR_FILLGRADIENT); + checkForUniqueItem(XATTR_FILLFLOATTRANSPARENCE); + checkForUniqueItem(XATTR_FILLHATCH); + static_cast<SfxStyleSheet*>(pStyleSheet)->Broadcast(SfxHint(SfxHintId::DataChanged)); GetScDrawView()->InvalidateAttribs(); }