chart2/source/chartcore.component | 4 chart2/source/inc/ChartStyle.hxx | 22 ++++- chart2/source/model/main/ChartModel.cxx | 5 - chart2/source/tools/ChartStyle.cxx | 129 ++++++++++++++++++++++++++++++-- chart2/source/view/main/VTitle.cxx | 3 5 files changed, 148 insertions(+), 15 deletions(-)
New commits: commit 4bf7014ba4b265fa0947bf4e6cc8bbee8f2ab94f Author: Markus Mohrhard <markus.mohrh...@googlemail.com> AuthorDate: Mon Aug 12 03:27:52 2019 +0800 Commit: Markus Mohrhard <markus.mohrh...@googlemail.com> CommitDate: Mon Aug 12 03:27:52 2019 +0800 tdf#126837: fix incorrect handling of visible flag for chart titles Change-Id: Idb8dfa18e924324dcf27339fd18ff90616651d40 diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index d0633263f8af..967edd72f55a 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -113,6 +113,9 @@ void VTitle::createShapes( m_nYPos = rPos.Y; uno::Reference< beans::XPropertySet > xTitleProperties( m_xTitle, uno::UNO_QUERY ); + sal_Bool bVisible = true; + if ((xTitleProperties->getPropertyValue("Visible") >>= bVisible) && !bVisible) + return; try { commit 816332b04ded68f0729bef34dd8774cb8fdabaf1 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> AuthorDate: Mon Aug 12 02:32:09 2019 +0800 Commit: Markus Mohrhard <markus.mohrh...@googlemail.com> CommitDate: Mon Aug 12 03:06:14 2019 +0800 implement a ChartStyles object Change-Id: Id7992faa801816be99c47f2bea754108b0296da5 diff --git a/chart2/source/chartcore.component b/chart2/source/chartcore.component index 4bb0f689c788..f58ba98ba3ac 100644 --- a/chart2/source/chartcore.component +++ b/chart2/source/chartcore.component @@ -256,8 +256,4 @@ constructor="com_sun_star_comp_chart2_ChartView_get_implementation"> <service name="com.sun.star.chart2.ChartView"/> </implementation> - <implementation name="com.sun.star.comp.chart2.ChartStyle" - constructor="com_sun_star_comp_chart2_ChartStyle_get_implementation"> - <service name="com.sun.star.chart2.ChartStyle"/> - </implementation> </component> diff --git a/chart2/source/inc/ChartStyle.hxx b/chart2/source/inc/ChartStyle.hxx index c12441e1cd76..30ecdfe0a6b4 100644 --- a/chart2/source/inc/ChartStyle.hxx +++ b/chart2/source/inc/ChartStyle.hxx @@ -16,6 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ + #ifndef INCLUDED_CHART2_SOURCE_INC_CHARTSTYLE_HXX #define INCLUDED_CHART2_SOURCE_INC_CHARTSTYLE_HXX @@ -25,13 +26,14 @@ #include <com/sun/star/chart2/XChartStyle.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/container/XNameContainer.hpp> #include <map> #include "PropertyHelper.hxx" #include "OPropertySet.hxx" #include "MutexContainer.hxx" -namespace chart2 +namespace chart { namespace impl { @@ -77,7 +79,8 @@ private: css::uno::Reference<css::beans::XPropertySetInfo> mxPropSetInfo; }; -class ChartStyle : public cppu::WeakImplHelper<css::chart2::XChartStyle, css::lang::XServiceInfo> +class ChartStyle : public cppu::WeakImplHelper<css::chart2::XChartStyle, css::lang::XServiceInfo, + css::style::XStyle> { public: explicit ChartStyle(); @@ -94,15 +97,28 @@ public: virtual void SAL_CALL applyStyleToDiagram(const css::uno::Reference<css::chart2::XDiagram>& xDiagram); + // XStyle + virtual sal_Bool SAL_CALL isUserDefined() override; + virtual sal_Bool SAL_CALL isInUse() override; + virtual OUString SAL_CALL getParentStyle() override; + virtual void setParentStyle(const OUString& rParentStyle) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName(const OUString& rName) override; + private: sal_Int16 m_nNumObjects; + OUString maName; std::map<sal_Int16, css::uno::Reference<css::beans::XPropertySet>> m_xChartStyle; void register_styles(); }; -} // namespace chart2 +css::uno::Reference<css::container::XNameContainer> getChartStyles(); + +} // namespace chart // INCLUDED_CHART2_SOURCE_INC_CHARTSTYLE_HXX #endif diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index ba5a5d399445..7c500abd4a07 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -31,6 +31,7 @@ #include <ChartView.hxx> #include <PopupRequest.hxx> #include <ModifyListenerHelper.hxx> +#include <ChartStyle.hxx> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> @@ -110,8 +111,8 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext) ModifyListenerHelper::addListener( m_xPageBackground, this ); m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY ); - m_xChartStyle.set( xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.chart2.ChartStyle" , m_xContext ), uno::UNO_QUERY ); + + ::chart::getChartStyles()->getByName("Default") >>= m_xChartStyle; } osl_atomic_decrement(&m_refCount); } diff --git a/chart2/source/tools/ChartStyle.cxx b/chart2/source/tools/ChartStyle.cxx index 71e94867dc3a..b2ccf466fcfd 100644 --- a/chart2/source/tools/ChartStyle.cxx +++ b/chart2/source/tools/ChartStyle.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <cppuhelper/supportsservice.hxx> +#include <rtl/instance.hxx> #include <vector> #include <Legend.hxx> @@ -49,7 +50,7 @@ class XComponentContext; } } -namespace chart2 +namespace chart { ChartObjectStyle::ChartObjectStyle(css::uno::Reference<css::beans::XPropertySetInfo> xPropSetInfo, ::cppu::IPropertyArrayHelper& rArrayHelper, @@ -208,19 +209,135 @@ ChartStyle::applyStyleToDiagram(const css::uno::Reference<css::chart2::XDiagram> } } +sal_Bool ChartStyle::isUserDefined() { return false; } + +sal_Bool ChartStyle::isInUse() { return true; } + +OUString ChartStyle::getParentStyle() { return ""; } + +void ChartStyle::setParentStyle(const OUString&) {} + +void ChartStyle::setName(const OUString& rName) { maName = rName; } + +OUString ChartStyle::getName() { return maName; } + +class ChartStyles : public cppu::WeakImplHelper<css::container::XNameContainer> +{ +public: + ChartStyles(); + virtual ~ChartStyles(); + + // XNameContainer + virtual void SAL_CALL insertByName(const OUString& rName, const css::uno::Any& rStyle); + virtual void SAL_CALL removeByName(const OUString& rName); + virtual void SAL_CALL replaceByName(const OUString& rName, const css::uno::Any& rStyle); + + virtual css::uno::Any SAL_CALL getByName(const OUString& rName); + virtual css::uno::Sequence<OUString> SAL_CALL getElementNames(); + virtual sal_Bool SAL_CALL hasByName(const OUString& rName); + virtual sal_Bool SAL_CALL hasElements(); + virtual css::uno::Type SAL_CALL getElementType(); + +private: + void addInitialStyles(); + + std::map<OUString, css::uno::Reference<css::chart2::XChartStyle>> maChartStyles; +}; + +ChartStyles::ChartStyles() { addInitialStyles(); } + +ChartStyles::~ChartStyles() {} + +void ChartStyles::addInitialStyles() +{ + css::uno::Any aDefaultStyle; + css::uno::Reference<css::chart2::XChartStyle> xChartStyle = new ChartStyle; + aDefaultStyle <<= xChartStyle; + insertByName("Default", aDefaultStyle); +} + +void ChartStyles::insertByName(const OUString& rName, const css::uno::Any& rStyle) +{ + css::uno::Reference<css::chart2::XChartStyle> xChartStyle; + if (!(rStyle >>= xChartStyle)) + throw css::lang::IllegalArgumentException(); + + maChartStyles[rName] = xChartStyle; +} + +void ChartStyles::removeByName(const OUString& rName) +{ + auto itr = maChartStyles.find(rName); + if (itr == maChartStyles.end()) + throw css::lang::IllegalArgumentException(); + + maChartStyles.erase(itr); +} + +void ChartStyles::replaceByName(const OUString& rName, const css::uno::Any& rStyle) +{ + css::uno::Reference<css::chart2::XChartStyle> xChartStyle; + if (!(rStyle >>= xChartStyle)) + throw css::lang::IllegalArgumentException(); + + auto itr = maChartStyles.find(rName); + if (itr == maChartStyles.end()) + throw css::lang::IllegalArgumentException(); + + maChartStyles[rName] = xChartStyle; +} + +css::uno::Any ChartStyles::getByName(const OUString& rName) +{ + auto itr = maChartStyles.find(rName); + if (itr == maChartStyles.end()) + throw css::lang::IllegalArgumentException(); + + css::uno::Any aRet; + aRet <<= itr->second; + + return aRet; +} + +css::uno::Sequence<OUString> ChartStyles::getElementNames() +{ + return css::uno::Sequence<OUString>(); +} + +sal_Bool ChartStyles::hasByName(const OUString& rName) +{ + auto itr = maChartStyles.find(rName); + if (itr == maChartStyles.end()) + return false; + + return true; +} + +sal_Bool ChartStyles::hasElements() { return !maChartStyles.empty(); } + +css::uno::Type ChartStyles::getElementType() { return css::uno::Type(); } + // // needed by MSC compiler using impl::ChartObjectStyle_Base; IMPLEMENT_FORWARD_XINTERFACE2(ChartObjectStyle, ChartObjectStyle_Base, ::property::OPropertySet) -} // namespace chart2 +namespace +{ +struct theChartStyles + : public rtl::StaticWithInit<css::uno::Reference<css::container::XNameContainer>, + theChartStyles> +{ + css::uno::Reference<css::container::XNameContainer> operator()() { return new ChartStyles; } +}; +} -extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -com_sun_star_comp_chart2_ChartStyle_get_implementation(css::uno::XComponentContext*, - css::uno::Sequence<css::uno::Any> const&) +css::uno::Reference<css::container::XNameContainer> getChartStyles() { - return cppu::acquire(new chart2::ChartStyle); + return theChartStyles::get(); } +} // namespace chart + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits