summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-01-21 15:43:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-01-22 17:55:28 +0100
commiteae55d7397f953ca8a4be1a2665e8ca887adfe81 (patch)
tree47d84a1b81c3a4d7b4719b328cb1241ae80f1a2f /chart2
parent2399373778cf0778ad15b1fec9a1bf289b4089de (diff)
rework line style to be a wide toolbar button
involves converting SvxLineStyleToolBoxControl to a PopupWindowController because chart is doing interesting things in its panel there needs to be a non-standard way to report/detect the selected line style, which is then reused to disable/enable the arrows when none is selected/deselected in non-chart sidebars SvxLineBox becomes a toolbar dropdown instead of a combobox itemwindow linectrl.cxx split into linewidthctrl.cxx and linewidthctrl because SvxLineBox is now needed in svxcore Change-Id: Icf0ef5e612b894a43d389af8a2908138c2e9c580 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87164 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.cxx101
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.hxx22
-rw-r--r--chart2/source/controller/sidebar/ChartLinePanel.cxx89
-rw-r--r--chart2/source/controller/sidebar/ChartLinePanel.hxx5
4 files changed, 139 insertions, 78 deletions
diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.cxx b/chart2/source/controller/sidebar/ChartColorWrapper.cxx
index 189b55059492..9a8c568a863d 100644
--- a/chart2/source/controller/sidebar/ChartColorWrapper.cxx
+++ b/chart2/source/controller/sidebar/ChartColorWrapper.cxx
@@ -10,11 +10,17 @@
#include "ChartColorWrapper.hxx"
#include <ObjectIdentifier.hxx>
+#include <PropertyHelper.hxx>
#include <com/sun/star/chart2/XDiagram.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/frame/XController.hpp>
+#include <svx/linectrl.hxx>
#include <svx/tbcontrl.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/unomid.hxx>
namespace chart::sidebar {
@@ -104,6 +110,101 @@ void ChartColorWrapper::updateData()
mpControl->statusChanged(aEvent);
}
+ChartLineStyleWrapper::ChartLineStyleWrapper(
+ css::uno::Reference<css::frame::XModel> const & xModel,
+ SvxLineStyleToolBoxControl* pControl)
+ : mxModel(xModel)
+ , mpControl(pControl)
+{
+}
+
+void ChartLineStyleWrapper::updateModel(const css::uno::Reference<css::frame::XModel>& xModel)
+{
+ mxModel = xModel;
+}
+
+namespace
+{
+ css::uno::Any getLineDash(
+ const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rDashName)
+ {
+ css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY);
+ css::uno::Reference<css::container::XNameAccess> xNameAccess(
+ xFact->createInstance("com.sun.star.drawing.DashTable"),
+ css::uno::UNO_QUERY );
+ if(xNameAccess.is())
+ {
+ if (!xNameAccess->hasByName(rDashName))
+ return css::uno::Any();
+
+ return xNameAccess->getByName(rDashName);
+ }
+
+ return css::uno::Any();
+ }
+}
+
+void ChartLineStyleWrapper::updateData()
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ if (!xPropSet.is())
+ return;
+
+ css::util::URL aUrl;
+ aUrl.Complete = ".uno:XLineStyle";
+
+ css::frame::FeatureStateEvent aEvent;
+ aEvent.IsEnabled = true;
+
+ aEvent.FeatureURL = aUrl;
+ aEvent.State = xPropSet->getPropertyValue("LineStyle");
+ mpControl->statusChanged(aEvent);
+
+ aUrl.Complete = ".uno:LineDash";
+
+ auto aLineDashName = xPropSet->getPropertyValue("LineDashName");
+ OUString aDashName;
+ aLineDashName >>= aDashName;
+ css::uno::Any aLineDash = getLineDash(mxModel, aDashName);
+ XLineDashItem aDashItem;
+ aDashItem.PutValue(aLineDash, MID_LINEDASH);
+
+ aEvent.FeatureURL = aUrl;
+ aDashItem.QueryValue(aEvent.State);
+ mpControl->statusChanged(aEvent);
+}
+
+bool ChartLineStyleWrapper::operator()(const OUString& rCommand, const css::uno::Any& rValue)
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+
+ if (!xPropSet.is())
+ {
+ SAL_WARN("chart2", "Invalid reference to xPropSet");
+ return false;
+ }
+
+ if (rCommand == ".uno:XLineStyle")
+ {
+ xPropSet->setPropertyValue("LineStyle", rValue);
+ return true;
+ }
+ else if (rCommand == ".uno:LineDash")
+ {
+ XLineDashItem aDashItem;
+ aDashItem.PutValue(rValue, 0);
+ css::uno::Any aAny;
+ aDashItem.QueryValue(aAny, MID_LINEDASH);
+ OUString aDashName = PropertyHelper::addLineDashUniqueNameToTable(aAny,
+ css::uno::Reference<css::lang::XMultiServiceFactory>(mxModel, css::uno::UNO_QUERY),
+ "");
+ xPropSet->setPropertyValue("LineDash", aAny);
+ xPropSet->setPropertyValue("LineDashName", css::uno::Any(aDashName));
+ return true;
+ }
+ return false;
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.hxx b/chart2/source/controller/sidebar/ChartColorWrapper.hxx
index 05b0e9f38fea..8f16c1b1dd33 100644
--- a/chart2/source/controller/sidebar/ChartColorWrapper.hxx
+++ b/chart2/source/controller/sidebar/ChartColorWrapper.hxx
@@ -16,13 +16,12 @@
namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } }
class SvxColorToolBoxControl;
+class SvxLineStyleToolBoxControl;
namespace chart { namespace sidebar {
class ChartColorWrapper
{
-private:
-
public:
ChartColorWrapper(css::uno::Reference<css::frame::XModel> const & xModel,
SvxColorToolBoxControl* pControl,
@@ -43,6 +42,25 @@ private:
OUString maPropertyName;
};
+class ChartLineStyleWrapper
+{
+public:
+ ChartLineStyleWrapper(css::uno::Reference<css::frame::XModel> const & xModel,
+ SvxLineStyleToolBoxControl* pControl);
+
+ bool operator()(const OUString& rCommand, const css::uno::Any& rValue);
+
+ void updateModel(const css::uno::Reference<css::frame::XModel>& xModel);
+
+ void updateData();
+
+private:
+
+ css::uno::Reference<css::frame::XModel> mxModel;
+
+ SvxLineStyleToolBoxControl* mpControl;
+};
+
} }
#endif
diff --git a/chart2/source/controller/sidebar/ChartLinePanel.cxx b/chart2/source/controller/sidebar/ChartLinePanel.cxx
index 2e410084466d..944b709cac56 100644
--- a/chart2/source/controller/sidebar/ChartLinePanel.cxx
+++ b/chart2/source/controller/sidebar/ChartLinePanel.cxx
@@ -19,6 +19,7 @@
#include <svx/xlntrit.hxx>
#include <svx/unomid.hxx>
+#include <svx/linectrl.hxx>
#include <svx/tbcontrl.hxx>
#include <sfx2/weldutils.hxx>
#include <vcl/svapp.hxx>
@@ -31,9 +32,16 @@ namespace chart::sidebar {
namespace {
-SvxColorToolBoxControl* getColorToolBoxControl(ToolbarUnoDispatcher& rToolBoxColor)
+SvxLineStyleToolBoxControl* getLineStyleToolBoxControl(ToolbarUnoDispatcher& rToolBoxColor)
{
- css::uno::Reference<css::frame::XToolbarController> xController = rToolBoxColor.GetControllerForCommand(".uno:XLineColor");
+ css::uno::Reference<css::frame::XToolbarController> xController = rToolBoxColor.GetControllerForCommand(".uno:XLineStyle");
+ SvxLineStyleToolBoxControl* pToolBoxLineStyleControl = dynamic_cast<SvxLineStyleToolBoxControl*>(xController.get());
+ return pToolBoxLineStyleControl;
+}
+
+SvxColorToolBoxControl* getColorToolBoxControl(ToolbarUnoDispatcher& rToolBoxLineStyle)
+{
+ css::uno::Reference<css::frame::XToolbarController> xController = rToolBoxLineStyle.GetControllerForCommand(".uno:XLineColor");
SvxColorToolBoxControl* pToolBoxColorControl = dynamic_cast<SvxColorToolBoxControl*>(xController.get());
return pToolBoxColorControl;
}
@@ -76,24 +84,6 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet(
return xPropSet;
}
-css::uno::Any getLineDash(
- const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rDashName)
-{
- css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY);
- css::uno::Reference<css::container::XNameAccess> xNameAccess(
- xFact->createInstance("com.sun.star.drawing.DashTable"),
- css::uno::UNO_QUERY );
- if(xNameAccess.is())
- {
- if (!xNameAccess->hasByName(rDashName))
- return css::uno::Any();
-
- return xNameAccess->getByName(rDashName);
- }
-
- return css::uno::Any();
-}
-
class PreventUpdate
{
public:
@@ -137,7 +127,8 @@ ChartLinePanel::ChartLinePanel(vcl::Window* pParent,
mxSelectionListener(new ChartSidebarSelectionListener(this)),
mbUpdate(true),
mbModelValid(true),
- maLineColorWrapper(mxModel, getColorToolBoxControl(*mxColorDispatch), "LineColor")
+ maLineColorWrapper(mxModel, getColorToolBoxControl(*mxColorDispatch), "LineColor"),
+ maLineStyleWrapper(mxModel, getLineStyleToolBoxControl(*mxLineStyleDispatch))
{
disableArrowHead();
std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM,
@@ -177,6 +168,9 @@ void ChartLinePanel::Initialize()
SvxColorToolBoxControl* pToolBoxColor = getColorToolBoxControl(*mxColorDispatch);
pToolBoxColor->setColorSelectFunction(maLineColorWrapper);
+ SvxLineStyleToolBoxControl* pToolBoxLineStyle = getLineStyleToolBoxControl(*mxLineStyleDispatch);
+ pToolBoxLineStyle->setLineStyleSelectFunction(maLineStyleWrapper);
+
setMapUnit(MapUnit::Map100thMM);
updateData();
}
@@ -196,19 +190,7 @@ void ChartLinePanel::updateData()
XLineTransparenceItem aLineTransparenceItem(nLineTransparence);
updateLineTransparence(false, true, &aLineTransparenceItem);
- css::drawing::LineStyle eStyle = css::drawing::LineStyle_SOLID;
- xPropSet->getPropertyValue("LineStyle") >>= eStyle;
- XLineStyleItem aStyleItem(eStyle);
- updateLineStyle(false, true, &aStyleItem);
-
- css::uno::Any aLineDashName = xPropSet->getPropertyValue("LineDashName");
- OUString aDashName;
- aLineDashName >>= aDashName;
- css::uno::Any aLineDash = getLineDash(mxModel, aDashName);
- XLineDashItem aDashItem;
- aDashItem.PutValue(aLineDash, MID_LINEDASH);
- updateLineDash(false, true, &aDashItem);
-
+ maLineStyleWrapper.updateData();
maLineColorWrapper.updateData();
}
@@ -235,6 +217,7 @@ void ChartLinePanel::updateModel(
mxModel = xModel;
mbModelValid = true;
+ maLineStyleWrapper.updateModel(mxModel);
maLineColorWrapper.updateModel(mxModel);
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
@@ -245,44 +228,6 @@ void ChartLinePanel::updateModel(
xSelectionSupplier->addSelectionChangeListener(mxSelectionListener.get());
}
-void ChartLinePanel::setLineStyle(const XLineStyleItem& rItem)
-{
- css::uno::Reference<css::beans::XPropertySet> xPropSet =
- getPropSet(mxModel);
-
- if (!xPropSet.is())
- return;
-
- PreventUpdate aPreventUpdate(mbUpdate);
- xPropSet->setPropertyValue("LineStyle", css::uno::Any(rItem.GetValue()));
-}
-
-void ChartLinePanel::setLineDash(const XLineDashItem& rItem)
-{
- css::uno::Reference<css::beans::XPropertySet> xPropSet =
- getPropSet(mxModel);
-
- if (!xPropSet.is())
- return;
-
- PreventUpdate aPreventUpdate(mbUpdate);
- css::uno::Any aAny;
- rItem.QueryValue(aAny, MID_LINEDASH);
- OUString aDashName = PropertyHelper::addLineDashUniqueNameToTable(aAny,
- css::uno::Reference<css::lang::XMultiServiceFactory>(mxModel, css::uno::UNO_QUERY),
- "");
- xPropSet->setPropertyValue("LineDash", aAny);
- xPropSet->setPropertyValue("LineDashName", css::uno::Any(aDashName));
-}
-
-void ChartLinePanel::setLineEndStyle(const XLineEndItem* /*pItem*/)
-{
-}
-
-void ChartLinePanel::setLineStartStyle(const XLineStartItem* /*pItem*/)
-{
-}
-
void ChartLinePanel::setLineJoint(const XLineJointItem* pItem)
{
css::uno::Reference<css::beans::XPropertySet> xPropSet =
diff --git a/chart2/source/controller/sidebar/ChartLinePanel.hxx b/chart2/source/controller/sidebar/ChartLinePanel.hxx
index c2e5d1fee7e1..2f1c520dd426 100644
--- a/chart2/source/controller/sidebar/ChartLinePanel.hxx
+++ b/chart2/source/controller/sidebar/ChartLinePanel.hxx
@@ -64,10 +64,6 @@ public:
protected:
- virtual void setLineStyle(const XLineStyleItem& rItem) override;
- virtual void setLineDash(const XLineDashItem& rItem) override;
- virtual void setLineEndStyle(const XLineEndItem* pItem) override;
- virtual void setLineStartStyle(const XLineStartItem* pItem) override;
virtual void setLineTransparency(const XLineTransparenceItem& rItem) override;
virtual void setLineJoint(const XLineJointItem* pItem) override;
virtual void setLineCap(const XLineCapItem* pItem) override;
@@ -83,6 +79,7 @@ private:
bool mbUpdate;
bool mbModelValid;
ChartColorWrapper maLineColorWrapper;
+ ChartLineStyleWrapper maLineStyleWrapper;
};
} } // end of namespace svx::sidebar