[Libreoffice-commits] core.git: Branch 'feature/chart-style-experiment-markus' - 7 commits - chart2/inc chart2/source chart2/uiconfig offapi/com
Gagandeep Singh (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 26 18:42:54 UTC 2019
chart2/inc/ChartModel.hxx | 1
chart2/source/controller/sidebar/Chart2PanelFactory.cxx | 2
chart2/source/controller/sidebar/ChartAreaPanel.cxx | 4
chart2/source/controller/sidebar/ChartElementsPanel.cxx | 15 -
chart2/source/controller/sidebar/ChartElementsPanel.hxx | 2
chart2/source/controller/sidebar/ChartStylesPanel.cxx | 226 +++++++++++++---
chart2/source/controller/sidebar/ChartStylesPanel.hxx | 45 ++-
chart2/source/inc/ChartStyle.hxx | 21 +
chart2/source/inc/OPropertySet.hxx | 10
chart2/source/model/main/ChartModel.cxx | 10
chart2/source/model/main/ChartModel_Persistence.cxx | 6
chart2/source/model/main/PageBackground.cxx | 4
chart2/source/model/main/Title.cxx | 4
chart2/source/model/main/Wall.cxx | 3
chart2/source/tools/ChartStyle.cxx | 165 +++++++++++
chart2/source/tools/ImplOPropertySet.cxx | 5
chart2/source/tools/ImplOPropertySet.hxx | 2
chart2/source/tools/OPropertySet.cxx | 29 ++
chart2/uiconfig/ui/sidebarelements.ui | 39 --
chart2/uiconfig/ui/sidebarstyle.ui | 113 ++------
offapi/com/sun/star/chart2/XChartStyle.idl | 9
offapi/com/sun/star/chart2/XChartStyled.idl | 1
22 files changed, 517 insertions(+), 199 deletions(-)
New commits:
commit 890506b378b1d1866af4cf149457ca9fe691fff5
Author: Gagandeep Singh <deepgagan231197 at gmail.com>
AuthorDate: Tue Aug 27 02:28:41 2019 +0800
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Tue Aug 27 02:28:41 2019 +0800
move default values from hard formatting to style
Change-Id: I240e58573d7cf24c2f2f36193a47dfce4bd92a11
diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx
index 8af5148a268b..c44840ea4974 100644
--- a/chart2/source/model/main/PageBackground.cxx
+++ b/chart2/source/model/main/PageBackground.cxx
@@ -57,10 +57,6 @@ static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
{
::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
::chart::FillProperties::AddDefaultsToMap( rOutMap );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
}
} // anonymous namespace
diff --git a/chart2/source/model/main/Title.cxx b/chart2/source/model/main/Title.cxx
index 4cd876f0c2b0..8e7f20906d11 100644
--- a/chart2/source/model/main/Title.cxx
+++ b/chart2/source/model/main/Title.cxx
@@ -173,10 +173,6 @@ static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
// own properties
::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_TITLE_TEXT_ROTATION, 0.0 );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_TEXT_STACKED, false );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
}
} // anonymous namespace
diff --git a/chart2/source/model/main/Wall.cxx b/chart2/source/model/main/Wall.cxx
index 537709a7255f..ba9852b2b21d 100644
--- a/chart2/source/model/main/Wall.cxx
+++ b/chart2/source/model/main/Wall.cxx
@@ -53,9 +53,6 @@ static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
{
::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
::chart::FillProperties::AddDefaultsToMap( rOutMap );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
}
} // anonymous namespace
diff --git a/chart2/source/tools/ChartStyle.cxx b/chart2/source/tools/ChartStyle.cxx
index 3130bd99f45d..e8e4d8052c0b 100644
--- a/chart2/source/tools/ChartStyle.cxx
+++ b/chart2/source/tools/ChartStyle.cxx
@@ -168,6 +168,12 @@ void ChartStyle::register_styles()
*chart::title::StaticTitleInfo::get(), *chart::title::StaticTitleInfoHelper::get(),
*chart::title::StaticTitleDefaults::get());
+ css::uno::Reference<css::beans::XPropertySet> xTitleStyle
+ = m_xChartStyle[css::chart2::ChartObjectType::TITLE];
+
+ xTitleStyle->setPropertyValue("LineStyle", css::uno::Any(css::drawing::LineStyle_NONE));
+ xTitleStyle->setPropertyValue("FillStyle", css::uno::Any(css::drawing::FillStyle_NONE));
+
m_xChartStyle[css::chart2::ChartObjectType::WALL] = new ChartObjectStyle(
*chart::wall::StaticWallInfo::get(), *chart::wall::StaticWallInfoHelper::get(),
*chart::wall::StaticWallDefaults::get());
@@ -186,11 +192,25 @@ void ChartStyle::register_styles()
*chart::grid::StaticGridInfo::get(), *chart::grid::StaticGridInfoHelper::get(),
*chart::grid::StaticGridDefaults::get());
+ css::uno::Reference<css::beans::XPropertySet> xGridStyle
+ = m_xChartStyle[css::chart2::ChartObjectType::GRID];
+
+ xGridStyle->setPropertyValue("LineStyle", css::uno::Any(css::drawing::LineStyle_SOLID));
+ xGridStyle->setPropertyValue("LineColor",
+ css::uno::Any(static_cast<sal_Int32>(0xb3b3b3))); // gray30
+
m_xChartStyle[css::chart2::ChartObjectType::PAGE]
= new ChartObjectStyle(*chart::page::StaticPageBackgroundInfo::get(),
*chart::page::StaticPageBackgroundInfoHelper::get(),
*chart::page::StaticPageBackgroundDefaults::get());
+ css::uno::Reference<css::beans::XPropertySet> xPageStyle
+ = m_xChartStyle[css::chart2::ChartObjectType::PAGE];
+
+ xPageStyle->setPropertyValue("LineStyle", css::uno::Any(css::drawing::LineStyle_NONE));
+ xPageStyle->setPropertyValue("FillStyle", css::uno::Any(css::drawing::FillStyle_SOLID));
+ xPageStyle->setPropertyValue("FillColor", css::uno::Any(static_cast<sal_Int32>(0xffffff)));
+
m_xChartStyle[css::chart2::ChartObjectType::DIAGRAM] = new ChartObjectStyle(
*chart::diagram::StaticDiagramInfo::get(), *chart::diagram::StaticDiagramInfoHelper::get(),
*chart::diagram::StaticDiagramDefaults::get());
commit 791e230359754a63d7922df466cfbb9dc5740142
Author: Gagandeep Singh <deepgagan231197 at gmail.com>
AuthorDate: Tue Aug 27 02:14:23 2019 +0800
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Tue Aug 27 02:22:16 2019 +0800
implement the sidebar model update interface for chart styles panel
Change-Id: Id6e46b405ecd8c46648968c8dc91f960e44259e7
diff --git a/chart2/source/controller/sidebar/ChartStylesPanel.cxx b/chart2/source/controller/sidebar/ChartStylesPanel.cxx
index 2f6452fdf10c..072cd0b1d332 100644
--- a/chart2/source/controller/sidebar/ChartStylesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartStylesPanel.cxx
@@ -110,6 +110,9 @@ ChartStylesPanel::ChartStylesPanel(vcl::Window* pParent,
, m_xModel(css::uno::Reference<css::chart2::XChartDocument>(pController->getModel(),
css::uno::UNO_QUERY))
, m_xChartStyles(::chart::getChartStyles())
+ , m_xListener(new ChartSidebarModifyListener(this))
+ , mbUpdate(true)
+ , mbModelValid(true)
{
get(maStyleList, "lb_styles");
get(maCreateStyleLabel, "label_create_from_chart");
@@ -167,6 +170,33 @@ void ChartStylesPanel::Initialize()
UpdateList();
}
+void ChartStylesPanel::updateData()
+{
+ if (!mbUpdate || !mbModelValid)
+ return;
+
+ return;
+}
+
+void ChartStylesPanel::modelInvalid() { mbModelValid = false; }
+
+void ChartStylesPanel::updateModel(css::uno::Reference<css::frame::XModel> xModel)
+{
+ if (mbModelValid)
+ {
+ css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(m_xModel,
+ css::uno::UNO_QUERY_THROW);
+ xBroadcaster->removeModifyListener(m_xListener);
+ }
+
+ m_xModel = css::uno::Reference<css::chart2::XChartDocument>(xModel, css::uno::UNO_QUERY);
+ mbModelValid = true;
+
+ css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(m_xModel,
+ css::uno::UNO_QUERY_THROW);
+ xBroadcasterNew->addModifyListener(m_xListener);
+}
+
IMPL_LINK(ChartStylesPanel, SelHdl, ListBox&, rBox, void)
{
OUString aSelectedEntry = rBox.GetSelectedEntry();
@@ -175,7 +205,8 @@ IMPL_LINK(ChartStylesPanel, SelHdl, ListBox&, rBox, void)
{
OUString aNewStyleName;
vcl::Window* pWin = Application::GetDefDialogParent();
- QueryString aQuery(pWin ? pWin->GetFrameWeld() : nullptr, "Select name for new chart style:", aNewStyleName);
+ QueryString aQuery(pWin ? pWin->GetFrameWeld() : nullptr,
+ "Select name for new chart style:", aNewStyleName);
int nReturnCode = aQuery.run();
if (nReturnCode == RET_OK)
diff --git a/chart2/source/controller/sidebar/ChartStylesPanel.hxx b/chart2/source/controller/sidebar/ChartStylesPanel.hxx
index 8ad1302e874f..81ff6f7bb57a 100644
--- a/chart2/source/controller/sidebar/ChartStylesPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartStylesPanel.hxx
@@ -13,6 +13,9 @@
#include <sfx2/sidebar/SidebarPanelBase.hxx>
#include <sfx2/sidebar/ControllerItem.hxx>
#include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
+#include "ChartSidebarModifyListener.hxx"
+
#include <vcl/EnumContext.hxx>
#include <svtools/ctrlbox.hxx>
#include <editeng/fhgtitem.hxx>
@@ -59,12 +62,19 @@ class ChartController;
namespace sidebar
{
-class ChartStylesPanel : public PanelLayout
+class ChartStylesPanel : public PanelLayout,
+ public sfx2::sidebar::SidebarModelUpdate,
+ public ChartSidebarModifyListenerParent
{
private:
css::uno::Reference<css::chart2::XChartDocument> m_xModel;
css::uno::Reference<css::container::XNameContainer> m_xChartStyles;
+ css::uno::Reference<css::util::XModifyListener> m_xListener;
+
+ bool mbUpdate;
+ bool mbModelValid;
+
VclPtr<ListBox> maStyleList;
VclPtr<FixedText> maCreateStyleLabel;
@@ -86,6 +96,11 @@ public:
virtual ~ChartStylesPanel() override;
virtual void dispose() override;
+
+ virtual void updateData() override;
+ virtual void modelInvalid() override;
+
+ virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) override;
};
} // namespace sidebar
commit 669c245cbf56a9268a8b310053f0491eb9cb22bf
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Sat Aug 24 00:20:17 2019 +0800
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Tue Aug 27 02:22:15 2019 +0800
set the Name for properties in XPropertyAcess' methods
Change-Id: Ia5e0b10be09b852855452304df482a523830e5f7
diff --git a/chart2/source/tools/OPropertySet.cxx b/chart2/source/tools/OPropertySet.cxx
index 6efa7f42c08a..fe4c69700fad 100644
--- a/chart2/source/tools/OPropertySet.cxx
+++ b/chart2/source/tools/OPropertySet.cxx
@@ -374,12 +374,16 @@ css::uno::Sequence< css::beans::PropertyValue > SAL_CALL OPropertySet::getProper
{
auto& rPropertyMap = m_pImplProperties->exportPropertyMap();
Sequence< css::beans::PropertyValue > aPropertySeq( rPropertyMap.size() );
+ cppu::IPropertyArrayHelper & rPH = getInfoHelper();
sal_Int32 nIdx = 0;
for (auto Itr = rPropertyMap.begin(); Itr != rPropertyMap.end(); Itr++, nIdx++ )
{
aPropertySeq[ nIdx ].Handle = Itr->first;
aPropertySeq[ nIdx ].Value = Itr->second;
+ OUString aName;
+ rPH.fillPropertyMembersByHandle( &aName, nullptr, Itr->first );
+ aPropertySeq[ nIdx ].Name = aName;
}
return aPropertySeq;
}
commit 3e0680080fa075f3444dc2b058d5d590ea28afd6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Sat Aug 24 00:17:39 2019 +0800
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Tue Aug 27 02:22:15 2019 +0800
make sure we are setting the correct type
Change-Id: I0daeaa5caf2ddee243020d46e7fbb9fd6b04c488
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 843c4e720e0d..360a66af34e3 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -352,7 +352,9 @@ void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem,
if (pStyleItem)
xPropSet->setPropertyValue("FillStyle", css::uno::Any(pStyleItem->GetValue()));
- xPropSet->setPropertyValue("FillColor", css::uno::Any(rColorItem.GetValue()));
+
+ sal_Int32 nColor = rColorItem.GetColorValue().mValue;
+ xPropSet->setPropertyValue("FillColor", css::uno::Any(nColor));
}
void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
commit 3678ed62f61c79d28ac549690ef6d41a6b817cc0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Wed Aug 21 01:57:38 2019 +0800
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Tue Aug 27 02:22:01 2019 +0800
update chart styles sidebar
Change-Id: I83edde38c4c76624916ee023f43242a22d8f27b9
diff --git a/chart2/source/controller/sidebar/ChartStylesPanel.cxx b/chart2/source/controller/sidebar/ChartStylesPanel.cxx
index 07d3fbea8514..2f6452fdf10c 100644
--- a/chart2/source/controller/sidebar/ChartStylesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartStylesPanel.cxx
@@ -175,7 +175,7 @@ IMPL_LINK(ChartStylesPanel, SelHdl, ListBox&, rBox, void)
{
OUString aNewStyleName;
vcl::Window* pWin = Application::GetDefDialogParent();
- QueryString aQuery(pWin ? pWin->GetFrameWeld() : nullptr, "", aNewStyleName);
+ QueryString aQuery(pWin ? pWin->GetFrameWeld() : nullptr, "Select name for new chart style:", aNewStyleName);
int nReturnCode = aQuery.run();
if (nReturnCode == RET_OK)
diff --git a/chart2/source/inc/ChartStyle.hxx b/chart2/source/inc/ChartStyle.hxx
index 047e12d241f4..fbe60d266087 100644
--- a/chart2/source/inc/ChartStyle.hxx
+++ b/chart2/source/inc/ChartStyle.hxx
@@ -107,7 +107,7 @@ public:
SAL_CALL getStyleForObject(const sal_Int16 nChartObjectType) override;
virtual void SAL_CALL
- applyStyleToDiagram(const css::uno::Reference<css::chart2::XDiagram>& xDiagram) override;
+ applyStyleToDiagram(const css::uno::Reference<css::chart2::XChartDocument>& xChartDocument) override;
virtual void SAL_CALL
applyStyleToTitle(const css::uno::Reference<css::chart2::XTitle>& xTitle) override;
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 37e3b0c4165e..982c0aa80d11 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -689,7 +689,7 @@ void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagra
ModifyListenerHelper::addListener( xDiagram, xListener );
setModified( true );
- m_xChartStyle->applyStyleToDiagram(xDiagram);
+ m_xChartStyle->applyStyleToDiagram(this);
}
Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData()
@@ -951,7 +951,7 @@ void SAL_CALL ChartModel::setChartStyle(const css::uno::Reference<css::chart2::X
MutexGuard aGuard( m_aModelMutex );
m_xChartStyle = xChartStyle;
- m_xChartStyle->applyStyleToDiagram(m_xDiagram);
+ m_xChartStyle->applyStyleToDiagram(this);
}
// ____ XInterface (for old API wrapper) ____
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 1bfc4c310e84..8a41cb048d5e 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -724,9 +724,8 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
{
if (m_xChartStyle.is())
{
- m_xChartStyle->applyStyleToTitle(getTitleObject());
m_xChartStyle->applyStyleToBackground(getPageBackground());
- m_xChartStyle->applyStyleToDiagram(xDiagram);
+ m_xChartStyle->applyStyleToDiagram(this);
}
}
diff --git a/chart2/source/tools/ChartStyle.cxx b/chart2/source/tools/ChartStyle.cxx
index dec56c485446..3130bd99f45d 100644
--- a/chart2/source/tools/ChartStyle.cxx
+++ b/chart2/source/tools/ChartStyle.cxx
@@ -266,9 +266,10 @@ void ChartStyle::applyStyleToCoordinates(
}
}
-void SAL_CALL
-ChartStyle::applyStyleToDiagram(const css::uno::Reference<css::chart2::XDiagram>& xDiagram)
+void SAL_CALL ChartStyle::applyStyleToDiagram(
+ const css::uno::Reference<css::chart2::XChartDocument>& xChartDocument)
{
+ css::uno::Reference<css::chart2::XDiagram> xDiagram = xChartDocument->getFirstDiagram();
css::uno::Reference<css::style::XStyleSupplier> xLegendStyle(xDiagram->getLegend(),
css::uno::UNO_QUERY);
if (xLegendStyle.is())
@@ -287,7 +288,7 @@ ChartStyle::applyStyleToDiagram(const css::uno::Reference<css::chart2::XDiagram>
css::uno::UNO_QUERY_THROW));
}
- css::uno::Reference<css::chart2::XTitled> xTitled(xDiagram, css::uno::UNO_QUERY);
+ css::uno::Reference<css::chart2::XTitled> xTitled(xChartDocument, css::uno::UNO_QUERY);
if (xTitled.is())
{
css::uno::Reference<css::chart2::XTitle> xTitle = xTitled->getTitleObject();
diff --git a/offapi/com/sun/star/chart2/XChartStyle.idl b/offapi/com/sun/star/chart2/XChartStyle.idl
index 81937f48da2e..3a80cb978fad 100644
--- a/offapi/com/sun/star/chart2/XChartStyle.idl
+++ b/offapi/com/sun/star/chart2/XChartStyle.idl
@@ -26,7 +26,7 @@ interface XChartStyle : ::com::sun::star::uno::XInterface
{
com::sun::star::beans::XPropertySet getStyleForObject([in] short chartObjectType);
- void applyStyleToDiagram([in] XDiagram chartDiagram);
+ void applyStyleToDiagram([in] XChartDocument chartDiagram);
void applyStyleToTitle([in] XTitle chartTitle);
commit 862988200a9844573586029430ebccd9d4ea804c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Wed Aug 21 00:35:58 2019 +0800
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Wed Aug 21 00:35:58 2019 +0800
small changes to the chart styles sidebar
Change-Id: I76ccf9d4ea3663f89787db22476004a37dd6e1e3
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index 30fb4082cc60..080caea479cd 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -390,6 +390,7 @@ public:
// _____ XChartStyled _____
virtual css::uno::Reference< css::chart2::XChartStyle > SAL_CALL getChartStyle() override;
+ virtual void SAL_CALL setChartStyle(const css::uno::Reference<css::chart2::XChartStyle>& xChartStyle ) override;
// ____ XInterface (for old API wrapper) ____
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
diff --git a/chart2/source/controller/sidebar/ChartStylesPanel.cxx b/chart2/source/controller/sidebar/ChartStylesPanel.cxx
index b58001831d0a..07d3fbea8514 100644
--- a/chart2/source/controller/sidebar/ChartStylesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartStylesPanel.cxx
@@ -10,40 +10,88 @@
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <vcl/lstbox.hxx>
#include <vcl/button.hxx>
+#include <vcl/svapp.hxx>
#include <iostream>
#include "ChartStylesPanel.hxx"
#include <ChartStyle.hxx>
#include <ChartModel.hxx>
#include <CloneHelper.hxx>
#include <com/sun/star/chart2/ChartObjectType.hpp>
+#include <com/sun/star/chart2/XChartStyled.hpp>
using namespace css;
using namespace css::uno;
+namespace
+{
+class QueryString : public weld::GenericDialogController
+{
+private:
+ OUString& m_rReturnValue;
+
+ std::unique_ptr<weld::Button> m_xOKButton;
+ std::unique_ptr<weld::Label> m_xFixedText;
+ std::unique_ptr<weld::Entry> m_xEdit;
+
+ DECL_LINK(ClickBtnHdl, weld::Button&, void);
+
+public:
+ // parent window, Query text, initial value
+ QueryString(weld::Window*, OUString const&, OUString&);
+};
+
+/*
+ * QueryString
+ */
+QueryString::QueryString(weld::Window* pParent, OUString const& rQuery, OUString& rRet)
+ : GenericDialogController(pParent, "vcl/ui/querydialog.ui", "QueryDialog")
+ , m_rReturnValue(rRet)
+ , m_xOKButton(m_xBuilder->weld_button("ok"))
+ , m_xFixedText(m_xBuilder->weld_label("label"))
+ , m_xEdit(m_xBuilder->weld_entry("entry"))
+{
+ m_xOKButton->connect_clicked(LINK(this, QueryString, ClickBtnHdl));
+ m_xFixedText->set_label(rQuery);
+ m_xEdit->set_text(m_rReturnValue);
+ m_xDialog->set_title(rQuery);
+}
+
+IMPL_LINK(QueryString, ClickBtnHdl, weld::Button&, rButton, void)
+{
+ if (&rButton == m_xOKButton.get())
+ {
+ m_rReturnValue = m_xEdit->get_text();
+ m_xDialog->response(RET_OK);
+ }
+ else
+ m_xDialog->response(RET_CANCEL);
+}
+}
+
namespace chart
{
namespace sidebar
{
-
namespace
{
-
ChartModel* getChartModel(const css::uno::Reference<css::frame::XModel>& xModel)
{
ChartModel* pModel = dynamic_cast<ChartModel*>(xModel.get());
return pModel;
}
-css::uno::Reference<css::chart2::XChartStyle> getCurrentStyle(const css::uno::Reference<css::frame::XModel>& xModel)
+css::uno::Reference<css::chart2::XChartStyle>
+getCurrentStyle(const css::uno::Reference<css::frame::XModel>& xModel)
{
return getChartModel(xModel)->getChartStyle();
}
} // namespace anonymous
-VclPtr<vcl::Window> ChartStylesPanel::Create(vcl::Window* pParent,
- const css::uno::Reference<css::frame::XFrame>& rxFrame,
- const css::uno::Reference<css::frame::XController>& pController)
+VclPtr<vcl::Window>
+ChartStylesPanel::Create(vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ const css::uno::Reference<css::frame::XController>& pController)
{
if (pParent == nullptr)
throw lang::IllegalArgumentException("no parent Window given to ChartStylesPanel::Create",
@@ -59,24 +107,14 @@ ChartStylesPanel::ChartStylesPanel(vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
const css::uno::Reference<css::frame::XController>& pController)
: PanelLayout(pParent, "ChartStylesPanel", "modules/schart/ui/sidebarstyle.ui", rxFrame)
- , m_xModel( pController->getModel() )
- , m_xChartStyles( ::chart::getChartStyles() )
+ , m_xModel(css::uno::Reference<css::chart2::XChartDocument>(pController->getModel(),
+ css::uno::UNO_QUERY))
+ , m_xChartStyles(::chart::getChartStyles())
{
- get(aStyleList, "stylelist");
- get(aApplyButton, "setstyle");
- get(aNewButton, "createstyle");
- get(aDefaultButton, "setdefault");
- get(aDeleteButton, "deletestyle");
+ get(maStyleList, "lb_styles");
+ get(maCreateStyleLabel, "label_create_from_chart");
- Link<ListBox&, void> aLink = LINK(this, ChartStylesPanel, SelHdl);
- Link<Button*, void> aLink2 = LINK(this, ChartStylesPanel, SetSelectionClickHdl);
-
- aStyleList->SetSelectHdl(aLink);
- aStyleList->SetDoubleClickHdl(LINK(this, ChartStylesPanel, SetSelectionHdl));
- aApplyButton->SetClickHdl(aLink2);
- aNewButton->SetClickHdl(aLink2);
- aDefaultButton->SetClickHdl(aLink2);
- aDeleteButton->SetClickHdl(aLink2);
+ maStyleList->SetSelectHdl(LINK(this, ChartStylesPanel, SelHdl));
Initialize();
}
@@ -85,11 +123,9 @@ ChartStylesPanel::~ChartStylesPanel() { disposeOnce(); }
void ChartStylesPanel::dispose()
{
- aStyleList.clear();
- aDefaultButton.clear();
- aApplyButton.clear();
- aNewButton.clear();
- aDeleteButton.clear();
+ maStyleList.clear();
+ maCreateStyleLabel.clear();
+
PanelLayout::dispose();
}
@@ -97,8 +133,9 @@ void ChartStylesPanel::createNewStyle(const OUString& sName)
{
css::uno::Reference<css::chart2::XChartStyle> xCurrentStyle = getCurrentStyle(m_xModel);
- css::uno::Reference<css::chart2::XChartStyle> xNewStyle = CloneHelper::CreateRefClone<css::chart2::XChartStyle>()(xCurrentStyle);
- xNewStyle->updateChartStyle(css::uno::Reference<css::chart2::XChartDocument>(m_xModel, css::uno::UNO_QUERY));
+ css::uno::Reference<css::chart2::XChartStyle> xNewStyle
+ = CloneHelper::CreateRefClone<css::chart2::XChartStyle>()(xCurrentStyle);
+ xNewStyle->updateChartStyle(m_xModel);
css::uno::Reference<css::style::XStyle> xStyle(xNewStyle, css::uno::UNO_QUERY);
xStyle->setName(sName);
m_xChartStyles->insertByName(sName, css::uno::Any(xNewStyle));
@@ -106,38 +143,62 @@ void ChartStylesPanel::createNewStyle(const OUString& sName)
UpdateList();
}
-void ChartStylesPanel::updateDefaultStyle(const OUString& sName)
-{
- m_xChartStyles->replaceByName("Default", css::uno::Any(m_xChartStyles->getByName(sName)));
-}
-
void ChartStylesPanel::UpdateList()
{
- aStyleList->Clear();
+ maStyleList->Clear();
css::uno::Sequence<OUString> aStyleNames = m_xChartStyles->getElementNames();
- for ( auto& rStyle : aStyleNames )
+ for (auto& rStyle : aStyleNames)
{
- if (rStyle != "Default")
- aStyleList->InsertEntry( rStyle );
+ maStyleList->InsertEntry(rStyle);
}
- OUString aCurrentChartStyleName = css::uno::Reference<css::style::XStyle>(getCurrentStyle(m_xModel),
- css::uno::UNO_QUERY_THROW)->getName();
- aStyleList->SelectEntry(aCurrentChartStyleName);
+ maStyleList->InsertEntry(maCreateStyleLabel->GetText());
+
+ OUString aCurrentChartStyleName = css::uno::Reference<css::style::XStyle>(
+ getCurrentStyle(m_xModel), css::uno::UNO_QUERY_THROW)
+ ->getName();
+ maStyleList->SelectEntry(aCurrentChartStyleName);
}
void ChartStylesPanel::Initialize()
{
+ maStyleList->Enable();
+ maStyleList->Show();
UpdateList();
}
-IMPL_LINK_NOARG(ChartStylesPanel, SelHdl, ListBox&, void) {}
-
-IMPL_LINK(ChartStylesPanel, SetSelectionClickHdl, Button*, pButton, void)
+IMPL_LINK(ChartStylesPanel, SelHdl, ListBox&, rBox, void)
{
-}
+ OUString aSelectedEntry = rBox.GetSelectedEntry();
+
+ if (aSelectedEntry == maCreateStyleLabel->GetText())
+ {
+ OUString aNewStyleName;
+ vcl::Window* pWin = Application::GetDefDialogParent();
+ QueryString aQuery(pWin ? pWin->GetFrameWeld() : nullptr, "", aNewStyleName);
+
+ int nReturnCode = aQuery.run();
+ if (nReturnCode == RET_OK)
+ {
+ if (aNewStyleName.isEmpty())
+ UpdateList();
+ else
+ createNewStyle(aNewStyleName);
+ }
+ else
+ UpdateList();
+ }
+ else
+ {
+ css::uno::Any aAny = m_xChartStyles->getByName(aSelectedEntry);
+ css::uno::Reference<css::chart2::XChartStyle> xChartStyle;
+ aAny >>= xChartStyle;
-IMPL_LINK_NOARG(ChartStylesPanel, SetSelectionHdl, ListBox&, void) {}
+ css::uno::Reference<css::chart2::XChartStyled> xChartModelStyled(m_xModel,
+ css::uno::UNO_QUERY);
+ xChartModelStyled->setChartStyle(xChartStyle);
+ }
+}
} // namespace sidebar
} // namespace chart
diff --git a/chart2/source/controller/sidebar/ChartStylesPanel.hxx b/chart2/source/controller/sidebar/ChartStylesPanel.hxx
index bd28eddb1965..8ad1302e874f 100644
--- a/chart2/source/controller/sidebar/ChartStylesPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartStylesPanel.hxx
@@ -22,6 +22,7 @@
#include <com/sun/star/chart2/XChartStyle.hpp>
#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
#include <vcl/button.hxx>
#include <svx/sidebar/PanelLayout.hxx>
@@ -61,34 +62,27 @@ namespace sidebar
class ChartStylesPanel : public PanelLayout
{
private:
- css::uno::Reference<css::frame::XModel> m_xModel;
+ css::uno::Reference<css::chart2::XChartDocument> m_xModel;
css::uno::Reference<css::container::XNameContainer> m_xChartStyles;
- VclPtr<ListBox> aStyleList;
- VclPtr<PushButton> aApplyButton;
- VclPtr<PushButton> aNewButton;
- VclPtr<PushButton> aDefaultButton;
- VclPtr<PushButton> aDeleteButton;
+ VclPtr<ListBox> maStyleList;
+ VclPtr<FixedText> maCreateStyleLabel;
- DECL_LINK(SetSelectionHdl, ListBox&, void);
- DECL_LINK(SetSelectionClickHdl, Button*, void);
DECL_LINK(SelHdl, ListBox&, void);
void UpdateList();
void Initialize();
- css::uno::Reference<css::chart2::XChartStyle> updateStyleFromChart(css::uno::Reference<css::chart2::XChartStyle>& xChartStyle);
- void createNewStyle(const OUString& sName);
- void updateDefaultStyle(const OUString& sName);
+ void createNewStyle(const OUString& rName);
public:
- static VclPtr<vcl::Window> Create(vcl::Window* pParent,
- const css::uno::Reference<css::frame::XFrame>& rxFrame,
- const css::uno::Reference<css::frame::XController>& rxController);
+ static VclPtr<vcl::Window>
+ Create(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ const css::uno::Reference<css::frame::XController>& rxController);
// constructor/destructor
ChartStylesPanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame,
- const css::uno::Reference<css::frame::XController>& pController);
+ const css::uno::Reference<css::frame::XController>& pController);
virtual ~ChartStylesPanel() override;
virtual void dispose() override;
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 4cda0d5882fc..37e3b0c4165e 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -946,6 +946,14 @@ uno::Reference< chart2::XChartStyle > SAL_CALL ChartModel::getChartStyle()
return m_xChartStyle;
}
+void SAL_CALL ChartModel::setChartStyle(const css::uno::Reference<css::chart2::XChartStyle>& xChartStyle)
+{
+ MutexGuard aGuard( m_aModelMutex );
+
+ m_xChartStyle = xChartStyle;
+ m_xChartStyle->applyStyleToDiagram(m_xDiagram);
+}
+
// ____ XInterface (for old API wrapper) ____
uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType )
{
diff --git a/chart2/source/tools/ChartStyle.cxx b/chart2/source/tools/ChartStyle.cxx
index 50bdde655d1c..dec56c485446 100644
--- a/chart2/source/tools/ChartStyle.cxx
+++ b/chart2/source/tools/ChartStyle.cxx
@@ -64,12 +64,13 @@ ChartObjectStyle::ChartObjectStyle(css::uno::Reference<css::beans::XPropertySetI
{
}
-ChartObjectStyle::ChartObjectStyle( const ChartObjectStyle & rOther )
+ChartObjectStyle::ChartObjectStyle(const ChartObjectStyle& rOther)
: OPropertySet(rOther.m_aMutex)
, mrArrayHelper(rOther.mrArrayHelper)
, mrPropertyMap(rOther.mrPropertyMap)
, mxPropSetInfo(rOther.mxPropSetInfo)
-{}
+{
+}
ChartObjectStyle::~ChartObjectStyle() {}
@@ -104,7 +105,7 @@ css::uno::Any ChartObjectStyle::GetDefaultValue(sal_Int32 nHandle) const
// _____ XCloneable _____
css::uno::Reference<css::util::XCloneable> SAL_CALL ChartObjectStyle::createClone()
{
- return css::uno::Reference<css::util::XCloneable>(new ChartObjectStyle( *this ));
+ return css::uno::Reference<css::util::XCloneable>(new ChartObjectStyle(*this));
}
ChartStyle::ChartStyle()
@@ -113,15 +114,16 @@ ChartStyle::ChartStyle()
register_styles();
}
-ChartStyle::ChartStyle( const ChartStyle & rOther )
+ChartStyle::ChartStyle(const ChartStyle& rOther)
: m_nNumObjects(rOther.m_nNumObjects)
{
- for ( sal_Int16 nIdx = 0; nIdx < m_nNumObjects; nIdx++ )
+ for (sal_Int16 nIdx = 0; nIdx < m_nNumObjects; nIdx++)
{
- auto It = rOther.m_xChartStyle.find( nIdx );
+ auto It = rOther.m_xChartStyle.find(nIdx);
if (It != rOther.m_xChartStyle.end())
- m_xChartStyle[ nIdx ] = CloneHelper::CreateRefClone<css::beans::XPropertySet>()( It->second );
+ m_xChartStyle[nIdx]
+ = CloneHelper::CreateRefClone<css::beans::XPropertySet>()(It->second);
}
}
@@ -313,14 +315,15 @@ ChartStyle::applyStyleToBackground(const css::uno::Reference<css::beans::XProper
}
void SAL_CALL
-ChartStyle::updateStyleElement(const sal_Int16 nChartObjectType, const css::uno::Sequence<css::beans::PropertyValue>& rProperties)
+ChartStyle::updateStyleElement(const sal_Int16 nChartObjectType,
+ const css::uno::Sequence<css::beans::PropertyValue>& rProperties)
{
- css::uno::Reference<css::beans::XPropertyAccess>
- xPropertyAccess(getStyleForObject(nChartObjectType), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::beans::XPropertyAccess> xPropertyAccess(
+ getStyleForObject(nChartObjectType), css::uno::UNO_QUERY_THROW);
if (xPropertyAccess.is())
{
- xPropertyAccess->setPropertyValues( rProperties );
+ xPropertyAccess->setPropertyValues(rProperties);
}
}
@@ -336,38 +339,46 @@ ChartStyle::updateChartStyle(const css::uno::Reference<css::chart2::XChartDocume
css::uno::Reference<css::chart2::XTitle> xMainTitle = xMainTitled->getTitleObject();
if (xMainTitle.is())
{
- xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(xMainTitle, css::uno::UNO_QUERY);
+ xPropAccess
+ = css::uno::Reference<css::beans::XPropertyAccess>(xMainTitle, css::uno::UNO_QUERY);
updateStyleElement(css::chart2::ChartObjectType::TITLE, xPropAccess->getPropertyValues());
}
- xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(rxModel->getPageBackground(), css::uno::UNO_QUERY);
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(rxModel->getPageBackground(),
+ css::uno::UNO_QUERY);
if (xPropAccess.is())
updateStyleElement(css::chart2::ChartObjectType::PAGE, xPropAccess->getPropertyValues());
- xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(rxModel->getFirstDiagram(), css::uno::UNO_QUERY);
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(rxModel->getFirstDiagram(),
+ css::uno::UNO_QUERY);
if (xPropAccess.is())
updateStyleElement(css::chart2::ChartObjectType::DIAGRAM, xPropAccess->getPropertyValues());
css::uno::Reference<css::chart2::XDiagram> xDiagram = rxModel->getFirstDiagram();
- xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xDiagram->getWall(), css::uno::UNO_QUERY);
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(xDiagram->getWall(),
+ css::uno::UNO_QUERY);
if (xPropAccess.is())
updateStyleElement(css::chart2::ChartObjectType::WALL, xPropAccess->getPropertyValues());
- xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xDiagram->getLegend(), css::uno::UNO_QUERY);
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(xDiagram->getLegend(),
+ css::uno::UNO_QUERY);
if (xPropAccess.is())
updateStyleElement(css::chart2::ChartObjectType::LEGEND, xPropAccess->getPropertyValues());
- css::uno::Reference<css::chart2::XTitled> xTitled( xDiagram, css::uno::UNO_QUERY);
+ css::uno::Reference<css::chart2::XTitled> xTitled(xDiagram, css::uno::UNO_QUERY);
css::uno::Reference<css::chart2::XTitle> xSubTitle = xTitled->getTitleObject();
if (xSubTitle.is())
{
- xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xSubTitle, css::uno::UNO_QUERY);
+ xPropAccess
+ = css::uno::Reference<css::beans::XPropertyAccess>(xSubTitle, css::uno::UNO_QUERY);
if (xPropAccess.is())
- updateStyleElement(css::chart2::ChartObjectType::TITLE, xPropAccess->getPropertyValues());
+ updateStyleElement(css::chart2::ChartObjectType::TITLE,
+ xPropAccess->getPropertyValues());
}
- css::uno::Reference<css::chart2::XCoordinateSystemContainer> xCooSysCont( xDiagram, css::uno::UNO_QUERY);
+ css::uno::Reference<css::chart2::XCoordinateSystemContainer> xCooSysCont(xDiagram,
+ css::uno::UNO_QUERY);
css::uno::Sequence<css::uno::Reference<css::chart2::XCoordinateSystem>> aCooSysSeq(
xCooSysCont->getCoordinateSystems());
@@ -380,17 +391,20 @@ ChartStyle::updateChartStyle(const css::uno::Reference<css::chart2::XChartDocume
for (sal_Int16 nDimIdx = 0; nDimIdx < nDimCount; nDimIdx++)
{
css::uno::Reference<css::chart2::XAxis> xAxis = xCooSys->getAxisByDimension(nDimIdx, 0);
- xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xAxis, css::uno::UNO_QUERY);
+ xPropAccess
+ = css::uno::Reference<css::beans::XPropertyAccess>(xAxis, css::uno::UNO_QUERY);
if (xPropAccess.is())
- updateStyleElement(css::chart2::ChartObjectType::AXIS, xPropAccess->getPropertyValues());
+ updateStyleElement(css::chart2::ChartObjectType::AXIS,
+ xPropAccess->getPropertyValues());
if (xCooSys->getMaximumAxisIndexByDimension(nDimIdx))
{
xAxis = xCooSys->getAxisByDimension(nDimIdx, 1);
- xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xAxis, css::uno::UNO_QUERY);
+ xPropAccess
+ = css::uno::Reference<css::beans::XPropertyAccess>(xAxis, css::uno::UNO_QUERY);
if (xPropAccess.is())
- updateStyleElement(css::chart2::ChartObjectType::AXIS, xPropAccess->getPropertyValues());
-
+ updateStyleElement(css::chart2::ChartObjectType::AXIS,
+ xPropAccess->getPropertyValues());
}
}
}
@@ -399,7 +413,7 @@ ChartStyle::updateChartStyle(const css::uno::Reference<css::chart2::XChartDocume
// _____ XCloneable _____
css::uno::Reference<css::util::XCloneable> SAL_CALL ChartStyle::createClone()
{
- return css::uno::Reference<css::util::XCloneable>(new ChartStyle( *this ));
+ return css::uno::Reference<css::util::XCloneable>(new ChartStyle(*this));
}
sal_Bool ChartStyle::isUserDefined() { return false; }
@@ -446,12 +460,10 @@ void ChartStyles::addInitialStyles()
css::uno::Any aDefaultStyle;
css::uno::Reference<css::chart2::XChartStyle> xChartStyle = new ChartStyle;
css::uno::Reference<css::style::XStyle> xStyle(xChartStyle, css::uno::UNO_QUERY_THROW);
- xStyle->setName("LibreOffice");
+ xStyle->setName("Default");
aDefaultStyle <<= xChartStyle;
- insertByName("LibreOffice", aDefaultStyle);
insertByName("Default", aDefaultStyle);
-
}
void ChartStyles::insertByName(const OUString& rName, const css::uno::Any& rStyle)
diff --git a/chart2/uiconfig/ui/sidebarstyle.ui b/chart2/uiconfig/ui/sidebarstyle.ui
index 4a6a118bdde6..b31727a96212 100644
--- a/chart2/uiconfig/ui/sidebarstyle.ui
+++ b/chart2/uiconfig/ui/sidebarstyle.ui
@@ -1,165 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="chart2">
<requires lib="gtk+" version="3.18"/>
- <object class="GtkGrid" id="FunctionPanel">
+ <object class="GtkGrid" id="ChartStylesPanel">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">6</property>
<child>
- <object class="GtkPaned" id="splitter">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="can_focus">False</property>
<property name="orientation">vertical</property>
- <property name="wide_handle">True</property>
<child>
- <object class="GtkGrid" id="grid6">
+ <object class="GtkBox" id="container">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label_style">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes" context="sidebarelements|label_chart_style">Default Chart Style:</property>
+ <property name="label" translatable="yes" context="chartsidebar|styles">Chart Style:</property>
<accessibility>
- <relation type="label-for" target="default_style"/>
+ <relation type="label-for" target="lb_styles"/>
</accessibility>
</object>
<packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="default_style">
+ <object class="GtkComboBoxText" id="lb_styles">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="editable">False</property>
<accessibility>
<relation type="labelled-by" target="label_style"/>
</accessibility>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">5</property>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkPaned" id="splitter">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="orientation">vertical</property>
- <property name="wide_handle">True</property>
- <child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkButton" id="setdefault">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="stylepanel|setdefault|tooltip_text">Set the Selected Style for all Charts</property>
- <property name="label">Default</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="setstyle">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="stylepanel|setstyle|tooltip_text">Set the Selected Style for Selected Chart</property>
- <property name="label">Set</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="createstyle">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="stylepanel|createstyle|tooltip_text">Create a New style from the Selected Chart</property>
- <property name="label">New</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="deletestyle">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="stylepanel|deletestyle|tooltip_text">Delete the style Selected in List</property>
- <property name="label">Delete</property>
- </object>
- <packing>
- <property name="left_attach">3</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkTreeView" id="stylelist:border">
- <property name="name">styles</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="expand">True</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
+ <object class="GtkLabel" id="label_create_from_chart">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="chartsidebar|styles|createnewstyle">Create style from chart</property>
</object>
<packing>
- <property name="resize">True</property>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
</child>
</object>
</interface>
diff --git a/offapi/com/sun/star/chart2/XChartStyled.idl b/offapi/com/sun/star/chart2/XChartStyled.idl
index 4c6a5f9b231a..0af9b2122095 100644
--- a/offapi/com/sun/star/chart2/XChartStyled.idl
+++ b/offapi/com/sun/star/chart2/XChartStyled.idl
@@ -34,6 +34,7 @@ module chart2
interface XChartStyled : ::com::sun::star::uno::XInterface
{
XChartStyle getChartStyle();
+ void setChartStyle([in] XChartStyle xChartStyle);
};
} ; // chart2
commit b67cabbd3145b2791f235b8bc6dd57d2c5d5e6fa
Author: Gagandeep Singh <deepgagan231197 at gmail.com>
AuthorDate: Sat Aug 17 12:43:19 2019 +0530
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Tue Aug 20 22:08:06 2019 +0800
Add XPropertyAccess and XCloneable to ChartStyles
* This patch also adds the Style Update to GUI
* Added liscense details to ChartStylesPanel.(h/c)xx
* Some minor bug fixes to applyStyleToCoordinates function
* Added the Default Chart GtkEntry to ChartStylePanel
Change-Id: I730fbf2f748b05d82d22ba45fa36bb70226db4c9
diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
index a9dec86803fc..0369aec5cb36 100644
--- a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
+++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
@@ -96,7 +96,7 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
else if (rsResourceURL.endsWith("/LinePanel"))
pPanel = ChartLinePanel::Create(pParentWindow, xFrame, pController);
else if (rsResourceURL.endsWith("/ChartStylesPanel"))
- pPanel = ChartStylesPanel::Create(pParentWindow, xFrame);
+ pPanel = ChartStylesPanel::Create(pParentWindow, xFrame, pController);
if (pPanel)
xElement = sfx2::sidebar::SidebarPanelBase::Create(
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index b445fd88886d..bc083bc6e74a 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -33,7 +33,6 @@
#include <AxisHelper.hxx>
#include <DiagramHelper.hxx>
#include <ChartTypeHelper.hxx>
-#include <ChartStyle.hxx>
#include <ChartModel.hxx>
@@ -304,8 +303,6 @@ ChartElementsPanel::ChartElementsPanel(
get(mpTextTitle, "text_title");
get(mpTextSubTitle, "text_subtitle");
- get(mpLBStylesBox, "cb_styles");
-
maTextTitle = mpTextTitle->GetText();
maTextSubTitle = mpTextSubTitle->GetText();
@@ -342,8 +339,6 @@ void ChartElementsPanel::dispose()
mpLBLegendPosition.clear();
mpBoxLegend.clear();
- mpLBStylesBox.clear();
-
mpLBAxis.clear();
mpLBGrid.clear();
@@ -484,16 +479,6 @@ void ChartElementsPanel::updateData()
mpLBLegendPosition->SelectEntryPos(getLegendPos(mxModel));
- css::uno::Sequence<OUString> aChartStyles = ::chart::getChartStyles()->getElementNames();
- mpLBStylesBox->Clear();
- for (auto& rStyle : aChartStyles)
- {
- mpLBStylesBox->InsertEntry(rStyle);
- }
-
- ChartModel* pModel = getChartModel(mxModel);
- OUString aCurrentChartStyleName = css::uno::Reference<css::style::XStyle>(pModel->getChartStyle(), css::uno::UNO_QUERY_THROW)->getName();
- mpLBStylesBox->SelectEntry(aCurrentChartStyleName);
}
VclPtr<vcl::Window> ChartElementsPanel::Create (
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
index b5719621e88b..eca293645cc4 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
@@ -95,8 +95,6 @@ private:
VclPtr<ListBox> mpLBLegendPosition;
VclPtr<VclHBox> mpBoxLegend;
- VclPtr<ListBox> mpLBStylesBox;
-
vcl::EnumContext maContext;
css::uno::Reference<css::frame::XModel> mxModel;
diff --git a/chart2/source/controller/sidebar/ChartStylesPanel.cxx b/chart2/source/controller/sidebar/ChartStylesPanel.cxx
index 82976b5b1e44..b58001831d0a 100644
--- a/chart2/source/controller/sidebar/ChartStylesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartStylesPanel.cxx
@@ -1,8 +1,21 @@
+/* -*- 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 <com/sun/star/lang/IllegalArgumentException.hpp>
#include <vcl/lstbox.hxx>
#include <vcl/button.hxx>
-
+#include <iostream>
#include "ChartStylesPanel.hxx"
+#include <ChartStyle.hxx>
+#include <ChartModel.hxx>
+#include <CloneHelper.hxx>
+#include <com/sun/star/chart2/ChartObjectType.hpp>
using namespace css;
using namespace css::uno;
@@ -11,8 +24,26 @@ namespace chart
{
namespace sidebar
{
+
+namespace
+{
+
+ChartModel* getChartModel(const css::uno::Reference<css::frame::XModel>& xModel)
+{
+ ChartModel* pModel = dynamic_cast<ChartModel*>(xModel.get());
+ return pModel;
+}
+
+css::uno::Reference<css::chart2::XChartStyle> getCurrentStyle(const css::uno::Reference<css::frame::XModel>& xModel)
+{
+ return getChartModel(xModel)->getChartStyle();
+}
+
+} // namespace anonymous
+
VclPtr<vcl::Window> ChartStylesPanel::Create(vcl::Window* pParent,
- const css::uno::Reference<css::frame::XFrame>& rxFrame)
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ const css::uno::Reference<css::frame::XController>& pController)
{
if (pParent == nullptr)
throw lang::IllegalArgumentException("no parent Window given to ChartStylesPanel::Create",
@@ -21,12 +52,15 @@ VclPtr<vcl::Window> ChartStylesPanel::Create(vcl::Window* pParent,
throw lang::IllegalArgumentException("no XFrame given to ChartStylesPanel::Create", nullptr,
1);
- return VclPtr<ChartStylesPanel>::Create(pParent, rxFrame);
+ return VclPtr<ChartStylesPanel>::Create(pParent, rxFrame, pController);
}
ChartStylesPanel::ChartStylesPanel(vcl::Window* pParent,
- const css::uno::Reference<css::frame::XFrame>& rxFrame)
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ const css::uno::Reference<css::frame::XController>& pController)
: PanelLayout(pParent, "ChartStylesPanel", "modules/schart/ui/sidebarstyle.ui", rxFrame)
+ , m_xModel( pController->getModel() )
+ , m_xChartStyles( ::chart::getChartStyles() )
{
get(aStyleList, "stylelist");
get(aApplyButton, "setstyle");
@@ -43,6 +77,8 @@ ChartStylesPanel::ChartStylesPanel(vcl::Window* pParent,
aNewButton->SetClickHdl(aLink2);
aDefaultButton->SetClickHdl(aLink2);
aDeleteButton->SetClickHdl(aLink2);
+
+ Initialize();
}
ChartStylesPanel::~ChartStylesPanel() { disposeOnce(); }
@@ -57,13 +93,53 @@ void ChartStylesPanel::dispose()
PanelLayout::dispose();
}
-void ChartStylesPanel::UpdateList() {}
+void ChartStylesPanel::createNewStyle(const OUString& sName)
+{
+ css::uno::Reference<css::chart2::XChartStyle> xCurrentStyle = getCurrentStyle(m_xModel);
+
+ css::uno::Reference<css::chart2::XChartStyle> xNewStyle = CloneHelper::CreateRefClone<css::chart2::XChartStyle>()(xCurrentStyle);
+ xNewStyle->updateChartStyle(css::uno::Reference<css::chart2::XChartDocument>(m_xModel, css::uno::UNO_QUERY));
+ css::uno::Reference<css::style::XStyle> xStyle(xNewStyle, css::uno::UNO_QUERY);
+ xStyle->setName(sName);
+ m_xChartStyles->insertByName(sName, css::uno::Any(xNewStyle));
+
+ UpdateList();
+}
+
+void ChartStylesPanel::updateDefaultStyle(const OUString& sName)
+{
+ m_xChartStyles->replaceByName("Default", css::uno::Any(m_xChartStyles->getByName(sName)));
+}
+
+void ChartStylesPanel::UpdateList()
+{
+ aStyleList->Clear();
+ css::uno::Sequence<OUString> aStyleNames = m_xChartStyles->getElementNames();
+ for ( auto& rStyle : aStyleNames )
+ {
+ if (rStyle != "Default")
+ aStyleList->InsertEntry( rStyle );
+ }
+
+ OUString aCurrentChartStyleName = css::uno::Reference<css::style::XStyle>(getCurrentStyle(m_xModel),
+ css::uno::UNO_QUERY_THROW)->getName();
+ aStyleList->SelectEntry(aCurrentChartStyleName);
+}
+
+void ChartStylesPanel::Initialize()
+{
+ UpdateList();
+}
IMPL_LINK_NOARG(ChartStylesPanel, SelHdl, ListBox&, void) {}
-IMPL_LINK_NOARG(ChartStylesPanel, SetSelectionClickHdl, Button*, void) {}
+IMPL_LINK(ChartStylesPanel, SetSelectionClickHdl, Button*, pButton, void)
+{
+}
IMPL_LINK_NOARG(ChartStylesPanel, SetSelectionHdl, ListBox&, void) {}
} // namespace sidebar
} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/sidebar/ChartStylesPanel.hxx b/chart2/source/controller/sidebar/ChartStylesPanel.hxx
index 610d6ce58bec..bd28eddb1965 100644
--- a/chart2/source/controller/sidebar/ChartStylesPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartStylesPanel.hxx
@@ -18,6 +18,8 @@
#include <editeng/fhgtitem.hxx>
#include <com/sun/star/ui/XUIElement.hpp>
#include <com/sun/star/ui/XSidebar.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/chart2/XChartStyle.hpp>
#include <vcl/lstbox.hxx>
#include <vcl/button.hxx>
@@ -59,6 +61,9 @@ namespace sidebar
class ChartStylesPanel : public PanelLayout
{
private:
+ css::uno::Reference<css::frame::XModel> m_xModel;
+ css::uno::Reference<css::container::XNameContainer> m_xChartStyles;
+
VclPtr<ListBox> aStyleList;
VclPtr<PushButton> aApplyButton;
VclPtr<PushButton> aNewButton;
@@ -70,13 +75,20 @@ private:
DECL_LINK(SelHdl, ListBox&, void);
void UpdateList();
+ void Initialize();
+
+ css::uno::Reference<css::chart2::XChartStyle> updateStyleFromChart(css::uno::Reference<css::chart2::XChartStyle>& xChartStyle);
+ void createNewStyle(const OUString& sName);
+ void updateDefaultStyle(const OUString& sName);
public:
static VclPtr<vcl::Window> Create(vcl::Window* pParent,
- const css::uno::Reference<css::frame::XFrame>& rxFrame);
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ const css::uno::Reference<css::frame::XController>& rxController);
// constructor/destructor
- ChartStylesPanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame);
+ ChartStylesPanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ const css::uno::Reference<css::frame::XController>& pController);
virtual ~ChartStylesPanel() override;
virtual void dispose() override;
diff --git a/chart2/source/inc/ChartStyle.hxx b/chart2/source/inc/ChartStyle.hxx
index 54cbc5fe243b..047e12d241f4 100644
--- a/chart2/source/inc/ChartStyle.hxx
+++ b/chart2/source/inc/ChartStyle.hxx
@@ -25,9 +25,11 @@
#include <cppuhelper/propshlp.hxx>
#include <com/sun/star/chart2/XChartStyle.hpp>
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
#include <map>
#include "PropertyHelper.hxx"
@@ -38,7 +40,8 @@ namespace chart
{
namespace impl
{
-typedef ::cppu::WeakImplHelper<css::style::XStyle> ChartObjectStyle_Base;
+typedef ::cppu::WeakImplHelper<css::style::XStyle,
+ css::util::XCloneable> ChartObjectStyle_Base;
}
class ChartObjectStyle : public chart::MutexContainer,
@@ -49,6 +52,7 @@ public:
ChartObjectStyle(css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo,
::cppu::IPropertyArrayHelper& rArrayHelper,
const chart::tPropertyValueMap& rPropertyMap);
+ explicit ChartObjectStyle( const ChartObjectStyle & rOther );
virtual ~ChartObjectStyle();
/// merge XInterface implementations
@@ -74,6 +78,9 @@ public:
virtual void SAL_CALL setName(const OUString&);
+ // _____ XCloneable _____
+ virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override;
+
private:
::cppu::IPropertyArrayHelper& mrArrayHelper;
const chart::tPropertyValueMap& mrPropertyMap;
@@ -81,16 +88,20 @@ private:
};
class ChartStyle : public cppu::WeakImplHelper<css::chart2::XChartStyle, css::lang::XServiceInfo,
- css::style::XStyle>
+ css::style::XStyle, css::util::XCloneable>
{
public:
explicit ChartStyle();
+ explicit ChartStyle( const ChartStyle & rOther );
virtual ~ChartStyle();
/// XServiceInfo declarations
virtual OUString SAL_CALL getImplementationName() override;
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+ // _____ XCloneable _____
+ virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override;
+
// _____ XChartStyle _____
virtual css::uno::Reference<css::beans::XPropertySet>
SAL_CALL getStyleForObject(const sal_Int16 nChartObjectType) override;
@@ -104,6 +115,10 @@ public:
virtual void SAL_CALL applyStyleToBackground(
const css::uno::Reference<css::beans::XPropertySet>& xBackground) override;
+ virtual void updateStyleElement(const sal_Int16 nChartObjectType, const css::uno::Sequence<css::beans::PropertyValue>& rProperties) override;
+
+ virtual void updateChartStyle(const css::uno::Reference<css::chart2::XChartDocument>& rxModel) override;
+
// XStyle
virtual sal_Bool SAL_CALL isUserDefined() override;
virtual sal_Bool SAL_CALL isInUse() override;
diff --git a/chart2/source/inc/OPropertySet.hxx b/chart2/source/inc/OPropertySet.hxx
index 2ee1caa164c8..12a55c677661 100644
--- a/chart2/source/inc/OPropertySet.hxx
+++ b/chart2/source/inc/OPropertySet.hxx
@@ -25,11 +25,13 @@
// interfaces and types
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/beans/XMultiPropertyStates.hpp>
#include <com/sun/star/style/XStyleSupplier.hpp>
#include "charttoolsdllapi.hxx"
#include <memory>
+#include <map>
namespace property
{
@@ -46,6 +48,7 @@ class OOO_DLLPUBLIC_CHARTTOOLS OPropertySet :
public css::lang::XTypeProvider,
public css::beans::XPropertyState,
public css::beans::XMultiPropertyStates,
+ public css::beans::XPropertyAccess,
public css::style::XStyleSupplier
{
public:
@@ -181,6 +184,9 @@ protected:
virtual void SAL_CALL setStyle( const css::uno::Reference< css::style::XStyle >& xStyle ) override;
// ____ XMultiPropertySet ____
+ // make getPropertyValues visible along with the XPropertyAccess function newly defined here
+ using ::cppu::OPropertySetHelper::getPropertyValues;
+
virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& PropertyNames,
const css::uno::Sequence< css::uno::Any >& Values ) override;
@@ -191,6 +197,10 @@ protected:
// Note: it is assumed that the base class implements setPropertyValue by
// using setFastPropertyValue
+ // XPropertyAccess
+ virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override;
+ virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue >& rPropertyValues ) override;
+
private:
/// reference to mutex of class deriving from here
::osl::Mutex & m_rMutex;
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 6ab5ebf9135b..1bfc4c310e84 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -723,7 +723,12 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
if (xDiagram.is())
{
if (m_xChartStyle.is())
+ {
+ m_xChartStyle->applyStyleToTitle(getTitleObject());
+ m_xChartStyle->applyStyleToBackground(getPageBackground());
m_xChartStyle->applyStyleToDiagram(xDiagram);
+ }
+
}
if (m_nInLoad == 0)
diff --git a/chart2/source/tools/ChartStyle.cxx b/chart2/source/tools/ChartStyle.cxx
index 2847b3db7f7d..50bdde655d1c 100644
--- a/chart2/source/tools/ChartStyle.cxx
+++ b/chart2/source/tools/ChartStyle.cxx
@@ -16,8 +16,9 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
+#include <iostream>
#include <ChartStyle.hxx>
+#include <CloneHelper.hxx>
#include <com/sun/star/chart2/ChartObjectType.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
@@ -63,6 +64,13 @@ ChartObjectStyle::ChartObjectStyle(css::uno::Reference<css::beans::XPropertySetI
{
}
+ChartObjectStyle::ChartObjectStyle( const ChartObjectStyle & rOther )
+ : OPropertySet(rOther.m_aMutex)
+ , mrArrayHelper(rOther.mrArrayHelper)
+ , mrPropertyMap(rOther.mrPropertyMap)
+ , mxPropSetInfo(rOther.mxPropSetInfo)
+{}
+
ChartObjectStyle::~ChartObjectStyle() {}
sal_Bool SAL_CALL ChartObjectStyle::isInUse() { return true; }
@@ -93,12 +101,30 @@ css::uno::Any ChartObjectStyle::GetDefaultValue(sal_Int32 nHandle) const
::cppu::IPropertyArrayHelper& SAL_CALL ChartObjectStyle::getInfoHelper() { return mrArrayHelper; }
+// _____ XCloneable _____
+css::uno::Reference<css::util::XCloneable> SAL_CALL ChartObjectStyle::createClone()
+{
+ return css::uno::Reference<css::util::XCloneable>(new ChartObjectStyle( *this ));
+}
+
ChartStyle::ChartStyle()
: m_nNumObjects(css::chart2::ChartObjectType::UNKNOWN)
{
register_styles();
}
+ChartStyle::ChartStyle( const ChartStyle & rOther )
+ : m_nNumObjects(rOther.m_nNumObjects)
+{
+ for ( sal_Int16 nIdx = 0; nIdx < m_nNumObjects; nIdx++ )
+ {
+ auto It = rOther.m_xChartStyle.find( nIdx );
+
+ if (It != rOther.m_xChartStyle.end())
+ m_xChartStyle[ nIdx ] = CloneHelper::CreateRefClone<css::beans::XPropertySet>()( It->second );
+ }
+}
+
ChartStyle::~ChartStyle() {}
css::uno::Reference<css::beans::XPropertySet>
@@ -226,10 +252,10 @@ void ChartStyle::applyStyleToCoordinates(
for (sal_Int32 nCooSysIdx = 0; nCooSysIdx < aCooSysSeq.getLength(); ++nCooSysIdx)
{
- css::uno::Reference<css::chart2::XCoordinateSystem> xCooSys(aCooSysSeq[nCooSysIdx],
- css::uno::UNO_QUERY);
+ css::uno::Reference<css::chart2::XCoordinateSystem> xCooSys = aCooSysSeq[nCooSysIdx];
+
sal_Int16 nDimCount = xCooSys->getDimension();
- for (sal_Int16 nDimIdx = 0; nDimIdx <= nDimCount; nDimIdx++)
+ for (sal_Int16 nDimIdx = 0; nDimIdx < nDimCount; nDimIdx++)
{
applyStyleToAxis(xCooSys->getAxisByDimension(nDimIdx, 0));
if (xCooSys->getMaximumAxisIndexByDimension(nDimIdx))
@@ -286,6 +312,96 @@ ChartStyle::applyStyleToBackground(const css::uno::Reference<css::beans::XProper
}
}
+void SAL_CALL
+ChartStyle::updateStyleElement(const sal_Int16 nChartObjectType, const css::uno::Sequence<css::beans::PropertyValue>& rProperties)
+{
+ css::uno::Reference<css::beans::XPropertyAccess>
+ xPropertyAccess(getStyleForObject(nChartObjectType), css::uno::UNO_QUERY_THROW);
+
+ if (xPropertyAccess.is())
+ {
+ xPropertyAccess->setPropertyValues( rProperties );
+ }
+}
+
+void SAL_CALL
+ChartStyle::updateChartStyle(const css::uno::Reference<css::chart2::XChartDocument>& rxModel)
+{
+ if (!rxModel.is())
+ return;
+
+ css::uno::Reference<css::beans::XPropertyAccess> xPropAccess;
+ css::uno::Reference<css::chart2::XTitled> xMainTitled(rxModel, css::uno::UNO_QUERY);
+
+ css::uno::Reference<css::chart2::XTitle> xMainTitle = xMainTitled->getTitleObject();
+ if (xMainTitle.is())
+ {
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(xMainTitle, css::uno::UNO_QUERY);
+ updateStyleElement(css::chart2::ChartObjectType::TITLE, xPropAccess->getPropertyValues());
+ }
+
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(rxModel->getPageBackground(), css::uno::UNO_QUERY);
+ if (xPropAccess.is())
+ updateStyleElement(css::chart2::ChartObjectType::PAGE, xPropAccess->getPropertyValues());
+
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>(rxModel->getFirstDiagram(), css::uno::UNO_QUERY);
+ if (xPropAccess.is())
+ updateStyleElement(css::chart2::ChartObjectType::DIAGRAM, xPropAccess->getPropertyValues());
+
+ css::uno::Reference<css::chart2::XDiagram> xDiagram = rxModel->getFirstDiagram();
+
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xDiagram->getWall(), css::uno::UNO_QUERY);
+ if (xPropAccess.is())
+ updateStyleElement(css::chart2::ChartObjectType::WALL, xPropAccess->getPropertyValues());
+
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xDiagram->getLegend(), css::uno::UNO_QUERY);
+ if (xPropAccess.is())
+ updateStyleElement(css::chart2::ChartObjectType::LEGEND, xPropAccess->getPropertyValues());
+
+ css::uno::Reference<css::chart2::XTitled> xTitled( xDiagram, css::uno::UNO_QUERY);
+ css::uno::Reference<css::chart2::XTitle> xSubTitle = xTitled->getTitleObject();
+ if (xSubTitle.is())
+ {
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xSubTitle, css::uno::UNO_QUERY);
+ if (xPropAccess.is())
+ updateStyleElement(css::chart2::ChartObjectType::TITLE, xPropAccess->getPropertyValues());
+ }
+
+ css::uno::Reference<css::chart2::XCoordinateSystemContainer> xCooSysCont( xDiagram, css::uno::UNO_QUERY);
+
+ css::uno::Sequence<css::uno::Reference<css::chart2::XCoordinateSystem>> aCooSysSeq(
+ xCooSysCont->getCoordinateSystems());
+
+ for (sal_Int32 nCooSysIdx = 0; nCooSysIdx < aCooSysSeq.getLength(); ++nCooSysIdx)
+ {
+ css::uno::Reference<css::chart2::XCoordinateSystem> xCooSys = aCooSysSeq[nCooSysIdx];
+
+ sal_Int16 nDimCount = xCooSys->getDimension();
+ for (sal_Int16 nDimIdx = 0; nDimIdx < nDimCount; nDimIdx++)
+ {
+ css::uno::Reference<css::chart2::XAxis> xAxis = xCooSys->getAxisByDimension(nDimIdx, 0);
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xAxis, css::uno::UNO_QUERY);
+ if (xPropAccess.is())
+ updateStyleElement(css::chart2::ChartObjectType::AXIS, xPropAccess->getPropertyValues());
+
+ if (xCooSys->getMaximumAxisIndexByDimension(nDimIdx))
+ {
+ xAxis = xCooSys->getAxisByDimension(nDimIdx, 1);
+ xPropAccess = css::uno::Reference<css::beans::XPropertyAccess>( xAxis, css::uno::UNO_QUERY);
+ if (xPropAccess.is())
+ updateStyleElement(css::chart2::ChartObjectType::AXIS, xPropAccess->getPropertyValues());
+
+ }
+ }
+ }
+}
+
+// _____ XCloneable _____
+css::uno::Reference<css::util::XCloneable> SAL_CALL ChartStyle::createClone()
+{
+ return css::uno::Reference<css::util::XCloneable>(new ChartStyle( *this ));
+}
+
sal_Bool ChartStyle::isUserDefined() { return false; }
sal_Bool ChartStyle::isInUse() { return true; }
@@ -330,10 +446,12 @@ void ChartStyles::addInitialStyles()
css::uno::Any aDefaultStyle;
css::uno::Reference<css::chart2::XChartStyle> xChartStyle = new ChartStyle;
css::uno::Reference<css::style::XStyle> xStyle(xChartStyle, css::uno::UNO_QUERY_THROW);
- xStyle->setName("Default");
+ xStyle->setName("LibreOffice");
aDefaultStyle <<= xChartStyle;
+ insertByName("LibreOffice", aDefaultStyle);
insertByName("Default", aDefaultStyle);
+
}
void ChartStyles::insertByName(const OUString& rName, const css::uno::Any& rStyle)
diff --git a/chart2/source/tools/ImplOPropertySet.cxx b/chart2/source/tools/ImplOPropertySet.cxx
index 2eb03d99e52a..8ebcd01c2a0a 100644
--- a/chart2/source/tools/ImplOPropertySet.cxx
+++ b/chart2/source/tools/ImplOPropertySet.cxx
@@ -175,6 +175,11 @@ bool ImplOPropertySet::SetStyle( const Reference< style::XStyle > & xStyle )
return true;
}
+const ImplOPropertySet::tPropertyMap& ImplOPropertySet::exportPropertyMap()
+{
+ return m_aProperties;
+}
+
} // namespace impl
} // namespace chart
diff --git a/chart2/source/tools/ImplOPropertySet.hxx b/chart2/source/tools/ImplOPropertySet.hxx
index 8cc1ea8b65d1..2ef61a85592b 100644
--- a/chart2/source/tools/ImplOPropertySet.hxx
+++ b/chart2/source/tools/ImplOPropertySet.hxx
@@ -73,6 +73,8 @@ public:
std::map< sal_Int32, css::uno::Any >
tPropertyMap;
+ const tPropertyMap& exportPropertyMap();
+
private:
tPropertyMap m_aProperties;
css::uno::Reference< css::style::XStyle >
diff --git a/chart2/source/tools/OPropertySet.cxx b/chart2/source/tools/OPropertySet.cxx
index 859dbcfdf757..6efa7f42c08a 100644
--- a/chart2/source/tools/OPropertySet.cxx
+++ b/chart2/source/tools/OPropertySet.cxx
@@ -78,6 +78,7 @@ Any SAL_CALL OPropertySet::queryInterface( const uno::Type& aType )
static_cast< beans::XFastPropertySet * >( this ),
static_cast< beans::XPropertyState * >( this ),
static_cast< beans::XMultiPropertyStates * >( this ),
+ static_cast< beans::XPropertyAccess * >( this ),
static_cast< style::XStyleSupplier * >( this ) );
}
@@ -92,6 +93,7 @@ Sequence< uno::Type > SAL_CALL
cppu::UnoType<beans::XFastPropertySet>::get(),
cppu::UnoType<beans::XPropertyState>::get(),
cppu::UnoType<beans::XMultiPropertyStates>::get(),
+ cppu::UnoType<beans::XPropertyAccess>::get(),
cppu::UnoType<style::XStyleSupplier>::get() };
return aTypeList;
@@ -367,6 +369,29 @@ void SAL_CALL OPropertySet::setFastPropertyValue( sal_Int32 nHandle, const Any&
firePropertyChangeEvent();
}
+// _____ XPropertyAccess _____
+css::uno::Sequence< css::beans::PropertyValue > SAL_CALL OPropertySet::getPropertyValues()
+{
+ auto& rPropertyMap = m_pImplProperties->exportPropertyMap();
+ Sequence< css::beans::PropertyValue > aPropertySeq( rPropertyMap.size() );
+
+ sal_Int32 nIdx = 0;
+ for (auto Itr = rPropertyMap.begin(); Itr != rPropertyMap.end(); Itr++, nIdx++ )
+ {
+ aPropertySeq[ nIdx ].Handle = Itr->first;
+ aPropertySeq[ nIdx ].Value = Itr->second;
+ }
+ return aPropertySeq;
+}
+
+void SAL_CALL OPropertySet::setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rPropertyValues )
+{
+ for (auto Itr = rPropertyValues.begin(); Itr != rPropertyValues.end(); Itr++)
+ {
+ setFastPropertyValue( Itr->Handle, Itr->Value );
+ }
+}
+
} // namespace property
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/uiconfig/ui/sidebarelements.ui b/chart2/uiconfig/ui/sidebarelements.ui
index 89ac8c9fd314..39e9b45b5edc 100644
--- a/chart2/uiconfig/ui/sidebarelements.ui
+++ b/chart2/uiconfig/ui/sidebarelements.ui
@@ -493,45 +493,6 @@
<property name="position">4</property>
</packing>
</child>
- <child>
- <object class="GtkGrid" id="grid6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="label_style">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="sidebarelements|label_chart_style">Chart Style:</property>
- <accessibility>
- <relation type="label-for" target="cb_styles"/>
- </accessibility>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBoxText" id="cb_styles">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <accessibility>
- <relation type="labelled-by" target="label_style"/>
- </accessibility>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
</object>
<packing>
<property name="left_attach">0</property>
diff --git a/chart2/uiconfig/ui/sidebarstyle.ui b/chart2/uiconfig/ui/sidebarstyle.ui
index 36eceae2c805..4a6a118bdde6 100644
--- a/chart2/uiconfig/ui/sidebarstyle.ui
+++ b/chart2/uiconfig/ui/sidebarstyle.ui
@@ -15,97 +15,151 @@
<property name="orientation">vertical</property>
<property name="wide_handle">True</property>
<child>
- <object class="GtkGrid">
+ <object class="GtkGrid" id="grid6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkButton" id="setdefault">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="stylepanel|setdefault|tooltip_text">Set the Selected Style for all Charts</property>
- <property name="label">Default</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
<child>
- <object class="GtkButton" id="setstyle">
+ <object class="GtkLabel" id="label_style">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="stylepanel|setstyle|tooltip_text">Set the Selected Style for Selected Chart</property>
- <property name="label">Set</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="sidebarelements|label_chart_style">Default Chart Style:</property>
+ <accessibility>
+ <relation type="label-for" target="default_style"/>
+ </accessibility>
</object>
<packing>
- <property name="left_attach">1</property>
+ <property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="createstyle">
+ <object class="GtkEntry" id="default_style">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="stylepanel|createstyle|tooltip_text">Create a New style from the Selected Chart</property>
- <property name="label">New</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="editable">False</property>
+ <accessibility>
+ <relation type="labelled-by" target="label_style"/>
+ </accessibility>
</object>
<packing>
- <property name="left_attach">2</property>
+ <property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkPaned" id="splitter">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="wide_handle">True</property>
<child>
- <object class="GtkButton" id="deletestyle">
+ <object class="GtkGrid">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="stylepanel|deletestyle|tooltip_text">Delete the style Selected in List</property>
- <property name="label">Delete</property>
- </object>
- <packing>
- <property name="left_attach">3</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkButton" id="setdefault">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes" context="stylepanel|setdefault|tooltip_text">Set the Selected Style for all Charts</property>
+ <property name="label">Default</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="setstyle">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes" context="stylepanel|setstyle|tooltip_text">Set the Selected Style for Selected Chart</property>
+ <property name="label">Set</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="createstyle">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes" context="stylepanel|createstyle|tooltip_text">Create a New style from the Selected Chart</property>
+ <property name="label">New</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="deletestyle">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes" context="stylepanel|deletestyle|tooltip_text">Delete the style Selected in List</property>
+ <property name="label">Delete</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
<property name="top_attach">0</property>
- </packing>
+ </packing>
</child>
+ <child>
+ <object class="GtkTreeView" id="stylelist:border">
+ <property name="name">styles</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="expand">True</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
</object>
<packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
</packing>
- </child>
- <child>
- <object class="GtkTreeView" id="stylelist:border">
- <property name="name">styles</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="expand">True</property>
- <property name="show_expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
</child>
</object>
<packing>
+ <property name="resize">True</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
- <packing>
- <property name="resize">True</property>
- </packing>
</child>
</object>
</interface>
diff --git a/offapi/com/sun/star/chart2/XChartStyle.idl b/offapi/com/sun/star/chart2/XChartStyle.idl
index 754a368206df..81937f48da2e 100644
--- a/offapi/com/sun/star/chart2/XChartStyle.idl
+++ b/offapi/com/sun/star/chart2/XChartStyle.idl
@@ -12,7 +12,9 @@
#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/beans/XPropertySet.idl>
+#include <com/sun/star/beans/PropertyValue.idl>
#include <com/sun/star/chart2/ChartObjectType.idl>
+#include <com/sun/star/chart2/XChartDocument.idl>
#include <com/sun/star/chart2/XDiagram.idl>
#include <com/sun/star/chart2/XTitle.idl>
#include <com/sun/star/chart2/XAxis.idl>
@@ -29,6 +31,11 @@ interface XChartStyle : ::com::sun::star::uno::XInterface
void applyStyleToTitle([in] XTitle chartTitle);
void applyStyleToBackground([in] com::sun::star::beans::XPropertySet chartBackground);
+
+ void updateStyleElement([in] short chartObjectType,
+ [in] sequence<com::sun::star::beans::PropertyValue> chartPropertySequence);
+
+ void updateChartStyle([in] XChartDocument chartDocument);
};
}; }; }; };
More information about the Libreoffice-commits
mailing list