svx/source/xoutdev/xattr.cxx | 13 +++++++++++ sw/source/uibase/shells/drawdlg.cxx | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
New commits: commit f08bbb5648c06a387e69f3a0e0a6a9a1eda7fc37 Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Sun Mar 22 19:43:03 2020 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Tue Mar 24 18:52:47 2020 +0100 lokit: unify fill transparency items Online just listens to .uno:FillFloatTransparence but the set-item in core it corresponds to, does not represent the fill-transparency types like 'None' and 'Solid'. This is represented by another item called XFillTransparencyItem. As a result the mobile wizard does not show the correct transparency fill type always. To solve this, this patch encodes the constant transparency percentage in case of Solid and None(always 0%) as an intensity and stores this info in the statechange message of .uno:FillFloatTransparence whenever there is no gradient type and corrects the 'style' attribute of the message appropriately. More detailed information is provided as comments at appropriate places in the patch. Change-Id: I443ef4ce349badf28f6c2c702b1014868d9c6ed5 (cherry picked from commit 34969e9c04f9305d19826c72a29e38e26794cbe3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90986 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index 4b11483e8e3a..2fc8ff28f861 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -2502,6 +2502,19 @@ boost::property_tree::ptree XFillFloatTransparenceItem::dumpAsJSON() const boost::property_tree::ptree aTree = XFillGradientItem::dumpAsJSON(); aTree.put("commandName", ".uno:FillFloatTransparence"); + if (!bEnabled) + { + boost::property_tree::ptree& rState = aTree.get_child("state"); + // When gradient fill is disabled, the intensity fields contain the + // constant encoded percent-transparency. However we use that here to just + // distinguish between 'None' and 'Solid' types and correct the 'style' + // property appropriately. + if (GetGradientValue().GetStartIntens() == 100) + rState.put("style", "NONE"); + else + rState.put("style", "SOLID"); + } + return aTree; } diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx index 78c49e0e5488..9e5939697602 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -36,6 +36,9 @@ #include <svx/chrtitem.hxx> #include <svx/xlnwtit.hxx> #include <svx/xflgrit.hxx> +#include <svx/xflftrit.hxx> +#include <svx/xfltrit.hxx> +#include <comphelper/lok.hxx> using namespace com::sun::star::drawing; @@ -314,6 +317,40 @@ void SwDrawShell::ExecDrawAttrArgs(SfxRequest const & rReq) pView->GetModel()->SetChanged(); } +static void lcl_unifyFillTransparencyItems(SfxItemSet& rSet) +{ + // Transparent fill options are None, Solid, Linear, Axial, Radial, Elliptical, Quadratic, Square. + // But this is represented across two items namely XFillTransparenceItem (for None and Solid) + // and XFillFloatTransparenceItem (for the rest). To simplify the representation in LOKit case let's + // use XFillFloatTransparenceItem to carry the information of XFillTransparenceItem when gradients + // are disabled. When gradient transparency is disabled, all fields of XFillFloatTransparenceItem are invalid + // and not used. So convert XFillTransparenceItem's constant transparency percentage as an intensity + // and assign this to the XFillFloatTransparenceItem's start-intensity and end-intensity fields. + // Now the LOK clients need only listen to statechange messages of XFillFloatTransparenceItem + // to get fill-transparency settings instead of listening to two separate items. + + XFillFloatTransparenceItem* pFillFloatTranspItem = + const_cast<XFillFloatTransparenceItem*> + (rSet.GetItem<XFillFloatTransparenceItem>(XATTR_FILLFLOATTRANSPARENCE)); + if (!pFillFloatTranspItem || pFillFloatTranspItem->IsEnabled()) + return; + + const XFillTransparenceItem* pFillTranspItem = + rSet.GetItem<XFillTransparenceItem>(XATTR_FILLTRANSPARENCE); + + if (!pFillTranspItem) + return; + + XGradient aTmpGradient = pFillFloatTranspItem->GetGradientValue(); + sal_uInt16 nTranspPercent = pFillTranspItem->GetValue(); + // Encode transparancy percentage as intensity + sal_uInt16 nIntensity = 100 - std::min<sal_uInt16> + (std::max<sal_uInt16>(nTranspPercent, 0), 100); + aTmpGradient.SetStartIntens(nIntensity); + aTmpGradient.SetEndIntens(nIntensity); + pFillFloatTranspItem->SetGradientValue(aTmpGradient); +} + void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet) { SdrView* pSdrView = GetShell().GetDrawView(); @@ -323,7 +360,11 @@ void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet) bool bDisable = Disable( rSet ); if( !bDisable ) + { pSdrView->GetAttributes( rSet ); + if (comphelper::LibreOfficeKit::isActive()) + lcl_unifyFillTransparencyItems(rSet); + } } else rSet.Put(pSdrView->GetDefaultAttr()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits