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 #include #include +#include +#include +#include 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 + (rSet.GetItem(XATTR_FILLFLOATTRANSPARENCE)); + if (!pFillFloatTranspItem || pFillFloatTranspItem->IsEnabled()) + return; + + const XFillTransparenceItem* pFillTranspItem = + rSet.GetItem(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 + (std::max(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());