summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2020-03-22 19:43:03 +0530
committerAndras Timar <andras.timar@collabora.com>2020-03-23 12:51:42 +0100
commit8f062cdae1c71c9dd2a1e3f81617b08ac7463c5d (patch)
tree66c53c4613fc7aa558c1bd4646b5b07ca06de356
parent4ae9a263f24e06cb675dbe2408cbc160e6441a42 (diff)
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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90878 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--svx/source/xoutdev/xattr.cxx13
-rw-r--r--sw/source/uibase/shells/drawdlg.cxx40
2 files changed, 53 insertions, 0 deletions
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 83e052231b58..1de52ad51ee5 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -2532,6 +2532,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 8b42f0ebb732..66176aca79e6 100644
--- a/sw/source/uibase/shells/drawdlg.cxx
+++ b/sw/source/uibase/shells/drawdlg.cxx
@@ -40,6 +40,8 @@
#include <svx/xflclit.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xflgrit.hxx>
+#include <svx/xflftrit.hxx>
+#include <svx/xfltrit.hxx>
#include <comphelper/lok.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -320,6 +322,40 @@ void SwDrawShell::ExecDrawAttrArgs(SfxRequest const & rReq)
pView->GetModel()->SetChanged();
}
+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();
@@ -329,7 +365,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());