summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/Library_chartcontroller.mk1
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.cxx9
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.hxx3
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.cxx80
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.hxx41
-rw-r--r--include/sfx2/sidebar/SidebarToolBox.hxx2
-rw-r--r--include/svx/PaletteManager.hxx5
-rw-r--r--include/svx/sidebar/AreaPropertyPanelBase.hxx3
-rw-r--r--include/svx/tbcontrl.hxx4
-rw-r--r--sfx2/source/sidebar/SidebarToolBox.cxx8
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx10
-rw-r--r--svx/source/tbxctrls/colorwindow.hxx7
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx24
13 files changed, 185 insertions, 12 deletions
diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk
index e06edd176ba1..9f8b65f8045f 100644
--- a/chart2/Library_chartcontroller.mk
+++ b/chart2/Library_chartcontroller.mk
@@ -191,6 +191,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\
chart2/source/controller/sidebar/Chart2PanelFactory \
chart2/source/controller/sidebar/ChartAreaPanel \
chart2/source/controller/sidebar/ChartAxisPanel \
+ chart2/source/controller/sidebar/ChartColorWrapper \
chart2/source/controller/sidebar/ChartElementsPanel \
chart2/source/controller/sidebar/ChartErrorBarPanel \
chart2/source/controller/sidebar/ChartLinePanel \
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 3230e7c32534..dbf9a6837b6b 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -19,6 +19,8 @@
#include <svx/xflftrit.hxx>
#include <svx/unomid.hxx>
+#include <svx/tbcontrl.hxx>
+
namespace chart { namespace sidebar {
namespace {
@@ -237,7 +239,8 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
mxListener(new ChartSidebarModifyListener(this)),
mxSelectionListener(new ChartSidebarSelectionListener(this)),
mbUpdate(true),
- mbModelValid(true)
+ mbModelValid(true),
+ maFillColorWrapper(mxModel)
{
std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND};
mxSelectionListener->setAcceptedTypes(aAcceptedTypes);
@@ -270,6 +273,10 @@ void ChartAreaPanel::Initialize()
if (xSelectionSupplier.is())
xSelectionSupplier->addSelectionChangeListener(mxSelectionListener.get());
+ css::uno::Reference<css::frame::XToolbarController> xController = mpToolBoxColor->GetFirstController();
+ SvxColorToolBoxControl* pToolBoxColor = dynamic_cast<SvxColorToolBoxControl*>(xController.get());
+ pToolBoxColor->setColorSelectFunction(maFillColorWrapper);
+
updateData();
}
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
index 48df2ace78c7..aa66339d975c 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx
@@ -30,6 +30,7 @@
#include "ChartSidebarModifyListener.hxx"
#include "ChartSidebarSelectionListener.hxx"
+#include "ChartColorWrapper.hxx"
class XFillFloatTransparenceItem;
class XFillTransparenceItem;
@@ -92,6 +93,8 @@ private:
bool mbUpdate;
bool mbModelValid;
+
+ ChartColorWrapper maFillColorWrapper;
};
} } // end of namespace svx::sidebar
diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.cxx b/chart2/source/controller/sidebar/ChartColorWrapper.cxx
new file mode 100644
index 000000000000..d8a8f870f28f
--- /dev/null
+++ b/chart2/source/controller/sidebar/ChartColorWrapper.cxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "ChartColorWrapper.hxx"
+
+#include "ChartController.hxx"
+
+namespace chart { namespace sidebar {
+
+namespace {
+
+OUString getCID(css::uno::Reference<css::frame::XModel> xModel)
+{
+ css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController());
+ css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
+ if (!xSelectionSupplier.is())
+ return OUString();
+
+ css::uno::Any aAny = xSelectionSupplier->getSelection();
+ if (!aAny.hasValue())
+ return OUString();
+
+ OUString aCID;
+ aAny >>= aCID;
+
+ return aCID;
+}
+
+css::uno::Reference<css::beans::XPropertySet> getPropSet(
+ css::uno::Reference<css::frame::XModel> xModel)
+{
+ OUString aCID = getCID(xModel);
+ css::uno::Reference<css::beans::XPropertySet> xPropSet =
+ ObjectIdentifier::getObjectPropertySet(aCID, xModel);
+
+ ObjectType eType = ObjectIdentifier::getObjectType(aCID);
+ if (eType == OBJECTTYPE_DIAGRAM)
+ {
+ css::uno::Reference<css::chart2::XDiagram> xDiagram(
+ xPropSet, css::uno::UNO_QUERY);
+ if (!xDiagram.is())
+ return xPropSet;
+
+ xPropSet.set(xDiagram->getWall());
+ }
+
+ return xPropSet;
+}
+
+}
+
+ChartColorWrapper::ChartColorWrapper(
+ css::uno::Reference<css::frame::XModel> xModel):
+ mxModel(xModel),
+ maPropertyName("FillColor")
+{
+}
+
+void ChartColorWrapper::operator()(const OUString& rCommand, const Color& rColor)
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ assert(xPropSet.is());
+
+ xPropSet->setPropertyValue(maPropertyName, css::uno::makeAny(rColor.GetColor()));
+}
+
+void ChartColorWrapper::updateModel(css::uno::Reference<css::frame::XModel> xModel)
+{
+ mxModel = xModel;
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.hxx b/chart2/source/controller/sidebar/ChartColorWrapper.hxx
new file mode 100644
index 000000000000..adbe9ef0d05f
--- /dev/null
+++ b/chart2/source/controller/sidebar/ChartColorWrapper.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_SIDEBAR_CHARTCOLORWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_SIDEBAR_CHARTCOLORWRAPPER_HXX
+
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <tools/color.hxx>
+
+namespace chart { namespace sidebar {
+
+class ChartColorWrapper
+{
+private:
+
+public:
+ ChartColorWrapper(css::uno::Reference<css::frame::XModel> xModel);
+
+ void operator()(const OUString& rCommand, const Color& rColor);
+
+ void updateModel(css::uno::Reference<css::frame::XModel> xModel);
+private:
+
+ // not the chart frame
+ // you need to get the chart frame through getActiveFrame
+ css::uno::Reference<css::frame::XModel> mxModel;
+
+ OUString maPropertyName;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx
index a3959698278e..574603b22e6d 100644
--- a/include/sfx2/sidebar/SidebarToolBox.hxx
+++ b/include/sfx2/sidebar/SidebarToolBox.hxx
@@ -61,6 +61,8 @@ public:
const css::uno::Reference<css::frame::XToolbarController>& rxController,
const OUString& rsCommandName);
+ css::uno::Reference<css::frame::XToolbarController> GetFirstController();
+
private:
Image maItemSeparator;
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index 7ad0cdb8ee86..561dcac43d93 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -50,6 +50,8 @@ class PaletteManager
std::deque<Color> maRecentColors;
std::vector<std::unique_ptr<Palette>> m_Palettes;
+ std::function<void(const OUString&, const Color&)> maColorSelectFunction;
+
public:
PaletteManager();
~PaletteManager();
@@ -69,6 +71,9 @@ public:
void SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater);
void PopupColorPicker(const OUString& aCommand);
+
+ void SetColorSelectFunction(std::function<void(const OUString&, const Color&)> aColorSelectFunction);
+
static void DispatchColorCommand(const OUString& aCommand, const Color& rColor);
};
diff --git a/include/svx/sidebar/AreaPropertyPanelBase.hxx b/include/svx/sidebar/AreaPropertyPanelBase.hxx
index 9fdbba114366..24ebcedc07ba 100644
--- a/include/svx/sidebar/AreaPropertyPanelBase.hxx
+++ b/include/svx/sidebar/AreaPropertyPanelBase.hxx
@@ -23,6 +23,7 @@
#include <vcl/ctrl.hxx>
#include <sfx2/sidebar/SidebarPanelBase.hxx>
#include <sfx2/sidebar/ControllerItem.hxx>
+#include <sfx2/sidebar/SidebarToolBox.hxx>
#include <svx/xgrad.hxx>
#include <svx/itemwin.hxx>
#include <svx/xfillit0.hxx>
@@ -124,7 +125,7 @@ protected:
VclPtr<FixedText> mpColorTextFT;
VclPtr<SvxFillTypeBox> mpLbFillType;
VclPtr<SvxFillAttrBox> mpLbFillAttr;
- VclPtr<ToolBox> mpToolBoxColor; // for new color picker
+ VclPtr<sfx2::sidebar::SidebarToolBox> mpToolBoxColor; // for new color picker
VclPtr<FixedText> mpTrspTextFT;
VclPtr<ListBox> mpLBTransType;
VclPtr<MetricField> mpMTRTransparent;
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 9e589ac44f59..584b99ed64eb 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -225,6 +225,7 @@ public:
Color GetColor();
};
+typedef std::function<void(const OUString&, const Color&)> ColorSelectFunction;
class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
{
using SfxToolBoxControl::StateChanged;
@@ -233,6 +234,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
PaletteManager mPaletteManager;
BorderColorStatus maBorderColorStatus;
bool bSidebarType;
+ ColorSelectFunction maColorSelectFunction;
DECL_LINK(SelectedHdl, Color*);
public:
SFX_DECL_TOOLBOX_CONTROL();
@@ -247,6 +249,8 @@ public:
// XSubToolbarController
virtual sal_Bool SAL_CALL opensSubToolbar() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL updateImage() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ void setColorSelectFunction(ColorSelectFunction aColorSelectFunction);
};
class SVX_DLLPUBLIC SvxFrameToolBoxControl : public SfxToolBoxControl
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index ce02e9ebb2ed..542088a437a9 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -205,6 +205,14 @@ sal_uInt16 SidebarToolBox::GetItemIdForSubToolbarName (const OUString& rsSubTool
return 0;
}
+css::uno::Reference<css::frame::XToolbarController> SidebarToolBox::GetFirstController()
+{
+ if (maControllers.empty())
+ return css::uno::Reference<css::frame::XToolbarController>();
+
+ return maControllers.begin()->second.mxController;
+}
+
void SidebarToolBox::RegisterHandlers()
{
if ( ! mbAreHandlersRegistered)
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 658348fcf3eb..8f0ff658bf30 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -36,7 +36,8 @@ PaletteManager::PaletteManager() :
mnCurrentPalette(0),
mnColorCount(0),
mpBtnUpdater(NULL),
- mLastColor(COL_AUTO)
+ mLastColor(COL_AUTO),
+ maColorSelectFunction(PaletteManager::DispatchColorCommand)
{
LoadPalettes();
mnNumOfPalettes += m_Palettes.size();
@@ -217,6 +218,11 @@ void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater)
mpBtnUpdater = pBtnUpdater;
}
+void PaletteManager::SetColorSelectFunction(std::function<void(const OUString&, const Color&)> aColorSelectFunction)
+{
+ maColorSelectFunction = aColorSelectFunction;
+}
+
void PaletteManager::PopupColorPicker(const OUString& aCommand)
{
// The calling object goes away during aColorDlg.Execute(), so we must copy this
@@ -230,7 +236,7 @@ void PaletteManager::PopupColorPicker(const OUString& aCommand)
mpBtnUpdater->Update( aColorDlg.GetColor() );
mLastColor = aColorDlg.GetColor();
AddRecentColor( mLastColor );
- DispatchColorCommand(aCommandCopy, mLastColor);
+ maColorSelectFunction(aCommandCopy, mLastColor);
}
}
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 97cccc5ff4d2..9cb27fdf4c9d 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -29,6 +29,8 @@
#include <svx/PaletteManager.hxx>
#include <vcl/lstbox.hxx>
+#include <functional>
+
class BorderColorStatus;
class SvxColorWindow_Impl : public SfxPopupWindow
@@ -50,6 +52,8 @@ private:
PaletteManager& mrPaletteManager;
BorderColorStatus& mrBorderColorStatus;
+ std::function<void(const OUString&, const Color&)> maColorSelectFunction;
+
DECL_LINK( SelectHdl, SvxColorValueSet* );
DECL_LINK( SelectPaletteHdl, void *);
DECL_LINK( AutoColorClickHdl, void * );
@@ -66,7 +70,8 @@ public:
sal_uInt16 nSlotId,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
const OUString& rWndTitle,
- vcl::Window* pParentWindow);
+ vcl::Window* pParentWindow,
+ std::function<void(const OUString&, const Color&)> maColorSelectFunction);
virtual ~SvxColorWindow_Impl();
virtual void dispose() SAL_OVERRIDE;
void StartSelection();
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index bc0912ff1c12..528b4eac14ef 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1215,7 +1215,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
sal_uInt16 nSlotId,
const Reference< XFrame >& rFrame,
const OUString& rWndTitle,
- vcl::Window* pParentWindow ):
+ vcl::Window* pParentWindow,
+ std::function<void(const OUString&, const Color&)> aFunction):
SfxPopupWindow( nSlotId, pParentWindow,
"palette_popup_window", "svx/ui/colorwindow.ui",
@@ -1223,7 +1224,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
theSlotId( nSlotId ),
maCommand( rCommand ),
mrPaletteManager( rPaletteManager ),
- mrBorderColorStatus( rBorderColorStatus )
+ mrBorderColorStatus( rBorderColorStatus ),
+ maColorSelectFunction(aFunction)
{
get(mpPaletteListBox, "palette_listbox");
get(mpButtonAutoColor, "auto_color_button");
@@ -1365,7 +1367,7 @@ IMPL_LINK(SvxColorWindow_Impl, SelectHdl, SvxColorValueSet*, pColorSet)
if ( maSelectedLink.IsSet() )
maSelectedLink.Call(&aColor);
- PaletteManager::DispatchColorCommand(maCommand, aColor);
+ maColorSelectFunction(maCommand, aColor);
return 0;
}
@@ -1407,7 +1409,7 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, AutoColorClickHdl)
if ( maSelectedLink.IsSet() )
maSelectedLink.Call(&aColor);
- PaletteManager::DispatchColorCommand(maCommand, aColor);
+ maColorSelectFunction(maCommand, aColor);
return 0;
}
@@ -2537,8 +2539,9 @@ VclPtr<vcl::Window> SvxFontNameToolBoxControl::CreateItemWindow( vcl::Window *pP
SvxColorToolBoxControl::SvxColorToolBoxControl(
sal_uInt16 nSlotId,
sal_uInt16 nId,
- ToolBox& rTbx ) :
- SfxToolBoxControl( nSlotId, nId, rTbx )
+ ToolBox& rTbx ):
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ maColorSelectFunction(PaletteManager::DispatchColorCommand)
{
if ( dynamic_cast< sfx2::sidebar::SidebarToolBox* >(&rTbx) )
bSidebarType = true;
@@ -2611,6 +2614,12 @@ SvxColorToolBoxControl::~SvxColorToolBoxControl()
{
}
+void SvxColorToolBoxControl::setColorSelectFunction(ColorSelectFunction aColorSelectFunction)
+{
+ maColorSelectFunction = aColorSelectFunction;
+ mPaletteManager.SetColorSelectFunction(aColorSelectFunction);
+}
+
VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow()
{
SvxColorWindow_Impl* pColorWin =
@@ -2622,7 +2631,8 @@ VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow()
GetSlotId(),
m_xFrame,
SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
- &GetToolBox() );
+ &GetToolBox(),
+ maColorSelectFunction);
switch( GetSlotId() )
{