diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /chart2/source/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'chart2/source/inc')
101 files changed, 10875 insertions, 0 deletions
diff --git a/chart2/source/inc/Axis.hxx b/chart2/source/inc/Axis.hxx new file mode 100644 index 0000000000..902a67487c --- /dev/null +++ b/chart2/source/inc/Axis.hxx @@ -0,0 +1,145 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" +#include "charttoolsdllapi.hxx" +#include "PropertyHelper.hxx" + +namespace chart +{ +class GridProperties; +class Title; + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::chart2::XAxis, + css::chart2::XTitled, + css::lang::XServiceInfo, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + Axis_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS Axis final : + public impl::Axis_Base, + public ::property::OPropertySet +{ +public: + explicit Axis(); + virtual ~Axis() override; + + /// 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +private: + explicit Axis( const Axis & rOther ); + + // late initialization to call after copy-constructing + void Init(); + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + + // ____ OPropertySet ____ + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + +public: + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + // ____ XAxis ____ + virtual void SAL_CALL setScaleData( const css::chart2::ScaleData& rScaleData ) override; + virtual css::chart2::ScaleData SAL_CALL getScaleData() override; + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getGridProperties() override; + virtual css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > > SAL_CALL getSubGridProperties() override; + virtual css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > > SAL_CALL getSubTickProperties() override; + + // ____ XTitled ____ + virtual css::uno::Reference< css::chart2::XTitle > SAL_CALL getTitleObject() override; + virtual void SAL_CALL setTitleObject( + const css::uno::Reference< css::chart2::XTitle >& Title ) override; + + // ____ XCloneable ____ + // Note: the coordinate systems are not cloned! + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + rtl::Reference< ::chart::Title > getTitleObject2() const; + void setTitleObject( const rtl::Reference< ::chart::Title >& xNewTitle ); + + rtl::Reference< ::chart::GridProperties > getGridProperties2(); + std::vector< rtl::Reference< ::chart::GridProperties > > getSubGridProperties2(); + +private: + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + void fireModifyEvent(); + + void AllocateSubGrids(); + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; + + css::chart2::ScaleData m_aScaleData; + + rtl::Reference< ::chart::GridProperties > m_xGrid; + + std::vector< rtl::Reference< ::chart::GridProperties > > m_aSubGridProperties; + + rtl::Reference< ::chart::Title > m_xTitle; +}; + +OOO_DLLPUBLIC_CHARTTOOLS const ::chart::tPropertyValueMap & StaticAxisDefaults(); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx new file mode 100644 index 0000000000..5b9de9d9a1 --- /dev/null +++ b/chart2/source/inc/AxisHelper.hxx @@ -0,0 +1,211 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "charttoolsdllapi.hxx" +#include <com/sun/star/chart2/ScaleData.hpp> +#include <rtl/ref.hxx> + +#include <vector> + +namespace chart { class ChartModel; } +namespace chart { class ExplicitCategoriesProvider; } +namespace chart { class ReferenceSizeProvider; } +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XAxis; } +namespace com::sun::star::chart2 { class XChartDocument; } +namespace com::sun::star::chart2 { class XChartType; } +namespace com::sun::star::chart2 { class XCoordinateSystem; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::chart2 { class XScaling; } +namespace com::sun::star::uno { class XComponentContext; } + +namespace chart +{ +class Axis; +class BaseCoordinateSystem; +class ChartType; +class Diagram; +class GridProperties; + +class OOO_DLLPUBLIC_CHARTTOOLS AxisHelper +{ +public: + static css::uno::Reference< css::chart2::XScaling > createLinearScaling(); + static css::uno::Reference< css::chart2::XScaling > createLogarithmicScaling( double fBase = 10.0 ); + + static css::chart2::ScaleData createDefaultScale(); + + static void removeExplicitScaling( css::chart2::ScaleData& rScaleData ); + + static bool isLogarithmic( const css::uno::Reference< css::chart2::XScaling >& xScaling ); + + static void checkDateAxis( css::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis ); + static css::chart2::ScaleData getDateCheckedScale( const rtl::Reference< ::chart::Axis >& xAxis, ChartModel& rModel ); + + static sal_Int32 getExplicitNumberFormatKeyForAxis( + const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCorrespondingCoordinateSystem + , const rtl::Reference< ::chart::ChartModel>& xChartDoc + , bool bSearchForParallelAxisIfNothingIsFound ); + + static rtl::Reference< ::chart::Axis > + createAxis( sal_Int32 nDimensionIndex, bool bMainAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram + , const css::uno::Reference< css::uno::XComponentContext >& xContext + , ReferenceSizeProvider * pRefSizeProvider = nullptr ); + + static rtl::Reference< ::chart::Axis > + createAxis( + sal_Int32 nDimensionIndex + , sal_Int32 nAxisIndex // 0==main or 1==secondary axis + , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys + , const css::uno::Reference< css::uno::XComponentContext > & xContext + , ReferenceSizeProvider * pRefSizeProvider = nullptr ); + + static void showAxis( sal_Int32 nDimensionIndex, bool bMainAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram + , const css::uno::Reference< css::uno::XComponentContext >& xContext + , ReferenceSizeProvider * pRefSizeProvider = nullptr ); + + static void showGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + + static void hideAxis( sal_Int32 nDimensionIndex, bool bMainAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + static void hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + + static bool isAxisShown( sal_Int32 nDimensionIndex, bool bMainAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + static bool isGridShown( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + + static void makeAxisVisible( const rtl::Reference< ::chart::Axis >& xAxis ); + static void makeGridVisible( const rtl::Reference< ::chart::GridProperties >& xGridProperties ); + + static void makeAxisInvisible( const rtl::Reference< ::chart::Axis >& xAxis ); + static void makeGridInvisible( const rtl::Reference< ::chart::GridProperties >& xGridProperties ); + + static void hideAxisIfNoDataIsAttached( const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram); + + SAL_DLLPRIVATE static bool areAxisLabelsVisible( const rtl::Reference< ::chart::Axis >& xAxisProperties ); + static bool isAxisVisible( const rtl::Reference< ::chart::Axis >& xAxis ); + static bool isGridVisible( const rtl::Reference< ::chart::GridProperties >& xGridProperties ); + + static rtl::Reference< ::chart::BaseCoordinateSystem > + getCoordinateSystemByIndex( + const rtl::Reference< ::chart::Diagram >& xDiagram + , sal_Int32 nIndex ); + + static rtl::Reference< ::chart::BaseCoordinateSystem > + getCoordinateSystemOfAxis( + const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + + static rtl::Reference< ::chart::Axis > + getAxis( sal_Int32 nDimensionIndex, bool bMainAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + static rtl::Reference< ::chart::Axis > + getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex + , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys ); + + static rtl::Reference< ::chart::Axis > + getCrossingMainAxis( const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys ); + + static rtl::Reference< ::chart::Axis > + getParallelAxis( const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + + static rtl::Reference< ::chart::GridProperties > + getGridProperties( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys + , sal_Int32 nDimensionIndex + , sal_Int32 nAxisIndex //0: Primary axis, 1: secondary axis + , sal_Int32 nSubGridIndex //-1: Main Grid; 0: First SubGrid etc + ); + + static sal_Int32 getDimensionIndexOfAxis( + const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram ); + + static bool getIndicesForAxis( + const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys + , sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex ); + + static bool getIndicesForAxis( + const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::Diagram >& xDiagram + , sal_Int32& rOutCooSysIndex, sal_Int32& rOutDimensionIndex, sal_Int32& rOutAxisIndex ); + + /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to + </sal_True> are returned + */ + static std::vector< rtl::Reference< ::chart::Axis > > + getAllAxesOfDiagram( const rtl::Reference< ::chart::Diagram >& xDiagram + , bool bOnlyVisible = false ); + + /** @param bOnlyVisible if </TRUE>, only axes with property "Show" set to + </sal_True> are returned + */ + SAL_DLLPRIVATE static std::vector< rtl::Reference< ::chart::Axis > > + getAllAxesOfCoordinateSystem( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys + , bool bOnlyVisible = false ); + + static std::vector< rtl::Reference< ::chart::GridProperties > > + getAllGrids( const rtl::Reference< ::chart::Diagram >& xDiagram ); + + static void getAxisOrGridPossibilities( css::uno::Sequence< sal_Bool >& rPossibilityList + , const rtl::Reference< ::chart::Diagram>& xDiagram, bool bAxis=true ); + + static void getAxisOrGridExistence( css::uno::Sequence< sal_Bool >& rExistenceList + , const rtl::Reference< ::chart::Diagram>& xDiagram, bool bAxis=true ); + + static bool changeVisibilityOfGrids( const rtl::Reference< ::chart::Diagram>& xDiagram + , const css::uno::Sequence< sal_Bool >& rOldExistenceList + , const css::uno::Sequence< sal_Bool >& rNewExistenceList ); + + static bool changeVisibilityOfAxes( const rtl::Reference< ::chart::Diagram>& xDiagram + , const css::uno::Sequence< sal_Bool >& rOldExistenceList + , const css::uno::Sequence< sal_Bool >& rNewExistenceList + , const css::uno::Reference< css::uno::XComponentContext >& xContext + , ReferenceSizeProvider * pRefSizeProvider ); + + static bool shouldAxisBeDisplayed( const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys ); + static bool isSecondaryYAxisNeeded( const rtl::Reference< + ::chart::BaseCoordinateSystem >& xCooSys ); + + static rtl::Reference< ::chart::ChartType > + getChartTypeByIndex( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys, + sal_Int32 nIndex ); + + static void setRTLAxisLayout( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys ); + + static rtl::Reference< ::chart::ChartType > + getFirstChartTypeWithSeriesAttachedToAxisIndex( const rtl::Reference< ::chart::Diagram >& xDiagram, const sal_Int32 nAttachedAxisIndex ); + + static bool isAxisPositioningEnabled(); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/AxisIndexDefines.hxx b/chart2/source/inc/AxisIndexDefines.hxx new file mode 100644 index 0000000000..5e6d32d691 --- /dev/null +++ b/chart2/source/inc/AxisIndexDefines.hxx @@ -0,0 +1,30 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sal/types.h> + +namespace chart +{ +const sal_Int32 MAIN_AXIS_INDEX = 0; +const sal_Int32 SECONDARY_AXIS_INDEX = 1; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/BaseCoordinateSystem.hxx b/chart2/source/inc/BaseCoordinateSystem.hxx new file mode 100644 index 0000000000..71f226abcd --- /dev/null +++ b/chart2/source/inc/BaseCoordinateSystem.hxx @@ -0,0 +1,129 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart2/XCoordinateSystem.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" + +#include <vector> + +namespace chart +{ +class Axis; +class ChartType; + +namespace impl +{ +typedef ::cppu::WeakImplHelper + < css::lang::XServiceInfo, + css::chart2::XCoordinateSystem, + css::chart2::XChartTypeContainer, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + BaseCoordinateSystem_Base; +} + +class SAL_DLLPUBLIC_RTTI BaseCoordinateSystem : + public impl::BaseCoordinateSystem_Base, + public ::property::OPropertySet +{ +public: + BaseCoordinateSystem( sal_Int32 nDimensionCount ); + explicit BaseCoordinateSystem( const BaseCoordinateSystem & rSource ); + virtual ~BaseCoordinateSystem() override; + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + // ____ XCoordinateSystem ____ + virtual ::sal_Int32 SAL_CALL getDimension() override; + virtual void SAL_CALL setAxisByDimension( + ::sal_Int32 nDimension, + const css::uno::Reference< css::chart2::XAxis >& xAxis, + ::sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::chart2::XAxis > SAL_CALL getAxisByDimension( + ::sal_Int32 nDimension, ::sal_Int32 nIndex ) override; + virtual ::sal_Int32 SAL_CALL getMaximumAxisIndexByDimension( ::sal_Int32 nDimension ) override; + + // ____ XChartTypeContainer ____ + virtual void SAL_CALL addChartType( + const css::uno::Reference< css::chart2::XChartType >& aChartType ) override; + virtual void SAL_CALL removeChartType( + const css::uno::Reference< css::chart2::XChartType >& aChartType ) override; + virtual css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > SAL_CALL getChartTypes() override; + virtual void SAL_CALL setChartTypes( + const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aChartTypes ) final override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + void setAxisByDimension( sal_Int32 nDimension, const rtl::Reference< ::chart::Axis >& xAxis, sal_Int32 nIndex ); + const rtl::Reference< ::chart::Axis > & getAxisByDimension2(sal_Int32 nDimension, sal_Int32 nIndex ) const; + + void setChartTypes( const std::vector< rtl::Reference< ::chart::ChartType > >& aChartTypes ); + const std::vector< rtl::Reference<::chart::ChartType > > & getChartTypes2() const { return m_aChartTypes; } + +protected: + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + void fireModifyEvent(); + +private: + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; + sal_Int32 m_nDimensionCount; + typedef std::vector< std::vector< rtl::Reference< ::chart::Axis > > > tAxisVecVecType; + tAxisVecVecType m_aAllAxis; //outer sequence is the dimension; inner sequence is the axis index that indicates main or secondary axis + std::vector< rtl::Reference<::chart::ChartType > > m_aChartTypes; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/BaseGFXHelper.hxx b/chart2/source/inc/BaseGFXHelper.hxx new file mode 100644 index 0000000000..18481031e2 --- /dev/null +++ b/chart2/source/inc/BaseGFXHelper.hxx @@ -0,0 +1,86 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <basegfx/range/b2irectangle.hxx> +#include <basegfx/tuple/b3dtuple.hxx> +#include <basegfx/vector/b3dvector.hxx> +#include <basegfx/range/b3drange.hxx> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/drawing/HomogenMatrix.hpp> +#include <com/sun/star/drawing/Direction3D.hpp> +#include <com/sun/star/drawing/Position3D.hpp> +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::awt { struct Rectangle; } +namespace com::sun::star::drawing { struct PolyPolygonShape3D; } + +namespace chart::BaseGFXHelper +{ + +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DRange getBoundVolume( const css::drawing::PolyPolygonShape3D& rPolyPoly ); + +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DRange getBoundVolume( const std::vector<std::vector<css::drawing::Position3D>>& rPolyPoly ); + +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B2IRectangle makeRectangle( + const css::awt::Point& rPosition, + const css::awt::Size& rSize ); + +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B2IRectangle makeRectangle( const css::awt::Rectangle& rRect ); + +OOO_DLLPUBLIC_CHARTTOOLS css::awt::Point B2IRectangleToAWTPoint( + const ::basegfx::B2IRectangle& rB2IRectangle ); + +OOO_DLLPUBLIC_CHARTTOOLS css::awt::Size B2IRectangleToAWTSize( + const ::basegfx::B2IRectangle& rB2IRectangle ); + +OOO_DLLPUBLIC_CHARTTOOLS css::awt::Rectangle toAwtRectangle(const basegfx::B2IRectangle& rB2IRectangle); + +::basegfx::B3DVector Direction3DToB3DVector( + const css::drawing::Direction3D& rDirection ); + +css::drawing::Direction3D B3DVectorToDirection3D( + const ::basegfx::B3DVector& rB3DVector ); + +::basegfx::B3DVector Position3DToB3DVector( + const css::drawing::Position3D& rPosition ); + +css::drawing::Position3D B3DVectorToPosition3D( + const ::basegfx::B3DVector& rB3DVector ); + +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix( + const css::drawing::HomogenMatrix & rHomogenMatrix ); + +OOO_DLLPUBLIC_CHARTTOOLS +css::drawing::HomogenMatrix B3DHomMatrixToHomogenMatrix( + const ::basegfx::B3DHomMatrix & rB3DMatrix ); + +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DTuple GetRotationFromMatrix( + const ::basegfx::B3DHomMatrix & rB3DMatrix ); + +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DTuple GetScaleFromMatrix( + const ::basegfx::B3DHomMatrix & rB3DMatrix ); + +void ReduceToRotationMatrix( ::basegfx::B3DHomMatrix & rB3DMatrix ); + +} // namespace chart::BaseGFXHelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/CachedDataSequence.hxx b/chart2/source/inc/CachedDataSequence.hxx new file mode 100644 index 0000000000..e9c1b9d50d --- /dev/null +++ b/chart2/source/inc/CachedDataSequence.hxx @@ -0,0 +1,164 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +// helper classes +#include <cppuhelper/compbase.hxx> +#include <comphelper/uno3.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/propertycontainer.hxx> +#include <comphelper/proparrhlp.hxx> + +// interfaces and types +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/chart2/data/XDataSequence.hpp> +#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> +#include <com/sun/star/chart2/data/XTextualDataSequence.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" + +namespace com::sun::star::uno { class XComponentContext; } + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakComponentImplHelper< + css::chart2::data::XDataSequence, + css::chart2::data::XNumericalDataSequence, + css::chart2::data::XTextualDataSequence, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::lang::XInitialization, + css::lang::XServiceInfo > + CachedDataSequence_Base; +} + +/** + * This sequence object does store actual values within, hence "cached". + */ +class CachedDataSequence final : + public ::comphelper::OMutexAndBroadcastHelper, + public ::comphelper::OPropertyContainer, + public ::comphelper::OPropertyArrayUsageHelper< CachedDataSequence >, + public impl::CachedDataSequence_Base +{ +public: + /** constructs an empty sequence + */ + CachedDataSequence(); + + explicit CachedDataSequence( const css::uno::Reference< css::uno::XComponentContext > & xContext ); + + /** creates a sequence and initializes it with the given string. This is + especially useful for labels, which only have one element. + */ + explicit CachedDataSequence( const OUString & rSingleText ); + + /// Copy CTOR + explicit CachedDataSequence( const CachedDataSequence & rSource ); + + virtual ~CachedDataSequence() override; + + /// declare XServiceInfo methods + 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +private: + // ____ XPropertySet ____ + /// @see css::beans::XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + /// @see ::comphelper::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + /// @see ::comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + + // ____ XDataSequence ____ + virtual css::uno::Sequence< css::uno::Any > SAL_CALL getData() override; + virtual OUString SAL_CALL getSourceRangeRepresentation() override; + virtual css::uno::Sequence< OUString > SAL_CALL generateLabel( + css::chart2::data::LabelOrigin nLabelOrigin ) override; + virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex ) override; + + // ____ XNumericalDataSequence ____ + /// @see css::chart::data::XNumericalDataSequence + virtual css::uno::Sequence< double > SAL_CALL getNumericalData() override; + + // ____ XTextualDataSequence ____ + /// @see css::chart::data::XTextualDataSequence + virtual css::uno::Sequence< OUString > SAL_CALL getTextualData() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // css::lang::XInitialization: + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > & aArguments) override; + + // <properties> + sal_Int32 m_nNumberFormatKey; + OUString m_sRole; + // </properties> + + enum DataType + { + NUMERICAL, + TEXTUAL, + MIXED + }; + + /** This method registers all properties. It should be called by all + constructors. + */ + void registerProperties(); + + /** is used by interface method getNumericalData(). + */ + css::uno::Sequence< double > Impl_getNumericalData() const; + /** is used by interface method getTextualData(). + */ + css::uno::Sequence< OUString > Impl_getTextualData() const; + /** is used by interface method getData(). + */ + css::uno::Sequence< css::uno::Any > Impl_getMixedData() const; + + enum DataType m_eCurrentDataType; + + css::uno::Sequence< double > m_aNumericalSequence; + css::uno::Sequence< OUString > m_aTextualSequence; + css::uno::Sequence< css::uno::Any > m_aMixedSequence; + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChangingResource.hxx b/chart2/source/inc/ChangingResource.hxx new file mode 100644 index 0000000000..bde5b09234 --- /dev/null +++ b/chart2/source/inc/ChangingResource.hxx @@ -0,0 +1,46 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +namespace chart +{ +class ChangingResource; +class ResourceChangeListener +{ +public: + virtual void stateChanged() = 0; + virtual ~ResourceChangeListener(); +}; + +class ChangingResource +{ +public: + ChangingResource(); + virtual ~ChangingResource(); + + void setChangeListener(ResourceChangeListener* pListener); + +protected: + ResourceChangeListener* m_pChangeListener; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/CharacterProperties.hxx b/chart2/source/inc/CharacterProperties.hxx new file mode 100644 index 0000000000..4dd7a4fbd1 --- /dev/null +++ b/chart2/source/inc/CharacterProperties.hxx @@ -0,0 +1,136 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "PropertyHelper.hxx" +#include "FastPropertyIdRanges.hxx" +#include "charttoolsdllapi.hxx" +#include <com/sun/star/awt/FontDescriptor.hpp> + +#include <vector> + +namespace com::sun::star::beans { class XMultiPropertySet; } +namespace com::sun::star::beans { struct Property; } + +namespace chart +{ + +// implements services +// com.sun.star.style.CharacterProperties +// com.sun.star.style.CharacterPropertiesAsian +// com.sun.star.style.CharacterPropertiesComplex +namespace CharacterProperties +{ + // FastProperty Ids for properties + enum + { + // com.sun.star.style.CharacterProperties + PROP_CHAR_FONT_NAME = FAST_PROPERTY_ID_START_CHAR_PROP, // ? + PROP_CHAR_FONT_STYLE_NAME, + PROP_CHAR_FONT_FAMILY, + PROP_CHAR_FONT_CHAR_SET, + PROP_CHAR_FONT_PITCH, + PROP_CHAR_COLOR, +// PROP_CHAR_BACKGROUND_COLOR, +// PROP_CHAR_BACKGROUND_TRANSPARENCY, alpha channel in COLOR + PROP_CHAR_ESCAPEMENT, + PROP_CHAR_CHAR_HEIGHT, + PROP_CHAR_UNDERLINE, + PROP_CHAR_UNDERLINE_COLOR, + PROP_CHAR_UNDERLINE_HAS_COLOR, + PROP_CHAR_OVERLINE, + PROP_CHAR_OVERLINE_COLOR, + PROP_CHAR_OVERLINE_HAS_COLOR, + PROP_CHAR_WEIGHT, + PROP_CHAR_POSTURE, + PROP_CHAR_AUTO_KERNING, + PROP_CHAR_KERNING, +// PROP_CHAR_CASE_MAPPING, +// PROP_CHAR_ROTATION, +//-- PROP_CHAR_ROTATION_IS_FIT_TO_LINE, +// PROP_CHAR_SCALE_WIDTH, + PROP_CHAR_ESCAPEMENT_HEIGHT, + +// PROP_CHAR_CROSSED_OUT, + PROP_CHAR_STRIKE_OUT, + PROP_CHAR_WORD_MODE, +// PROP_CHAR_FLASH, + PROP_CHAR_LOCALE, +//-- PROP_CHAR_KEEP_TOGETHER, +//-- PROP_CHAR_NO_LINE_BREAK, + PROP_CHAR_SHADOWED, + PROP_CHAR_CONTOURED, + PROP_CHAR_RELIEF, +//-- PROP_CHAR_COMBINE_IS_ON, +//-- PROP_CHAR_COMBINE_PREFIX, +//-- PROP_CHAR_COMBINE_SUFFIX, + + PROP_CHAR_EMPHASIS, +// PROP_CHAR_RUBY_TEXT, +// PROP_CHAR_RUBY_ADJUST, +// PROP_CHAR_RUBY_STYLE_NAME, +// PROP_CHAR_RUBY_IS_ABOVE, +// PROP_CHAR_INHIBIT_HYPHENATION, + + // Asian (com.sun.star.style.CharacterPropertiesAsian) + PROP_CHAR_ASIAN_FONT_NAME, + PROP_CHAR_ASIAN_FONT_STYLE_NAME, + PROP_CHAR_ASIAN_FONT_FAMILY, + PROP_CHAR_ASIAN_CHAR_SET, + PROP_CHAR_ASIAN_FONT_PITCH, + PROP_CHAR_ASIAN_CHAR_HEIGHT, + PROP_CHAR_ASIAN_WEIGHT, + PROP_CHAR_ASIAN_POSTURE, + PROP_CHAR_ASIAN_LOCALE, +//-- PROP_CHAR_ASIAN_USE_SCRIPT_TYPE_DISTANCE, +//-- PROP_CHAR_ASIAN_USE_FORBIDDEN_RULES, +//-- PROP_CHAR_ASIAN_HANGING_PUNCTUATION_ALLOWED, + + // Complex Text Layout (com.sun.star.style.CharacterPropertiesComplex) + PROP_CHAR_COMPLEX_FONT_NAME, + PROP_CHAR_COMPLEX_FONT_STYLE_NAME, + PROP_CHAR_COMPLEX_FONT_FAMILY, + PROP_CHAR_COMPLEX_CHAR_SET, + PROP_CHAR_COMPLEX_FONT_PITCH, + PROP_CHAR_COMPLEX_CHAR_HEIGHT, + PROP_CHAR_COMPLEX_WEIGHT, + PROP_CHAR_COMPLEX_POSTURE, + PROP_CHAR_COMPLEX_LOCALE, + PROP_PARA_IS_CHARACTER_DISTANCE, + + PROP_WRITING_MODE, + + // don't use + FAST_PROPERTY_ID_END_CHAR_PROP + }; + + OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector( + std::vector< css::beans::Property > & rOutProperties ); + + OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ); + + OOO_DLLPUBLIC_CHARTTOOLS bool IsCharacterPropertyHandle( sal_Int32 nHandle ); + + OOO_DLLPUBLIC_CHARTTOOLS css::awt::FontDescriptor createFontDescriptorFromPropertySet( + const css::uno::Reference< css::beans::XMultiPropertySet > & xMultiPropSet ); +} + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx new file mode 100644 index 0000000000..9c18af92be --- /dev/null +++ b/chart2/source/inc/ChartModelHelper.hxx @@ -0,0 +1,77 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/awt/Size.hpp> +#include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> + +#include <vector> + +namespace chart { class ChartModel; } +namespace com::sun::star::chart2 { class XChartDocument; } +namespace com::sun::star::chart2 { class XChartType; } +namespace com::sun::star::chart2 { class XCoordinateSystem; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::chart2::data { class XDataProvider; } +namespace com::sun::star::chart2::data { class XRangeHighlighter; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::view { class XSelectionSupplier; } + +namespace chart +{ +class BaseCoordinateSystem; +class ChartType; +class DataSeries; +class Diagram; +class InternalDataProvider; + +class OOO_DLLPUBLIC_CHARTTOOLS ChartModelHelper +{ +public: + static rtl::Reference< InternalDataProvider > createInternalDataProvider( + const rtl::Reference<::chart::ChartModel>& xChartDoc, bool bConnectToModel ); + + static rtl::Reference< ::chart::BaseCoordinateSystem > + getFirstCoordinateSystem( const rtl::Reference<::chart::ChartModel>& xModel ); + + static std::vector< rtl::Reference< ::chart::DataSeries > > + getDataSeries( const rtl::Reference< ::chart::ChartModel > & xModel ); + + static rtl::Reference< ChartType > + getChartTypeOfSeries( + const rtl::Reference<::chart::ChartModel>& xModel + , const rtl::Reference< ::chart::DataSeries >& xGivenDataSeries ); + + static css::awt::Size getDefaultPageSize(); + + static css::awt::Size getPageSize( const rtl::Reference<::chart::ChartModel>& xModel ); + + static void triggerRangeHighlighting( const rtl::Reference<::chart::ChartModel>& xModel ); + + static bool isIncludeHiddenCells( const rtl::Reference<::chart::ChartModel>& xChartModel ); + + static bool setIncludeHiddenCells( bool bIncludeHiddenCells, ChartModel& rModel); + +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartResourceGroupDlgs.hxx b/chart2/source/inc/ChartResourceGroupDlgs.hxx new file mode 100644 index 0000000000..e545854889 --- /dev/null +++ b/chart2/source/inc/ChartResourceGroupDlgs.hxx @@ -0,0 +1,63 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <vcl/weld.hxx> + +namespace chart +{ +class ChartTypeParameter; + +class SplinePropertiesDialog final : public weld::GenericDialogController +{ +public: + explicit SplinePropertiesDialog(weld::Window* pParent); + + void fillControls(const ChartTypeParameter& rParameter); + void fillParameter(ChartTypeParameter& rParameter, bool bSmoothLines); + +private: + DECL_LINK(SplineTypeListBoxHdl, weld::ComboBox&, void); + +private: + std::unique_ptr<weld::ComboBox> m_xLB_Spline_Type; + std::unique_ptr<weld::SpinButton> m_xMF_SplineResolution; + std::unique_ptr<weld::Label> m_xFT_SplineOrder; + std::unique_ptr<weld::SpinButton> m_xMF_SplineOrder; +}; + +class SteppedPropertiesDialog final : public weld::GenericDialogController +{ +public: + explicit SteppedPropertiesDialog(weld::Window* pParent); + + void fillControls(const ChartTypeParameter& rParameter); + void fillParameter(ChartTypeParameter& rParameter, bool bSteppedLines); + +private: + std::unique_ptr<weld::RadioButton> m_xRB_Start; + std::unique_ptr<weld::RadioButton> m_xRB_End; + std::unique_ptr<weld::RadioButton> m_xRB_CenterX; + std::unique_ptr<weld::RadioButton> m_xRB_CenterY; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartResourceGroups.hxx b/chart2/source/inc/ChartResourceGroups.hxx new file mode 100644 index 0000000000..9ae397d84f --- /dev/null +++ b/chart2/source/inc/ChartResourceGroups.hxx @@ -0,0 +1,147 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "res_BarGeometry.hxx" +#include "ChangingResource.hxx" +#include "ChartTypeDialogController.hxx" +#include "ChartResourceGroupDlgs.hxx" + +namespace chart +{ +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +class SplinePropertiesDialog; +class SteppedPropertiesDialog; + +enum +{ + POS_3DSCHEME_SIMPLE = 0, + POS_3DSCHEME_REALISTIC = 1 +}; + +class Dim3DLookResourceGroup final : public ChangingResource +{ +public: + explicit Dim3DLookResourceGroup(weld::Builder* pBuilder); + + void showControls(bool bShow); + + void fillControls(const ChartTypeParameter& rParameter); + void fillParameter(ChartTypeParameter& rParameter); + +private: + DECL_LINK(Dim3DLookCheckHdl, weld::Toggleable&, void); + DECL_LINK(SelectSchemeHdl, weld::ComboBox&, void); + +private: + std::unique_ptr<weld::CheckButton> m_xCB_3DLook; + std::unique_ptr<weld::ComboBox> m_xLB_Scheme; +}; + +class SortByXValuesResourceGroup final : public ChangingResource +{ +public: + explicit SortByXValuesResourceGroup(weld::Builder* pBuilder); + + void showControls(bool bShow); + + void fillControls(const ChartTypeParameter& rParameter); + void fillParameter(ChartTypeParameter& rParameter); + +private: + DECL_LINK(SortByXValuesCheckHdl, weld::Toggleable&, void); + +private: + std::unique_ptr<weld::CheckButton> m_xCB_XValueSorting; +}; + +class StackingResourceGroup final : public ChangingResource +{ +public: + explicit StackingResourceGroup(weld::Builder* pBuilder); + + void showControls(bool bShow); + + void fillControls(const ChartTypeParameter& rParameter); + void fillParameter(ChartTypeParameter& rParameter); + +private: + DECL_LINK(StackingChangeHdl, weld::Toggleable&, void); + DECL_LINK(StackingEnableHdl, weld::Toggleable&, void); + +private: + std::unique_ptr<weld::CheckButton> m_xCB_Stacked; + std::unique_ptr<weld::RadioButton> m_xRB_Stack_Y; + std::unique_ptr<weld::RadioButton> m_xRB_Stack_Y_Percent; + std::unique_ptr<weld::RadioButton> m_xRB_Stack_Z; +}; + +#define POS_LINETYPE_STRAIGHT 0 +#define POS_LINETYPE_SMOOTH 1 +#define POS_LINETYPE_STEPPED 2 + +class SplineResourceGroup final : public ChangingResource +{ +public: + explicit SplineResourceGroup(weld::Builder* pBuilder, weld::Window* pParent); + + void showControls(bool bShow); + + void fillControls(const ChartTypeParameter& rParameter); + void fillParameter(ChartTypeParameter& rParameter); + +private: + DECL_LINK(LineTypeChangeHdl, weld::ComboBox&, void); + DECL_LINK(SplineDetailsDialogHdl, weld::Button&, void); + DECL_LINK(SteppedDetailsDialogHdl, weld::Button&, void); + std::shared_ptr<SplinePropertiesDialog> getSplinePropertiesDialog(); + std::shared_ptr<SteppedPropertiesDialog> getSteppedPropertiesDialog(); + +private: + weld::Window* m_pParent; + std::unique_ptr<weld::Label> m_xFT_LineType; + std::unique_ptr<weld::ComboBox> m_xLB_LineType; + std::unique_ptr<weld::Button> m_xPB_DetailsDialog; + std::shared_ptr<SplinePropertiesDialog> m_xSplinePropertiesDialog; + std::shared_ptr<SteppedPropertiesDialog> m_xSteppedPropertiesDialog; +}; + +class GeometryResourceGroup final : public ChangingResource +{ +public: + explicit GeometryResourceGroup(weld::Builder* pBuilder); + + void showControls(bool bShow); + + void fillControls(const ChartTypeParameter& rParameter); + void fillParameter(ChartTypeParameter& rParameter); + +private: + DECL_LINK(GeometryChangeHdl, weld::TreeView&, void); + +private: + BarGeometryResources m_aGeometryResources; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartType.hxx b/chart2/source/inc/ChartType.hxx new file mode 100644 index 0000000000..267d06f406 --- /dev/null +++ b/chart2/source/inc/ChartType.hxx @@ -0,0 +1,161 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart2/XChartType.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include <rtl/ref.hxx> + +#include <vector> +#include "charttoolsdllapi.hxx" + +namespace chart +{ +class BaseCoordinateSystem; +class DataSeries; +class ModifyEventForwarder; + +enum +{ + PROP_PIECHARTTYPE_USE_RINGS, + PROP_PIECHARTTYPE_3DRELATIVEHEIGHT +}; + + + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::chart2::XChartType, + css::chart2::XDataSeriesContainer, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + ChartType_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS ChartType : + public impl::ChartType_Base, + public ::property::OPropertySet +{ +public: + explicit ChartType(); + virtual ~ChartType() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + + explicit ChartType( const ChartType & rOther ); + + // ____ XChartType ____ + // still abstract ! implement ! + virtual OUString SAL_CALL getChartType() override = 0; + virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL + createCoordinateSystem( ::sal_Int32 DimensionCount ) final override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedMandatoryRoles() override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedOptionalRoles() override; + virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override; + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedPropertyRoles() override; + + // ____ XDataSeriesContainer ____ + virtual void SAL_CALL addDataSeries( + const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override; + virtual void SAL_CALL removeDataSeries( + const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override; + virtual css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > > SAL_CALL getDataSeries() override; + virtual void SAL_CALL setDataSeries( + const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aDataSeries ) override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + virtual rtl::Reference<ChartType> cloneChartType() const = 0; + + void addDataSeries( + const rtl::Reference< ::chart::DataSeries >& aDataSeries ); + void removeDataSeries( + const rtl::Reference< ::chart::DataSeries >& aDataSeries ); + void setDataSeries( + const std::vector< rtl::Reference< ::chart::DataSeries > >& aDataSeries ); + const std::vector< rtl::Reference< ::chart::DataSeries > > & getDataSeries2() const { return m_aDataSeries; } + + virtual rtl::Reference< ::chart::BaseCoordinateSystem > + createCoordinateSystem2( sal_Int32 DimensionCount ); + +protected: + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + void fireModifyEvent(); + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +protected: + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; + +private: + void impl_addDataSeriesWithoutNotification( + const rtl::Reference< ::chart::DataSeries >& aDataSeries ); + +private: + typedef + std::vector< rtl::Reference< ::chart::DataSeries > > tDataSeriesContainerType; + + // --- mutable members: the following members need mutex guard --- + + tDataSeriesContainerType m_aDataSeries; + + bool m_bNotifyChanges; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartTypeDialogController.hxx b/chart2/source/inc/ChartTypeDialogController.hxx new file mode 100644 index 0000000000..4c03ff269e --- /dev/null +++ b/chart2/source/inc/ChartTypeDialogController.hxx @@ -0,0 +1,325 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sal/config.h> + +#include <map> + +#include "ChangingResource.hxx" +#include "ThreeDHelper.hxx" + +#include <com/sun/star/chart2/CurveStyle.hpp> +#include <vcl/weld.hxx> + +namespace com::sun::star::beans +{ +class XPropertySet; +} +namespace com::sun::star::chart2 +{ +class XChartDocument; +} +namespace com::sun::star::lang +{ +class XMultiServiceFactory; +} + +class ValueSet; + +namespace chart +{ +class ChartModel; +class ChartTypeTemplate; +class ChartTypeManager; + +enum GlobalStackMode +{ + GlobalStackMode_NONE, + GlobalStackMode_STACK_Y, + GlobalStackMode_STACK_Y_PERCENT, + GlobalStackMode_STACK_Z +}; + +class ChartTypeParameter +{ +public: + ChartTypeParameter(sal_Int32 nSubTypeIndex, bool bXAxisWithValues = false, bool b3DLook = false, + GlobalStackMode eStackMode = GlobalStackMode_NONE, bool _bSymbols = true, + bool _bLines = true, + css::chart2::CurveStyle eCurveStyle = css::chart2::CurveStyle_LINES); + ChartTypeParameter(); + + bool mapsToSameService(const ChartTypeParameter& rParameter) const; + bool mapsToSimilarService(const ChartTypeParameter& rParameter, + sal_Int32 nTheHigherTheLess) const; + + sal_Int32 nSubTypeIndex; //starting with 1 + + bool bXAxisWithValues; + bool b3DLook; + bool bSymbols; + bool bLines; + + GlobalStackMode eStackMode; + css::chart2::CurveStyle eCurveStyle; + + sal_Int32 nCurveResolution; + sal_Int32 nSplineOrder; + + sal_Int32 nGeometry3D; + + ThreeDLookScheme eThreeDLookScheme; + bool bSortByXValues; + + bool mbRoundedEdge; +}; + +typedef std::map<OUString, ChartTypeParameter> tTemplateServiceChartTypeParameterMap; + +class ChartTypeDialogController : public ChangingResource +{ +public: + ChartTypeDialogController(); + virtual ~ChartTypeDialogController() override; + + virtual OUString getName() = 0; + virtual OUString getImage() = 0; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const = 0; + virtual void fillSubTypeList(ValueSet& rSubTypeList, const ChartTypeParameter& rParameter); + + virtual bool shouldShow_3DLookControl() const; + virtual bool shouldShow_StackingControl() const; + virtual bool shouldShow_SplineControl() const; + virtual bool shouldShow_GeometryControl() const; + virtual bool shouldShow_SortByXValuesResourceGroup() const; + + virtual void showExtraControls(weld::Builder* pBuilder); + virtual void hideExtraControls() const; + virtual void + fillExtraControls(const rtl::Reference<::chart::ChartModel>& xChartModel, + const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps) const; + /// @throws css::uno::RuntimeException + virtual void setTemplateProperties( + const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps) const; + + bool isSubType(const OUString& rServiceName); + ChartTypeParameter getChartTypeParameterForService( + const OUString& rServiceName, + const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps); + virtual void adjustSubTypeAndEnableControls( + ChartTypeParameter& + rParameter); //if you have different counts of subtypes you may need to adjust the index + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter); + virtual void adjustParameterToMainType(ChartTypeParameter& rParameter); + OUString getServiceNameForParameter(const ChartTypeParameter& rParameter) const; + void commitToModel(const ChartTypeParameter& rParameter, + const rtl::Reference<::chart::ChartModel>& xChartModel); + rtl::Reference<::chart::ChartTypeTemplate> + getCurrentTemplate(const ChartTypeParameter& rParameter, + const rtl::Reference<::chart::ChartTypeManager>& xTemplateManager) const; + +protected: + bool bSupportsXAxisWithValues; + bool bSupports3D; +}; + +class ColumnOrBarChartDialogController_Base : public ChartTypeDialogController +{ +public: + ColumnOrBarChartDialogController_Base(); + virtual ~ColumnOrBarChartDialogController_Base() override; + + virtual bool shouldShow_3DLookControl() const override; + virtual bool shouldShow_GeometryControl() const override; + + virtual void adjustSubTypeAndEnableControls(ChartTypeParameter& rParameter) override; +}; + +class ColumnChartDialogController final : public ColumnOrBarChartDialogController_Base +{ +public: + ColumnChartDialogController(); + virtual ~ColumnChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; +}; + +class BarChartDialogController final : public ColumnOrBarChartDialogController_Base +{ +public: + BarChartDialogController(); + virtual ~BarChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; +}; + +class PieChartDialogController final : public ChartTypeDialogController +{ +public: + PieChartDialogController(); + virtual ~PieChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override; + + virtual bool shouldShow_3DLookControl() const override; +}; + +class LineChartDialogController final : public ChartTypeDialogController +{ +public: + LineChartDialogController(); + virtual ~LineChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override; + virtual void adjustParameterToMainType(ChartTypeParameter& rParameter) override; + + virtual bool shouldShow_StackingControl() const override; + virtual bool shouldShow_SplineControl() const override; +}; + +class XYChartDialogController final : public ChartTypeDialogController +{ +public: + XYChartDialogController(); + virtual ~XYChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override; + + virtual bool shouldShow_SplineControl() const override; + virtual bool shouldShow_SortByXValuesResourceGroup() const override; +}; + +class AreaChartDialogController final : public ChartTypeDialogController +{ +public: + AreaChartDialogController(); + virtual ~AreaChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override; + virtual void adjustParameterToMainType(ChartTypeParameter& rParameter) override; + + virtual bool shouldShow_3DLookControl() const override; +}; + +class NetChartDialogController final : public ChartTypeDialogController +{ +public: + NetChartDialogController(); + virtual ~NetChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override; + + virtual bool shouldShow_StackingControl() const override; +}; + +class StockChartDialogController final : public ChartTypeDialogController +{ +public: + StockChartDialogController(); + virtual ~StockChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override; +}; + +class CombiColumnLineChartDialogController final : public ChartTypeDialogController +{ +public: + CombiColumnLineChartDialogController(); + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override; + + virtual void showExtraControls(weld::Builder* pBuilder) override; + virtual void hideExtraControls() const override; + virtual void fillExtraControls( + const rtl::Reference<::chart::ChartModel>& xChartModel, + const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps) const override; + + virtual void setTemplateProperties( + const css::uno::Reference<css::beans::XPropertySet>& xTemplateProps) const override; + +private: + DECL_LINK(ChangeLineCountHdl, weld::SpinButton&, void); + +private: + std::unique_ptr<weld::Label> m_xFT_NumberOfLines; + std::unique_ptr<weld::SpinButton> m_xMF_NumberOfLines; +}; + +class BubbleChartDialogController final : public ChartTypeDialogController +{ +public: + BubbleChartDialogController(); + virtual ~BubbleChartDialogController() override; + + virtual OUString getName() override; + virtual OUString getImage() override; + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const override; + virtual void fillSubTypeList(ValueSet& rSubTypeList, + const ChartTypeParameter& rParameter) override; + virtual void adjustParameterToSubType(ChartTypeParameter& rParameter) override; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx new file mode 100644 index 0000000000..379f96ad0e --- /dev/null +++ b/chart2/source/inc/ChartTypeHelper.hxx @@ -0,0 +1,90 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/drawing/Direction3D.hpp> +#include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> + +namespace com::sun::star::chart2 { class XChartType; } +namespace com::sun::star::chart2 { class XDataSeries; } + +namespace chart +{ +class ChartType; +class DataSeries; + +class OOO_DLLPUBLIC_CHARTTOOLS ChartTypeHelper +{ +public: + static bool isSupportingGeometryProperties( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingStatisticProperties( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingRegressionProperties(const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingMainAxis( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex ); + static bool isSupportingSecondaryAxis( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingAreaProperties( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingSymbolProperties( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingOverlapAndGapWidthProperties( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingBarConnectors( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingRightAngledAxes( const rtl::Reference< ::chart::ChartType >& xChartType ); + static bool isSupportingAxisSideBySide( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool isSupportingStartingAngle( const rtl::Reference< ::chart::ChartType >& xChartType ); + //starting value for bars or baseline for areas for example + static bool isSupportingBaseValue( const rtl::Reference< ::chart::ChartType >& xChartType ); + static bool isSupportingAxisPositioning( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex ); + static bool isSupportingDateAxis( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionIndex ); + static bool isSupportingComplexCategory( const rtl::Reference< ::chart::ChartType >& xChartType ); + static bool isSupportingCategoryPositioning( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool shiftCategoryPosAtXAxisPerDefault( const rtl::Reference< ::chart::ChartType >& xChartType ); + + //returns sequence of css::chart::DataLabelPlacement + static css::uno::Sequence < sal_Int32 > getSupportedLabelPlacements( + const rtl::Reference< ::chart::ChartType >& xChartType, bool bSwapXAndY + , const rtl::Reference< ::chart::DataSeries >& xSeries ); + + //returns sequence of css::chart::MissingValueTreatment + static css::uno::Sequence < sal_Int32 > getSupportedMissingValueTreatments( + const rtl::Reference< ::chart::ChartType >& xChartType ); + + SAL_DLLPRIVATE static css::drawing::Direction3D getDefaultSimpleLightDirection( const rtl::Reference< ::chart::ChartType >& xChartType ); + SAL_DLLPRIVATE static css::drawing::Direction3D getDefaultRealisticLightDirection( const rtl::Reference< ::chart::ChartType >& xChartType ); + SAL_DLLPRIVATE static sal_Int32 getDefaultDirectLightColor( bool bSimple, const rtl::Reference< ::chart::ChartType >& xChartType ); + SAL_DLLPRIVATE static sal_Int32 getDefaultAmbientLightColor( bool bSimple, const rtl::Reference< ::chart::ChartType >& xChartType ); + static sal_Int32 getNumberOfDisplayedSeries( const rtl::Reference< ::chart::ChartType >& xChartType, sal_Int32 nNumberOfSeries ); + SAL_DLLPRIVATE static bool noBordersForSimpleScheme( const rtl::Reference< ::chart::ChartType >& xChartType ); + + static bool isSeriesInFrontOfAxisLine( const rtl::Reference< ::chart::ChartType >& xChartType ); + + static sal_Int32 //one of css::chart2::AxisType + getAxisType( const rtl::Reference< ::chart::ChartType >& xChartType + , sal_Int32 nDimensionIndex ); + + static OUString getRoleOfSequenceForYAxisNumberFormatDetection( const rtl::Reference< + ::chart::ChartType >& xChartType ); + + static OUString getRoleOfSequenceForDataLabelNumberFormatDetection( const rtl::Reference< + ::chart::ChartType >& xChartType ); + + static bool isSupportingOnlyDeepStackingFor3D( const rtl::Reference< ::chart::ChartType >& xChartType ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartTypeTemplate.hxx b/chart2/source/inc/ChartTypeTemplate.hxx new file mode 100644 index 0000000000..b22165e79f --- /dev/null +++ b/chart2/source/inc/ChartTypeTemplate.hxx @@ -0,0 +1,283 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <cppuhelper/implbase.hxx> +#include "DataInterpreter.hxx" +#include "StackMode.hxx" +#include <com/sun/star/chart2/XChartTypeTemplate.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> +#include <vector> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::chart2 { class XChartType; } +namespace com::sun::star::chart2 { class XCoordinateSystem; } +namespace com::sun::star::chart2 { class XCoordinateSystemContainer; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::chart2::data { class XDataSource; } +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } +namespace com::sun::star::uno { class XComponentContext; } + +namespace chart +{ +class BaseCoordinateSystem; +class ChartType; +class DataSeries; +class Diagram; +class LabeledDataSequence; + +/** For creating diagrams and modifying existing diagrams. A base class that + implements XChartTypeTemplate and offers some tooling for classes that + derive from this class. + + createDiagramByDataSource + + This does the following steps using some virtual helper-methods, that may be + overridden by derived classes: + + * creates an XDiagram via service-factory. + + * convert the given XDataSource to a sequence of XDataSeries using the + method createDataSeries(). In this class the DataInterpreter helper class + is used to create a standard interpretation (just y-values). + + * call applyDefaultStyle() for all XDataSeries in order to apply default + styles. In this class the series get the system-wide default colors as + "Color" property. + + * call applyStyle() for applying chart-type specific styles to all series. + The default implementation is empty. + + * call createCoordinateSystems() and apply them to the diagram. As + default one cartesian system with Scales using a linear Scaling is + created. + + * createChartTypes() is called in order to define the structure of the + diagram. For details see comment of this function. As default this + method creates a tree where all series appear in one branch with the chart + type determined by getChartTypeForNewSeries(). The stacking is determined + via the method getStackMode(). + + * create an XLegend via the global service factory, set it at the diagram. + */ +class OOO_DLLPUBLIC_CHARTTOOLS ChartTypeTemplate : public ::cppu::WeakImplHelper< + css::chart2::XChartTypeTemplate, + css::lang::XServiceName > +{ +public: + explicit ChartTypeTemplate( css::uno::Reference< css::uno::XComponentContext > const & xContext, + OUString aServiceName ); + virtual ~ChartTypeTemplate() override; + + rtl::Reference< ::chart::Diagram > createDiagramByDataSource2( + const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource, + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ); + + // ____ XChartTypeTemplate ____ + virtual css::uno::Reference< css::chart2::XDiagram > SAL_CALL createDiagramByDataSource( + const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource, + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override final; + /// denotes if the chart needs categories at the first scale + virtual sal_Bool SAL_CALL supportsCategories() override; + virtual void SAL_CALL changeDiagram( + const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override final; + virtual void SAL_CALL changeDiagramData( + const css::uno::Reference< css::chart2::XDiagram >& xDiagram, + const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource, + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override final; + virtual sal_Bool SAL_CALL matchesTemplate( + const css::uno::Reference< css::chart2::XDiagram >& xDiagram, + sal_Bool bAdaptProperties ) override final; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getDataInterpreter() override final; + virtual css::uno::Reference< ::css::chart2::XChartType > SAL_CALL getChartTypeForNewSeries( + const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override final; + virtual void SAL_CALL applyStyle( + const css::uno::Reference< css::chart2::XDataSeries >& xSeries, + ::sal_Int32 nChartTypeIndex, + ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount ) override final; + virtual void SAL_CALL resetStyles( + const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override final; + + void changeDiagram( + const rtl::Reference< ::chart::Diagram >& xDiagram ); + void changeDiagramData( + const rtl::Reference< ::chart::Diagram >& xDiagram, + const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource, + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ); + virtual bool matchesTemplate2( + const rtl::Reference< ::chart::Diagram >& xDiagram, + bool bAdaptProperties ); + virtual rtl::Reference< ::chart::ChartType > + getChartTypeForNewSeries2( const std::vector< + rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) = 0; + virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2(); + virtual void applyStyle2( + const rtl::Reference< ::chart::DataSeries >& xSeries, + ::sal_Int32 nChartTypeIndex, + ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount ); + virtual void resetStyles2( + const rtl::Reference< ::chart::Diagram >& xDiagram ); + + /// @throws css::uno::RuntimeException + void applyStyles( + const rtl::Reference< ::chart::Diagram >& xDiagram ); + + // ____ XServiceName ____ + virtual OUString SAL_CALL getServiceName() override; + + // Methods to override for automatic creation + + /// returns 2 by default. Supported are 2 and 3 + virtual sal_Int32 getDimension() const; + + /** returns StackMode::NONE by default. This is a global flag used for all + series of a specific chart type. If percent stacking is supported, the + percent stacking mode is retrieved from the first chart type (index 0) + + @param nChartTypeIndex denotes the index of the charttype in means + defined by the template creation order, i.e., 0 means the first + chart type that a template creates. + */ + virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const; + + virtual rtl::Reference< ::chart::ChartType > + getChartTypeForIndex( sal_Int32 nChartTypeIndex ) = 0; + + virtual bool isSwapXAndY() const; + + // Methods for creating the diagram piecewise + + /** Allows derived classes to manipulate the diagrams whole, like changing + the wall color. The default implementation is empty. It is called by + FillDiagram which is called by createDiagramByDataSource and + changeDiagram + */ + virtual void adaptDiagram( + const rtl::Reference< ::chart::Diagram > & xDiagram ); + + /** Creates a 2d or 3d cartesian coordinate system with mathematically + oriented, linear scales with auto-min/max. If the given + CoordinateSystemContainer is not empty, those coordinate system should + be reused. + + <p>The dimension depends on the value returned by getDimension().</p> + */ + virtual void createCoordinateSystems( + const rtl::Reference< ::chart::Diagram > & xDiagram ); + + /** Sets categories at the scales of dimension 0 and the percent stacking at + the scales of dimension 1 of all given coordinate systems. + + <p>Called by FillDiagram.</p> + */ + virtual void adaptScales( + const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & aCooSysSeq, + const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xCategories ); + + /** create a data series tree, that fits the requirements of the chart type. + + <p>As default, this creates a tree with the following structure:</p> + + <pre> + root + | + +-- chart type (determined by getChartTypeForNewSeries()) + | + +-- category (DiscreteStackableScaleGroup using scale 0) + | + +-- values (ContinuousStackableScaleGroup using scale 1) + | + +-- series 0 + | + +-- series 1 + | + ... + | + +.. series n-1 + </pre> + + <p>If there are less than two scales available the returned tree is + empty.</p> + */ + virtual void createChartTypes( + const std::vector< + std::vector< + rtl::Reference< + ::chart::DataSeries > > > & aSeriesSeq, + const std::vector< + rtl::Reference< + ::chart::BaseCoordinateSystem > > & rCoordSys, + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq + ); + + /** create axes and add them to the given container. If there are already + compatible axes in the container these should be maintained. + + <p>As default, this method creates as many axes as there are dimensions + in the given first coordinate system. Each of the axis + represents one of the dimensions of the coordinate systems. If there are series + requesting a secondary axes a secondary y axes is added</p> + */ + void createAxes( + const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & rCoordSys ); + + /** Give the number of requested axis per dimension here. Default is one + axis for each dimension + */ + virtual sal_Int32 getAxisCountByDimension( sal_Int32 nDimension ); + + /** adapt properties of existing axes and remove superfluous axes + */ + virtual void adaptAxes( + const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & rCoordSys ); + + const css::uno::Reference< css::uno::XComponentContext >& + GetComponentContext() const { return m_xContext;} + + static void copyPropertiesFromOldToNewCoordinateSystem( + const std::vector< rtl::Reference< ChartType > > & rOldChartTypesSeq, + const rtl::Reference< ChartType > & xNewChartType ); + +protected: + css::uno::Reference< css::uno::XComponentContext > m_xContext; + mutable rtl::Reference< ::chart::DataInterpreter > m_xDataInterpreter; + +private: + const OUString m_aServiceName; + +private: + /** modifies the given diagram + */ + void FillDiagram( const rtl::Reference< ::chart::Diagram >& xDiagram, + const std::vector< + std::vector< + rtl::Reference< + ::chart::DataSeries > > > & aSeriesSeq, + const css::uno::Reference< css::chart2::data::XLabeledDataSequence >& xCategories, + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq); +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartTypeTemplateProvider.hxx b/chart2/source/inc/ChartTypeTemplateProvider.hxx new file mode 100644 index 0000000000..400b1c8e28 --- /dev/null +++ b/chart2/source/inc/ChartTypeTemplateProvider.hxx @@ -0,0 +1,37 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <rtl/ref.hxx> + +namespace chart +{ +class ChartTypeTemplate; + +class ChartTypeTemplateProvider +{ +public: + virtual rtl::Reference<::chart::ChartTypeTemplate> getCurrentTemplate() const = 0; + virtual ~ChartTypeTemplateProvider() {} +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ChartViewHelper.hxx b/chart2/source/inc/ChartViewHelper.hxx new file mode 100644 index 0000000000..be70dd9fec --- /dev/null +++ b/chart2/source/inc/ChartViewHelper.hxx @@ -0,0 +1,44 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> + +#include <com/sun/star/uno/Reference.hxx> + +namespace com::sun::star::chart2 +{ +class XChartDocument; +} + +namespace chart +{ +class ChartModel; + +namespace ChartViewHelper +{ +OOO_DLLPUBLIC_CHARTTOOLS void setViewToDirtyState(const rtl::Reference<ChartModel>& xChartModel); +OOO_DLLPUBLIC_CHARTTOOLS void +setViewToDirtyState_UNO(const css::uno::Reference<css::chart2::XChartDocument>& xChartModel); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/CloneHelper.hxx b/chart2/source/inc/CloneHelper.hxx new file mode 100644 index 0000000000..c0896efb5c --- /dev/null +++ b/chart2/source/inc/CloneHelper.hxx @@ -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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/util/XCloneable.hpp> +#include <rtl/ref.hxx> +#include <algorithm> +#include <iterator> +#include <vector> + +namespace chart::CloneHelper +{ + +/// functor that clones a UNO-Reference +template< class Interface > + struct CreateRefClone +{ + css::uno::Reference<Interface> operator() ( const css::uno::Reference<Interface> & xOther ) + { + css::uno::Reference<Interface> xResult; + css::uno::Reference< css::util::XCloneable > + xCloneable( xOther, css::uno::UNO_QUERY ); + if( xCloneable.is()) + xResult.set( xCloneable->createClone(), css::uno::UNO_QUERY ); + + return xResult; + } +}; + +/// clones a vector of UNO-References +template< class Interface > + void CloneRefVector( + const std::vector< css::uno::Reference< Interface > > & rSource, + std::vector< css::uno::Reference< Interface > > & rDestination ) +{ + std::transform( rSource.begin(), rSource.end(), + std::back_inserter( rDestination ), + CreateRefClone< Interface >()); +} + +template< class T > + void CloneRefVector( + const std::vector< rtl::Reference< T > > & rSource, + std::vector< rtl::Reference< T > > & rDestination ) +{ + for (const auto & rSourceItem : rSource) + rDestination.push_back(static_cast<T*>(rSourceItem->createClone().get())); +} + +/// clones a UNO-sequence of UNO-References +template< class Interface > + void CloneRefSequence( + const css::uno::Sequence< css::uno::Reference<Interface> > & rSource, + css::uno::Sequence< css::uno::Reference<Interface> > & rDestination ) +{ + rDestination.realloc( rSource.getLength()); + std::transform( rSource.begin(), rSource.end(), + rDestination.getArray(), + CreateRefClone< Interface >()); +} + +} // namespace chart::CloneHelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ColorPerPointHelper.hxx b/chart2/source/inc/ColorPerPointHelper.hxx new file mode 100644 index 0000000000..43a8d56802 --- /dev/null +++ b/chart2/source/inc/ColorPerPointHelper.hxx @@ -0,0 +1,50 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +namespace chart +{ +class DataSeries; + +class OOO_DLLPUBLIC_CHARTTOOLS ColorPerPointHelper +{ +public: + static bool hasPointOwnColor( + const rtl::Reference< ::chart::DataSeries >& xDataSeries + , sal_Int32 nPointIndex + , const css::uno::Reference< css::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance + ); + + // returns true if AttributedDataPoints contains nPointIndex and the + // property Color is DEFAULT + SAL_DLLPRIVATE static bool hasPointOwnProperties( + const rtl::Reference< ::chart::DataSeries >& xDataSeries + , sal_Int32 nPointIndex ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/CommonConverters.hxx b/chart2/source/inc/CommonConverters.hxx new file mode 100644 index 0000000000..c6dc7b2ecd --- /dev/null +++ b/chart2/source/inc/CommonConverters.hxx @@ -0,0 +1,219 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/drawing/Direction3D.hpp> +#include <com/sun/star/drawing/HomogenMatrix.hpp> +#include <com/sun/star/drawing/HomogenMatrix3.hpp> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> +#include <com/sun/star/drawing/Position3D.hpp> +#include <com/sun/star/drawing/PolyPolygonShape3D.hpp> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/point/b3dpoint.hxx> +#include <basegfx/vector/b3dvector.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::awt { struct Rectangle; } +namespace com::sun::star::chart2::data { class XDataSequence; } +namespace com::sun::star::drawing { struct PolyPolygonBezierCoords; } + +namespace chart +{ + +/** +diverse methods for class conversions; e.g. ::basegfx::B3DHomMatrix to HomogenMatrix +and operations e.g drawing::Position3D + drawing::Direction3D +*/ + +/** ::basegfx::B3DHomMatrix -> HomogenMatrix +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::HomogenMatrix + B3DHomMatrixToHomogenMatrix( const ::basegfx::B3DHomMatrix& rM ); + +/** HomogenMatrix -> ::basegfx::B3DHomMatrix +*/ +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix( const css::drawing::HomogenMatrix& rHM ); + +/** ::basegfx::B3DHomMatrix -> B2DHomMatrix +*/ +OOO_DLLPUBLIC_CHARTTOOLS +::basegfx::B2DHomMatrix IgnoreZ( const ::basegfx::B3DHomMatrix& rM ); + +/** B2DHomMatrix <-> HomogenMatrix3 +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::HomogenMatrix3 + B2DHomMatrixToHomogenMatrix3( const ::basegfx::B2DHomMatrix& rM ); + +/** Position3D -> B3DPoint +*/ +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DPoint Position3DToB3DPoint( const css::drawing::Position3D& rPosition ); + +/** B3DVector -> Direction3D +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Direction3D B3DVectorToDirection3D( const ::basegfx::B3DVector& rVector); + +/** B3DPoint -> Position3D +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D B3DPointToPosition3D( const ::basegfx::B3DPoint& rPoint); + +/** Direction3D -> B3DVector +*/ +OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DVector Direction3DToB3DVector( const css::drawing::Direction3D& rDirection); + +/** PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D +*/ +OOO_DLLPUBLIC_CHARTTOOLS +void AddPointToPoly( css::drawing::PolyPolygonShape3D& rPoly + , const css::drawing::Position3D& rPos + , sal_Int32 nSequenceIndex=0 ); +OOO_DLLPUBLIC_CHARTTOOLS +void AddPointToPoly( std::vector<std::vector<css::drawing::Position3D>>& rPoly + , const css::drawing::Position3D& rPos + , sal_Int32 nSequenceIndex=0 ); + +/** get a single Point from a Polygon +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D getPointFromPoly( + const std::vector<std::vector<css::drawing::Position3D>>& rPolygon + , sal_Int32 nPointIndex, sal_Int32 nPolyIndex ); +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D getPointFromPoly( + const css::drawing::PolyPolygonShape3D& rPolygon + , sal_Int32 nPointIndex, sal_Int32 nPolyIndex ); + +OOO_DLLPUBLIC_CHARTTOOLS +void addPolygon( std::vector<std::vector<css::drawing::Position3D>>& rRet + , const std::vector<std::vector<css::drawing::Position3D>>& rAdd ); +/** PolyPolygonShape3D + PolyPolygonShape3D -> PolyPolygonShape3D +*/ +OOO_DLLPUBLIC_CHARTTOOLS +void appendPoly( std::vector<std::vector<css::drawing::Position3D>>& rRet + , const std::vector<std::vector<css::drawing::Position3D>>& rAdd ); + +/** PolyPolygonBezierCoords -> PolyPolygonShape3D +*/ +OOO_DLLPUBLIC_CHARTTOOLS +css::drawing::PolyPolygonShape3D BezierToPoly( + const css::drawing::PolyPolygonBezierCoords& rBezier ); + +/** PolyPolygonShape3D -> drawing::PointSequenceSequence (2D) +*/ +OOO_DLLPUBLIC_CHARTTOOLS +css::drawing::PointSequenceSequence PolyToPointSequence( + const css::drawing::PolyPolygonShape3D& rPolyPolygon ); +OOO_DLLPUBLIC_CHARTTOOLS +css::drawing::PointSequenceSequence PolyToPointSequence( + const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon ); + +/** PolyPolygonShape3D -> basegfx::B2DPolyPolygon (2D) +*/ +OOO_DLLPUBLIC_CHARTTOOLS +basegfx::B2DPolyPolygon PolyToB2DPolyPolygon( + const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon ); + +/** drawing::PointSequenceSequence + drawing::PointSequenceSequence +*/ +OOO_DLLPUBLIC_CHARTTOOLS +void appendPointSequence( css::drawing::PointSequenceSequence& rTarget + , const css::drawing::PointSequenceSequence& rAdd ); + +/** Position3D + Direction3D == Position3D +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D + operator+( const css::drawing::Position3D& rPos + , const css::drawing::Direction3D& rDirection); + +/** Position3D - Position3D == Direction3D +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Direction3D + operator-( const css::drawing::Position3D& rPos1 + , const css::drawing::Position3D& rPos2); + +/** awt::Rect --> awt::Point (2D) +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::awt::Point ToPoint( const css::awt::Rectangle& rRectangle ); + +/** awt::Rect --> awt::Size (2D) +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::awt::Size ToSize( const css::awt::Rectangle& rRectangle ); + +/** Position3D --> awt::Point (2D) +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::awt::Point Position3DToAWTPoint( const css::drawing::Position3D& rPos ); + +/** Direction3D --> awt::Size (2D) +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::awt::Size Direction3DToAWTSize( const css::drawing::Direction3D& rDirection ); + +/** Sequence<double> -> drawing::Position3D +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D + SequenceToPosition3D( const css::uno::Sequence< double >& rSeq ); + +/** chart2::XDataSequence -> uno::Sequence< double > +*/ + +OOO_DLLPUBLIC_CHARTTOOLS +css::uno::Sequence< double > DataSequenceToDoubleSequence( + const css::uno::Reference< css::chart2::data::XDataSequence > & xDataSequence ); + +OOO_DLLPUBLIC_CHARTTOOLS +css::uno::Sequence< OUString > DataSequenceToStringSequence( + const css::uno::Reference< css::chart2::data::XDataSequence > & xDataSequence ); + +/** std::vector< std::vector< T > > -> std::vector< T > + */ +template< typename T > +std::vector< T > + FlattenSequence( const std::vector< std::vector< T > > & aSeqSeq ) +{ + sal_Int32 nOuter, nInner, nCount = 0, + nResultSize = 0; + const sal_Int32 nOuterSize = aSeqSeq.size(); + for( nOuter=0; nOuter<nOuterSize; ++nOuter ) + nResultSize += aSeqSeq[nOuter].size(); + std::vector< T > aResult( nResultSize ); + + for( nOuter=0; nOuter<nOuterSize; ++nOuter ) + { + const sal_Int32 nInnerSize = aSeqSeq[nOuter].size(); + for( nInner=0; nInner<nInnerSize; ++nInner, ++nCount ) + aResult[nCount] = aSeqSeq[nOuter][nInner]; + } + return aResult; +} + +OOO_DLLPUBLIC_CHARTTOOLS +bool hasDoubleValue( const css::uno::Any& rAny ); + +OOO_DLLPUBLIC_CHARTTOOLS +bool hasLongOrShortValue( const css::uno::Any& rAny ); +OOO_DLLPUBLIC_CHARTTOOLS +sal_Int16 getShortForLongAlso( const css::uno::Any& rAny ); + +OOO_DLLPUBLIC_CHARTTOOLS +bool replaceParamterInString( OUString & rInOutResourceString, + std::u16string_view rParamToReplace, + std::u16string_view rReplaceWith ); + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/CommonFunctors.hxx b/chart2/source/inc/CommonFunctors.hxx new file mode 100644 index 0000000000..7bb776490c --- /dev/null +++ b/chart2/source/inc/CommonFunctors.hxx @@ -0,0 +1,126 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <o3tl/any.hxx> +#include <rtl/math.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <rtl/ustring.hxx> +#include "charttoolsdllapi.hxx" + +#include <limits> + +namespace chart::CommonFunctors +{ + +/** unary function to convert any type T into a css::uno::Any. + + <p>uno::makeAny is an inline function. Thus is cannot be taken directly + (via mem_fun_ptr)</p> +*/ +template< typename T > + struct makeAny +{ + css::uno::Any operator() ( const T & aVal ) + { + return css::uno::Any( aVal ); + } +}; + +/** unary function to convert css::uno::Any into a double number. + + <p>In case no number can be generated from the Any, NaN is returned.</p> +*/ +struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble +{ + double operator() ( const css::uno::Any & rAny ) + { + double fResult = std::numeric_limits<double>::quiet_NaN(); + rAny >>= fResult; + return fResult; + } +}; + +/** unary function to convert css::uno::Any into an + OUString. +*/ +struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString +{ + OUString operator() ( const css::uno::Any & rAny ) + { + if( auto pDouble = o3tl::tryAccess<double>(rAny) ) + { + if( std::isnan(*pDouble) ) + return OUString(); + return ::rtl::math::doubleToUString( + * pDouble, + rtl_math_StringFormat_Automatic, + rtl_math_DecimalPlaces_Max, // use maximum decimal places available + '.', // decimal separator + true // remove trailing zeros + ); + } + else if( auto s = o3tl::tryAccess<OUString>(rAny) ) + { + return *s; + } + + return OUString(); + } +}; + +/** unary function to convert an OUString into a double number. + + <p>For conversion rtl::math::StringToDouble is used.</p> + */ +struct OOO_DLLPUBLIC_CHARTTOOLS OUStringToDouble +{ + double operator() ( std::u16string_view rStr ) + { + rtl_math_ConversionStatus eConversionStatus; + double fResult = ::rtl::math::stringToDouble( rStr, '.', ',', & eConversionStatus ); + + if( eConversionStatus != rtl_math_ConversionStatus_Ok ) + return std::numeric_limits<double>::quiet_NaN(); + + return fResult; + } +}; + +/** unary function to convert a double number into an OUString. + + <p>For conversion rtl::math::DoubleToOUString is used.</p> + */ +struct OOO_DLLPUBLIC_CHARTTOOLS DoubleToOUString +{ + OUString operator() ( double fNumber ) + { + return ::rtl::math::doubleToUString( + fNumber, + rtl_math_StringFormat_Automatic, + rtl_math_DecimalPlaces_Max, // use maximum decimal places available + '.', + true + ); + } +}; + +} // namespace chart::CommonFunctors + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ConfigColorScheme.hxx b/chart2/source/inc/ConfigColorScheme.hxx new file mode 100644 index 0000000000..8375c60027 --- /dev/null +++ b/chart2/source/inc/ConfigColorScheme.hxx @@ -0,0 +1,76 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "charttoolsdllapi.hxx" +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/chart2/XColorScheme.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <memory> +#include <string_view> + +namespace com::sun::star::uno { class XComponentContext; } + +namespace chart +{ + +OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::XColorScheme > createConfigColorScheme( + const css::uno::Reference< css::uno::XComponentContext > & xContext ); + +namespace impl +{ +class ChartConfigItem; +} + +class ConfigColorScheme final : + public ::cppu::WeakImplHelper< + css::chart2::XColorScheme, + css::lang::XServiceInfo > +{ +public: + explicit ConfigColorScheme( const css::uno::Reference< css::uno::XComponentContext > & xContext ); + virtual ~ConfigColorScheme() override; + + /// declare XServiceInfo methods + 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; + + // ____ ConfigItemListener ____ + void notify(); + +protected: + // ____ XColorScheme ____ + virtual ::sal_Int32 SAL_CALL getColorByIndex( ::sal_Int32 nIndex ) override; + +private: + void retrieveConfigColors(); + + // member variables + css::uno::Reference< css::uno::XComponentContext > m_xContext; + std::unique_ptr< impl::ChartConfigItem > m_apChartConfigItem; + mutable css::uno::Sequence< sal_Int64 > m_aColorSequence; + mutable sal_Int32 m_nNumberOfColors; + bool m_bNeedsUpdate; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ControllerLockGuard.hxx b/chart2/source/inc/ControllerLockGuard.hxx new file mode 100644 index 0000000000..f9de7aa5b4 --- /dev/null +++ b/chart2/source/inc/ControllerLockGuard.hxx @@ -0,0 +1,95 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> + +namespace chart +{ +class ChartModel; +} +namespace com::sun::star::frame +{ +class XModel; +} + +namespace chart +{ +/** This guard calls lockControllers at the given Model in the CTOR and + unlockControllers in the DTOR. Using this ensures that controllers do not + remain locked when leaving a function even in case an exception is thrown. + */ +class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockGuardUNO +{ +public: + explicit ControllerLockGuardUNO(rtl::Reference<::chart::ChartModel> xModel); + ~ControllerLockGuardUNO(); + +private: + rtl::Reference<::chart::ChartModel> mxModel; +}; + +class ControllerLockGuard +{ +public: + explicit ControllerLockGuard(ChartModel& rModel); + ~ControllerLockGuard(); + +private: + ChartModel& mrModel; +}; + +/** This helper class can be used to pass a locking mechanism to other objects + without exposing the full XModel to it. + + Use the ControllerLockHelperGuard to lock/unlock the model during a block of + instructions. + */ +class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockHelper +{ +public: + explicit ControllerLockHelper(rtl::Reference<::chart::ChartModel> xModel); + ~ControllerLockHelper(); + + SAL_DLLPRIVATE void lockControllers(); + SAL_DLLPRIVATE void unlockControllers(); + +private: + rtl::Reference<::chart::ChartModel> m_xModel; +}; + +/** This guard calls lockControllers at the given ControllerLockHelper in the + CTOR and unlockControllers in the DTOR. Using this ensures that controllers + do not remain locked when leaving a function even in case an exception is + thrown. + */ +class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockHelperGuard +{ +public: + explicit ControllerLockHelperGuard(ControllerLockHelper& rHelper); + ~ControllerLockHelperGuard(); + +private: + ControllerLockHelper& m_rHelper; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DataInterpreter.hxx b/chart2/source/inc/DataInterpreter.hxx new file mode 100644 index 0000000000..7638e5ccee --- /dev/null +++ b/chart2/source/inc/DataInterpreter.hxx @@ -0,0 +1,154 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "DataSeries.hxx" +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <rtl/ref.hxx> +#include <vector> + +namespace chart +{ +class DataSeries; +class DataSource; +class LabeledDataSequence; + +/** offers tooling to interpret different data sources in a structural + and chart-type-dependent way. + */ +struct InterpretedData +{ + std::vector< std::vector< rtl::Reference<::chart::DataSeries> > > Series; + css::uno::Reference< css::chart2::data::XLabeledDataSequence > Categories; +}; + +/** offers tooling to interpret different data sources in a structural + and chart-type-dependent way. + */ +class SAL_DLLPUBLIC_RTTI DataInterpreter : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo > +{ +public: + explicit DataInterpreter(); + virtual ~DataInterpreter() override; + + /// 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; + + // convenience methods + static OUString GetRole( const css::uno::Reference< css::chart2::data::XDataSequence > & xSeq ); + + static void SetRole( + const css::uno::Reference< css::chart2::data::XDataSequence > & xSeq, + const OUString & rRole ); + + static css::uno::Any GetProperty( + const css::uno::Sequence<css::beans::PropertyValue > & aArguments, + std::u16string_view rName ); + + static bool HasCategories( + const css::uno::Sequence< css::beans::PropertyValue > & rArguments, + const std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > & rData ); + + static bool UseCategoriesAsX( + const css::uno::Sequence< css::beans::PropertyValue > & rArguments ); + + static std::vector<css::uno::Reference< css::chart2::data::XLabeledDataSequence >> getDataSequences( + const css::uno::Reference< css::chart2::data::XDataSource >& xSource); + + // ____ DataInterpreter ____ + /** Interprets the given data. + + @param xSource + the data source. + + @param aArguments + Arguments that tell the template how to slice the given + range. The properties should be defined in a separate + service. + + <p>For standard parameters that may be used, see the + service StandardDiagramCreationParameters. + </p> + + @param aSeriesToReUse + use all the data series given here for the result before + creating new ones. + */ + virtual InterpretedData interpretDataSource( + const css::uno::Reference< css::chart2::data::XDataSource >& xSource, + const css::uno::Sequence< css::beans::PropertyValue >& aArguments, + const std::vector< rtl::Reference< ::chart::DataSeries > >& aSeriesToReUse ); + + /** Re-interprets the data given in <code>aInterpretedData</code> + while keeping the number of data series and the categories. + */ + virtual InterpretedData reinterpretDataSeries( + const InterpretedData& aInterpretedData ); + + /** parses the given data and states, if a + reinterpretDataSeries() call can be done + without data loss. + + @return + `TRUE`, if the data given in + <code>aInterpretedData</code> has a similar structure than + the one required is used as output of the data interpreter. + */ + virtual bool isDataCompatible( + const InterpretedData& aInterpretedData ); + + /** Try to reverse the operation done in + interpretDataSource(). + + <p>In case <code>aInterpretedData</code> is the result of + interpretDataSource()( <code>xSource</code> ), + the result of this method should be <code>xSource</code>.</p> + */ + static rtl::Reference< ::chart::DataSource > mergeInterpretedData( + const InterpretedData& aInterpretedData ); + + /** Get chart information that is specific to a particular chart + type, by key. + + @param sKey + name of the piece of data to retrieve. + + <p>Supported key strings:</p> + <ul> + <li><tt>"stock variant"</tt>: stock chart variant, + with 0 = neither Open Values nor volume, 1 = Open Values, + 2 = volume, 3 = both. Valid for candlestick charts.</li> + </ul> + + @return + The value requested, or nothing if not present. + */ + virtual css::uno::Any getChartTypeSpecificData( + const OUString& sKey ); +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DataSeries.hxx b/chart2/source/inc/DataSeries.hxx new file mode 100644 index 0000000000..e643486d59 --- /dev/null +++ b/chart2/source/inc/DataSeries.hxx @@ -0,0 +1,190 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +// UNO types +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/chart2/data/XDataSink.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +// helper classes +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include "ModifyListenerHelper.hxx" +#include "PropertyHelper.hxx" + +// STL +#include <vector> +#include <map> + +#include "OPropertySet.hxx" +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::beans { class XPropertySet; } + +namespace chart +{ +class LabeledDataSequence; +class RegressionCurveModel; + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::chart2::XDataSeries, + css::chart2::data::XDataSink, + css::chart2::data::XDataSource, + css::lang::XServiceInfo, + css::chart2::XRegressionCurveContainer, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + DataSeries_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS DataSeries + final + : public impl::DataSeries_Base + , public ::property::OPropertySet +{ +public: + explicit DataSeries(); + virtual ~DataSeries() override; + + /// 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + explicit DataSeries( const DataSeries & rOther ); + + // ____ XDataSeries ____ + /// @see css::chart2::XDataSeries + virtual css::uno::Reference< css::beans::XPropertySet > + SAL_CALL getDataPointByIndex( sal_Int32 nIndex ) override; + virtual void SAL_CALL resetDataPoint( sal_Int32 nIndex ) override; + virtual void SAL_CALL resetAllDataPoints() override; + + // ____ XDataSink ____ + /// @see css::chart2::data::XDataSink + virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > >& aData ) override; + + // ____ XDataSource ____ + /// @see css::chart2::data::XDataSource + virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() override; + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast + ( sal_Int32 nHandle, + const css::uno::Any& rValue ) override; + + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + /// @see css::beans::XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + /// make original interface function visible again + using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue; + + // ____ XRegressionCurveContainer ____ + /// @see css::chart2::XRegressionCurveContainer + virtual void SAL_CALL addRegressionCurve( + const css::uno::Reference< css::chart2::XRegressionCurve >& aRegressionCurve ) override; + virtual void SAL_CALL removeRegressionCurve( + const css::uno::Reference< css::chart2::XRegressionCurve >& aRegressionCurve ) override; + virtual css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > > SAL_CALL getRegressionCurves() override; + virtual void SAL_CALL setRegressionCurves( + const css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > >& aRegressionCurves ) override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + typedef std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > tDataSequenceContainer; + + void setData( const tDataSequenceContainer& aData ); + const tDataSequenceContainer & getDataSequences2() const { return m_aDataSequences; } + + typedef + std::vector< rtl::Reference< ::chart::RegressionCurveModel > > + tRegressionCurveContainerType; + + const tRegressionCurveContainerType & getRegressionCurves2() const { return m_aRegressionCurves; } + + /** Get the label of a series (e.g. for the legend) + + @param rLabelSequenceRole + The data sequence contained in xSeries that has this role will be used + to take its label. + */ + OUString getLabelForRole( const OUString & rLabelSequenceRole ); + + bool hasUnhiddenData(); + +private: + + // late initialization to call after copy-constructing + void Init( const DataSeries & rOther ); + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + void fireModifyEvent(); + + tDataSequenceContainer m_aDataSequences; + + typedef std::map< sal_Int32, + css::uno::Reference< css::beans::XPropertySet > > tDataPointAttributeContainer; + tDataPointAttributeContainer m_aAttributedDataPoints; + + tRegressionCurveContainerType m_aRegressionCurves; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +OOO_DLLPUBLIC_CHARTTOOLS const tPropertyValueMap & StaticDataSeriesDefaults(); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx new file mode 100644 index 0000000000..b1f4e0ba34 --- /dev/null +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -0,0 +1,170 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "StackMode.hxx" +#include "charttoolsdllapi.hxx" +#include <com/sun/star/uno/Reference.h> +#include <rtl/ustring.hxx> +#include <rtl/ref.hxx> + +#include <vector> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XChartType; } +namespace com::sun::star::chart2 { class XCoordinateSystem; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::chart2::data { class XDataSequence; } +namespace com::sun::star::chart2::data { class XDataSource; } +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } +namespace com::sun::star::uno { class Any; } +namespace com::sun::star::uno { template <class E> class Sequence; } +namespace chart { class BaseCoordinateSystem; } +namespace chart { class ChartType; } +namespace chart { class DataSource; } +namespace chart { class Diagram; } +namespace chart { class DataSeries; } +namespace chart { class LabeledDataSequence; } + +namespace chart::DataSeriesHelper +{ + +OOO_DLLPUBLIC_CHARTTOOLS OUString + getRole( const css::uno::Reference<css::chart2::data::XLabeledDataSequence>& xLabeledDataSequence ); + +/** Retrieves the data sequence in the given data source that matches the + given role. If more than one sequences match the role, the first match + is returned. If no sequence matches, an empty reference is returned. + + @param aSource + The data source containing all data sequences to be searched through. + + @param aRole + The role that is to be filtered out. +*/ +OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XLabeledDataSequence > + getDataSequenceByRole( const css::uno::Reference< css::chart2::data::XDataSource > & xSource, + const OUString& aRole, + bool bMatchPrefix = false ); + +/** Retrieves all data sequences in the given data source that match the given + role prefix. + + @param aSource + The data source containing all data sequences to be searched through. + + @param aRole + The role that is to be filtered out. +*/ +OOO_DLLPUBLIC_CHARTTOOLS std::vector< + css::uno::Reference< css::chart2::data::XLabeledDataSequence > > + getAllDataSequencesByRole( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > & aDataSequences, + const OUString& aRole ); +OOO_DLLPUBLIC_CHARTTOOLS std::vector< + css::uno::Reference< css::chart2::data::XLabeledDataSequence > > + getAllDataSequencesByRole( const std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > & aDataSequences, + const OUString& aRole ); + +OOO_DLLPUBLIC_CHARTTOOLS +std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > +getAllDataSequences( + const std::vector<rtl::Reference<::chart::DataSeries> >& aSeries ); + +/** Retrieves all data sequences found in the given data series and puts them + into a data source. The order of sequences will match the order of the data + series. + */ +OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference< ::chart::DataSource > + getDataSource( const std::vector< rtl::Reference< ::chart::DataSeries > > & aSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS void setStackModeAtSeries( + const std::vector< rtl::Reference< ::chart::DataSeries > > & aSeries, + const rtl::Reference< ::chart::BaseCoordinateSystem > & xCorrespondingCoordinateSystem, + StackMode eStackMode ); + +OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getAttachedAxisIndex( + const rtl::Reference< ::chart::DataSeries > & xSeries ); + +/// @param nAxisIndex, if -1 it is determined by the given data series via getAttachedAxisIndex +OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getNumberFormatKeyFromAxis( + const rtl::Reference< ::chart::DataSeries > & xSeries, + const rtl::Reference< ::chart::BaseCoordinateSystem > & xCorrespondingCoordinateSystem, + sal_Int32 nDimensionIndex, + sal_Int32 nAxisIndex = -1 ); + +OOO_DLLPUBLIC_CHARTTOOLS +rtl::Reference< ::chart::BaseCoordinateSystem > + getCoordinateSystemOfSeries( + const rtl::Reference< ::chart::DataSeries > & xSeries, + const rtl::Reference< ::chart::Diagram > & xDiagram ); + +OOO_DLLPUBLIC_CHARTTOOLS +rtl::Reference< ::chart::ChartType > + getChartTypeOfSeries( + const rtl::Reference< ::chart::DataSeries > & xSeries, + const rtl::Reference< ::chart::Diagram > & xDiagram ); + +OOO_DLLPUBLIC_CHARTTOOLS void deleteSeries( + const rtl::Reference< ::chart::DataSeries > & xSeries, + const rtl::Reference< ::chart::ChartType > & xChartType ); + +OOO_DLLPUBLIC_CHARTTOOLS void switchSymbolsOnOrOff( + const rtl::Reference< ::chart::DataSeries > & xSeries, + bool bSymbolsOn, sal_Int32 nSeriesIndex ); + +OOO_DLLPUBLIC_CHARTTOOLS void switchLinesOnOrOff( + const rtl::Reference< ::chart::DataSeries > & xSeries, + bool bLinesOn ); + +OOO_DLLPUBLIC_CHARTTOOLS +void makeLinesThickOrThin( const rtl::Reference< ::chart::DataSeries > & xSeries, bool bThick ); + +OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints( + const rtl::Reference< ::chart::DataSeries >& xSeries, + const OUString& rPropertyName, + const css::uno::Any& rPropertyValue ); + + +OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue( + const rtl::Reference< ::chart::DataSeries >& xSeries, + const OUString& rPropertyName, + const css::uno::Any& rPropertyValue ); + +OOO_DLLPUBLIC_CHARTTOOLS +sal_Int32 translateIndexFromHiddenToFullSequence( sal_Int32 nClippedIndex, const css::uno::Reference< + css::chart2::data::XDataSequence >& xDataSequence, bool bTranslate ); + +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtSeries( const rtl::Reference< ::chart::DataSeries >& xSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelsAtPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS bool hasDataLabelAtPoint( const rtl::Reference< ::chart::DataSeries >& xSeries, sal_Int32 nPointIndex ); + +OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelsToSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS void insertDataLabelToPoint( const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet ); + +OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromSeriesAndAllPoints( const rtl::Reference< ::chart::DataSeries >& xSeries ); + +OOO_DLLPUBLIC_CHARTTOOLS void deleteDataLabelsFromPoint( const css::uno::Reference< css::beans::XPropertySet >& xPointPropertySet ); + +} // namespace chart::DataSeriesHelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DataSeriesProperties.hxx b/chart2/source/inc/DataSeriesProperties.hxx new file mode 100644 index 0000000000..7d36721ef0 --- /dev/null +++ b/chart2/source/inc/DataSeriesProperties.hxx @@ -0,0 +1,48 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "PropertyHelper.hxx" +#include "FastPropertyIdRanges.hxx" + +#include <vector> + +namespace com::sun::star::beans { struct Property; } + +namespace chart::DataSeriesProperties +{ + enum + { + PROP_DATASERIES_ATTRIBUTED_DATA_POINTS = FAST_PROPERTY_ID_START_DATA_SERIES, + PROP_DATASERIES_STACKING_DIRECTION, + PROP_DATASERIES_VARY_COLORS_BY_POINT, + PROP_DATASERIES_ATTACHED_AXIS_INDEX, + PROP_DATASERIES_SHOW_LEGEND_ENTRY, + PROP_DATASERIES_DELETED_LEGEND_ENTRIES, + PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES + }; + + void AddPropertiesToVector( + std::vector< css::beans::Property > & rOutProperties ); + + void AddDefaultsToMap( tPropertyValueMap & rOutMap ); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DataSource.hxx b/chart2/source/inc/DataSource.hxx new file mode 100644 index 0000000000..6e9b84ed9b --- /dev/null +++ b/chart2/source/inc/DataSource.hxx @@ -0,0 +1,66 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/chart2/data/XDataSink.hpp> +#include <cppuhelper/implbase.hxx> +#include <vector> +#include "charttoolsdllapi.hxx" + +namespace chart +{ +class LabeledDataSequence; + +class OOO_DLLPUBLIC_CHARTTOOLS DataSource final : public + ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::chart2::data::XDataSource, + css::chart2::data::XDataSink > +{ +public: + explicit DataSource(); + explicit DataSource( + const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > & rSequences ); + explicit DataSource( + const std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > & rSequences ); + + virtual ~DataSource() override; + + /// declare XServiceInfo methods + 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; + + // ____ XDataSource ____ + virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL + getDataSequences() override; + + // ____ XDataSink ____ + virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > >& aData ) override; + +private: + css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > + m_aDataSeq; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DataSourceHelper.hxx b/chart2/source/inc/DataSourceHelper.hxx new file mode 100644 index 0000000000..52ed689459 --- /dev/null +++ b/chart2/source/inc/DataSourceHelper.hxx @@ -0,0 +1,126 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "charttoolsdllapi.hxx" +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.h> +#include <rtl/ref.hxx> + +namespace chart { class ChartModel; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::chart2 { class XChartDocument; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::chart2::data { class XDataSequence; } +namespace com::sun::star::chart2::data { class XDataSource; } +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } +namespace com::sun::star::frame { class XModel; } + +namespace chart +{ +class DataSource; +class Diagram; +class LabeledDataSequence; + +class OOO_DLLPUBLIC_CHARTTOOLS DataSourceHelper +{ +public: + static css::uno::Reference< css::chart2::data::XDataSequence > + createCachedDataSequence(); + + static css::uno::Reference< css::chart2::data::XDataSequence > + createCachedDataSequence( const OUString & rSingleText ); + + static rtl::Reference< LabeledDataSequence > + createLabeledDataSequence( + const css::uno::Reference< css::chart2::data::XDataSequence >& xValues , + const css::uno::Reference< css::chart2::data::XDataSequence >& xLabels ); + + static rtl::Reference< LabeledDataSequence > + createLabeledDataSequence( + const css::uno::Reference< css::chart2::data::XDataSequence >& xValues ); + + static rtl::Reference< LabeledDataSequence > + createLabeledDataSequence(); + + static css::uno::Sequence< css::beans::PropertyValue > + createArguments( + bool bUseColumns, bool bFirstCellAsLabel, bool bHasCategories ); + + static css::uno::Sequence< + css::beans::PropertyValue > createArguments( + const OUString & rRangeRepresentation, + const css::uno::Sequence< sal_Int32 >& rSequenceMapping, + bool bUseColumns, bool bFirstCellAsLabel, bool bHasCategories ); + + SAL_DLLPRIVATE static void readArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments + , OUString & rRangeRepresentation, css::uno::Sequence< sal_Int32 >& rSequenceMapping + , bool& bUseColumns, bool& bFirstCellAsLabel, bool& bHasCategories ); + + static rtl::Reference< ::chart::DataSource > + pressUsedDataIntoRectangularFormat( const rtl::Reference< ::chart::ChartModel >& xChartDoc ); + + SAL_DLLPRIVATE static css::uno::Sequence< OUString > getUsedDataRanges( + const rtl::Reference< ::chart::Diagram > & xDiagram ); + + static css::uno::Sequence< OUString > getUsedDataRanges( + const rtl::Reference<::chart::ChartModel> & xChartModel ); + + static rtl::Reference< ::chart::DataSource > getUsedData( + ChartModel& rModel ); + + static bool detectRangeSegmentation( + const rtl::Reference<::chart::ChartModel>& xChartModel + , OUString& rOutRangeString + , css::uno::Sequence< sal_Int32 >& rSequenceMapping + , bool& rOutUseColumns + , bool& rOutFirstCellAsLabel + , bool& rOutHasCategories ); + + static void setRangeSegmentation( + const rtl::Reference<::chart::ChartModel>& xChartModel + , const css::uno::Sequence< sal_Int32 >& rSequenceMapping + , bool bUseColumns + , bool bFirstCellAsLabel + , bool bUseCategories ); + + /** Returns true, if all arguments necessary for getting all data by a + rectangular region are returned by detectArguments at the given + document's data provider. + + Currently, this is: CellRangeRepresentation, DataRowSource, + HasCategories and FirstCellAsLabel. + */ + static bool allArgumentsForRectRangeDetected( + const rtl::Reference<::chart::ChartModel>& xChartDocument ); + + SAL_DLLPRIVATE static css::uno::Sequence< OUString > getRangesFromLabeledDataSequence( + const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xLSeq ); + + SAL_DLLPRIVATE static OUString getRangeFromValues( + const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xLSeq ); + + SAL_DLLPRIVATE static css::uno::Sequence< OUString > getRangesFromDataSource( + const css::uno::Reference< css::chart2::data::XDataSource > & xSource ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DataTable.hxx b/chart2/source/inc/DataTable.hxx new file mode 100644 index 0000000000..da15e264f4 --- /dev/null +++ b/chart2/source/inc/DataTable.hxx @@ -0,0 +1,87 @@ +/* -*- 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/. + */ + +#pragma once + +#include "OPropertySet.hxx" +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> + +#include "charttoolsdllapi.hxx" +#include <com/sun/star/chart2/XDataTable.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" + +namespace chart +{ +typedef cppu::WeakImplHelper<css::chart2::XDataTable, css::lang::XServiceInfo, + css::util::XCloneable, css::util::XModifyBroadcaster, + css::util::XModifyListener> + DataTable_Base; + +/** Data table implementation */ +class OOO_DLLPUBLIC_CHARTTOOLS DataTable final : public DataTable_Base, + public ::property::OPropertySet +{ +public: + explicit DataTable(); + virtual ~DataTable() override; + + /// 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + explicit DataTable(DataTable const& rOther); + +private: + // ____ OPropertySet ____ + virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override; + + // ____ OPropertySet ____ + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + // ____ XPropertySet ____ + virtual css::uno::Reference<css::beans::XPropertySetInfo> + SAL_CALL getPropertySetInfo() override; + + // ____ XCloneable ____ + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL + addModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override; + virtual void SAL_CALL + removeModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override; + +private: + // ____ XModifyListener ____ + virtual void SAL_CALL modified(const css::lang::EventObject& aEvent) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx new file mode 100644 index 0000000000..1d3e8bd789 --- /dev/null +++ b/chart2/source/inc/Diagram.hxx @@ -0,0 +1,381 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/chart/X3DDefaultSetter.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "ModifyListenerHelper.hxx" +#include "charttoolsdllapi.hxx" + +#include <vector> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2::data { class XDataSource; } +namespace com::sun::star::uno { class XComponentContext; } + +namespace chart +{ +class Axis; +class BaseCoordinateSystem; +class ChartType; +class ChartTypeManager; +class ChartTypeTemplate; +class DataSeries; +class Legend; +class DataTable; +class RegressionCurveModel; +enum class StackMode; +class Wall; +enum class ThreeDLookScheme; + +enum class DiagramPositioningMode +{ + Auto, Excluding, Including +}; + + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::chart2::XDiagram, + css::lang::XServiceInfo, + css::chart2::XCoordinateSystemContainer, + css::chart2::XTitled, + css::chart::X3DDefaultSetter, + css::util::XModifyBroadcaster, + css::util::XModifyListener, + css::util::XCloneable > + Diagram_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS Diagram + final + : public impl::Diagram_Base + , public ::property::OPropertySet +{ +public: + Diagram( css::uno::Reference< css::uno::XComponentContext > xContext ); + virtual ~Diagram() override; + + /// 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + explicit Diagram( const Diagram & rOther ); + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + + // ____ OPropertySet ____ + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + // ____ XFastPropertySet ____ + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + + /// make original interface function visible again + using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue; + + virtual void SAL_CALL getFastPropertyValue( + css::uno::Any& rValue, sal_Int32 nHandle ) const override; + + // ____ XDiagram ____ + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getWall() override; + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getFloor() override; + virtual css::uno::Reference< css::chart2::XLegend > SAL_CALL getLegend() override; + virtual void SAL_CALL setLegend( const css::uno::Reference< + css::chart2::XLegend >& xLegend ) override; + virtual css::uno::Reference< css::chart2::XColorScheme > SAL_CALL getDefaultColorScheme() override; + virtual void SAL_CALL setDefaultColorScheme( + const css::uno::Reference< css::chart2::XColorScheme >& xColorScheme ) override; + virtual void SAL_CALL setDiagramData( + const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource, + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override; + + virtual css::uno::Reference<css::chart2::XDataTable> SAL_CALL getDataTable() override; + virtual void SAL_CALL setDataTable(const css::uno::Reference<css::chart2::XDataTable>& xDataTable) override; + + // ____ XCoordinateSystemContainer ____ + virtual void SAL_CALL addCoordinateSystem( + const css::uno::Reference< css::chart2::XCoordinateSystem >& aCoordSys ) override; + virtual void SAL_CALL removeCoordinateSystem( + const css::uno::Reference< css::chart2::XCoordinateSystem >& aCoordSys ) override; + virtual css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > SAL_CALL getCoordinateSystems() override; + virtual void SAL_CALL setCoordinateSystems( + const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > >& aCoordinateSystems ) override; + + // ____ XTitled ____ + virtual css::uno::Reference< + css::chart2::XTitle > SAL_CALL getTitleObject() override; + virtual void SAL_CALL setTitleObject( const css::uno::Reference< + css::chart2::XTitle >& Title ) override; + + // ____ X3DDefaultSetter ____ + virtual void SAL_CALL set3DSettingsToDefault() override; + virtual void SAL_CALL setDefaultRotation() override; + virtual void SAL_CALL setDefaultIllumination() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + typedef + std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > + tCoordinateSystemContainerType; + + tCoordinateSystemContainerType getBaseCoordinateSystems() const; + void setCoordinateSystems( + const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > >& aCoordinateSystems ); + + rtl::Reference< ::chart::Legend > getLegend2() const; + void setLegend(const rtl::Reference< ::chart::Legend > &); + + void setDataTable(const rtl::Reference<::chart::DataTable>& xNewDataTable); + rtl::Reference<::chart::DataTable> getDataTableRef() const; + + DiagramPositioningMode getDiagramPositioningMode(); + + //returns integer from constant group css::chart::MissingValueTreatment + sal_Int32 getCorrectedMissingValueTreatment( + const rtl::Reference< ::chart::ChartType >& xChartType ); + + void setGeometry3D( sal_Int32 nNewGeometry ); + + sal_Int32 getGeometry3D( bool& rbFound, bool& rbAmbiguous ); + + bool isPieOrDonutChart(); + + bool isSupportingFloorAndWall(); + + /** + * Move a series forward or backward. + * + * @param xDiagram + * Reference to the diagram that contains the series. + * + * @param xGivenDataSeries + * Reference to the series that should be moved. + * + * @param bForward + * Direction in which the series should be moved. + * + * @returns </sal_True> if the series was moved successfully. + * + */ + bool moveSeries( + const rtl::Reference< DataSeries >& xGivenDataSeries, + bool bForward ); + + /** + * Test if a series can be moved. + * + * @param xDiagram + * Reference to the diagram that contains the series. + * + * @param xGivenDataSeries + * Reference to the series that should be tested for moving. + * + * @param bForward + * Direction of the move to be checked. + * + * @returns </sal_True> if the series can be moved. + * + */ + bool isSeriesMoveable( + const rtl::Reference< DataSeries >& xGivenDataSeries, + bool bForward ); + + std::vector< rtl::Reference< ChartType > > getChartTypes(); + + rtl::Reference< ChartType > getChartTypeByIndex( sal_Int32 nIndex ); + + bool isSupportingDateAxis(); + + css::uno::Reference< css::chart2::data::XLabeledDataSequence > + getCategories(); + + void setCategories( + const css::uno::Reference< css::chart2::data::XLabeledDataSequence >& xCategories, + bool bSetAxisType = false, // when this flag is true ... + bool bCategoryAxis = true);// set the AxisType to CATEGORY or back to REALNUMBER + + bool isCategory(); + + /** return all data series in this diagram grouped by chart-types + */ + std::vector< + std::vector< + rtl::Reference< ::chart::DataSeries > > > + getDataSeriesGroups(); + + std::vector< rtl::Reference< ::chart::DataSeries > > + getDataSeries(); + + rtl::Reference< ChartType > + getChartTypeOfSeries( const rtl::Reference< DataSeries >& xSeries ); + + rtl::Reference< ::chart::Axis > getAttachedAxis( + const rtl::Reference< ::chart::DataSeries >& xSeries ); + + bool attachSeriesToAxis( bool bMainAxis, + const rtl::Reference< DataSeries >& xSeries, + const css::uno::Reference< css::uno::XComponentContext > & xContext, + bool bAdaptAxes=true ); + + /** Replaces all occurrences of xCooSysToReplace in the tree with + xReplacement in the diagram's tree + */ + SAL_DLLPRIVATE void replaceCoordinateSystem( + const rtl::Reference< ::chart::BaseCoordinateSystem > & xCooSysToReplace, + const rtl::Reference< ::chart::BaseCoordinateSystem > & xReplacement ); + + + /** Returns the dimension found for all chart types in the tree. If the + dimension is not unique, 0 is returned. + */ + sal_Int32 getDimension(); + + /** Sets the dimension of the diagram given. + + 1. Sets the dimension of all used ChartTypes + 2. Adapts the DataSeriesTree to reflect the new dimension + 3. If new coordinate-systems have to be created, adapts the + XCoordinateSystemContainer of the diagram. + */ + void setDimension( sal_Int32 nNewDimensionCount ); + + + StackMode getStackMode(bool& rbFound, bool& rbAmbiguous); + + /** The stacking mode is only set at the series found inside + the first chart type. This is the standard for all current + templates (the only template that has more than one chart-type and + allows stacking is bar/line combi, and for this the stacking only + applies to the first chart type/the bars) + */ + void setStackMode(StackMode eStackMode); + + + /** Sets the "SwapXAndYAxis" property at all coordinate systems found in the + given diagram. + + "vertical==true" for bar charts, "vertical==false" for column charts + */ + void setVertical( bool bVertical ); + + /** Gets the "SwapXAndYAxis" property at all coordinate systems found in the + given diagram. + + "vertical==true" for bar charts, "vertical==false" for column charts + */ + bool getVertical( bool& rbOutFoundResult, bool& rbOutAmbiguousResult ); + + struct tTemplateWithServiceName { + rtl::Reference< ::chart::ChartTypeTemplate > xChartTypeTemplate; + OUString sServiceName; + }; + + /** tries to find a template in the chart-type manager that matches this + diagram. + + @return + A pair containing a template with the correct properties set as + first entry and the service name of the templates second entry. If + no template was found both elements are empty. + */ + tTemplateWithServiceName + getTemplate(const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager); + + std::vector<rtl::Reference<::chart::RegressionCurveModel> > + getAllRegressionCurvesNotMeanValueLine(); + + double getCameraDistance(); + void setCameraDistance( double fCameraDistance ); + + void getRotation( + sal_Int32& rnHorizontalAngleDegree, sal_Int32& rnVerticalAngleDegree ); + void setRotation( + sal_Int32 nHorizontalAngleDegree, sal_Int32 nVerticalYAngleDegree ); + void getRotationAngle( + double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad ); + void setRotationAngle( + double fXAngleRad, double fYAngleRad, double fZAngleRad ); + + ThreeDLookScheme detectScheme(); + void setScheme( ThreeDLookScheme aScheme ); + + void setDefaultRotation( bool bPieOrDonut ); + + void switchRightAngledAxes( bool bRightAngledAxes ); + +private: + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + void fireModifyEvent(); + + css::uno::Reference<css::uno::XComponentContext> m_xContext; + tCoordinateSystemContainerType m_aCoordSystems; + + rtl::Reference<Wall> m_xWall; + rtl::Reference<Wall> m_xFloor; + + css::uno::Reference<css::chart2::XTitle> m_xTitle; + + rtl::Reference<::chart::Legend> m_xLegend; + rtl::Reference<::chart::DataTable> m_xDataTable; + css::uno::Reference<css::chart2::XColorScheme> m_xColorScheme; + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; + +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx new file mode 100644 index 0000000000..c65bce883d --- /dev/null +++ b/chart2/source/inc/DiagramHelper.hxx @@ -0,0 +1,116 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "StackMode.hxx" +#include "charttoolsdllapi.hxx" +#include "ChartTypeTemplate.hxx" +#include <com/sun/star/awt/Rectangle.hpp> +#include <rtl/ref.hxx> + +#include <vector> + +namespace chart { class ChartModel; } +namespace com::sun::star::chart2 { class XAxis; } +namespace com::sun::star::chart2 { class XChartDocument; } +namespace com::sun::star::chart2 { class XChartType; } +namespace com::sun::star::chart2 { class XCoordinateSystem; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::uno { class XComponentContext; } +namespace com::sun::star::util { class XNumberFormats; } +namespace com::sun::star::util { class XNumberFormatsSupplier; } + +namespace chart +{ +class Axis; +class BaseCoordinateSystem; +class ChartType; +class ChartTypeManager; +class ChartTypeTemplate; +class DataSeries; +class Diagram; +class LabeledDataSequence; + +class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper +{ +public: + + /** Retrieves the stackmode of the first DataSeries or none. If the series have differing stack + modes, rbAmbiguous is set to true. If no series is there rbFound is set to false. + + @param xCorrespondingCoordinateSystem + The coordinate system in which the given chart type xChartType is + located. (This is needed for determining percent stacking. If + omitted, the result will just indicate "not stacked", "stacked" or + "ambiguous") + */ + static StackMode getStackModeFromChartType( + const rtl::Reference< ::chart::ChartType > & xChartType, + bool& rbFound, bool& rbAmbiguous, + const rtl::Reference< ::chart::BaseCoordinateSystem > & xCorrespondingCoordinateSystem + ); + + static bool isSeriesAttachedToMainAxis( + const rtl::Reference< ::chart::DataSeries >& xDataSeries ); + + static css::uno::Sequence< OUString > + getExplicitSimpleCategories( ChartModel& rModel ); + + SAL_DLLPRIVATE static css::uno::Sequence< OUString > + generateAutomaticCategoriesFromCooSys( + const rtl::Reference< ::chart::BaseCoordinateSystem > & xCooSys ); + + static void switchToDateCategories( + const rtl::Reference<::chart::ChartModel> & xChartDoc ); + + static void switchToTextCategories( + const rtl::Reference<::chart::ChartModel> & xChartDoc ); + + static bool isDateNumberFormat( sal_Int32 nNumberFormat, const css::uno::Reference< css::util::XNumberFormats >& xNumberFormats ); + static sal_Int32 getDateNumberFormat( const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); + static sal_Int32 getDateTimeInputNumberFormat( const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier, double fNumber ); + + static sal_Int32 getPercentNumberFormat( const css::uno::Reference< + css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); + + SAL_DLLPRIVATE static bool areChartTypesCompatible( + const rtl::Reference< ::chart::ChartType >& xFirstType, + const rtl::Reference< ::chart::ChartType >& xSecondType ); + + static bool setDiagramPositioning( const rtl::Reference<::chart::ChartModel>& xChartModel, + const css::awt::Rectangle& rPosRect /*100th mm*/ ); + + static css::awt::Rectangle getDiagramRectangleFromModel( const rtl::Reference<::chart::ChartModel>& xChartModel ); + + static bool switchDiagramPositioningToExcludingPositioning( ChartModel& rModel + , bool bResetModifiedState //set model back to unchanged if it was unchanged before + , bool bConvertAlsoFromAutoPositioning ); + +private: + DiagramHelper() = delete; + +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/DisposeHelper.hxx b/chart2/source/inc/DisposeHelper.hxx new file mode 100644 index 0000000000..58dc2d5c55 --- /dev/null +++ b/chart2/source/inc/DisposeHelper.hxx @@ -0,0 +1,49 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/lang/XComponent.hpp> + +namespace chart::DisposeHelper +{ +template <class T> void Dispose(const T& xInterface) +{ + css::uno::Reference<css::lang::XComponent> xComponent(xInterface, css::uno::UNO_QUERY); + if (xComponent.is()) + xComponent->dispose(); +} + +template <class T> void DisposeAndClear(css::uno::Reference<T>& rInterface) +{ + Dispose<css::uno::Reference<T>>(rInterface); + rInterface.clear(); +} + +template <class Container> void DisposeAllElements(Container& rContainer) +{ + for (const auto& rElement : rContainer) + { + Dispose<typename Container::value_type>(rElement); + } +} + +} // namespace chart::DisposeHelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ErrorBar.hxx b/chart2/source/inc/ErrorBar.hxx new file mode 100644 index 0000000000..ed6d646be5 --- /dev/null +++ b/chart2/source/inc/ErrorBar.hxx @@ -0,0 +1,137 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "charttoolsdllapi.hxx" + +#include <cppuhelper/implbase.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/chart2/data/XDataSink.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/drawing/LineJoint.hpp> +#include <com/sun/star/drawing/LineDash.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/util/Color.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include "ModifyListenerHelper.hxx" + + +#include <vector> + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener, + css::chart2::data::XDataSource, + css::chart2::data::XDataSink, + css::beans::XPropertySet, + css::beans::XPropertyState > + ErrorBar_Base; +} + +class ErrorBar final : public impl::ErrorBar_Base +{ +private: + OUString maDashName; + css::drawing::LineDash maLineDash; + sal_Int32 mnLineWidth; + css::drawing::LineStyle meLineStyle; + css::util::Color maLineColor; + sal_Int16 mnLineTransparence; + css::drawing::LineJoint meLineJoint; + bool mbShowPositiveError; + bool mbShowNegativeError; + double mfPositiveError; + double mfNegativeError; + double mfWeight; + sal_Int32 meStyle; + +public: + OOO_DLLPUBLIC_CHARTTOOLS explicit ErrorBar(); + virtual ~ErrorBar() override; + + /// 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; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XPropertyState + virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& rPropName ) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( + const css::uno::Sequence< OUString >& rPropNames ) override; + virtual void SAL_CALL setPropertyToDefault( const OUString& rPropName ) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& rPropName ) override; + +private: + ErrorBar( const ErrorBar & rOther ); + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ XDataSink ____ + virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > >& aData ) override; + + // ____ XDataSource ____ + virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() override; + + typedef std::vector< css::uno::Reference< + css::chart2::data::XLabeledDataSequence > > tDataSequenceContainer; + tDataSequenceContainer m_aDataSequences; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/EventListenerHelper.hxx b/chart2/source/inc/EventListenerHelper.hxx new file mode 100644 index 0000000000..19c93c152f --- /dev/null +++ b/chart2/source/inc/EventListenerHelper.hxx @@ -0,0 +1,121 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/lang/XComponent.hpp> + +#include <algorithm> +#include <utility> + +namespace com::sun::star::lang { class XEventListener; } + +namespace chart +{ +namespace EventListenerHelper +{ + +namespace impl +{ + +template< class InterfaceRef > +struct addListenerFunctor +{ + explicit addListenerFunctor( css::uno::Reference< css::lang::XEventListener > xListener ) : + m_xListener(std::move( xListener )) + {} + + void operator() ( const InterfaceRef & xObject ) + { + css::uno::Reference< css::lang::XComponent > + xBroadcaster( xObject, css::uno::UNO_QUERY ); + if( xBroadcaster.is() && m_xListener.is()) + xBroadcaster->addEventListener( m_xListener ); + } +private: + css::uno::Reference< css::lang::XEventListener > m_xListener; +}; + +template< class InterfaceRef > +struct removeListenerFunctor +{ + explicit removeListenerFunctor( css::uno::Reference< css::lang::XEventListener > xListener ) : + m_xListener(std::move( xListener )) + {} + + void operator() ( const InterfaceRef & xObject ) + { + css::uno::Reference< css::lang::XComponent > + xBroadcaster( xObject, css::uno::UNO_QUERY ); + if( xBroadcaster.is() && m_xListener.is()) + xBroadcaster->removeEventListener( m_xListener ); + } +private: + css::uno::Reference< css::lang::XEventListener > m_xListener; +}; + +} // namespace impl + +template< class InterfaceRef > +void addListener( + const InterfaceRef & xObject, + const css::uno::Reference< css::lang::XEventListener > & xListener ) +{ + if( xListener.is()) + { + impl::addListenerFunctor< InterfaceRef > aFunctor( xListener ); + aFunctor( xObject ); + } +} + +template< class Container > +void addListenerToAllElements( + const Container & rContainer, + const css::uno::Reference< css::lang::XEventListener > & xListener ) +{ + if( xListener.is()) + std::for_each( rContainer.begin(), rContainer.end(), + impl::addListenerFunctor< typename Container::value_type >( xListener )); +} + +template< class InterfaceRef > +void removeListener( + const InterfaceRef & xObject, + const css::uno::Reference< css::lang::XEventListener > & xListener ) +{ + if( xListener.is()) + { + impl::removeListenerFunctor< InterfaceRef > aFunctor( xListener ); + aFunctor( xObject ); + } +} + +template< class Container > +void removeListenerFromAllElements( + const Container & rContainer, + const css::uno::Reference< css::lang::XEventListener > & xListener ) +{ + if( xListener.is()) + std::for_each( rContainer.begin(), rContainer.end(), + impl::removeListenerFunctor< typename Container::value_type >( xListener )); +} + +} // namespace EventListenerHelper +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ExplicitCategoriesProvider.hxx b/chart2/source/inc/ExplicitCategoriesProvider.hxx new file mode 100644 index 0000000000..c393b49a86 --- /dev/null +++ b/chart2/source/inc/ExplicitCategoriesProvider.hxx @@ -0,0 +1,115 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "charttoolsdllapi.hxx" +#include <unotools/weakref.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.h> + +#include <utility> +#include <vector> + +namespace chart { class ChartModel; } +namespace com::sun::star::chart2 { class XCoordinateSystem; } +namespace com::sun::star::chart2::data { class XDataSequence; } +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } +namespace com::sun::star::uno { class Any; } + +namespace chart +{ +class BaseCoordinateSystem; +class LabeledDataSequence; + +struct OOO_DLLPUBLIC_CHARTTOOLS ComplexCategory +{ + OUString Text; + sal_Int32 Count; + + ComplexCategory( OUString aText, sal_Int32 nCount ) : Text(std::move( aText )), Count (nCount) + {} +}; + +class SplitCategoriesProvider +{ +public: + virtual ~SplitCategoriesProvider(); + + virtual sal_Int32 getLevelCount() const = 0; + virtual css::uno::Sequence< OUString > getStringsForLevel( sal_Int32 nIndex ) const = 0; +}; + +class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider final +{ +public: + ExplicitCategoriesProvider( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSysModel + , ChartModel& rChartModel + ); + ~ExplicitCategoriesProvider(); + + void init(); + + css::uno::Reference< css::chart2::data::XDataSequence > getOriginalCategories(); + + css::uno::Sequence< OUString > const & getSimpleCategories(); + const std::vector<ComplexCategory>* getCategoriesByLevel( sal_Int32 nLevel ); + + static OUString getCategoryByIndex( + const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSysModel + , ChartModel& rModel + , sal_Int32 nIndex ); + + static css::uno::Sequence< OUString > getExplicitSimpleCategories( + const SplitCategoriesProvider& rSplitCategoriesProvider ); + + static void convertCategoryAnysToText( css::uno::Sequence< OUString >& rOutTexts + , const css::uno::Sequence< css::uno::Any >& rInAnys + , ChartModel& rModel ); + + bool hasComplexCategories() const; + sal_Int32 getCategoryLevelCount() const; + + const std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence> >& + getSplitCategoriesList() const { return m_aSplitCategoriesList;} + + bool isDateAxis(); + const std::vector< double >& getDateCategories(); + +private: + ExplicitCategoriesProvider(ExplicitCategoriesProvider const &) = delete; + ExplicitCategoriesProvider& operator =(ExplicitCategoriesProvider const &) = delete; + + bool volatile m_bDirty; + unotools::WeakReference< ::chart::BaseCoordinateSystem > m_xCooSysModel; + ChartModel& mrModel; + css::uno::Reference< css::chart2::data::XLabeledDataSequence> m_xOriginalCategories; + + bool m_bIsExplicitCategoriesInited; + css::uno::Sequence< OUString > m_aExplicitCategories; + std::vector< std::vector< ComplexCategory > > m_aComplexCats; + std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence> > m_aSplitCategoriesList; + + bool m_bIsDateAxis; + bool m_bIsAutoDate; + std::vector< double > m_aDateCategories; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx b/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx new file mode 100644 index 0000000000..c929ac80cd --- /dev/null +++ b/chart2/source/inc/ExponentialRegressionCurveCalculator.hxx @@ -0,0 +1,62 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "RegressionCurveCalculator.hxx" + +namespace chart +{ + +class ExponentialRegressionCurveCalculator final : public RegressionCurveCalculator +{ +public: + ExponentialRegressionCurveCalculator(); + virtual ~ExponentialRegressionCurveCalculator() override; + +protected: + virtual OUString ImplGetRepresentation( + const css::uno::Reference<css::util::XNumberFormatter>& xNumFormatter, + sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const override; + +private: + // ____ XRegressionCurveCalculator ____ + virtual void SAL_CALL recalculateRegression( + const css::uno::Sequence<double>& aXValues, + const css::uno::Sequence<double>& aYValues ) override; + + virtual double SAL_CALL getCurveValue( double x ) override; + + virtual css::uno::Sequence<css::geometry::RealPoint2D> SAL_CALL getCurveValues( + double min, + double max, + sal_Int32 nPointCount, + const css::uno::Reference<css::chart2::XScaling>& xScalingX, + const css::uno::Reference<css::chart2::XScaling>& xScalingY, + sal_Bool bMaySkipPointsInCalculation ) override; + + // formula is: f(x) = m_fSign * exp(m_fLogIntercept) * exp( m_fLogSlope * x ) + // mathematical model f(x) = Intercept * Slope^x + double m_fLogSlope; + double m_fLogIntercept; + double m_fSign; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/FastPropertyIdRanges.hxx b/chart2/source/inc/FastPropertyIdRanges.hxx new file mode 100644 index 0000000000..d06809e44c --- /dev/null +++ b/chart2/source/inc/FastPropertyIdRanges.hxx @@ -0,0 +1,46 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +namespace chart +{ +enum FastPropertyIdRanges +{ + FAST_PROPERTY_ID_START = 10000, + FAST_PROPERTY_ID_START_DATA_SERIES = FAST_PROPERTY_ID_START + 1000, + FAST_PROPERTY_ID_START_DATA_POINT = FAST_PROPERTY_ID_START + 2000, + FAST_PROPERTY_ID_START_CHAR_PROP = FAST_PROPERTY_ID_START + 3000, + FAST_PROPERTY_ID_START_LINE_PROP = FAST_PROPERTY_ID_START + 4000, + FAST_PROPERTY_ID_START_FILL_PROP = FAST_PROPERTY_ID_START + 5000, + FAST_PROPERTY_ID_START_USERDEF_PROP = FAST_PROPERTY_ID_START + 6000, + FAST_PROPERTY_ID_START_SCENE_PROP = FAST_PROPERTY_ID_START + 7000, + // FAST_PROPERTY_ID_START_NAMED_FILL_PROP = FAST_PROPERTY_ID_START + 8000, + // FAST_PROPERTY_ID_START_NAMED_LINE_PROP = FAST_PROPERTY_ID_START + 9000, + FAST_PROPERTY_ID_START_CHART_STATISTIC_PROP = FAST_PROPERTY_ID_START + 12000, + FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP = FAST_PROPERTY_ID_START + 13000, + FAST_PROPERTY_ID_START_CHART_DATACAPTION_PROP = FAST_PROPERTY_ID_START + 14000, + FAST_PROPERTY_ID_START_CHART_SPLINE_PROP = FAST_PROPERTY_ID_START + 15000, + FAST_PROPERTY_ID_START_CHART_STOCK_PROP = FAST_PROPERTY_ID_START + 16000, + FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP = FAST_PROPERTY_ID_START + 17000, + FAST_PROPERTY_ID_START_SCALE_TEXT_PROP = FAST_PROPERTY_ID_START + 18000, +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/FillProperties.hxx b/chart2/source/inc/FillProperties.hxx new file mode 100644 index 0000000000..84759cfa0c --- /dev/null +++ b/chart2/source/inc/FillProperties.hxx @@ -0,0 +1,74 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "PropertyHelper.hxx" +#include "FastPropertyIdRanges.hxx" +#include "charttoolsdllapi.hxx" + +#include <vector> + +namespace com::sun::star::beans { struct Property; } + +namespace chart +{ + +// implements service FillProperties +namespace FillProperties +{ + // FastProperty Ids for properties + enum + { + // com.sun.star.drawing.FillProperties + PROP_FILL_STYLE = FAST_PROPERTY_ID_START_FILL_PROP + , PROP_FILL_COLOR + , PROP_FILL_TRANSPARENCE + , PROP_FILL_TRANSPARENCE_GRADIENT_NAME +// , PROP_FILL_TRANSPARENCE_GRADIENT //optional + , PROP_FILL_GRADIENT_NAME + , PROP_FILL_GRADIENT_STEPCOUNT +// , PROP_FILL_GRADIENT //optional + , PROP_FILL_HATCH_NAME +// , PROP_FILL_HATCH //optional + // bitmap properties start + , PROP_FILL_BITMAP_NAME +// , PROP_FILL_BITMAP //optional +// , PROP_FILL_BITMAP_URL //optional + , PROP_FILL_BITMAP_OFFSETX + , PROP_FILL_BITMAP_OFFSETY + , PROP_FILL_BITMAP_POSITION_OFFSETX + , PROP_FILL_BITMAP_POSITION_OFFSETY + , PROP_FILL_BITMAP_RECTANGLEPOINT + , PROP_FILL_BITMAP_LOGICALSIZE + , PROP_FILL_BITMAP_SIZEX + , PROP_FILL_BITMAP_SIZEY + , PROP_FILL_BITMAP_MODE + // bitmap properties end + , PROP_FILL_BACKGROUND + }; + + OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector( + std::vector< css::beans::Property > & rOutProperties ); + + OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ); +} + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/FormattedString.hxx b/chart2/source/inc/FormattedString.hxx new file mode 100644 index 0000000000..23c81454fa --- /dev/null +++ b/chart2/source/inc/FormattedString.hxx @@ -0,0 +1,142 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" +#include "PropertyHelper.hxx" + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::chart2::XDataPointCustomLabelField, // inherits from XFormattedString2 + css::lang::XServiceInfo, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + FormattedString_Base; +} + +class FormattedString final : + public impl::FormattedString_Base, + public ::property::OPropertySet +{ +public: + explicit FormattedString(); + virtual ~FormattedString() override; + + /// declare XServiceInfo methods + 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + virtual void SAL_CALL setPropertyValue(const OUString& p1, const css::uno::Any& p2) override + { ::property::OPropertySet::setPropertyValue(p1, p2); } + virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& p1) override + { return ::property::OPropertySet::getPropertyValue(p1); } + virtual void SAL_CALL addPropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override + { ::property::OPropertySet::addPropertyChangeListener(p1, p2); } + virtual void SAL_CALL removePropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override + { ::property::OPropertySet::removePropertyChangeListener(p1, p2); } + virtual void SAL_CALL addVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override + { ::property::OPropertySet::addVetoableChangeListener(p1, p2); } + virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override + { ::property::OPropertySet::removeVetoableChangeListener(p1, p2); } + + explicit FormattedString( const FormattedString & rOther ); + + // ____ XFormattedString ____ + virtual OUString SAL_CALL getString() override; + virtual void SAL_CALL setString( const OUString& String ) override; + + // ____ XDataPointCustomLabelField ____ + virtual css::chart2::DataPointCustomLabelFieldType SAL_CALL getFieldType() override; + virtual void SAL_CALL + setFieldType( const css::chart2::DataPointCustomLabelFieldType FieldType ) override; + virtual OUString SAL_CALL getGuid() override; + void SAL_CALL setGuid( const OUString& guid ) override; + virtual sal_Bool SAL_CALL getDataLabelsRange() override; + virtual void SAL_CALL setDataLabelsRange( sal_Bool dataLabelsRange ) override; + virtual OUString SAL_CALL getCellRange() override; + virtual void SAL_CALL setCellRange( const OUString& cellRange ) override; + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + + // ____ OPropertySet ____ + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + +private: + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + void fireModifyEvent(); + + // ____ XFormattedString ____ + OUString m_aString; + + // ____ XDataPointCustomLabelField ____ + css::chart2::DataPointCustomLabelFieldType m_aType; + OUString m_aGuid; + OUString m_aCellRange; + bool m_bDataLabelsRange; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +OOO_DLLPUBLIC_CHARTTOOLS const ::chart::tPropertyValueMap & StaticFormattedStringDefaults(); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/FormattedStringHelper.hxx b/chart2/source/inc/FormattedStringHelper.hxx new file mode 100644 index 0000000000..9e4d33b6af --- /dev/null +++ b/chart2/source/inc/FormattedStringHelper.hxx @@ -0,0 +1,44 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <rtl/ref.hxx> +#include <rtl/ustring.hxx> +#include <vector> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XFormattedString2; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +namespace chart +{ +class FormattedString; + +class FormattedStringHelper +{ +public: + static rtl::Reference< ::chart::FormattedString > + createFormattedString( + const OUString & rString + , const css::uno::Reference< css::beans::XPropertySet > & xTextProperties ) noexcept; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/GridProperties.hxx b/chart2/source/inc/GridProperties.hxx new file mode 100644 index 0000000000..e5264a1b2f --- /dev/null +++ b/chart2/source/inc/GridProperties.hxx @@ -0,0 +1,98 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" + +#include "OPropertySet.hxx" + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + GridProperties_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS GridProperties final : + public impl::GridProperties_Base, + public ::property::OPropertySet +{ +public: + explicit GridProperties(); + explicit GridProperties( const GridProperties & rOther ); + virtual ~GridProperties() override; + + /// 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + +private: + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/InternalData.hxx b/chart2/source/inc/InternalData.hxx new file mode 100644 index 0000000000..9d9abeb3a7 --- /dev/null +++ b/chart2/source/inc/InternalData.hxx @@ -0,0 +1,96 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/uno/Sequence.hxx> + +#include <vector> +#include <valarray> + +namespace chart +{ + +class InternalData +{ +public: + InternalData(); + + void createDefaultData(); + + void setData( const css::uno::Sequence< css::uno::Sequence< double > > & rDataInRows ); + css::uno::Sequence< css::uno::Sequence< double > > getData() const; + + css::uno::Sequence< double > getColumnValues( sal_Int32 nColumnIndex ) const; + css::uno::Sequence< double > getRowValues( sal_Int32 nRowIndex ) const; + + void setColumnValues( sal_Int32 nColumnIndex, const std::vector< double > & rNewData ); + void setRowValues( sal_Int32 nRowIndex, const std::vector< double > & rNewData ); + + void setComplexColumnLabel( sal_Int32 nColumnIndex, std::vector< css::uno::Any >&& rComplexLabel ); + void setComplexRowLabel( sal_Int32 nRowIndex, std::vector< css::uno::Any >&& rComplexLabel ); + + std::vector< css::uno::Any > getComplexColumnLabel( sal_Int32 nColumnIndex ) const; + std::vector< css::uno::Any > getComplexRowLabel( sal_Int32 nRowIndex ) const; + + void swapRowWithNext( sal_Int32 nRowIndex ); + void swapColumnWithNext( sal_Int32 nColumnIndex ); + + void insertColumn( sal_Int32 nAfterIndex ); + void insertRow( sal_Int32 nAfterIndex ); + void deleteColumn( sal_Int32 nAtIndex ); + void deleteRow( sal_Int32 nAtIndex ); + + /// @return the index of the newly appended column + sal_Int32 appendColumn(); + /// @return the index of the newly appended row + sal_Int32 appendRow(); + + sal_Int32 getRowCount() const; + sal_Int32 getColumnCount() const; + + typedef std::vector< std::vector< css::uno::Any > > tVecVecAny; //inner index is hierarchical level + + void setComplexRowLabels( tVecVecAny&& rNewRowLabels ); + const tVecVecAny& getComplexRowLabels() const; + void setComplexColumnLabels( tVecVecAny&& rNewColumnLabels ); + const tVecVecAny& getComplexColumnLabels() const; + + void dump() const; + +private: //methods + /** resizes the data if at least one of the given dimensions is larger than + before. The data is never becoming smaller only larger. + + @return </true>, if the data was enlarged + */ + bool enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount ); + +private: + sal_Int32 m_nColumnCount; + sal_Int32 m_nRowCount; + + typedef std::valarray< double > tDataType; + tDataType m_aData; + tVecVecAny m_aRowLabels;//outer index is row index, inner index is category level + tVecVecAny m_aColumnLabels;//outer index is column index +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx new file mode 100644 index 0000000000..a5032efcda --- /dev/null +++ b/chart2/source/inc/InternalDataProvider.hxx @@ -0,0 +1,220 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "InternalData.hxx" + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart/XDateCategories.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> +#include <com/sun/star/chart2/XInternalDataProvider.hpp> +#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> +#include <rtl/ref.hxx> + +#include <map> + +namespace com::sun::star::chart2 { class XChartDocument; } + +namespace chart +{ +class ChartModel; +class UncachedDataSequence; + +namespace impl +{ + +typedef ::cppu::WeakImplHelper< + css::chart2::XInternalDataProvider, + css::chart2::data::XRangeXMLConversion, + css::chart2::XAnyDescriptionAccess, + css::chart::XDateCategories, + css::util::XCloneable, + css::lang::XInitialization, + css::lang::XServiceInfo > + InternalDataProvider_Base; +} + +/** Data provider that handles data internally. This is used for charts with + their own data. + + <p>The format for single ranges is "categories|label n|n" where n is a + non-negative number. Meaning return all categories, the label of sequence n, + or the data of sequence n.</p> + + <p>The format for a complete range is "all". (Do we need more than + that?)</p> + */ +class InternalDataProvider final : + public impl::InternalDataProvider_Base +{ +public: + explicit InternalDataProvider(); + + // #i120559# allow handing over a default for data orientation + // (DataInColumns) that will be used when no data is available + explicit InternalDataProvider( + const rtl::Reference< ::chart::ChartModel > & xChartDoc, + bool bConnectToModel, + bool bDefaultDataInColumns ); + explicit InternalDataProvider( const InternalDataProvider & rOther ); + virtual ~InternalDataProvider() override; + + /// declare XServiceInfo methods + 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; + + // ____ XInternalDataProvider ____ + virtual sal_Bool SAL_CALL hasDataByRangeRepresentation( const OUString& aRange ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL + getDataByRangeRepresentation( const OUString& aRange ) override; + virtual void SAL_CALL setDataByRangeRepresentation( + const OUString& aRange, + const css::uno::Sequence< css::uno::Any >& aNewData ) override; + virtual void SAL_CALL insertSequence( ::sal_Int32 nAfterIndex ) override; + virtual void SAL_CALL deleteSequence( ::sal_Int32 nAtIndex ) override; + virtual void SAL_CALL appendSequence() override; + virtual void SAL_CALL insertComplexCategoryLevel( ::sal_Int32 nLevel ) override; + virtual void SAL_CALL deleteComplexCategoryLevel( ::sal_Int32 nLevel ) override; + virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex ) override; + virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex ) override; + virtual void SAL_CALL swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex ) override; + virtual void SAL_CALL registerDataSequenceForChanges( + const css::uno::Reference< css::chart2::data::XDataSequence >& xSeq ) override; + + // ____ XDataProvider (base of XInternalDataProvider) ____ + virtual sal_Bool SAL_CALL createDataSourcePossible( + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override; + virtual css::uno::Reference< css::chart2::data::XDataSource > SAL_CALL createDataSource( + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL detectArguments( + const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource ) override; + virtual sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible( + const OUString& aRangeRepresentation ) override; + virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation( + const OUString& aRangeRepresentation ) override; + + virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation, + const OUString& aRoleQualifier ) override; + + virtual css::uno::Reference< css::sheet::XRangeSelection > SAL_CALL getRangeSelection() override; + + // ____ XRangeXMLConversion ____ + virtual OUString SAL_CALL convertRangeToXML( + const OUString& aRangeRepresentation ) override; + virtual OUString SAL_CALL convertRangeFromXML( + const OUString& aXMLRange ) override; + + // ____ XDateCategories ____ + virtual css::uno::Sequence< double > SAL_CALL getDateCategories() override; + virtual void SAL_CALL setDateCategories( const css::uno::Sequence< double >& rDates ) override; + + // ____ XAnyDescriptionAccess ____ + virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL + getAnyRowDescriptions() override; + virtual void SAL_CALL setAnyRowDescriptions( + const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aRowDescriptions ) override; + virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL + getAnyColumnDescriptions() override; + virtual void SAL_CALL setAnyColumnDescriptions( + const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aColumnDescriptions ) override; + + // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____ + virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL + getComplexRowDescriptions() override; + virtual void SAL_CALL setComplexRowDescriptions( + const css::uno::Sequence< css::uno::Sequence< OUString > >& aRowDescriptions ) override; + virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL + getComplexColumnDescriptions() override; + virtual void SAL_CALL setComplexColumnDescriptions( + const css::uno::Sequence< css::uno::Sequence< OUString > >& aColumnDescriptions ) override; + + // ____ XChartDataArray (base of XComplexDescriptionAccess) ____ + virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override; + virtual void SAL_CALL setData( + const css::uno::Sequence< css::uno::Sequence< double > >& aData ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override; + virtual void SAL_CALL setRowDescriptions( + const css::uno::Sequence< OUString >& aRowDescriptions ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions() override; + virtual void SAL_CALL setColumnDescriptions( + const css::uno::Sequence< OUString >& aColumnDescriptions ) override; + + // ____ XChartData (base of XChartDataArray) ____ + virtual void SAL_CALL addChartDataChangeEventListener( + const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; + virtual void SAL_CALL removeChartDataChangeEventListener( + const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; + virtual double SAL_CALL getNotANumber() override; + virtual sal_Bool SAL_CALL isNotANumber( + double nNumber ) override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + // css::lang::XInitialization: + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > & aArguments) override; + +private: + void addDataSequenceToMap( + const OUString & rRangeRepresentation, + const css::uno::Reference< css::chart2::data::XDataSequence > & xSequence ); + + css::uno::Reference< css::chart2::data::XDataSequence > + createDataSequenceAndAddToMap( const OUString & rRangeRepresentation, + const OUString & rRole ); + rtl::Reference< UncachedDataSequence > + createDataSequenceAndAddToMap( const OUString & rRangeRepresentation ); + + rtl::Reference<UncachedDataSequence> + createDataSequenceFromArray( const OUString& rArrayStr, std::u16string_view rRole, + std::u16string_view rRoleQualifier); + + void deleteMapReferences( const OUString & rRangeRepresentation ); + + void adaptMapReferences( + const OUString & rOldRangeRepresentation, + const OUString & rNewRangeRepresentation ); + + void increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd ); + void decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd ); + + typedef std::multimap< OUString, + css::uno::WeakReference< css::chart2::data::XDataSequence > > + tSequenceMap; + typedef std::pair< tSequenceMap::iterator, tSequenceMap::iterator > tSequenceMapRange; + + /** cache for all sequences that have been returned. + + If the range-representation of a sequence changes and it is still + referred to by some component (weak reference is valid), the range will + be adapted. + */ + tSequenceMap m_aSequenceMap; + InternalData m_aInternalData; + bool m_bDataInColumns; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/LabeledDataSequence.hxx b/chart2/source/inc/LabeledDataSequence.hxx new file mode 100644 index 0000000000..ab5338420b --- /dev/null +++ b/chart2/source/inc/LabeledDataSequence.hxx @@ -0,0 +1,88 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <cppuhelper/implbase.hxx> + +#include <com/sun/star/chart2/data/XLabeledDataSequence2.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include "ModifyListenerHelper.hxx" +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::chart2::data { class XDataSequence; } +namespace com::sun::star::util { class XCloneable; } +namespace com::sun::star::util { class XModifyListener; } + +namespace chart +{ + +namespace impl +{ +typedef cppu::WeakImplHelper< + css::chart2::data::XLabeledDataSequence2, + css::lang::XServiceInfo > + LabeledDataSequence_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS LabeledDataSequence final : + public impl::LabeledDataSequence_Base +{ +public: + explicit LabeledDataSequence(); + explicit LabeledDataSequence(const LabeledDataSequence &); + explicit LabeledDataSequence( + css::uno::Reference< css::chart2::data::XDataSequence > xValues ); + explicit LabeledDataSequence( + css::uno::Reference< css::chart2::data::XDataSequence > xValues, + css::uno::Reference< css::chart2::data::XDataSequence > xLabels ); + + virtual ~LabeledDataSequence() override; + + /// declare XServiceInfo methods + 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; + + // ____ XLabeledDataSequence ____ + virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL getValues() override; + virtual void SAL_CALL setValues( + const css::uno::Reference< css::chart2::data::XDataSequence >& xSequence ) override; + virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL getLabel() override; + virtual void SAL_CALL setLabel( + const css::uno::Reference< css::chart2::data::XDataSequence >& xSequence ) override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + +private: + css::uno::Reference< css::chart2::data::XDataSequence > m_xData; + css::uno::Reference< css::chart2::data::XDataSequence > m_xLabel; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/Legend.hxx b/chart2/source/inc/Legend.hxx new file mode 100644 index 0000000000..9caa0c7b06 --- /dev/null +++ b/chart2/source/inc/Legend.hxx @@ -0,0 +1,106 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include <com/sun/star/chart2/XLegend.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" +#include "charttoolsdllapi.hxx" +#include "PropertyHelper.hxx" + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::chart2::XLegend, + css::lang::XServiceInfo, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + Legend_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS Legend final : + public impl::Legend_Base, + public ::property::OPropertySet +{ +public: + explicit Legend(); + virtual ~Legend() override; + + /// 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + explicit Legend( const Legend & rOther ); + +private: + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + + // ____ OPropertySet ____ + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + +public: + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + +private: + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +OOO_DLLPUBLIC_CHARTTOOLS const ::chart::tPropertyValueMap& StaticLegendDefaults(); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/LegendHelper.hxx b/chart2/source/inc/LegendHelper.hxx new file mode 100644 index 0000000000..f2bf2e55fe --- /dev/null +++ b/chart2/source/inc/LegendHelper.hxx @@ -0,0 +1,58 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ref.hxx> +#include "charttoolsdllapi.hxx" + +namespace chart { class ChartModel; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::chart2 { class XLegend; } +namespace com::sun::star::uno { class XComponentContext; } + +namespace chart +{ +class Diagram; +class Legend; + +class OOO_DLLPUBLIC_CHARTTOOLS LegendHelper +{ +public: + static rtl::Reference< ::chart::Legend > + showLegend( ChartModel& rModel + , const css::uno::Reference< css::uno::XComponentContext >& xContext ); + + static void hideLegend( ChartModel& rModel ); + + static rtl::Reference< ::chart::Legend > + getLegend( ChartModel& rModel + , const css::uno::Reference< css::uno::XComponentContext >& xContext = nullptr + , bool bCreate = false ); + + /** returns <FALSE/>, if either there is no legend at the diagram, or there + is a legend which has a "Show" property of value <FALSE/>. Otherwise, + <TRUE/> is returned. + */ + static bool hasLegend( const rtl::Reference< ::chart::Diagram > & xDiagram ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/LifeTime.hxx b/chart2/source/inc/LifeTime.hxx new file mode 100644 index 0000000000..e16edd1e59 --- /dev/null +++ b/chart2/source/inc/LifeTime.hxx @@ -0,0 +1,198 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <mutex> +#include <osl/conditn.hxx> +#include <comphelper/interfacecontainer4.hxx> +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::document { class XStorageChangeListener; } +namespace com::sun::star::lang { class XComponent; } +namespace com::sun::star::lang { class XEventListener; } +namespace com::sun::star::util { class CloseVetoException; } +namespace com::sun::star::util { class XCloseListener; } +namespace com::sun::star::util { class XCloseable; } +namespace com::sun::star::util { class XModifyListener; } +namespace com::sun::star::view { class XSelectionChangeListener; } + +namespace apphelper +{ + +class OOO_DLLPUBLIC_CHARTTOOLS LifeTimeManager +{ +friend class LifeTimeGuard; +public: + LifeTimeManager( css::lang::XComponent* pComponent ); + virtual ~LifeTimeManager(); + + bool impl_isDisposed( bool bAssert=true ); + /// @throws css::uno::RuntimeException + bool dispose(); + + mutable std::mutex m_aAccessMutex; + ::comphelper::OInterfaceContainerHelper4<css::util::XCloseListener> m_aCloseListeners; + ::comphelper::OInterfaceContainerHelper4<css::util::XModifyListener> m_aModifyListeners; + ::comphelper::OInterfaceContainerHelper4<css::document::XStorageChangeListener> m_aStorageChangeListeners; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners; + ::comphelper::OInterfaceContainerHelper4<css::view::XSelectionChangeListener> m_aSelectionChangeListeners; + +protected: + SAL_DLLPRIVATE virtual bool impl_canStartApiCall(); + SAL_DLLPRIVATE virtual void impl_apiCallCountReachedNull(std::unique_lock<std::mutex>& /*rGuard*/){} + + SAL_DLLPRIVATE void impl_registerApiCall(bool bLongLastingCall); + SAL_DLLPRIVATE void impl_unregisterApiCall(std::unique_lock<std::mutex>& rGuard, bool bLongLastingCall); + + css::lang::XComponent* m_pComponent; + ::osl::Condition m_aNoAccessCountCondition; + sal_Int32 m_nAccessCount; + bool volatile m_bDisposed; + bool volatile m_bInDispose; + ::osl::Condition m_aNoLongLastingCallCountCondition; + sal_Int32 m_nLongLastingCallCount; +}; + +class CloseableLifeTimeManager final : public LifeTimeManager +{ + css::util::XCloseable* m_pCloseable; + + ::osl::Condition m_aEndTryClosingCondition; + bool volatile m_bClosed; + bool volatile m_bInTryClose; + //the ownership between model and controller is not clear at first + //each controller might consider him as owner of the model first + //at start the model is not considered as owner of itself + bool volatile m_bOwnership; + +public: + CloseableLifeTimeManager( css::util::XCloseable* pCloseable + , css::lang::XComponent* pComponent ); + virtual ~CloseableLifeTimeManager() override; + + bool impl_isDisposedOrClosed( bool bAssert=true ); +/// @throws css::uno::Exception + bool g_close_startTryClose(bool bDeliverOwnership); +/// @throws css::util::CloseVetoException + void g_close_isNeedToCancelLongLastingCalls( bool bDeliverOwnership, css::util::CloseVetoException const & ex ); + void g_close_endTryClose(bool bDeliverOwnership ); + void g_close_endTryClose_doClose(); +/// @throws css::uno::RuntimeException + void g_addCloseListener( const css::uno::Reference< css::util::XCloseListener > & xListener ); + +private: + virtual bool impl_canStartApiCall() override; + virtual void impl_apiCallCountReachedNull(std::unique_lock<std::mutex>& rGuard) override; + + void impl_setOwnership( bool bDeliverOwnership, bool bMyVeto ); + void impl_doClose(std::unique_lock<std::mutex>& rGuard); +}; + +/* +Use this Guard in your ApiCalls to protect access on resources +which will be released in dispose. +It's guaranteed that the release of resources only starts if your +guarded call has finished. +! It's only partly guaranteed that this resources will not change during the call. +See the example for details. + +This class is to be used as described in the example. + +If this guard is used in all api calls of an XCloseable object +it's guaranteed that the closeable will close itself after finishing the last call +if it should do so. + + ::ApiCall +{ + //hold no mutex!!! + LifeTimeGuard aLifeTimeGuard(m_aLifeTimeManager); + + //mutex is acquired; call is not registered + + if(!aLifeTimeGuard.startApiCall()) + return ; //behave as passive as possible, if disposed or closed + + //mutex is acquired, call is registered + { + //you might access some private members here + //but then you need to protect access to these members always like this + //never call to the outside here + } + + aLifeTimeGuard.clear(); //!!! + + //Mutex is released, the running call is still registered + //this call will finish before the 'release-section' in dispose is allowed to start + + { + //you might access some private members here guarded with your own mutex + //but release your mutex at the end of this block + } + + //you can call to the outside (without holding the mutex) without becoming disposed + + //End of method -> ~LifeTimeGuard + //-> call is unregistered + //-> this object might be disposed now +} + +your XComponent::dispose method has to be implemented in the following way: + + ::dispose() +{ + //hold no mutex!!! + if( !m_aLifeTimeManager.dispose() ) + return; + + //--release all resources and references + +} + +*/ + +class LifeTimeGuard +{ + +public: + LifeTimeGuard( LifeTimeManager& rManager ) + : m_guard( rManager.m_aAccessMutex ) + , m_rManager(rManager) + , m_bCallRegistered(false) + , m_bLongLastingCallRegistered(false) + { + + } + bool startApiCall(bool bLongLastingCall=false); + ~LifeTimeGuard(); + void clear() { m_guard.unlock(); } + +private: + std::unique_lock<std::mutex> m_guard; + LifeTimeManager& m_rManager; + bool m_bCallRegistered; + bool m_bLongLastingCallRegistered; + +private: + LifeTimeGuard( const LifeTimeGuard& ) = delete; + LifeTimeGuard& operator= ( const LifeTimeGuard& ) = delete; +}; + +}//end namespace apphelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/LinePropertiesHelper.hxx b/chart2/source/inc/LinePropertiesHelper.hxx new file mode 100644 index 0000000000..2999de81a7 --- /dev/null +++ b/chart2/source/inc/LinePropertiesHelper.hxx @@ -0,0 +1,68 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "PropertyHelper.hxx" +#include "FastPropertyIdRanges.hxx" +#include "charttoolsdllapi.hxx" + +#include <vector> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::beans { struct Property; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +namespace chart +{ + +// implements service LineProperties +namespace LinePropertiesHelper +{ + // FastProperty Ids for properties + enum + { + // com.sun.star.drawing.LineProperties + PROP_LINE_STYLE = FAST_PROPERTY_ID_START_LINE_PROP, + PROP_LINE_DASH, + PROP_LINE_DASH_NAME, //not in service description + PROP_LINE_COLOR, + PROP_LINE_TRANSPARENCE, + PROP_LINE_WIDTH, + PROP_LINE_JOINT, + PROP_LINE_CAP + }; + + OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector( + std::vector< css::beans::Property > & rOutProperties ); + + OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ); + + bool IsLineVisible( const css::uno::Reference< + css::beans::XPropertySet >& xLineProperties ); + void SetLineVisible( const css::uno::Reference< + css::beans::XPropertySet >& xLineProperties ); + void SetLineInvisible( const css::uno::Reference< + css::beans::XPropertySet >& xLineProperties ); + void SetLineColor( const css::uno::Reference< + css::beans::XPropertySet >& xGridProperties, sal_Int32 nColor ); +} + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/LinearRegressionCurveCalculator.hxx b/chart2/source/inc/LinearRegressionCurveCalculator.hxx new file mode 100644 index 0000000000..05853b26a8 --- /dev/null +++ b/chart2/source/inc/LinearRegressionCurveCalculator.hxx @@ -0,0 +1,51 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "PolynomialRegressionCurveCalculator.hxx" + +namespace chart +{ + +class LinearRegressionCurveCalculator final : public PolynomialRegressionCurveCalculator +{ +public: + LinearRegressionCurveCalculator(); + virtual ~LinearRegressionCurveCalculator() override; + +private: + virtual void SAL_CALL setRegressionProperties( + sal_Int32 aDegree, + sal_Bool aForceIntercept, + double aInterceptValue, + sal_Int32 aPeriod, + sal_Int32 nMovingType) override; + + virtual css::uno::Sequence<css::geometry::RealPoint2D> SAL_CALL getCurveValues( + double min, + double max, + sal_Int32 nPointCount, + const css::uno::Reference<css::chart2::XScaling>& xScalingX, + const css::uno::Reference<css::chart2::XScaling>& xScalingY, + sal_Bool bMaySkipPointsInCalculation ) override; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/LogarithmicRegressionCurveCalculator.hxx b/chart2/source/inc/LogarithmicRegressionCurveCalculator.hxx new file mode 100644 index 0000000000..02fa1fc22b --- /dev/null +++ b/chart2/source/inc/LogarithmicRegressionCurveCalculator.hxx @@ -0,0 +1,60 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "RegressionCurveCalculator.hxx" + +namespace chart +{ + +class LogarithmicRegressionCurveCalculator final : public RegressionCurveCalculator +{ +public: + LogarithmicRegressionCurveCalculator(); + virtual ~LogarithmicRegressionCurveCalculator() override; + +protected: + virtual OUString ImplGetRepresentation( + const css::uno::Reference<css::util::XNumberFormatter>& xNumFormatter, + sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const override; + +private: + // ____ XRegressionCurveCalculator ____ + virtual void SAL_CALL recalculateRegression( + const css::uno::Sequence<double>& aXValues, + const css::uno::Sequence<double>& aYValues ) override; + + virtual double SAL_CALL getCurveValue( double x ) override; + + virtual css::uno::Sequence<css::geometry::RealPoint2D> SAL_CALL getCurveValues( + double min, + double max, + sal_Int32 nPointCount, + const css::uno::Reference<css::chart2::XScaling>& xScalingX, + const css::uno::Reference<css::chart2::XScaling>& xScalingY, + sal_Bool bMaySkipPointsInCalculation ) override; + + // formula is: f(x) = m_fSlope * log( x ) + m_fIntercept + double m_fSlope; + double m_fIntercept; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/MeanValueRegressionCurveCalculator.hxx b/chart2/source/inc/MeanValueRegressionCurveCalculator.hxx new file mode 100644 index 0000000000..be46e97388 --- /dev/null +++ b/chart2/source/inc/MeanValueRegressionCurveCalculator.hxx @@ -0,0 +1,59 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "RegressionCurveCalculator.hxx" + +namespace chart +{ + +class MeanValueRegressionCurveCalculator final : public RegressionCurveCalculator +{ +public: + MeanValueRegressionCurveCalculator(); + virtual ~MeanValueRegressionCurveCalculator() override; + +protected: + virtual OUString ImplGetRepresentation( + const css::uno::Reference<css::util::XNumberFormatter>& xNumFormatter, + sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const override; + +private: + // ____ XRegressionCurveCalculator ____ + virtual void SAL_CALL recalculateRegression( + const css::uno::Sequence<double>& aXValues, + const css::uno::Sequence<double>& aYValues ) override; + + virtual double SAL_CALL getCurveValue( double x ) override; + + virtual css::uno::Sequence<css::geometry::RealPoint2D> SAL_CALL getCurveValues( + double min, + double max, + sal_Int32 nPointCount, + const css::uno::Reference<css::chart2::XScaling>& xScalingX, + const css::uno::Reference<css::chart2::XScaling>& xScalingY, + sal_Bool bMaySkipPointsInCalculation ) override; + + // formula is: f(x) = m_fMeanValue + double m_fMeanValue; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/MediaDescriptorHelper.hxx b/chart2/source/inc/MediaDescriptorHelper.hxx new file mode 100644 index 0000000000..cfef8fc14f --- /dev/null +++ b/chart2/source/inc/MediaDescriptorHelper.hxx @@ -0,0 +1,90 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::io { class XOutputStream; } +namespace com::sun::star::io { class XStream; } + +/* +* This class helps to read and write the properties mentioned in the service description +* com.sun.star.document.MediaDescriptor from and to a sequence of PropertyValues. +* Properties that are not mentioned in the service description +* are stored in the member AdditionalProperties. +* +* As an additional feature this helper class can generate a reduced sequence of PropertyValues +* that does not contain properties which are known to be only view relevant. This +* reduced sequence than might be attached to a model directly. +*/ + +namespace apphelper +{ + +class OOO_DLLPUBLIC_CHARTTOOLS MediaDescriptorHelper final +{ +public: + MediaDescriptorHelper( const css::uno::Sequence< css::beans::PropertyValue > & rMediaDescriptor ); + + const css::uno::Sequence< css::beans::PropertyValue >& getReducedForModel() const { return m_aModelProperties;} + + //all properties given in the constructor are stored in the following three sequences + + //properties which should be given to a model are additionally stored in this sequence (not documented properties and deprecated properties are not included!) + css::uno::Sequence< css::beans::PropertyValue > + m_aModelProperties; //these are properties which are not described in service com.sun.star.document.MediaDescriptor + + OUString FilterName; //internal filter name. + bool ISSET_FilterName; + + OUString HierarchicalDocumentName; + + css::uno::Reference< css::io::XOutputStream > + OutputStream; //a stream to receive the document data for saving + bool ISSET_OutputStream; + css::uno::Reference< css::io::XInputStream > + InputStream; //content of document. + bool ISSET_InputStream; + + bool ReadOnly; //open document readonly. + + OUString URL;// FileName, URL of the document. + bool ISSET_URL; + + // new framework objects + css::uno::Reference< css::embed::XStorage > + Storage; + bool ISSET_Storage; + css::uno::Reference< css::io::XStream > + Stream; + bool ISSET_Stream; + +private: + SAL_DLLPRIVATE void impl_init(); +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ModifyListenerCallBack.hxx b/chart2/source/inc/ModifyListenerCallBack.hxx new file mode 100644 index 0000000000..406804189e --- /dev/null +++ b/chart2/source/inc/ModifyListenerCallBack.hxx @@ -0,0 +1,57 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <tools/link.hxx> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include "charttoolsdllapi.hxx" + +namespace chart +{ +/** Use this class as a member if you want to listen on a XModifyBroadcaster +without becoming a XModifyListener yourself + */ + +class ModifyListenerCallBack_impl; + +class OOO_DLLPUBLIC_CHARTTOOLS ModifyListenerCallBack final +{ +public: + explicit ModifyListenerCallBack(const Link<void*, void>& rCallBack); + + ~ModifyListenerCallBack(); + + void startListening( + const ::com::sun::star::uno::Reference<::com::sun::star::util::XModifyBroadcaster>& + xBroadcaster); + SAL_DLLPRIVATE void stopListening(); + +private: //methods + ModifyListenerCallBack(const ModifyListenerCallBack&) = delete; + +private: //member + ModifyListenerCallBack_impl* pModifyListener_impl; + css::uno::Reference<css::util::XModifyListener> m_xModifyListener; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ModifyListenerHelper.hxx b/chart2/source/inc/ModifyListenerHelper.hxx new file mode 100644 index 0000000000..ee90d407a6 --- /dev/null +++ b/chart2/source/inc/ModifyListenerHelper.hxx @@ -0,0 +1,254 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <comphelper/interfacecontainer4.hxx> +#include <comphelper/compbase.hxx> +#include <rtl/ref.hxx> + +#include <mutex> +#include <algorithm> +#include <utility> + +namespace chart +{ + +/** This helper class serves as forwarder of modify events. It can be used + whenever an object has to send modify events after it gets a modify event of + one of its children. + */ +class ModifyEventForwarder final : + public ::comphelper::WeakComponentImplHelper< + css::util::XModifyBroadcaster, + css::util::XModifyListener > +{ +public: + ModifyEventForwarder(); + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + +private: + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ WeakComponentImplHelperBase ____ + virtual void disposing(std::unique_lock<std::mutex>& ) override; + + comphelper::OInterfaceContainerHelper4<css::util::XModifyListener> m_aModifyListeners; +}; + +} + +namespace chart::ModifyListenerHelper +{ + +namespace impl +{ + +template< class InterfaceRef > +struct addListenerFunctor +{ + explicit addListenerFunctor( css::uno::Reference< css::util::XModifyListener > xListener ) : + m_xListener(std::move( xListener )) + {} + + void operator() ( const InterfaceRef & xObject ) + { + css::uno::Reference< css::util::XModifyBroadcaster > + xBroadcaster( xObject, css::uno::UNO_QUERY ); + if( xBroadcaster.is() && m_xListener.is()) + xBroadcaster->addModifyListener( m_xListener ); + } +private: + css::uno::Reference< css::util::XModifyListener > m_xListener; +}; + +template< class InterfaceRef > +struct removeListenerFunctor +{ + explicit removeListenerFunctor( css::uno::Reference< css::util::XModifyListener > xListener ) : + m_xListener(std::move( xListener )) + {} + + void operator() ( const InterfaceRef & xObject ) + { + css::uno::Reference< css::util::XModifyBroadcaster > + xBroadcaster( xObject, css::uno::UNO_QUERY ); + if( xBroadcaster.is() && m_xListener.is()) + xBroadcaster->removeModifyListener( m_xListener ); + } +private: + css::uno::Reference< css::util::XModifyListener > m_xListener; +}; + +template< class Pair > +struct addListenerToMappedElementFunctor +{ + explicit addListenerToMappedElementFunctor( css::uno::Reference< css::util::XModifyListener > xListener ) : + m_xListener(std::move( xListener )) + {} + + void operator() ( const Pair & aPair ) + { + css::uno::Reference< css::util::XModifyBroadcaster > + xBroadcaster( aPair.second, css::uno::UNO_QUERY ); + if( xBroadcaster.is() && m_xListener.is()) + xBroadcaster->addModifyListener( m_xListener ); + } +private: + css::uno::Reference< css::util::XModifyListener > m_xListener; +}; + +template< class Pair > +struct removeListenerFromMappedElementFunctor +{ + explicit removeListenerFromMappedElementFunctor( css::uno::Reference< css::util::XModifyListener > xListener ) : + m_xListener(std::move( xListener )) + {} + + void operator() ( const Pair & aPair ) + { + css::uno::Reference< css::util::XModifyBroadcaster > + xBroadcaster( aPair.second, css::uno::UNO_QUERY ); + if( xBroadcaster.is() && m_xListener.is()) + xBroadcaster->removeModifyListener( m_xListener ); + } +private: + css::uno::Reference< css::util::XModifyListener > m_xListener; +}; + +} // namespace impl + +template< class InterfaceRef > +void addListener( + const InterfaceRef & xObject, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( xListener.is()) + { + impl::addListenerFunctor< InterfaceRef > aFunctor( xListener ); + aFunctor( xObject ); + } +} +template< class T > +void addListener( + const rtl::Reference<T> & xBroadcaster, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( xBroadcaster && xListener ) + xBroadcaster->addModifyListener( xListener ); +} + +template< class Container > +void addListenerToAllElements( + const Container & rContainer, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( xListener.is()) + std::for_each( rContainer.begin(), rContainer.end(), + impl::addListenerFunctor< typename Container::value_type >( xListener )); +} + +template< class T > +void addListenerToAllElements( + const std::vector<rtl::Reference<T>> & rContainer, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( !xListener ) + return; + for (auto const & i : rContainer) + i->addModifyListener(xListener); +} + +template< class Container > +void addListenerToAllMapElements( + const Container & rContainer, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( xListener.is()) + std::for_each( rContainer.begin(), rContainer.end(), + impl::addListenerToMappedElementFunctor< typename Container::value_type >( xListener )); +} + +template< class InterfaceRef > +void removeListener( + const InterfaceRef & xObject, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( xListener.is()) + { + impl::removeListenerFunctor< InterfaceRef > aFunctor( xListener ); + aFunctor( xObject ); + } +} + +template< class T > +void removeListener( + const rtl::Reference<T> & xBroadcaster, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( xBroadcaster && xListener ) + xBroadcaster->removeModifyListener( xListener ); +} + +template< class Container > +void removeListenerFromAllElements( + const Container & rContainer, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( xListener.is()) + std::for_each( rContainer.begin(), rContainer.end(), + impl::removeListenerFunctor< typename Container::value_type >( xListener )); +} + +template< class T > +void removeListenerFromAllElements( + const std::vector<rtl::Reference<T>> & rContainer, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( !xListener ) + return; + for (auto const & i : rContainer) + i->removeModifyListener(xListener); +} + +template< class Container > +void removeListenerFromAllMapElements( + const Container & rContainer, + const css::uno::Reference< css::util::XModifyListener > & xListener ) +{ + if( xListener.is()) + std::for_each( rContainer.begin(), rContainer.end(), + impl::removeListenerFromMappedElementFunctor< typename Container::value_type >( xListener )); +} + +} // namespace chart::ModifyListenerHelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx b/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx new file mode 100644 index 0000000000..f7e25fe513 --- /dev/null +++ b/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx @@ -0,0 +1,63 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "RegressionCurveCalculator.hxx" +#include "RegressionCalculationHelper.hxx" +#include <vector> + +namespace chart +{ + +class MovingAverageRegressionCurveCalculator final : public RegressionCurveCalculator +{ +public: + MovingAverageRegressionCurveCalculator(); + virtual ~MovingAverageRegressionCurveCalculator() override; + +protected: + virtual OUString ImplGetRepresentation( + const css::uno::Reference<css::util::XNumberFormatter>& xNumFormatter, + sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const override; + +private: + // ____ XRegressionCurveCalculator ____ + virtual void SAL_CALL recalculateRegression( + const css::uno::Sequence<double>& aXValues, + const css::uno::Sequence<double>& aYValues ) override; + + virtual double SAL_CALL getCurveValue( double x ) override; + + virtual css::uno::Sequence<css::geometry::RealPoint2D> SAL_CALL getCurveValues( + double min, + double max, + sal_Int32 nPointCount, + const css::uno::Reference<css::chart2::XScaling>& xScalingX, + const css::uno::Reference<css::chart2::XScaling>& xScalingY, + sal_Bool bMaySkipPointsInCalculation ) override; + + void calculateValues(RegressionCalculationHelper::tDoubleVectorPair aValues, bool bUseXAvg); + void calculateValuesCentral(RegressionCalculationHelper::tDoubleVectorPair aValues); + std::vector<double> aYList; + std::vector<double> aXList; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/NameContainer.hxx b/chart2/source/inc/NameContainer.hxx new file mode 100644 index 0000000000..12fc76978b --- /dev/null +++ b/chart2/source/inc/NameContainer.hxx @@ -0,0 +1,82 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <cppuhelper/implbase.hxx> + +#include <map> + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::container::XNameContainer, + css::lang::XServiceInfo, + css::util::XCloneable > + NameContainer_Base; +} + +/// Contains the XML namespaces map +/// +class NameContainer final : public impl::NameContainer_Base +{ +public: + NameContainer(); + explicit NameContainer( const NameContainer & rOther ); + virtual ~NameContainer() override; + + // XServiceInfo + 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; + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual sal_Bool SAL_CALL hasElements( ) override; + virtual css::uno::Type SAL_CALL getElementType( ) override; + + // XCloneable + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + +private: //member + + typedef std::map< OUString, css::uno::Any > tContentMap; + tContentMap m_aMap; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/NumberFormatterWrapper.hxx b/chart2/source/inc/NumberFormatterWrapper.hxx new file mode 100644 index 0000000000..c3412fc9c9 --- /dev/null +++ b/chart2/source/inc/NumberFormatterWrapper.hxx @@ -0,0 +1,68 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "charttoolsdllapi.hxx" +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <tools/date.hxx> + +class SvNumberFormatter; +class Color; + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS NumberFormatterWrapper final +{ +public: + NumberFormatterWrapper( const css::uno::Reference< css::util::XNumberFormatsSupplier >& xSupplier ); + ~NumberFormatterWrapper(); + + SvNumberFormatter* getSvNumberFormatter() const { return m_pNumberFormatter;} + const css::uno::Reference< css::util::XNumberFormatsSupplier >& + getNumberFormatsSupplier() const { return m_xNumberFormatsSupplier; }; + + OUString getFormattedString( sal_Int32 nNumberFormatKey, double fValue, Color& rLabelColor, bool& rbColorChanged ) const; + Date getNullDate() const; + +private: //private member + css::uno::Reference< css::util::XNumberFormatsSupplier > + m_xNumberFormatsSupplier; + + SvNumberFormatter* m_pNumberFormatter; + css::uno::Any m_aNullDate; +}; + +class FixedNumberFormatter final +{ +public: + FixedNumberFormatter( const css::uno::Reference< css::util::XNumberFormatsSupplier >& xSupplier + , sal_Int32 nNumberFormatKey ); + ~FixedNumberFormatter(); + + OUString getFormattedString( double fValue, Color& rLabelColor, bool& rbColorChanged ) const; + +private: + NumberFormatterWrapper m_aNumberFormatterWrapper; + sal_uInt32 m_nNumberFormatKey; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/OPropertySet.hxx b/chart2/source/inc/OPropertySet.hxx new file mode 100644 index 0000000000..aa5d2e7cd4 --- /dev/null +++ b/chart2/source/inc/OPropertySet.hxx @@ -0,0 +1,233 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +// helper classes +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> + +// interfaces and types +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <com/sun/star/style/XStyleSupplier.hpp> +#include "charttoolsdllapi.hxx" + +#include <unordered_map> + +namespace property +{ + +class OOO_DLLPUBLIC_CHARTTOOLS OPropertySet : + protected cppu::BaseMutex, + public ::cppu::OBroadcastHelper, + // includes beans::XPropertySet, XMultiPropertySet and XFastPropertySet + public ::cppu::OPropertySetHelper, + // includes uno::XWeak (and XInterface, esp. ref-counting) + + public css::lang::XTypeProvider, + public css::beans::XPropertyState, + public css::beans::XMultiPropertyStates, + public css::style::XStyleSupplier +{ +public: + OPropertySet(); + virtual ~OPropertySet(); + +protected: + explicit OPropertySet( const OPropertySet & rOther ); + + void SetNewValuesExplicitlyEvenIfTheyEqualDefault(); + + /** implement this method to provide default values for all properties + supporting defaults. If a property does not have a default value, you + may throw an UnknownPropertyException. + We pass the any by reference because this code is very hot and doing + it this way is cheaper than the two step process of constructing a new + any and then assigning to via a return value. + + @throws css::beans::UnknownPropertyException + @throws css::uno::RuntimeException + */ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const = 0; + + /** The InfoHelper table contains all property names and types of + this object. + + @return the object that provides information for the + PropertySetInfo + + @see ::cppu::OPropertySetHelper + */ + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override = 0; + + /** Try to convert the value <code>rValue</code> to the type required by the + property associated with <code>nHandle</code>. + + Override this method to take influence in modification of properties. + + If the conversion changed , </sal_True> is returned and the converted value + is in <code>rConvertedValue</code>. The former value is contained in + <code>rOldValue</code>. + + After this call returns successfully, the vetoable listeners are + notified. + + @throws IllegalArgumentException, if the conversion was not successful, + or if there is no corresponding property to the given handle. + + @param rConvertedValue the converted value. Only set if return is true. + @param rOldValue the old value. Only set if return is true. + @param nHandle the handle of the property. + + @return true, if the conversion was successful and converted value + differs from the old value. + + @see ::cppu::OPropertySetHelper + */ + virtual sal_Bool SAL_CALL convertFastPropertyValue + ( css::uno::Any & rConvertedValue, + css::uno::Any & rOldValue, + sal_Int32 nHandle, + const css::uno::Any& rValue ) override final; + + /** The same as setFastPropertyValue; nHandle is always valid. + The changes must not be broadcasted in this method. + + @attention + Although you are permitted to throw any UNO exception, only the following + are valid for usage: + -- css::beans::UnknownPropertyException + -- css::beans::PropertyVetoException + -- css::lang::IllegalArgumentException + -- css::lang::WrappedTargetException + -- css::uno::RuntimeException + + @param nHandle handle + @param rValue value + + @see ::cppu::OPropertySetHelper + */ + virtual void SAL_CALL setFastPropertyValue_NoBroadcast + ( sal_Int32 nHandle, + const css::uno::Any& rValue ) override; + + /** + The same as getFastPropertyValue, but return the value through rValue and + nHandle is always valid. + + @see ::cppu::OPropertySetHelper + */ + virtual void SAL_CALL getFastPropertyValue + ( css::uno::Any& rValue, + sal_Int32 nHandle ) const override; + + /** implement this method in derived classes to get called when properties + change. + */ + virtual void firePropertyChangeEvent(); + +public: + /// make original interface function visible again + using ::cppu::OPropertySetHelper::getFastPropertyValue; + + // Interfaces + + // ____ XInterface ____ + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + + // ____ XTypeProvider ____ + virtual css::uno::Sequence< css::uno::Type > SAL_CALL + getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() override; + + // ____ XPropertyState ____ + virtual css::beans::PropertyState SAL_CALL + getPropertyState( const OUString& PropertyName ) override final; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL + getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override final; + virtual void SAL_CALL + setPropertyToDefault( const OUString& PropertyName ) override final; + virtual css::uno::Any SAL_CALL + getPropertyDefault( const OUString& aPropertyName ) override final; + + // ____ XMultiPropertyStates ____ + // Note: getPropertyStates() is already implemented in XPropertyState with the + // same signature + virtual void SAL_CALL + setAllPropertiesToDefault() override final; + virtual void SAL_CALL + setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override final; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL + getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override final; + + // ____ XStyleSupplier ____ + virtual css::uno::Reference< css::style::XStyle > SAL_CALL getStyle() override final; + virtual void SAL_CALL setStyle( const css::uno::Reference< css::style::XStyle >& xStyle ) override final; + + // ____ XMultiPropertySet ____ + virtual void SAL_CALL setPropertyValues( + const css::uno::Sequence< OUString >& PropertyNames, + const css::uno::Sequence< css::uno::Any >& Values ) override final; + + // ____ XFastPropertySet ____ + virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue ) override final; + + // Note: it is assumed that the base class implements setPropertyValue by + // using setFastPropertyValue + +private: + /** supports states DIRECT_VALUE and DEFAULT_VALUE + */ + css::beans::PropertyState + GetPropertyStateByHandle( sal_Int32 nHandle ) const; + + css::uno::Sequence< css::beans::PropertyState > + GetPropertyStatesByHandle( const std::vector< sal_Int32 > & aHandles ) const; + + void SetPropertyToDefault( sal_Int32 nHandle ); + void SetPropertiesToDefault( const std::vector< sal_Int32 > & aHandles ); + void SetAllPropertiesToDefault(); + + /** @param rValue is set to the value for the property given in nHandle. If + the property is not set, the style chain is searched for any + instance set there. If there was no value found either in the + property set itself or any of its styles, rValue remains + unchanged and false is returned. + + @return false if the property is default, true otherwise. + */ + bool GetPropertyValueByHandle( + css::uno::Any & rValue, + sal_Int32 nHandle ) const; + + void SetPropertyValueByHandle( sal_Int32 nHandle, + const css::uno::Any & rValue ); + + bool SetStyle( const css::uno::Reference< css::style::XStyle > & xStyle ); + + bool m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault; + std::unordered_map< sal_Int32, css::uno::Any > m_aProperties; + css::uno::Reference< css::style::XStyle > m_xStyle; +}; + +} // namespace property + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx new file mode 100644 index 0000000000..c6d0c724bd --- /dev/null +++ b/chart2/source/inc/ObjectIdentifier.hxx @@ -0,0 +1,262 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sal/config.h> + +#include <string_view> + +#include "TitleHelper.hxx" +#include "charttoolsdllapi.hxx" + +#include <rtl/ustring.hxx> +#include <rtl/ref.hxx> + +namespace chart { class ChartModel; } +namespace com::sun::star::awt { struct Point; } +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XAxis; } +namespace com::sun::star::chart2 { class XChartDocument; } +namespace com::sun::star::chart2 { class XCoordinateSystem; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::drawing { class XShape; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::uno { class XInterface; } + +namespace chart +{ +class Axis; +class BaseCoordinateSystem; +class DataSeries; +class Diagram; +class Legend; + +enum ObjectType +{ + OBJECTTYPE_PAGE, + OBJECTTYPE_TITLE, + OBJECTTYPE_LEGEND, + OBJECTTYPE_LEGEND_ENTRY, + OBJECTTYPE_DIAGRAM, + OBJECTTYPE_DIAGRAM_WALL, + OBJECTTYPE_DIAGRAM_FLOOR, + OBJECTTYPE_AXIS, + OBJECTTYPE_AXIS_UNITLABEL, + OBJECTTYPE_GRID, + OBJECTTYPE_SUBGRID, + OBJECTTYPE_DATA_SERIES, + OBJECTTYPE_DATA_POINT, + OBJECTTYPE_DATA_LABELS, + OBJECTTYPE_DATA_LABEL, + OBJECTTYPE_DATA_ERRORS_X, + OBJECTTYPE_DATA_ERRORS_Y, + OBJECTTYPE_DATA_ERRORS_Z, + OBJECTTYPE_DATA_CURVE,//e.g. a statistical method printed as line + OBJECTTYPE_DATA_AVERAGE_LINE, + OBJECTTYPE_DATA_CURVE_EQUATION, + OBJECTTYPE_DATA_STOCK_RANGE, + OBJECTTYPE_DATA_STOCK_LOSS, + OBJECTTYPE_DATA_STOCK_GAIN, + OBJECTTYPE_DATA_TABLE, + OBJECTTYPE_SHAPE, + OBJECTTYPE_UNKNOWN +}; + +class OOO_DLLPUBLIC_CHARTTOOLS ObjectIdentifier +{ + //CID == ClassifiedIdentifier <--> name of shape + //semicolon, colon, equal sign and slash have special meanings in a CID + //and are therefore not allowed in its components + + //syntax of a CID: CID:/classification/ObjectID + + //where classification: nothing or "MultiClick" or "DragMethod=DragMethodServiceName" and "DragParameter=DragParameterString" + // or a combination of these separated with a colon + //where DragMethodServiceName can be a selfdefined servicename for special actions //todo define standard service for this purpose + //where DragParameterString is any string you like to transport information to your special drag service + // only semicolon, colon, equal sign and slash are not allowed characters + // also the keywords used in the ObjectIdentifiers are not allowed + + //where ObjectID: Parent-Particle:Particle //e.g. Series=2:Point=22 + //where Particle: Type=ParticleID //e.g. Point=22 + //where Type: getStringForType( ObjectType eType ) or other string + +public: + ObjectIdentifier(); + ObjectIdentifier( OUString aObjectCID ); + ObjectIdentifier( const css::uno::Reference< css::drawing::XShape >& rxShape ); + ObjectIdentifier( const css::uno::Any& rAny ); + + bool operator==( const ObjectIdentifier& rOID ) const; + bool operator!=( const ObjectIdentifier& rOID ) const; + bool operator<( const ObjectIdentifier& rOID ) const; + + static OUString createClassifiedIdentifierForObject( + const css::uno::Reference< css::uno::XInterface >& xObject + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + static OUString createClassifiedIdentifierForObject( + const rtl::Reference< ::chart::Title >& xObject + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + static OUString createClassifiedIdentifierForObject( + const rtl::Reference< ::chart::Legend >& xObject + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + static OUString createClassifiedIdentifierForObject( + const rtl::Reference< ::chart::Axis >& xObject + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + + static OUString createClassifiedIdentifierForParticle( + std::u16string_view rParticle ); + + static OUString createClassifiedIdentifierForParticles( + std::u16string_view rParentParticle + , std::u16string_view rChildParticle + , std::u16string_view rDragMethodServiceName = std::u16string_view() + , std::u16string_view rDragParameterString = std::u16string_view() ); + + static OUString createClassifiedIdentifierForGrid( + const css::uno::Reference< css::chart2::XAxis >& xAxis + , const rtl::Reference<::chart::ChartModel>& xChartModel + , sal_Int32 nSubIndex = -1 );//-1: main grid, 0: first subgrid etc + + SAL_DLLPRIVATE static OUString createParticleForDiagram(); + + static OUString createParticleForCoordinateSystem( + const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + + static OUString createParticleForAxis( + sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); + + static OUString createParticleForGrid( + sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); + + static OUString createParticleForSeries( sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex + , sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex ); + + static OUString createParticleForLegend( + const rtl::Reference<::chart::ChartModel>& xChartModel ); + + /** Creates an identifier for the data table */ + static OUString createParticleForDataTable( + const rtl::Reference<::chart::ChartModel>& xChartModel ); + + static OUString addChildParticle( std::u16string_view rParticle, std::u16string_view rChildParticle ); + static OUString createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex ); + static sal_Int32 getIndexFromParticleOrCID( std::u16string_view rParticleOrCID ); + + static OUString createClassifiedIdentifier( + enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES + , std::u16string_view rParticleID );//e.g. SeriesID + + static OUString createClassifiedIdentifierWithParent( + enum ObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID + , std::u16string_view rParticleID //for points or subgrids this is an Index or otherwise an identifier from the model object + , std::u16string_view rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId" + , std::u16string_view rDragMethodServiceName = std::u16string_view() + , std::u16string_view rDragParameterString = std::u16string_view() + ); + + static bool isCID( std::u16string_view rName ); + static std::u16string_view getDragMethodServiceName( std::u16string_view rClassifiedIdentifier ); + static std::u16string_view getDragParameterString( std::u16string_view rCID ); + static bool isDragableObject( std::u16string_view rClassifiedIdentifier ); + bool isDragableObject() const; + static bool isRotateableObject( std::u16string_view rClassifiedIdentifier ); + static bool isMultiClickObject( std::u16string_view rClassifiedIdentifier ); + static bool areSiblings( std::u16string_view rCID1, std::u16string_view rCID2 );//identical object is no sibling + static bool areIdenticalObjects( std::u16string_view rCID1, std::u16string_view rCID2 ); + + static OUString getStringForType( ObjectType eObjectType ); + static ObjectType getObjectType( std::u16string_view rCID ); + ObjectType getObjectType() const; + + static OUString createSeriesSubObjectStub( ObjectType eSubObjectType + , std::u16string_view rSeriesParticle + , std::u16string_view rDragMethodServiceName = std::u16string_view() + , std::u16string_view rDragParameterString = std::u16string_view() ); + static OUString createPointCID( std::u16string_view rPointCID_Stub, sal_Int32 nIndex ); + + static OUString createDataCurveCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex, bool bAverageLine ); + static OUString createDataCurveEquationCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex ); + + SAL_DLLPRIVATE static OUString getObjectID( std::u16string_view rCID ); + static std::u16string_view getParticleID( std::u16string_view rCID ); + static std::u16string_view getFullParentParticle( std::u16string_view rCID ); + + //returns the series particle of a CID when the CID is a child of the series + static OUString getSeriesParticleFromCID( std::u16string_view rCID ); + + //return the model object that is indicated by rObjectCID + static css::uno::Reference< css::beans::XPropertySet > + getObjectPropertySet( + std::u16string_view rObjectCID + , const rtl::Reference< ::chart::ChartModel >& xChartDocument ); + + //return the axis object that belongs to rObjectCID if any + static rtl::Reference< ::chart::Axis > + getAxisForCID( + std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + + //return the series object that belongs to rObjectCID if any + static rtl::Reference< ::chart::DataSeries > + getDataSeriesForCID( + std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + + static rtl::Reference< ::chart::Diagram > + getDiagramForCID( + std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + + static const OUString& getPieSegmentDragMethodServiceName(); + static OUString createPieSegmentDragParameterString( + sal_Int32 nOffsetPercent + , const css::awt::Point& rMinimumPosition + , const css::awt::Point& rMaximumPosition ); + static bool parsePieSegmentDragParameterString( std::u16string_view rDragParameterString + , sal_Int32& rOffsetPercent + , css::awt::Point& rMinimumPosition + , css::awt::Point& rMaximumPosition ); + + static TitleHelper::eTitleType getTitleTypeForCID( std::u16string_view rCID ); + + static OUString getMovedSeriesCID( std::u16string_view rObjectCID, bool bForward ); + + bool isValid() const; + bool isAutoGeneratedObject() const; + bool isAdditionalShape() const; + const OUString& getObjectCID() const { return m_aObjectCID;} + const css::uno::Reference< css::drawing::XShape >& getAdditionalShape() const { return m_xAdditionalShape;} + css::uno::Any getAny() const; + +private: + // #i12587# support for shapes in chart + // For autogenerated chart objects a CID is specified in m_aObjectCID, + // for all other objects m_xAdditionalShape is set. + // Note, that if m_aObjectCID is set, m_xAdditionalShape must be empty + // and vice versa. + OUString m_aObjectCID; + css::uno::Reference< css::drawing::XShape > m_xAdditionalShape; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx b/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx new file mode 100644 index 0000000000..73512497b1 --- /dev/null +++ b/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx @@ -0,0 +1,61 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "RegressionCurveCalculator.hxx" +#include <vector> + +namespace RegressionCalculationHelper +{ + typedef std::pair< std::vector< double >, std::vector< double > > tDoubleVectorPair; +} + +namespace chart +{ + +class PolynomialRegressionCurveCalculator : public RegressionCurveCalculator +{ +public: + PolynomialRegressionCurveCalculator(); + virtual ~PolynomialRegressionCurveCalculator() override; + +protected: + virtual OUString ImplGetRepresentation( + const css::uno::Reference<css::util::XNumberFormatter>& xNumFormatter, + sal_Int32 nNumberFormatKey, sal_Int32* pFormulaMaxWidth = nullptr ) const override; + + virtual double SAL_CALL getCurveValue( double x ) override; + +private: + // ____ XRegressionCurveCalculator ____ + virtual void SAL_CALL recalculateRegression( + const css::uno::Sequence<double>& aXValues, + const css::uno::Sequence<double>& aYValues ) override; + + void computeCorrelationCoefficient( + RegressionCalculationHelper::tDoubleVectorPair& rValues, + const sal_Int32 aNoValues, + double yAverage ); + + std::vector<double> mCoefficients; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/PopupRequest.hxx b/chart2/source/inc/PopupRequest.hxx new file mode 100644 index 0000000000..a755fdfa3c --- /dev/null +++ b/chart2/source/inc/PopupRequest.hxx @@ -0,0 +1,42 @@ +/* -*- 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/. + */ + +#pragma once + +#include "charttoolsdllapi.hxx" + +#include <comphelper/compbase.hxx> +#include <com/sun/star/awt/XRequestCallback.hpp> + +namespace chart +{ +namespace impl +{ +typedef comphelper::WeakComponentImplHelper<css::awt::XRequestCallback> PopupRequest_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS PopupRequest final : public impl::PopupRequest_Base +{ +public: + explicit PopupRequest(); + virtual ~PopupRequest() override; + + css::uno::Reference<css::awt::XCallback> const& getCallback() const { return m_xCallback; } + + // ____ XRequestCallback ____ + virtual void SAL_CALL addCallback(const css::uno::Reference<::css::awt::XCallback>& xCallback, + const css::uno::Any& aData) override; + +private: + css::uno::Reference<css::awt::XCallback> m_xCallback; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/PotentialRegressionCurveCalculator.hxx b/chart2/source/inc/PotentialRegressionCurveCalculator.hxx new file mode 100644 index 0000000000..a0d05b4a2f --- /dev/null +++ b/chart2/source/inc/PotentialRegressionCurveCalculator.hxx @@ -0,0 +1,61 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "RegressionCurveCalculator.hxx" + +namespace chart +{ + +class PotentialRegressionCurveCalculator final : public RegressionCurveCalculator +{ +public: + PotentialRegressionCurveCalculator(); + virtual ~PotentialRegressionCurveCalculator() override; + +protected: + virtual OUString ImplGetRepresentation( + const css::uno::Reference<css::util::XNumberFormatter>& xNumFormatter, + sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const override; + +private: + // ____ XRegressionCurveCalculator ____ + virtual void SAL_CALL recalculateRegression( + const css::uno::Sequence<double>& aXValues, + const css::uno::Sequence<double>& aYValues ) override; + + virtual double SAL_CALL getCurveValue( double x ) override; + + virtual css::uno::Sequence<css::geometry::RealPoint2D> SAL_CALL getCurveValues( + double min, + double max, + sal_Int32 nPointCount, + const css::uno::Reference<css::chart2::XScaling>& xScalingX, + const css::uno::Reference<css::chart2::XScaling>& xScalingY, + sal_Bool bMaySkipPointsInCalculation ) override; + + // formula is: f(x) = x ^ m_fSlope * m_fSign * m_fIntercept + double m_fSlope; + double m_fIntercept; + double m_fSign; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/PropertyHelper.hxx b/chart2/source/inc/PropertyHelper.hxx new file mode 100644 index 0000000000..14aa576095 --- /dev/null +++ b/chart2/source/inc/PropertyHelper.hxx @@ -0,0 +1,148 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/beans/Property.hpp> +#include <com/sun/star/uno/Any.hxx> +#include "charttoolsdllapi.hxx" + +#include <unordered_map> + +namespace com::sun::star::lang { class XMultiServiceFactory; } + +namespace chart +{ + +typedef int tPropertyValueMapKey; + +typedef std::unordered_map<tPropertyValueMapKey, css::uno::Any> tPropertyValueMap; + +namespace PropertyHelper +{ + +/** adds a line dash with a unique name to the gradient obtained by the given + factory. + + @return The name used for storing this element in the table +*/ +OOO_DLLPUBLIC_CHARTTOOLS OUString addLineDashUniqueNameToTable( + const css::uno::Any & rValue, + const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact, + const OUString & rPreferredName ); + +/** adds a gradient with a unique name to the gradient obtained by the given + factory. + + @return The name used for storing this element in the table +*/ +OOO_DLLPUBLIC_CHARTTOOLS OUString addGradientUniqueNameToTable( + const css::uno::Any & rValue, + const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact, + const OUString & rPreferredName ); + +/** adds a transparency gradient with a unique name to the gradient obtained + by the given factory. + + @return The name used for storing this element in the table +*/ +OOO_DLLPUBLIC_CHARTTOOLS +OUString addTransparencyGradientUniqueNameToTable( + const css::uno::Any & rValue, + const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact, + const OUString & rPreferredName ); + +/** adds a hatch with a unique name to the gradient obtained by the given + factory. + + @return The name used for storing this element in the table +*/ +OOO_DLLPUBLIC_CHARTTOOLS OUString addHatchUniqueNameToTable( + const css::uno::Any & rValue, + const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact, + const OUString & rPreferredName ); + +/** adds a bitmap with a unique name to the gradient obtained by the given + factory. + + @return The name used for storing this element in the table +*/ +OOO_DLLPUBLIC_CHARTTOOLS OUString addBitmapUniqueNameToTable( + const css::uno::Any & rValue, + const css::uno::Reference< css::lang::XMultiServiceFactory > & xFact, + const OUString & rPreferredName ); + +/** Set a property to a certain value in the given map. This works for + properties that are already set, and those which are not yet in the map. + + @param any is the value encapsulated in the variant type Any + */ +OOO_DLLPUBLIC_CHARTTOOLS +void setPropertyValueAny( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, + const css::uno::Any & rAny ); + +/** Set a property to a certain value in the given map. This works for + properties that are already set, and those which are not yet in the map. + + @param value is the value of type Value that will be put into a variant type + Any before set in the property map. + */ +template< typename Value > + void setPropertyValue( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const Value & value ) +{ + setPropertyValueAny( rOutMap, key, css::uno::Any( value )); +} + +template<> + void setPropertyValue< css::uno::Any >( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const css::uno::Any & rAny ); + +OOO_DLLPUBLIC_CHARTTOOLS void setPropertyValueDefaultAny( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const css::uno::Any & rAny ); + +/** Calls setPropertyValue() but asserts that the given property hasn't been set + before. + */ +template< typename Value > + void setPropertyValueDefault( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const Value & value ) +{ + setPropertyValueDefaultAny( rOutMap, key, css::uno::Any( value )); +} + +/** Calls setPropertyValue() but asserts that the given property hasn't been set + before. + */ +template<> + void setPropertyValueDefault< css::uno::Any >( tPropertyValueMap & rOutMap, tPropertyValueMapKey key, const css::uno::Any & rAny ); + +/** Calls setPropertyValueDefault() with an empty Any as value + */ +OOO_DLLPUBLIC_CHARTTOOLS void setEmptyPropertyValueDefault( tPropertyValueMap & rOutMap, tPropertyValueMapKey key ); + +} // namespace PropertyHelper + +struct OOO_DLLPUBLIC_CHARTTOOLS PropertyNameLess +{ + bool operator() ( const css::beans::Property & first, + const css::beans::Property & second ) + { + return ( first.Name.compareTo( second.Name ) < 0 ); + } +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/RangeHighlighter.hxx b/chart2/source/inc/RangeHighlighter.hxx new file mode 100644 index 0000000000..c7bcdd2c5c --- /dev/null +++ b/chart2/source/inc/RangeHighlighter.hxx @@ -0,0 +1,107 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <comphelper/compbase.hxx> +#include <comphelper/interfacecontainer4.hxx> +#include <com/sun/star/chart2/data/XRangeHighlighter.hpp> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <rtl/ref.hxx> + +namespace com::sun::star { + namespace chart2 { + class XDiagram; + class XDataSeries; + class XAxis; + } +} +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::view { class XSelectionSupplier; } + +namespace chart +{ +class ChartModel; +class DataSeries; +class Diagram; + +namespace impl +{ +typedef comphelper::WeakComponentImplHelper< + css::chart2::data::XRangeHighlighter, + css::view::XSelectionChangeListener + > + RangeHighlighter_Base; +} + +class RangeHighlighter final : + public impl::RangeHighlighter_Base +{ +public: + explicit RangeHighlighter( + const rtl::Reference< ::chart::ChartModel > & xSelectionSupplier ); + virtual ~RangeHighlighter() override; + +protected: + // ____ XRangeHighlighter ____ + virtual css::uno::Sequence< css::chart2::data::HighlightedRange > SAL_CALL getSelectedRanges() override; + virtual void SAL_CALL addSelectionChangeListener( + const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; + virtual void SAL_CALL removeSelectionChangeListener( + const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; + + // ____ XSelectionChangeListener ____ + virtual void SAL_CALL selectionChanged( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XSelectionChangeListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ WeakComponentImplHelperBase ____ + // is called when dispose() is called at this component + virtual void disposing(std::unique_lock<std::mutex>&) override; + +private: + void fireSelectionEvent(); + void startListening(); + void stopListening(); + void determineRanges(); + + void fillRangesForDiagram( const rtl::Reference< ::chart::Diagram > & xDiagram ); + void fillRangesForDataSeries( const css::uno::Reference< css::chart2::XDataSeries > & xSeries ); + void fillRangesForCategories( const css::uno::Reference< css::chart2::XAxis > & xAxis ); + void fillRangesForDataPoint( const rtl::Reference< ::chart::DataSeries > & xDataSeries, sal_Int32 nIndex ); + void fillRangesForErrorBars( const css::uno::Reference< css::beans::XPropertySet > & xErrorBar, + const css::uno::Reference< css::chart2::XDataSeries > & xDataSeries ); + + css::uno::Reference< css::view::XSelectionSupplier > + m_xSelectionSupplier; + rtl::Reference< ::chart::ChartModel > m_xChartModel; + css::uno::Reference< css::view::XSelectionChangeListener > + m_xListener; + css::uno::Sequence< css::chart2::data::HighlightedRange > + m_aSelectedRanges; + sal_Int32 m_nAddedListenerCount; + bool m_bIncludeHiddenCells; + comphelper::OInterfaceContainerHelper4<css::view::XSelectionChangeListener> maSelectionChangeListeners; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ReferenceSizeProvider.hxx b/chart2/source/inc/ReferenceSizeProvider.hxx new file mode 100644 index 0000000000..dbacd093ff --- /dev/null +++ b/chart2/source/inc/ReferenceSizeProvider.hxx @@ -0,0 +1,130 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/awt/Size.hpp> +#include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> +#include <ChartModel.hxx> + +namespace com::sun::star { + namespace chart2 { + class XTitle; + class XTitled; + class XChartDocument; + } + namespace beans { + class XPropertySet; + } +} + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS ReferenceSizeProvider +{ +public: + + enum AutoResizeState + { + AUTO_RESIZE_YES, + AUTO_RESIZE_NO, + AUTO_RESIZE_AMBIGUOUS, + AUTO_RESIZE_UNKNOWN + }; + + ReferenceSizeProvider( + css::awt::Size aPageSize, + const rtl::Reference<::chart::ChartModel> & xChartDoc ); + + const css::awt::Size& getPageSize() const { return m_aPageSize;} + + /** Retrieves the state auto-resize from all objects that support this + feature. If all objects return the same state, AUTO_RESIZE_YES or + AUTO_RESIZE_NO is returned. + + If no object supporting the feature is found, AUTO_RESIZE_UNKNOWN is + returned. If there are multiple objects, some with state YES and some + with state NO, AUTO_RESIZE_AMBIGUOUS is returned. + */ + static AutoResizeState getAutoResizeState( + const rtl::Reference<::chart::ChartModel> & xChartDoc ); + + /** sets or resets the auto-resize at all objects that support this feature + for text to the opposite of the current setting. If the current state + is ambiguous, it is turned on. If the current state is unknown it stays + unknown. + */ + void toggleAutoResizeState(); + + /** Sets the ReferencePageSize according to the internal settings of this + class at the XPropertySet, and the adapted font sizes if bAdaptFontSizes + is </sal_True>. + */ + SAL_DLLPRIVATE void setValuesAtPropertySet( + const css::uno::Reference< css::beans::XPropertySet > & xProp, + bool bAdaptFontSizes = true ); + + /** Sets the ReferencePageSize according to the internal settings of this + class at the XTitle, and the adapted font sizes at the contained + XFormattedStrings + */ + SAL_DLLPRIVATE void setValuesAtTitle( + const css::uno::Reference< css::chart2::XTitle > & xTitle ); + + /** Sets the internal value at all data series in the currently set model. + This is useful, if you have changed a chart-type and thus probably added + some new data series via model functionality. + */ + void setValuesAtAllDataSeries(); + +private: + SAL_DLLPRIVATE bool useAutoScale() const { return m_bUseAutoScale;} + + /** sets the auto-resize at all objects that support this feature for text. + eNewState must be either AUTO_RESIZE_YES or AUTO_RESIZE_NO + */ + SAL_DLLPRIVATE void setAutoResizeState( AutoResizeState eNewState ); + + /** Retrieves the auto-resize state from the given propertyset. The result + will be put into eInOutState. If you initialize eInOutState with + AUTO_RESIZE_UNKNOWN, you will get the actual state. If you pass any + other state, the result will be the accumulated state, + esp. AUTO_RESIZE_AMBIGUOUS, if the value was NO before, and is YES for + the current property set, or the other way round. + */ + SAL_DLLPRIVATE static void getAutoResizeFromPropSet( + const css::uno::Reference< css::beans::XPropertySet > & xProp, + AutoResizeState & rInOutState ); + + SAL_DLLPRIVATE void impl_setValuesAtTitled( + const css::uno::Reference< css::chart2::XTitled > & xTitled ); + SAL_DLLPRIVATE static void impl_getAutoResizeFromTitled( + const css::uno::Reference< css::chart2::XTitled > & xTitled, + AutoResizeState & rInOutState ); + + css::awt::Size m_aPageSize; + rtl::Reference<::chart::ChartModel> m_xChartDoc; + bool m_bUseAutoScale; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/RegressionCalculationHelper.hxx b/chart2/source/inc/RegressionCalculationHelper.hxx new file mode 100644 index 0000000000..0b9600e99d --- /dev/null +++ b/chart2/source/inc/RegressionCalculationHelper.hxx @@ -0,0 +1,134 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/uno/Sequence.hxx> + +#include <cmath> +#include <utility> +#include <vector> + +namespace chart::RegressionCalculationHelper +{ + +typedef std::pair< std::vector< double >, std::vector< double > > tDoubleVectorPair; + +/** takes the given x- and y-values and copies them into the resulting pair, + which contains x-values in the first element and the y-values in the second + one. All tuples for which aPred is false are not copied. + + <p>The function below provide a set of useful predicates that can be + used to pass as parameter aPred.</p> + */ +template< class Pred > +tDoubleVectorPair + cleanup( const css::uno::Sequence< double > & rXValues, + const css::uno::Sequence< double > & rYValues, + Pred aPred ) +{ + tDoubleVectorPair aResult; + sal_Int32 nSize = std::min( rXValues.getLength(), rYValues.getLength()); + for( sal_Int32 i=0; i<nSize; ++i ) + { + if( aPred( rXValues[i], rYValues[i] )) + { + aResult.first.push_back( rXValues[i] ); + aResult.second.push_back( rYValues[i] ); + } + } + + return aResult; +} + +class isValid +{ +public: + bool operator()( double x, double y ) + { return ! ( std::isnan( x ) || + std::isnan( y ) || + std::isinf( x ) || + std::isinf( y ) ); + } +}; + +class isValidAndXPositive +{ +public: + bool operator()( double x, double y ) + { return ! ( std::isnan( x ) || + std::isnan( y ) || + std::isinf( x ) || + std::isinf( y ) || + x <= 0.0 ); + } +}; + +class isValidAndYPositive +{ +public: + bool operator()( double x, double y ) + { return ! ( std::isnan( x ) || + std::isnan( y ) || + std::isinf( x ) || + std::isinf( y ) || + y <= 0.0 ); + } +}; + +class isValidAndYNegative +{ +public: + bool operator()( double x, double y ) + { return ! ( std::isnan( x ) || + std::isnan( y ) || + std::isinf( x ) || + std::isinf( y ) || + y >= 0.0 ); + } +}; + +class isValidAndBothPositive +{ +public: + bool operator()( double x, double y ) + { return ! ( std::isnan( x ) || + std::isnan( y ) || + std::isinf( x ) || + std::isinf( y ) || + x <= 0.0 || + y <= 0.0 ); + } +}; + +class isValidAndXPositiveAndYNegative +{ +public: + bool operator()( double x, double y ) + { return ! ( std::isnan( x ) || + std::isnan( y ) || + std::isinf( x ) || + std::isinf( y ) || + x <= 0.0 || + y >= 0.0 ); + } +}; + +} // namespace chart::RegressionCalculationHelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/RegressionCurveCalculator.hxx b/chart2/source/inc/RegressionCurveCalculator.hxx new file mode 100644 index 0000000000..ebb3ad40f6 --- /dev/null +++ b/chart2/source/inc/RegressionCurveCalculator.hxx @@ -0,0 +1,103 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <cppuhelper/implbase.hxx> +#include <rtl/ustrbuf.hxx> + +#include <com/sun/star/chart2/XRegressionCurveCalculator.hpp> + +namespace com::sun::star::util { class XNumberFormatsSupplier; } +namespace com::sun::star::util { class XNumberFormatter; } + +namespace chart +{ + +class RegressionCurveCalculator : public + cppu::WeakImplHelper< css::chart2::XRegressionCurveCalculator > +{ +public: + RegressionCurveCalculator(); + virtual ~RegressionCurveCalculator() override; + + static bool isLinearScaling( + const css::uno::Reference< css::chart2::XScaling >& xScaling ); + + static bool isLogarithmicScaling( + const css::uno::Reference< css::chart2::XScaling >& xScaling ); + + // ____ XRegressionCurveCalculator ____ + virtual void SAL_CALL setRegressionProperties( + sal_Int32 aDegree, + sal_Bool aForceIntercept, + double aInterceptValue, + sal_Int32 aPeriod, + sal_Int32 nMovingType) override; + + virtual void SAL_CALL recalculateRegression( + const css::uno::Sequence< double >& aXValues, + const css::uno::Sequence< double >& aYValues ) override = 0; + + virtual double SAL_CALL getCurveValue( double x ) override = 0; + + virtual css::uno::Sequence< css::geometry::RealPoint2D > SAL_CALL getCurveValues( + double min, + double max, + sal_Int32 nPointCount, + const css::uno::Reference< css::chart2::XScaling >& xScalingX, + const css::uno::Reference< css::chart2::XScaling >& xScalingY, + sal_Bool bMaySkipPointsInCalculation ) override; + + virtual double SAL_CALL getCorrelationCoefficient() override; + + virtual OUString SAL_CALL getRepresentation() override; + + virtual OUString SAL_CALL getFormattedRepresentation( + const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumFmtSupplier, + sal_Int32 nNumberFormatKey, sal_Int32 nFormulaLength ) override; + + virtual void SAL_CALL setXYNames( + const OUString& aXName, const OUString& aYName ) override; + +protected: + virtual OUString ImplGetRepresentation( + const css::uno::Reference< css::util::XNumberFormatter >& xNumFormatter, + sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const = 0; + + static OUString getFormattedString( + const css::uno::Reference< css::util::XNumberFormatter >& xNumFormatter, + sal_Int32 nNumberFormatKey, + double fNumber, + const sal_Int32* pStringLength ); + + static void addStringToEquation( OUStringBuffer& aStrEquation, sal_Int32& nLineLength, OUStringBuffer const & aAddString, const sal_Int32* pMaxLength ); + + double m_fCorrelationCoefficient; + + sal_Int32 mDegree; + bool mForceIntercept; + double mInterceptValue; + sal_Int32 mPeriod; + OUString mXName, mYName; + sal_Int32 mnMovingType; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx new file mode 100644 index 0000000000..f9d9195064 --- /dev/null +++ b/chart2/source/inc/RegressionCurveHelper.hxx @@ -0,0 +1,202 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <svx/chrtitem.hxx> +#include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> + +#include <vector> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::chart2 { class XRegressionCurve; } +namespace com::sun::star::chart2 { class XRegressionCurveCalculator; } +namespace com::sun::star::chart2 { class XRegressionCurveContainer; } +namespace com::sun::star::chart2::data { class XDataSource; } +namespace com::sun::star::frame { class XModel; } +namespace chart { class ChartModel; } +namespace chart { class DataSeries; } +namespace chart { class RegressionCurveModel; } +namespace chart { class RegressionCurveCalculator; } + +namespace chart::RegressionCurveHelper +{ + /// returns a model mean-value line + rtl::Reference<::chart::RegressionCurveModel> createMeanValueLine(); + + /// returns a model regression curve + rtl::Reference<::chart::RegressionCurveModel> + createRegressionCurveByServiceName( std::u16string_view aServiceName ); + + OOO_DLLPUBLIC_CHARTTOOLS bool hasMeanValueLine( + const css::uno::Reference<css::chart2::XRegressionCurveContainer> & xRegCnt ); + OOO_DLLPUBLIC_CHARTTOOLS bool hasMeanValueLine( + const rtl::Reference<::chart::DataSeries> & xRegCnt ); + + OOO_DLLPUBLIC_CHARTTOOLS bool isMeanValueLine( + const css::uno::Reference<css::chart2::XRegressionCurve> & xRegCurve ); + OOO_DLLPUBLIC_CHARTTOOLS bool isMeanValueLine( + const rtl::Reference<::chart::RegressionCurveModel> & xRegCurve ); + + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel> + getMeanValueLine( + const css::uno::Reference<css::chart2::XRegressionCurveContainer> & xRegCnt ); + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel> + getMeanValueLine( + const rtl::Reference<::chart::DataSeries> & xRegCnt ); + + /** creates a mean-value line and adds it to the container. + + @param xSeriesProp + If set, this property-set will be used to apply a line color + */ + OOO_DLLPUBLIC_CHARTTOOLS void addMeanValueLine( + css::uno::Reference<css::chart2::XRegressionCurveContainer> const & xRegCnt, + const css::uno::Reference<css::beans::XPropertySet>& xSeriesProp ); + OOO_DLLPUBLIC_CHARTTOOLS void addMeanValueLine( + rtl::Reference<::chart::DataSeries> const & xRegCnt, + const css::uno::Reference<css::beans::XPropertySet>& xSeriesProp ); + + OOO_DLLPUBLIC_CHARTTOOLS void removeMeanValueLine( + css::uno::Reference<css::chart2::XRegressionCurveContainer> const & xRegCnt ); + OOO_DLLPUBLIC_CHARTTOOLS void removeMeanValueLine( + rtl::Reference<::chart::DataSeries> const & xRegCnt ); + + /** Returns the first regression curve found that is not of type + mean-value line + */ + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel> + getFirstCurveNotMeanValueLine( + const css::uno::Reference<css::chart2::XRegressionCurveContainer>& xCurveContainer ); + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel> + getFirstCurveNotMeanValueLine( + const rtl::Reference<::chart::DataSeries>& xCurveContainer ); + + /** Returns the regression curve found at the index provided. + */ + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel> + getRegressionCurveAtIndex( + const rtl::Reference<::chart::DataSeries>& xCurveContainer, + sal_Int32 aIndex); + + /** Returns the type of the first regression curve found that is not of type + mean-value line + */ + OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress getFirstRegressTypeNotMeanValueLine( + const css::uno::Reference<css::chart2::XRegressionCurveContainer>& xCurveContainer ); + + OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress getRegressionType( + const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); + + /** @param xPropertySource is taken as source to copy all properties from if + not null + @param xEquationProperties is set at the new regression curve as + equation properties if not null + */ + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel> + addRegressionCurve( + SvxChartRegress eType, + css::uno::Reference<css::chart2::XRegressionCurveContainer> const & xCurveContainer, + const css::uno::Reference<css::beans::XPropertySet >& xPropertySource = + css::uno::Reference<css::beans::XPropertySet>(), + const css::uno::Reference<css::beans::XPropertySet>& xEquationProperties = + css::uno::Reference<css::beans::XPropertySet>() ); + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel> + addRegressionCurve( + SvxChartRegress eType, + rtl::Reference<::chart::DataSeries> const & xCurveContainer, + const css::uno::Reference<css::beans::XPropertySet >& xPropertySource = + css::uno::Reference<css::beans::XPropertySet>(), + const css::uno::Reference<css::beans::XPropertySet>& xEquationProperties = + css::uno::Reference<css::beans::XPropertySet>() ); + + OOO_DLLPUBLIC_CHARTTOOLS bool removeAllExceptMeanValueLine( + rtl::Reference<::chart::DataSeries> const & xCurveContainer ); + + OOO_DLLPUBLIC_CHARTTOOLS void removeEquations( + rtl::Reference<::chart::DataSeries> const & xCurveContainer ); + + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel> + changeRegressionCurveType( + SvxChartRegress eType, + css::uno::Reference<css::chart2::XRegressionCurveContainer> const & xRegressionCurveContainer, + css::uno::Reference<css::chart2::XRegressionCurve> const & xRegressionCurve ); + + /// returns a calculator object for regression curves (used by the view) + OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveCalculator> + createRegressionCurveCalculatorByServiceName( std::u16string_view aServiceName ); + + /** recalculates the regression parameters according to the data given in + the data source. + + A sequence having the role "values-x" will be used as x-values for the + calculation if found. Otherwise a sequence (1, 2, 3, ...) of category + indexes will be used for the recalculateRegression() method of the + regression curve. + + The first sequence having the role "values-y" will be used as y-values + for the recalculateRegression() method of the regression curve. + + @param bUseXValuesIfAvailable + If false, the sequence (1, 2, 3, ...) will always be used, even if + there is a data-sequence with role "values-x" + */ + void initializeCurveCalculator( + const css::uno::Reference<css::chart2::XRegressionCurveCalculator>& xOutCurveCalculator, + const css::uno::Reference<css::chart2::data::XDataSource>& xSource, + bool bUseXValuesIfAvailable ); + + /** Same method as above, but uses the given XModel to determine the + parameter bUseXValuesIfAvailable in the above function. It is also + necessary that the data::XDataSource is an XDataSeries, thus this parameter + also changed. + */ + OOO_DLLPUBLIC_CHARTTOOLS void initializeCurveCalculator( + const css::uno::Reference<css::chart2::XRegressionCurveCalculator>& xOutCurveCalculator, + const rtl::Reference<::chart::DataSeries>& xSeries, + const rtl::Reference<::chart::ChartModel>& xModel ); + + OOO_DLLPUBLIC_CHARTTOOLS OUString getUINameForRegressionCurve( + const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); + + OOO_DLLPUBLIC_CHARTTOOLS OUString getRegressionCurveName( + const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); + + OOO_DLLPUBLIC_CHARTTOOLS OUString getRegressionCurveGenericName( + const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); + + OOO_DLLPUBLIC_CHARTTOOLS OUString getRegressionCurveSpecificName( + const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); + + OOO_DLLPUBLIC_CHARTTOOLS void resetEquationPosition( + const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); + + /// @return the index of the given curve in the given container. -1 if not contained + OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getRegressionCurveIndex( + const rtl::Reference<::chart::DataSeries>& xContainer, + const rtl::Reference<::chart::RegressionCurveModel>& xCurve ); + + OOO_DLLPUBLIC_CHARTTOOLS bool hasEquation(const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); + OOO_DLLPUBLIC_CHARTTOOLS bool MayHaveCorrelationCoefficient(const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/RegressionCurveModel.hxx b/chart2/source/inc/RegressionCurveModel.hxx new file mode 100644 index 0000000000..ddd75a8391 --- /dev/null +++ b/chart2/source/inc/RegressionCurveModel.hxx @@ -0,0 +1,242 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" + +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include <sal/types.h> + +#include <com/sun/star/chart2/XRegressionCurve.hpp> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::lang::XServiceName, + css::chart2::XRegressionCurve, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + RegressionCurveModel_Base; +} + +class SAL_DLLPUBLIC_RTTI RegressionCurveModel : + public impl::RegressionCurveModel_Base, + public ::property::OPropertySet +{ +public: + enum tCurveType + { + CURVE_TYPE_MEAN_VALUE, + CURVE_TYPE_LINEAR, + CURVE_TYPE_LOGARITHM, + CURVE_TYPE_EXPONENTIAL, + CURVE_TYPE_POWER, + CURVE_TYPE_POLYNOMIAL, + CURVE_TYPE_MOVING_AVERAGE + }; + + RegressionCurveModel( tCurveType eCurveType ); + RegressionCurveModel( const RegressionCurveModel & rOther ); + virtual ~RegressionCurveModel() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +protected: + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + + // ____ OPropertySet ____ + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + +public: + // ____ XRegressionCurve ____ + virtual css::uno::Reference< css::chart2::XRegressionCurveCalculator > SAL_CALL getCalculator() override; + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getEquationProperties() override; + virtual void SAL_CALL setEquationProperties( + const css::uno::Reference< css::beans::XPropertySet >& xEquationProperties ) override; + + // ____ XServiceName ____ + virtual OUString SAL_CALL getServiceName() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + +protected: + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + using ::cppu::OPropertySetHelper::disposing; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + + void fireModifyEvent(); + +private: + const tCurveType m_eRegressionCurveType; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; + css::uno::Reference< css::beans::XPropertySet > m_xEquationProperties; + void setPropertyMayHaveR2(); +}; + +// implementations for factory instantiation + +class MeanValueRegressionCurve : public RegressionCurveModel +{ +public: + explicit MeanValueRegressionCurve(); + explicit MeanValueRegressionCurve( + const MeanValueRegressionCurve & rOther ); + virtual ~MeanValueRegressionCurve() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + /// 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; +}; + +class LinearRegressionCurve : public RegressionCurveModel +{ +public: + explicit LinearRegressionCurve(); + explicit LinearRegressionCurve( const LinearRegressionCurve & rOther ); + virtual ~LinearRegressionCurve() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + /// 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; +}; + +class LogarithmicRegressionCurve : public RegressionCurveModel +{ +public: + explicit LogarithmicRegressionCurve(); + explicit LogarithmicRegressionCurve( const LogarithmicRegressionCurve & rOther ); + virtual ~LogarithmicRegressionCurve() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + /// 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; +}; + +class ExponentialRegressionCurve : public RegressionCurveModel +{ +public: + explicit ExponentialRegressionCurve(); + explicit ExponentialRegressionCurve( const ExponentialRegressionCurve & rOther ); + virtual ~ExponentialRegressionCurve() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + /// 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; +}; + +class PotentialRegressionCurve : public RegressionCurveModel +{ +public: + explicit PotentialRegressionCurve(); + explicit PotentialRegressionCurve( const PotentialRegressionCurve & rOther ); + virtual ~PotentialRegressionCurve() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + /// 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; +}; + +class PolynomialRegressionCurve : public RegressionCurveModel +{ +public: + explicit PolynomialRegressionCurve(); + explicit PolynomialRegressionCurve( const PolynomialRegressionCurve & rOther ); + virtual ~PolynomialRegressionCurve() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + /// 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; +}; + +class MovingAverageRegressionCurve : public RegressionCurveModel +{ +public: + explicit MovingAverageRegressionCurve(); + explicit MovingAverageRegressionCurve( const MovingAverageRegressionCurve & rOther ); + virtual ~MovingAverageRegressionCurve() override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + /// 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; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/RelativePositionHelper.hxx b/chart2/source/inc/RelativePositionHelper.hxx new file mode 100644 index 0000000000..5a6bcbbc85 --- /dev/null +++ b/chart2/source/inc/RelativePositionHelper.hxx @@ -0,0 +1,103 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/chart2/RelativePosition.hpp> +#include <com/sun/star/drawing/Alignment.hpp> +#include <com/sun/star/awt/Point.hpp> +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::awt { struct Size; } +namespace com::sun::star::chart2 { struct RelativeSize; } + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS RelativePositionHelper +{ +public: + /** returns the upper left corner of an object that has size aObjectSize and + where the point indicated by aAnchor has coordinates indicated by aPoint + ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the + coordinates of the bottom left corner of an object with size aObjectSize ) + */ + static css::awt::Point + getUpperLeftCornerOfAnchoredObject( + css::awt::Point aPoint, + css::awt::Size aObjectSize, + css::drawing::Alignment aAnchor ); + + /** returns the center of an object that has size aObjectSize and + where the point indicated by aAnchor has coordinates indicated by aPoint + ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the + coordinates of the bottom left corner of an object with size aObjectSize ) + */ + static css::awt::Point + getCenterOfAnchoredObject( + css::awt::Point aPoint, + css::awt::Size aUnrotatedObjectSize, + css::drawing::Alignment aAnchor, + double fAnglePi ); + + /** Returns a relative position that is the same point after the anchor has + been changed to the given one. The passed object size is taken into + account for shifting the position. + */ + SAL_DLLPRIVATE static css::chart2::RelativePosition + getReanchoredPosition( + const css::chart2::RelativePosition & rPosition, + const css::chart2::RelativeSize & rObjectSize, + css::drawing::Alignment aNewAnchor ); + + /** grows a relative size about the given amount and shifts the given + position such that the resize is relative to the former rectangle's + center. + + The resize is only done, if after + transformation, the position and size are within the bounds [0,1]. + + @return </sal_True>, if changes were applied. + + <p>That means, if the position's alignment is center, the position will + not change at all.</p> + */ + static bool centerGrow( + css::chart2::RelativePosition & rInOutPosition, + css::chart2::RelativeSize & rInOutSize, + double fAmountX, double fAmountY ); + + /** shifts a relative position about the given amount + + The shift is only done, if after + transformation, the object represented by the position + rInOutPosition and its size rObjectSize the position and size are + within the bounds [0,1]. + + @return </sal_True>, if changes were applied. + */ + static bool moveObject( + css::chart2::RelativePosition & rInOutPosition, + const css::chart2::RelativeSize & rObjectSize, + double fAmountX, double fAmountY ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/RelativeSizeHelper.hxx b/chart2/source/inc/RelativeSizeHelper.hxx new file mode 100644 index 0000000000..b07876bb67 --- /dev/null +++ b/chart2/source/inc/RelativeSizeHelper.hxx @@ -0,0 +1,56 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::awt { struct Size; } +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } +class SvxShapeText; + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS RelativeSizeHelper +{ +public: + static double calculate( + double fValue, + const css::awt::Size & rOldReferenceSize, + const css::awt::Size & rNewReferenceSize ); + + static void adaptFontSizes( + const css::uno::Reference< + css::beans::XPropertySet > & xTargetProperties, + const css::awt::Size & rOldReferenceSize, + const css::awt::Size & rNewReferenceSize ); + + static void adaptFontSizes( + SvxShapeText& xTargetProperties, + const css::awt::Size & rOldReferenceSize, + const css::awt::Size & rNewReferenceSize ); + +private: + RelativeSizeHelper() = delete; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ResId.hxx b/chart2/source/inc/ResId.hxx new file mode 100644 index 0000000000..48baf852ab --- /dev/null +++ b/chart2/source/inc/ResId.hxx @@ -0,0 +1,31 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <rtl/ustring.hxx> +#include "charttoolsdllapi.hxx" +#include <unotools/resmgr.hxx> + +namespace chart +{ +OUString OOO_DLLPUBLIC_CHARTTOOLS SchResId(TranslateId aId); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/Scaling.hxx b/chart2/source/inc/Scaling.hxx new file mode 100644 index 0000000000..6f6310933d --- /dev/null +++ b/chart2/source/inc/Scaling.hxx @@ -0,0 +1,159 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/chart2/XScaling.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <cppuhelper/implbase.hxx> + +namespace chart +{ + +class LogarithmicScaling final : + public ::cppu::WeakImplHelper< + css::chart2::XScaling, + css::lang::XServiceName, + css::lang::XServiceInfo + > +{ +public: + /// base is 10.0 + explicit LogarithmicScaling(); + LogarithmicScaling( double fBase ); + virtual ~LogarithmicScaling() override; + + /// declare XServiceInfo methods + 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; + + // ____ XScaling ____ + virtual double SAL_CALL doScaling( double value ) override; + + virtual css::uno::Reference< + css::chart2::XScaling > SAL_CALL + getInverseScaling() override; + + // ____ XServiceName ____ + virtual OUString SAL_CALL getServiceName() override; + +private: + const double m_fBase; + const double m_fLogOfBase; +}; + +class ExponentialScaling final : + public ::cppu::WeakImplHelper< + css::chart2::XScaling, + css::lang::XServiceName, + css::lang::XServiceInfo + > +{ +public: + /// base is 10.0 + explicit ExponentialScaling(); + explicit ExponentialScaling( double fBase ); + virtual ~ExponentialScaling() override; + + /// declare XServiceInfo methods + 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; + + // ____ XScaling ____ + virtual double SAL_CALL + doScaling( double value ) override; + + virtual css::uno::Reference< css::chart2::XScaling > SAL_CALL + getInverseScaling() override; + + // ____ XServiceName ____ + virtual OUString SAL_CALL getServiceName() override; + +private: + const double m_fBase; +}; + +class LinearScaling final : public ::cppu::WeakImplHelper< + css::chart2::XScaling, + css::lang::XServiceName, + css::lang::XServiceInfo + > +{ +public: + /// y(x) = x + explicit LinearScaling(); + /// y(x) = fSlope * x + fOffset + LinearScaling( double fSlope, double fOffset ); + virtual ~LinearScaling() override; + + /// declare XServiceInfo methods + 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; + + // ____ XScaling ____ + virtual double SAL_CALL doScaling( double value ) override; + + virtual css::uno::Reference< css::chart2::XScaling > SAL_CALL + getInverseScaling() override; + + // ____ XServiceName ____ + virtual OUString SAL_CALL getServiceName() override; + +private: + const double m_fSlope; + const double m_fOffset; +}; + +class PowerScaling final : public ::cppu::WeakImplHelper< + css::chart2::XScaling, + css::lang::XServiceName, + css::lang::XServiceInfo + > +{ +public: + /// exponent 10.0 + explicit PowerScaling(); + explicit PowerScaling( double fExponent ); + virtual ~PowerScaling() override; + + /// declare XServiceInfo methods + 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; + + // ____ XScaling ____ + virtual double SAL_CALL + doScaling( double value ) override; + + virtual css::uno::Reference< css::chart2::XScaling > SAL_CALL + getInverseScaling() override; + + // ____ XServiceName ____ + virtual OUString SAL_CALL getServiceName() override; + +private: + const double m_fExponent; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/SceneProperties.hxx b/chart2/source/inc/SceneProperties.hxx new file mode 100644 index 0000000000..ab7d89711a --- /dev/null +++ b/chart2/source/inc/SceneProperties.hxx @@ -0,0 +1,82 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "PropertyHelper.hxx" +#include "FastPropertyIdRanges.hxx" +#include "charttoolsdllapi.hxx" + +#include <vector> + +namespace com::sun::star::beans { struct Property; } + +namespace chart +{ + +// implements service SceneProperties +namespace SceneProperties +{ + // FastProperty Ids for properties + enum + { + // "com.sun.star.drawing.SceneProperties" (does not exist) + PROP_SCENE_TRANSF_MATRIX = FAST_PROPERTY_ID_START_SCENE_PROP, + PROP_SCENE_DISTANCE, + PROP_SCENE_FOCAL_LENGTH, + PROP_SCENE_SHADOW_SLANT, + PROP_SCENE_SHADE_MODE, + PROP_SCENE_AMBIENT_COLOR, + PROP_SCENE_TWO_SIDED_LIGHTING, + PROP_SCENE_CAMERA_GEOMETRY, + PROP_SCENE_PERSPECTIVE, + PROP_SCENE_LIGHT_COLOR_1, + PROP_SCENE_LIGHT_DIRECTION_1, + PROP_SCENE_LIGHT_ON_1, + PROP_SCENE_LIGHT_COLOR_2, + PROP_SCENE_LIGHT_DIRECTION_2, + PROP_SCENE_LIGHT_ON_2, + PROP_SCENE_LIGHT_COLOR_3, + PROP_SCENE_LIGHT_DIRECTION_3, + PROP_SCENE_LIGHT_ON_3, + PROP_SCENE_LIGHT_COLOR_4, + PROP_SCENE_LIGHT_DIRECTION_4, + PROP_SCENE_LIGHT_ON_4, + PROP_SCENE_LIGHT_COLOR_5, + PROP_SCENE_LIGHT_DIRECTION_5, + PROP_SCENE_LIGHT_ON_5, + PROP_SCENE_LIGHT_COLOR_6, + PROP_SCENE_LIGHT_DIRECTION_6, + PROP_SCENE_LIGHT_ON_6, + PROP_SCENE_LIGHT_COLOR_7, + PROP_SCENE_LIGHT_DIRECTION_7, + PROP_SCENE_LIGHT_ON_7, + PROP_SCENE_LIGHT_COLOR_8, + PROP_SCENE_LIGHT_DIRECTION_8, + PROP_SCENE_LIGHT_ON_8 + }; + + OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector( + std::vector< css::beans::Property > & rOutProperties ); + + OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ); +} + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/StackMode.hxx b/chart2/source/inc/StackMode.hxx new file mode 100644 index 0000000000..718befc4e5 --- /dev/null +++ b/chart2/source/inc/StackMode.hxx @@ -0,0 +1,35 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +namespace chart +{ +// needed for chart type templates + +enum class StackMode +{ + NONE, + YStacked, + YStackedPercent, + ZStacked +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/StatisticsHelper.hxx b/chart2/source/inc/StatisticsHelper.hxx new file mode 100644 index 0000000000..e700802002 --- /dev/null +++ b/chart2/source/inc/StatisticsHelper.hxx @@ -0,0 +1,102 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/uno/Reference.h> +#include <rtl/ustring.hxx> +#include <rtl/ref.hxx> +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2::data { class XDataProvider; } +namespace com::sun::star::chart2::data { class XDataSequence; } +namespace com::sun::star::chart2::data { class XDataSource; } +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } +namespace com::sun::star::uno { template <typename > class Sequence; } +namespace chart { class LabeledDataSequence; } +namespace chart { class DataSeries; } + +namespace chart::StatisticsHelper +{ + /** Calculates 1/n * sum (x_i - x_mean)^2. + + @see http://mathworld.wolfram.com/Variance.html + */ + OOO_DLLPUBLIC_CHARTTOOLS double getVariance( const css::uno::Sequence< double > & rData ); + + // square root of the variance + OOO_DLLPUBLIC_CHARTTOOLS double getStandardDeviation( const css::uno::Sequence< double > & rData ); + + // also called "Standard deviation of the mean (SDOM)" + OOO_DLLPUBLIC_CHARTTOOLS double getStandardError( const css::uno::Sequence< double > & rData ); + + OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XLabeledDataSequence > + getErrorLabeledDataSequenceFromDataSource( + const css::uno::Reference< css::chart2::data::XDataSource > & xDataSource, + bool bPositiveValue, + bool bYError = true ); + + OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XDataSequence > + getErrorDataSequenceFromDataSource( + const css::uno::Reference< css::chart2::data::XDataSource > & xDataSource, + bool bPositiveValue, + bool bYError = true ); + + OOO_DLLPUBLIC_CHARTTOOLS double getErrorFromDataSource( + const css::uno::Reference< css::chart2::data::XDataSource > & xDataSource, + sal_Int32 nIndex, + bool bPositiveValue, + bool bYError = true ); + + OOO_DLLPUBLIC_CHARTTOOLS void setErrorDataSequence( + const css::uno::Reference< css::chart2::data::XDataSource > & xDataSource, + const css::uno::Reference< css::chart2::data::XDataProvider > & xDataProvider, + const OUString & rNewRange, + bool bPositiveValue, + bool bYError = true, + OUString const * pXMLRange = nullptr ); + + /// @return the newly created or existing error bar object + OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::beans::XPropertySet > + addErrorBars( + const rtl::Reference< ::chart::DataSeries > & xDataSeries, + sal_Int32 nStyle, + bool bYError = true ); + + OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::beans::XPropertySet > + getErrorBars( + const rtl::Reference< ::chart::DataSeries > & xDataSeries, + bool bYError = true ); + + OOO_DLLPUBLIC_CHARTTOOLS bool hasErrorBars( + const rtl::Reference< ::chart::DataSeries > & xDataSeries, + bool bYError = true ); + + OOO_DLLPUBLIC_CHARTTOOLS void removeErrorBars( + const rtl::Reference< ::chart::DataSeries > & xDataSeries, + bool bYError = true ); + + OOO_DLLPUBLIC_CHARTTOOLS bool usesErrorBarRanges( + const rtl::Reference< ::chart::DataSeries > & xDataSeries, + bool bYError = true ); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/ThreeDHelper.hxx b/chart2/source/inc/ThreeDHelper.hxx new file mode 100644 index 0000000000..a8fc1d63fb --- /dev/null +++ b/chart2/source/inc/ThreeDHelper.hxx @@ -0,0 +1,100 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/drawing/CameraGeometry.hpp> +#include <rtl/ref.hxx> +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XDiagram; } + +namespace chart +{ +class Diagram; + +enum class ThreeDLookScheme +{ + ThreeDLookScheme_Simple, + ThreeDLookScheme_Realistic, + ThreeDLookScheme_Unknown +}; + +enum CuboidPlanePosition +{ + CuboidPlanePosition_Left, + CuboidPlanePosition_Right, + CuboidPlanePosition_Top, + CuboidPlanePosition_Bottom, + CuboidPlanePosition_Front, + CuboidPlanePosition_Back +}; + +class OOO_DLLPUBLIC_CHARTTOOLS ThreeDHelper +{ +public: + + /** Returns the default camera geometry that is set in the Diagram CTOR. + This is not the property default! + + @todo deprecate the hard set camera geometry and use the property + default + */ + static css::drawing::CameraGeometry getDefaultCameraGeometry( bool bPie=false ); + + static void adaptRadAnglesForRightAngledAxes( double& rfXAngleRad, double& rfYAngleRad ); + static double getXDegreeAngleLimitForRightAngledAxes() { return 90.0; } + static double getYDegreeAngleLimitForRightAngledAxes() { return 45.0; } + + static double getValueClippedToRange( double fValue, const double& fPositivLimit ); + + static void convertElevationRotationDegToXYZAngleRad( + sal_Int32 nElevationDeg, sal_Int32 nRotationDeg + , double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad ); + + SAL_DLLPRIVATE static void convertXYZAngleRadToElevationRotationDeg( + sal_Int32& rnElevationDeg, sal_Int32& rnRotationDeg + , double fXRad, double fYRad, double fZRad ); + + SAL_DLLPRIVATE static void ensureCameraDistanceRange( double& rfCameraDistance ); + SAL_DLLPRIVATE static void getCameraDistanceRange( double& rfMinimumDistance, double& rfMaximumDistance ); + + static double CameraDistanceToPerspective( double fCameraDistance ); + static double PerspectiveToCameraDistance( double fPerspective ); + + static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardLeftWall( const rtl::Reference< + ::chart::Diagram >& xDiagram ); + static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardBackWall(const rtl::Reference< + ::chart::Diagram >& xDiagram ); + static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardBottom(const rtl::Reference< + ::chart::Diagram >& xDiagram ); + + //sal_Int32 nRoundedEdges: <0 or >100 -> mixed state + //sal_Int32 nObjectLines: 0->no lines; 1->all lines on; other->mixed state + + static void getRoundedEdgesAndObjectLines( const rtl::Reference< ::chart::Diagram >& xDiagram + , sal_Int32& rnRoundedEdges, sal_Int32& rnObjectLines ); + static void setRoundedEdgesAndObjectLines( const rtl::Reference< ::chart::Diagram >& xDiagram + , sal_Int32 nRoundedEdges, sal_Int32 nObjectLines ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/Title.hxx b/chart2/source/inc/Title.hxx new file mode 100644 index 0000000000..2f21b60402 --- /dev/null +++ b/chart2/source/inc/Title.hxx @@ -0,0 +1,109 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "OPropertySet.hxx" +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> +#include <com/sun/star/chart2/XTitle.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakImplHelper< + css::chart2::XTitle, + css::lang::XServiceInfo, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::util::XModifyListener > + Title_Base; +} + +class OOO_DLLPUBLIC_CHARTTOOLS Title final : + public impl::Title_Base, + public ::property::OPropertySet +{ +public: + explicit Title(); + virtual ~Title() override; + + /// 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + explicit Title( const Title & rOther ); + + // ____ OPropertySet ____ + virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; + + // ____ OPropertySet ____ + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() override; + + // ____ XTitle ____ + virtual css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > > SAL_CALL getText() override; + virtual void SAL_CALL setText( const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& Strings ) override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + +private: + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const css::lang::EventObject& aEvent ) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + void fireModifyEvent(); + + css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > > m_aStrings; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/TitleHelper.hxx b/chart2/source/inc/TitleHelper.hxx new file mode 100644 index 0000000000..ac9f961879 --- /dev/null +++ b/chart2/source/inc/TitleHelper.hxx @@ -0,0 +1,94 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/uno/Reference.h> +#include <rtl/ref.hxx> +#include <rtl/ustring.hxx> +#include "charttoolsdllapi.hxx" +#include "Title.hxx" + +namespace chart { class ChartModel; } +namespace chart { class ReferenceSizeProvider; } +namespace com::sun::star::chart2 { class XTitle; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::uno { class XComponentContext; } + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS TitleHelper +{ +public: + enum eTitleType + { + TITLE_BEGIN = 0, + MAIN_TITLE = 0, + SUB_TITLE, + X_AXIS_TITLE, + Y_AXIS_TITLE, + Z_AXIS_TITLE, + SECONDARY_X_AXIS_TITLE, + SECONDARY_Y_AXIS_TITLE, + NORMAL_TITLE_END, + + //it is intended that this both types are after NORMAL_TITLE_END + TITLE_AT_STANDARD_X_AXIS_POSITION, //equals the Y_AXIS_TITLE for barchart + TITLE_AT_STANDARD_Y_AXIS_POSITION //equals the X_AXIS_TITLE for barchart + }; + + static rtl::Reference< ::chart::Title > + getTitle( eTitleType nTitleIndex + , ChartModel& rModel ); + + static rtl::Reference< ::chart::Title > + getTitle( eTitleType nTitleIndex + , const rtl::Reference< ::chart::ChartModel >& xModel ); + + static rtl::Reference< ::chart::Title > + createTitle( eTitleType nTitleIndex + , const OUString& rTitleText + , const rtl::Reference< ::chart::ChartModel >& xModel + , const css::uno::Reference< css::uno::XComponentContext > & xContext + , ReferenceSizeProvider * pRefSizeProvider = nullptr ); + static rtl::Reference< ::chart::Title > + createOrShowTitle( eTitleType nTitleIndex + , const OUString& rTitleText + , const rtl::Reference< ::chart::ChartModel >& xModel + , const css::uno::Reference< css::uno::XComponentContext > & xContex ); + + static void removeTitle( eTitleType nTitleIndex + , const rtl::Reference< ::chart::ChartModel >& xModel ); + + static OUString getCompleteString( const rtl::Reference< ::chart::Title >& xTitle ); + static void setCompleteString( const OUString& rNewText + , const rtl::Reference< ::chart::Title >& xTitle + , const css::uno::Reference< css::uno::XComponentContext > & xContext + , const float * pDefaultCharHeight = nullptr ); + + static bool getTitleType( eTitleType& rType + , const rtl::Reference< ::chart::Title >& xTitle + , const rtl::Reference< ::chart::ChartModel >& xModel ); + static void hideTitle( eTitleType nTitleIndex, + const rtl::Reference< ::chart::ChartModel > & xModel); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/UncachedDataSequence.hxx b/chart2/source/inc/UncachedDataSequence.hxx new file mode 100644 index 0000000000..ca32af236d --- /dev/null +++ b/chart2/source/inc/UncachedDataSequence.hxx @@ -0,0 +1,173 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +// helper classes +#include <cppuhelper/compbase.hxx> +#include <comphelper/uno3.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/propertycontainer.hxx> +#include <comphelper/proparrhlp.hxx> +#include <rtl/ref.hxx> + +// interfaces and types +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart2/data/XDataSequence.hpp> +#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> +#include <com/sun/star/chart2/data/XTextualDataSequence.hpp> +#include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/util/XModifiable.hpp> + +namespace com::sun::star::beans { class XPropertySetInfo; } +namespace com::sun::star::chart2 { class XInternalDataProvider; } + +namespace chart +{ +class InternalDataProvider; +class ModifyEventForwarder; + +namespace impl +{ +typedef ::cppu::WeakComponentImplHelper< + css::chart2::data::XDataSequence, + css::chart2::data::XNumericalDataSequence, + css::chart2::data::XTextualDataSequence, + css::util::XCloneable, + css::util::XModifiable, // contains util::XModifyBroadcaster + css::container::XIndexReplace, + css::container::XNamed, // for setting a new range representation + css::lang::XServiceInfo > + UncachedDataSequence_Base; +} + +/** + * This sequence object does NOT store actual sequence data. Instead, it + * references a column inside the internal data table (represented by class + * InternalData) via range representation string. The range representation + * string ends with a numeric value that indicates the column index within + * the internal data table. + * + * <p>A range representation can be either '0', '1', '2', ..., or 'label 1', + * 'label 2', ...</p> + */ +class UncachedDataSequence final : + public ::comphelper::OMutexAndBroadcastHelper, + public ::comphelper::OPropertyContainer, + public ::comphelper::OPropertyArrayUsageHelper< UncachedDataSequence >, + public impl::UncachedDataSequence_Base +{ +public: + /** The referring data provider is held as uno reference to ensure its + lifetime is at least as long as the one of this object. + */ + UncachedDataSequence( + rtl::Reference< InternalDataProvider > xIntDataProv, + OUString aRangeRepresentation ); + UncachedDataSequence( + rtl::Reference< InternalDataProvider > xIntDataProv, + OUString aRangeRepresentation, + const OUString & rRole ); + UncachedDataSequence( const UncachedDataSequence & rSource ); + virtual ~UncachedDataSequence() override; + + /// declare XServiceInfo methods + 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; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +private: + // ____ XPropertySet ____ + /// @see css::beans::XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + /// @see ::comphelper::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + /// @see ::comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + + // ____ XDataSequence ____ + virtual css::uno::Sequence< css::uno::Any > SAL_CALL getData() override; + virtual OUString SAL_CALL getSourceRangeRepresentation() override; + virtual css::uno::Sequence< OUString > SAL_CALL generateLabel( + css::chart2::data::LabelOrigin nLabelOrigin ) override; + virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex ) override; + + // ____ XNumericalDataSequence ____ + /// @see css::chart::data::XNumericalDataSequence + virtual css::uno::Sequence< double > SAL_CALL getNumericalData() override; + + // ____ XTextualDataSequence ____ + /// @see css::chart::data::XTextualDataSequence + virtual css::uno::Sequence< OUString > SAL_CALL getTextualData() override; + + // ____ XIndexReplace ____ + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const css::uno::Any& Element ) override; + + // ____ XIndexAccess (base of XIndexReplace) ____ + virtual ::sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override; + + // ____ XElementAccess (base of XIndexAccess) ____ + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // ____ XNamed (for setting a new range representation) ____ + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // ____ XCloneable ____ + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // ____ XModifiable ____ + virtual sal_Bool SAL_CALL isModified() override; + virtual void SAL_CALL setModified( sal_Bool bModified ) override; + + // ____ XModifyBroadcaster (base of XModifiable) ____ + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + void fireModifyEvent(); + + // <properties> + sal_Int32 m_nNumberFormatKey; + OUString m_sRole; + OUString m_aXMLRange; + // </properties> + + /** This method registers all properties. It should be called by all + constructors. + */ + void registerProperties(); + + rtl::Reference< InternalDataProvider > m_xDataProvider; + OUString m_aSourceRepresentation; + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/UserDefinedProperties.hxx b/chart2/source/inc/UserDefinedProperties.hxx new file mode 100644 index 0000000000..07ab7b5bbc --- /dev/null +++ b/chart2/source/inc/UserDefinedProperties.hxx @@ -0,0 +1,54 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "FastPropertyIdRanges.hxx" +#include "charttoolsdllapi.hxx" + +#include <vector> + +namespace com::sun::star::beans { struct Property; } + +namespace chart +{ + +// implements service com.sun.star.xml.UserDefinedAttributesSupplier +namespace UserDefinedProperties +{ + // FastProperty Ids for properties + enum + { + // UserDefined attributes in the chart-properties + PROP_XML_USERDEF_CHART = FAST_PROPERTY_ID_START_USERDEF_PROP, + PROP_XML_USERDEF_TEXT, + PROP_XML_USERDEF_PARA, + // com.sun.star.xml.UserDefinedAttributesSupplier + // UserDefined attributes in the other properties-sections. (as long as + // there is no reliable mechanism, properties may move between the + // sections) + PROP_XML_USERDEF + }; + + OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector( + std::vector< css::beans::Property > & rOutProperties ); +} + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/WeakListenerAdapter.hxx b/chart2/source/inc/WeakListenerAdapter.hxx new file mode 100644 index 0000000000..f300f1aa03 --- /dev/null +++ b/chart2/source/inc/WeakListenerAdapter.hxx @@ -0,0 +1,86 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/implbase.hxx> + +namespace chart +{ + +/** Adapter that enables adding listeners as weak UNO references. Thus, adding + an object as listener to a broadcaster does not increase its reference + count. + + <p>The helper class, of course, is held as hard reference at the + broadcaster, but this should never be a problem as the adapter's life time + depends on no other object.</p> + + <p>Note that in order to remove an object as listener, you have to remove + the same wrapper that you added, i.e., you should store the adapter as a + member in the adapted class for later use.</p> + */ +template< class Listener > + class WeakListenerAdapter : public + ::cppu::WeakImplHelper< Listener > +{ +public: + explicit WeakListenerAdapter( const css::uno::Reference< Listener > & xListener ) : + m_xListener( xListener ) + {} + +protected: + // ____ XEventListener (base of all listeners) ____ + virtual void SAL_CALL disposing( + const css::lang::EventObject& Source ) override + { + css::uno::Reference< css::lang::XEventListener > xEventListener( + css::uno::Reference< Listener >( m_xListener), css::uno::UNO_QUERY ); + if( xEventListener.is()) + xEventListener->disposing( Source ); + } + + css::uno::Reference< Listener > getListener() const + { + return m_xListener; + } + +private: + css::uno::WeakReference< Listener > m_xListener; +}; + +class WeakSelectionChangeListenerAdapter final : + public WeakListenerAdapter< css::view::XSelectionChangeListener > +{ +public: + explicit WeakSelectionChangeListenerAdapter( + const css::uno::Reference< css::view::XSelectionChangeListener > & xListener ); + virtual ~WeakSelectionChangeListenerAdapter() override; + +protected: + // ____ XSelectionChangeListener ____ + virtual void SAL_CALL selectionChanged( + const css::lang::EventObject& aEvent ) override; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/WrappedDefaultProperty.hxx b/chart2/source/inc/WrappedDefaultProperty.hxx new file mode 100644 index 0000000000..757eef248b --- /dev/null +++ b/chart2/source/inc/WrappedDefaultProperty.hxx @@ -0,0 +1,51 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "WrappedProperty.hxx" +#include "charttoolsdllapi.hxx" + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS WrappedDefaultProperty : public WrappedProperty +{ +public: + explicit WrappedDefaultProperty( + const OUString& rOuterName, const OUString& rInnerName, + css::uno::Any aNewOuterDefault ); + virtual ~WrappedDefaultProperty() override; + + virtual void setPropertyToDefault( + const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; + + virtual css::uno::Any getPropertyDefault( + const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; + + virtual css::beans::PropertyState getPropertyState( + const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; +private: + css::uno::Any m_aOuterDefaultValue; +}; + +} // namespace chart + +// CHART2_WRAPPEDPROPERTYNEWDEFAULT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/WrappedDirectStateProperty.hxx b/chart2/source/inc/WrappedDirectStateProperty.hxx new file mode 100644 index 0000000000..28398efd81 --- /dev/null +++ b/chart2/source/inc/WrappedDirectStateProperty.hxx @@ -0,0 +1,40 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "WrappedProperty.hxx" +#include "charttoolsdllapi.hxx" + +namespace chart +{ +class OOO_DLLPUBLIC_CHARTTOOLS WrappedDirectStateProperty : public WrappedProperty +{ +public: + explicit WrappedDirectStateProperty(const OUString& rOuterName, const OUString& rInnerName); + virtual ~WrappedDirectStateProperty() override; + + virtual css::beans::PropertyState getPropertyState( + const css::uno::Reference<css::beans::XPropertyState>& xInnerPropertyState) const override; +}; + +} // namespace chart + +// CHART2_WRAPPEDPROPERTYNEWDEFAULT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/WrappedIgnoreProperty.hxx b/chart2/source/inc/WrappedIgnoreProperty.hxx new file mode 100644 index 0000000000..a031097bda --- /dev/null +++ b/chart2/source/inc/WrappedIgnoreProperty.hxx @@ -0,0 +1,62 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "WrappedProperty.hxx" +#include "charttoolsdllapi.hxx" + +#include <vector> + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS WrappedIgnoreProperty final : public WrappedProperty +{ +public: + WrappedIgnoreProperty( const OUString& rOuterName, const css::uno::Any& rDefaultValue ); + virtual ~WrappedIgnoreProperty() override; + + virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; + + virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; + +SAL_DLLPRIVATE virtual void setPropertyToDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; + +SAL_DLLPRIVATE virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; + +SAL_DLLPRIVATE virtual css::beans::PropertyState getPropertyState( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; + +private: + css::uno::Any m_aDefaultValue; + mutable css::uno::Any m_aCurrentValue; +}; + +class OOO_DLLPUBLIC_CHARTTOOLS WrappedIgnoreProperties +{ +public: + static void addIgnoreLineProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList ); + + static void addIgnoreFillProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList ); + SAL_DLLPRIVATE static void addIgnoreFillProperties_without_BitmapProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList ); + SAL_DLLPRIVATE static void addIgnoreFillProperties_only_BitmapProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/WrappedProperty.hxx b/chart2/source/inc/WrappedProperty.hxx new file mode 100644 index 0000000000..1ec91f71f9 --- /dev/null +++ b/chart2/source/inc/WrappedProperty.hxx @@ -0,0 +1,86 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/uno/Any.hxx> +#include <rtl/ustring.hxx> +#include "charttoolsdllapi.hxx" + +#include <map> +#include <memory> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::beans { class XPropertyState; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS WrappedProperty +{ + /** The property visible to the outer PropertySet in the PropertySetWrapper may have a different name, type and value than + a corresponding property of the inner PropertySet. Use this class to do the conversion between the two. + */ +public: + WrappedProperty( OUString aOuterName, OUString aInnerName ); + virtual ~WrappedProperty(); + + const OUString& getOuterName() const { return m_aOuterName;} + virtual OUString getInnerName() const; + + /// @throws css::beans::UnknownPropertyException + /// @throws css::beans::PropertyVetoException + /// @throws css::lang::IllegalArgumentException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const; + + /// @throws css::beans::UnknownPropertyException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const; + + /// @throws css::beans::UnknownPropertyException + /// @throws css::uno::RuntimeException + virtual void setPropertyToDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const; + + /// @throws css::beans::UnknownPropertyException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const; + + /// @throws css::beans::UnknownPropertyException + /// @throws css::uno::RuntimeException + virtual css::beans::PropertyState getPropertyState( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const; + +protected: + virtual css::uno::Any convertInnerToOuterValue( const css::uno::Any& rInnerValue ) const; + virtual css::uno::Any convertOuterToInnerValue( const css::uno::Any& rOuterValue ) const; + +protected: + OUString m_aOuterName; + OUString m_aInnerName; +}; + +typedef std::map< sal_Int32, std::unique_ptr<const WrappedProperty> > tWrappedPropertyMap; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/WrappedPropertySet.hxx b/chart2/source/inc/WrappedPropertySet.hxx new file mode 100644 index 0000000000..ec3d43632c --- /dev/null +++ b/chart2/source/inc/WrappedPropertySet.hxx @@ -0,0 +1,123 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "WrappedProperty.hxx" +#include "charttoolsdllapi.hxx" +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <cppuhelper/implbase.hxx> + +#include <memory> +#include <mutex> +#include <vector> + +namespace cppu { class IPropertyArrayHelper; } +namespace cppu { class OPropertyArrayHelper; } + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTTOOLS WrappedPropertySet : + public ::cppu::WeakImplHelper + < css::beans::XPropertySet + , css::beans::XMultiPropertySet + , css::beans::XPropertyState + , css::beans::XMultiPropertyStates + > +{ +public: + WrappedPropertySet(); + virtual ~WrappedPropertySet() override; + + void clearWrappedPropertySet(); + +public: + //XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + //XMultiPropertySet + //getPropertySetInfo() already declared in XPropertySet + virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override; + virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + + //XPropertyState + virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; + virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; + + //XMultiPropertyStates + //getPropertyStates() already declared in XPropertyState + virtual void SAL_CALL setAllPropertiesToDefault( ) override; + virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override; + +protected: //methods + /** give all the properties that should be visible to the outer side + */ + virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence()=0; + /** give a list of all properties that need a special treatment; + properties that are not in this list will be wrapped identical. + The base class 'WrappedPropertySet' will take ownership on the contained pointer. + It is not allowed to have duplicate entries in this list. + */ + virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties()=0; + + virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() = 0; + SAL_DLLPRIVATE css::uno::Reference< css::beans::XPropertyState > getInnerPropertyState(); + + ::cppu::IPropertyArrayHelper& getInfoHelper(); + SAL_DLLPRIVATE tWrappedPropertyMap& getWrappedPropertyMap(); + + const WrappedProperty* getWrappedProperty( const OUString& rOuterName ); + const WrappedProperty* getWrappedProperty( sal_Int32 nHandle ); + + std::mutex m_aMutex; + +private: + css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo;//outer PropertySetInfo + + std::unique_ptr<::cppu::OPropertyArrayHelper> m_pPropertyArrayHelper;//holds all possible outer properties + + std::unique_ptr<tWrappedPropertyMap> m_pWrappedPropertyMap;//holds all wrapped properties (containing the special mapping from inner to outer properties) + + //Container for the XPropertyChangedListener. The listeners are inserted by handle. + //OMultiTypeInterfaceContainerHelperInt32 m_aBoundListenerContainer; + + //Container for the XPropertyVetoableListener. The listeners are inserted by handle. + //OMultiTypeInterfaceContainerHelperInt32 m_aVetoableListenerContainer; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/XMLRangeHelper.hxx b/chart2/source/inc/XMLRangeHelper.hxx new file mode 100644 index 0000000000..519c9b7722 --- /dev/null +++ b/chart2/source/inc/XMLRangeHelper.hxx @@ -0,0 +1,60 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include "charttoolsdllapi.hxx" + +namespace chart::XMLRangeHelper +{ + +struct OOO_DLLPUBLIC_CHARTTOOLS Cell +{ + sal_Int32 nColumn; + sal_Int32 nRow; + bool bRelativeColumn; + bool bRelativeRow; + bool bIsEmpty; + + Cell() : + nColumn(0), + nRow(0), + bRelativeColumn(false), + bRelativeRow(false), + bIsEmpty(true) + {} + + bool empty() const { return bIsEmpty; } +}; + +struct OOO_DLLPUBLIC_CHARTTOOLS CellRange +{ + Cell aUpperLeft; + Cell aLowerRight; + OUString aTableName; +}; + +CellRange getCellRangeFromXMLString( const OUString & rXMLString ); + +OUString getXMLStringFromCellRange( const CellRange & rRange ); + +} // namespace chart::XMLRangeHelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/charttoolsdllapi.hxx b/chart2/source/inc/charttoolsdllapi.hxx new file mode 100644 index 0000000000..96336e1012 --- /dev/null +++ b/chart2/source/inc/charttoolsdllapi.hxx @@ -0,0 +1,32 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sal/config.h> + +#include <sal/types.h> + +#if defined OOO_DLLIMPLEMENTATION_CHARTTOOLS +#define OOO_DLLPUBLIC_CHARTTOOLS SAL_DLLPUBLIC_EXPORT +#else +#define OOO_DLLPUBLIC_CHARTTOOLS SAL_DLLPUBLIC_IMPORT +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx new file mode 100644 index 0000000000..a5099cc0c3 --- /dev/null +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -0,0 +1,236 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <svl/typedwhich.hxx> + +class SvxSizeItem; +class SfxIntegerListItem; +class SfxBoolItem; +class SfxStringItem; +class SfxInt32Item; +class SfxUInt32Item; +class SvxChartIndicateItem; +class SvxDoubleItem; +class SvxBrushItem; +class SvxChartKindErrorItem; +class SvxChartTextOrderItem; +class SvxChartRegressItem; +class SdrAngleItem; + +// SCHATTR + +// can't this be changed to 0? +constexpr sal_uInt16 SCHATTR_START = 1; + +constexpr sal_uInt16 SCHATTR_DATADESCR_START (SCHATTR_START); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_SHOW_NUMBER (SCHATTR_DATADESCR_START); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_SHOW_PERCENTAGE (SCHATTR_DATADESCR_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_SHOW_CATEGORY (SCHATTR_DATADESCR_START + 2); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_SHOW_SYMBOL (SCHATTR_DATADESCR_START + 3); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_WRAP_TEXT (SCHATTR_DATADESCR_START + 4); +constexpr TypedWhichId<SfxStringItem> SCHATTR_DATADESCR_SEPARATOR (SCHATTR_DATADESCR_START + 5); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_DATADESCR_PLACEMENT (SCHATTR_DATADESCR_START + 6); +constexpr TypedWhichId<SfxIntegerListItem> SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS (SCHATTR_DATADESCR_START + 7); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_NO_PERCENTVALUE (SCHATTR_DATADESCR_START + 8); //percentage values should not be offered +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_CUSTOM_LEADER_LINES (SCHATTR_DATADESCR_START + 9); +constexpr TypedWhichId<SfxUInt32Item> SCHATTR_PERCENT_NUMBERFORMAT_VALUE (SCHATTR_DATADESCR_START + 10); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_PERCENT_NUMBERFORMAT_SOURCE (SCHATTR_DATADESCR_START + 11); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME (SCHATTR_DATADESCR_START + 12); +constexpr sal_uInt16 SCHATTR_DATADESCR_END (SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME); + +//legend +constexpr sal_uInt16 SCHATTR_LEGEND_START (SCHATTR_DATADESCR_END + 1); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_LEGEND_POS (SCHATTR_LEGEND_START); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_LEGEND_SHOW (SCHATTR_LEGEND_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_LEGEND_NO_OVERLAY (SCHATTR_LEGEND_START + 2); +constexpr sal_uInt16 SCHATTR_LEGEND_END (SCHATTR_LEGEND_NO_OVERLAY); + +//text +constexpr sal_uInt16 SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1); +constexpr TypedWhichId<SdrAngleItem> SCHATTR_TEXT_DEGREES (SCHATTR_TEXT_START); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_TEXT_STACKED (SCHATTR_TEXT_START + 1); +constexpr sal_uInt16 SCHATTR_TEXT_END (SCHATTR_TEXT_STACKED); + +// statistic +constexpr sal_uInt16 SCHATTR_STAT_START (SCHATTR_TEXT_END + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STAT_AVERAGE (SCHATTR_STAT_START); +constexpr TypedWhichId<SvxChartKindErrorItem> SCHATTR_STAT_KIND_ERROR (SCHATTR_STAT_START + 1); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_STAT_PERCENT (SCHATTR_STAT_START + 2); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_STAT_BIGERROR (SCHATTR_STAT_START + 3); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_STAT_CONSTPLUS (SCHATTR_STAT_START + 4); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_STAT_CONSTMINUS (SCHATTR_STAT_START + 5); +constexpr TypedWhichId<SvxChartIndicateItem> SCHATTR_STAT_INDICATE (SCHATTR_STAT_START + 6); +constexpr TypedWhichId<SfxStringItem> SCHATTR_STAT_RANGE_POS (SCHATTR_STAT_START + 7); +constexpr TypedWhichId<SfxStringItem> SCHATTR_STAT_RANGE_NEG (SCHATTR_STAT_START + 8); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STAT_ERRORBAR_TYPE (SCHATTR_STAT_START + 9); +constexpr sal_uInt16 SCHATTR_STAT_END (SCHATTR_STAT_ERRORBAR_TYPE); + +// these attributes are for replacement of enum eChartStyle + +constexpr sal_uInt16 SCHATTR_STYLE_START (SCHATTR_STAT_END + 1); + +// for whole chart +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STYLE_DEEP (SCHATTR_STYLE_START ); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STYLE_3D (SCHATTR_STYLE_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STYLE_VERTICAL (SCHATTR_STYLE_START + 2); + +// also for series +constexpr TypedWhichId<SfxInt32Item> SCHATTR_STYLE_BASETYPE (SCHATTR_STYLE_START + 3);// Line,Area,...,Pie +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STYLE_LINES (SCHATTR_STYLE_START + 4);// draw line +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STYLE_PERCENT (SCHATTR_STYLE_START + 5); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STYLE_STACKED (SCHATTR_STYLE_START + 6); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_STYLE_SPLINES (SCHATTR_STYLE_START + 7); + +// also for data point +constexpr TypedWhichId<SfxInt32Item> SCHATTR_STYLE_SYMBOL (SCHATTR_STYLE_START + 8); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_STYLE_SHAPE (SCHATTR_STYLE_START + 9); +constexpr sal_uInt16 SCHATTR_STYLE_END (SCHATTR_STYLE_SHAPE ); + +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS (SCHATTR_STYLE_END + 1); // see chtmodel.hxx defines CHART_AXIS_PRIMARY_X, etc. +//Re-mapped: +constexpr sal_uInt16 SCHATTR_AXIS_START (SCHATTR_AXIS + 1); +//axis scale +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXISTYPE (SCHATTR_AXIS_START); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_REVERSE (SCHATTR_AXIS_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_AUTO_MIN (SCHATTR_AXIS_START + 2); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_AXIS_MIN (SCHATTR_AXIS_START + 3); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_AUTO_MAX (SCHATTR_AXIS_START + 4); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_AXIS_MAX (SCHATTR_AXIS_START + 5); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_AUTO_STEP_MAIN (SCHATTR_AXIS_START + 6); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_AXIS_STEP_MAIN (SCHATTR_AXIS_START + 7); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_MAIN_TIME_UNIT (SCHATTR_AXIS_START + 8); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_AUTO_STEP_HELP (SCHATTR_AXIS_START + 9); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_STEP_HELP (SCHATTR_AXIS_START + 10); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_HELP_TIME_UNIT (SCHATTR_AXIS_START + 11); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_AUTO_TIME_RESOLUTION (SCHATTR_AXIS_START + 12); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_TIME_RESOLUTION (SCHATTR_AXIS_START + 13); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_LOGARITHM (SCHATTR_AXIS_START + 14); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_AUTO_DATEAXIS (SCHATTR_AXIS_START + 15); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_ALLOW_DATEAXIS (SCHATTR_AXIS_START + 16); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_AUTO_ORIGIN (SCHATTR_AXIS_START + 17); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_AXIS_ORIGIN (SCHATTR_AXIS_START + 18); +//axis position +constexpr sal_uInt16 SCHATTR_AXIS_POSITION_START (SCHATTR_AXIS_ORIGIN + 1); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_TICKS (SCHATTR_AXIS_POSITION_START); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_HELPTICKS (SCHATTR_AXIS_POSITION_START + 1); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_POSITION (SCHATTR_AXIS_POSITION_START + 2); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_AXIS_POSITION_VALUE (SCHATTR_AXIS_POSITION_START + 3); +constexpr TypedWhichId<SfxUInt32Item> SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT (SCHATTR_AXIS_POSITION_START + 4); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION (SCHATTR_AXIS_POSITION_START + 5); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_LABEL_POSITION (SCHATTR_AXIS_POSITION_START + 6); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_MARK_POSITION (SCHATTR_AXIS_POSITION_START + 7); +//axis label +constexpr sal_uInt16 SCHATTR_AXIS_LABEL_START (SCHATTR_AXIS_MARK_POSITION + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_SHOWDESCR (SCHATTR_AXIS_LABEL_START); +constexpr TypedWhichId<SvxChartTextOrderItem> SCHATTR_AXIS_LABEL_ORDER (SCHATTR_AXIS_LABEL_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_LABEL_OVERLAP (SCHATTR_AXIS_LABEL_START + 2); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_LABEL_BREAK (SCHATTR_AXIS_LABEL_START + 3); +constexpr sal_uInt16 SCHATTR_AXIS_LABEL_END (SCHATTR_AXIS_LABEL_BREAK); + +constexpr sal_uInt16 SCHATTR_AXIS_END (SCHATTR_AXIS_LABEL_END); + +constexpr TypedWhichId<SvxBrushItem> SCHATTR_SYMBOL_BRUSH (SCHATTR_AXIS_END + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STOCK_VOLUME (SCHATTR_AXIS_END + 2); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_STOCK_UPDOWN (SCHATTR_AXIS_END + 3); +constexpr TypedWhichId<SvxSizeItem> SCHATTR_SYMBOL_SIZE (SCHATTR_AXIS_END + 4); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY (SCHATTR_AXIS_END + 5); + +// non persistent items (binary format) +constexpr sal_uInt16 SCHATTR_CHARTTYPE_START (SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY + 1); + +// new from New Chart +constexpr TypedWhichId<SfxInt32Item> SCHATTR_BAR_OVERLAP (SCHATTR_CHARTTYPE_START ); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_BAR_GAPWIDTH (SCHATTR_CHARTTYPE_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_BAR_CONNECT (SCHATTR_CHARTTYPE_START + 2); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_NUM_OF_LINES_FOR_BAR (SCHATTR_CHARTTYPE_START + 3); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_SPLINE_ORDER (SCHATTR_CHARTTYPE_START + 4); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_SPLINE_RESOLUTION (SCHATTR_CHARTTYPE_START + 5); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_GROUP_BARS_PER_AXIS (SCHATTR_CHARTTYPE_START + 6); +constexpr TypedWhichId<SdrAngleItem> SCHATTR_STARTING_ANGLE (SCHATTR_CHARTTYPE_START + 7); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_CLOCKWISE (SCHATTR_CHARTTYPE_START + 8); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_MISSING_VALUE_TREATMENT (SCHATTR_CHARTTYPE_START + 9); +constexpr TypedWhichId<SfxIntegerListItem> SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS (SCHATTR_CHARTTYPE_START + 10); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_INCLUDE_HIDDEN_CELLS (SCHATTR_CHARTTYPE_START + 11); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_HIDE_LEGEND_ENTRY (SCHATTR_CHARTTYPE_START + 12); + +constexpr sal_uInt16 SCHATTR_CHARTTYPE_END (SCHATTR_HIDE_LEGEND_ENTRY); + +// items for transporting information to dialogs +constexpr sal_uInt16 SCHATTR_MISC_START (SCHATTR_CHARTTYPE_END + 1); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_FOR_ALL_SERIES (SCHATTR_MISC_START); +constexpr sal_uInt16 SCHATTR_MISC_END (SCHATTR_AXIS_FOR_ALL_SERIES); + +// regression curve +constexpr sal_uInt16 SCHATTR_REGRESSION_START (SCHATTR_MISC_END + 1); +constexpr TypedWhichId<SvxChartRegressItem> SCHATTR_REGRESSION_TYPE (SCHATTR_REGRESSION_START); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_REGRESSION_SHOW_EQUATION (SCHATTR_REGRESSION_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_REGRESSION_SHOW_COEFF (SCHATTR_REGRESSION_START + 2); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_REGRESSION_DEGREE (SCHATTR_REGRESSION_START + 3); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_REGRESSION_PERIOD (SCHATTR_REGRESSION_START + 4); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD (SCHATTR_REGRESSION_START + 5); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD (SCHATTR_REGRESSION_START + 6); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_REGRESSION_SET_INTERCEPT (SCHATTR_REGRESSION_START + 7); +constexpr TypedWhichId<SvxDoubleItem> SCHATTR_REGRESSION_INTERCEPT_VALUE (SCHATTR_REGRESSION_START + 8); +constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_CURVE_NAME (SCHATTR_REGRESSION_START + 9); +constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_XNAME (SCHATTR_REGRESSION_START + 10); +constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_YNAME (SCHATTR_REGRESSION_START + 11); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_REGRESSION_MOVING_TYPE (SCHATTR_REGRESSION_START + 12); +constexpr sal_uInt16 SCHATTR_REGRESSION_END (SCHATTR_REGRESSION_MOVING_TYPE); + +constexpr sal_uInt16 SCHATTR_DATA_TABLE_START (SCHATTR_REGRESSION_END + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATA_TABLE_HORIZONTAL_BORDER (SCHATTR_DATA_TABLE_START + 0); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATA_TABLE_VERTICAL_BORDER (SCHATTR_DATA_TABLE_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATA_TABLE_OUTLINE (SCHATTR_DATA_TABLE_START + 2); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATA_TABLE_KEYS (SCHATTR_DATA_TABLE_START + 3); +constexpr sal_uInt16 SCHATTR_DATA_TABLE_END (SCHATTR_DATA_TABLE_KEYS); + +constexpr sal_uInt16 SCHATTR_END (SCHATTR_DATA_TABLE_END); + +// values for Items + +// values for SCHATTR_AXIS_TICKS and SCHATTR_AXIS_HELPTICKS items +#define CHAXIS_MARK_BOTH 3 +#define CHAXIS_MARK_OUTER 2 +#define CHAXIS_MARK_INNER 1 +#define CHAXIS_MARK_NONE 0 + +// values for SCHATTR_AXISTYPE items +#define CHART_AXIS_REALNUMBER 0 +#define CHART_AXIS_PERCENT 1 +#define CHART_AXIS_CATEGORY 2 +#define CHART_AXIS_SERIES 3 +#define CHART_AXIS_DATE 4 + +// values for SCHATTR_STYLE_SHAPE items +#define CHART_SHAPE3D_IGNORE -2 //internal! (GetChartShapeStyle()!) +#define CHART_SHAPE3D_SQUARE 0 +#define CHART_SHAPE3D_CYLINDER 1 +#define CHART_SHAPE3D_CONE 2 +#define CHART_SHAPE3D_PYRAMID 3 //reserved +#define CHART_SHAPE3D_HANOI 4 + +// values for SCHATTR_AXIS items +#define CHART_AXIS_PRIMARY_X 1 +#define CHART_AXIS_PRIMARY_Y 2 +#define CHART_AXIS_PRIMARY_Z 3 +#define CHART_AXIS_SECONDARY_Y 4 +#define CHART_AXIS_SECONDARY_X 5 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/chartview/DataPointSymbolSupplier.hxx b/chart2/source/inc/chartview/DataPointSymbolSupplier.hxx new file mode 100644 index 0000000000..58d8a9ff2e --- /dev/null +++ b/chart2/source/inc/chartview/DataPointSymbolSupplier.hxx @@ -0,0 +1,42 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <chartview/chartviewdllapi.hxx> +#include <rtl/ref.hxx> +#include <svx/unoshape.hxx> + +namespace com::sun::star::drawing { class XShapes; } +namespace com::sun::star::drawing { struct Direction3D; } + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTVIEW DataPointSymbolSupplier +{ +public: + static rtl::Reference< SvxShapeGroup > + create2DSymbolList( const rtl::Reference<SvxDrawPage>& xTarget + , const css::drawing::Direction3D& rSize ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/chartview/DrawModelWrapper.hxx b/chart2/source/inc/chartview/DrawModelWrapper.hxx new file mode 100644 index 0000000000..080587e7ec --- /dev/null +++ b/chart2/source/inc/chartview/DrawModelWrapper.hxx @@ -0,0 +1,92 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <svx/svdmodel.hxx> +#include <svx/unopage.hxx> +#include <svx/unoshape.hxx> +#include <chartview/chartviewdllapi.hxx> + +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::drawing { class XDrawPage; } +namespace com::sun::star::drawing { class XShape; } +namespace com::sun::star::drawing { class XShapes; } + +class SdrObjList; +class SdrObject; + +namespace chart +{ + +class OOO_DLLPUBLIC_CHARTVIEW DrawModelWrapper final : private SdrModel +{ +private: + rtl::Reference<SvxDrawPage> m_xMainDrawPage; + rtl::Reference<SvxDrawPage> m_xHiddenDrawPage; + rtl::Reference<SfxItemPool> m_xChartItemPool; + VclPtr<OutputDevice> m_pRefDevice; + +public: + SAL_DLLPRIVATE DrawModelWrapper(); + SAL_DLLPRIVATE virtual ~DrawModelWrapper() override; + + css::uno::Reference< css::lang::XMultiServiceFactory > getShapeFactory(); + + // the main page will contain the normal view objects + const rtl::Reference<SvxDrawPage> & getMainDrawPage(); + SAL_DLLPRIVATE void clearMainDrawPage(); + + // the extra page is not visible, but contains some extras like the symbols for data points + const rtl::Reference<SvxDrawPage> & getHiddenDrawPage(); + + static rtl::Reference<SvxShapeGroupAnyD> + getChartRootShape( const rtl::Reference<SvxDrawPage>& xPage ); + + SAL_DLLPRIVATE void lockControllers(); + SAL_DLLPRIVATE void unlockControllers(); + + OutputDevice* getReferenceDevice() const; + + SfxItemPool& GetItemPool(); + + SAL_DLLPRIVATE virtual css::uno::Reference< css::frame::XModel > + createUnoModel() override; + SAL_DLLPRIVATE css::uno::Reference< css::frame::XModel > + getUnoModel(); + SdrModel& getSdrModel(); + + XColorListRef GetColorList() const; + XDashListRef GetDashList() const; + XLineEndListRef GetLineEndList() const; + XGradientListRef GetGradientList() const; + XHatchListRef GetHatchList() const; + XBitmapListRef GetBitmapList() const; + XPatternListRef GetPatternList() const; + + SdrObject* getNamedSdrObject( const OUString& rName ); + static SdrObject* getNamedSdrObject( const OUString& rName, SdrObjList const * pObjList ); + + static bool removeShape( const rtl::Reference<SvxShape>& xShape ); + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/chartview/ExplicitScaleValues.hxx b/chart2/source/inc/chartview/ExplicitScaleValues.hxx new file mode 100644 index 0000000000..a49dddeb66 --- /dev/null +++ b/chart2/source/inc/chartview/ExplicitScaleValues.hxx @@ -0,0 +1,154 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <chartview/chartviewdllapi.hxx> +#include <com/sun/star/chart/TimeInterval.hpp> +#include <com/sun/star/chart2/AxisOrientation.hpp> +#include <com/sun/star/chart2/XScaling.hpp> +#include <tools/date.hxx> +#include <vector> + +namespace com::sun::star::chart2 +{ +class XScaling; +} + +namespace chart +{ +/** This structure contains the explicit values for a scale like Minimum and Maximum. + See also css::chart2::ScaleData. +*/ +struct OOO_DLLPUBLIC_CHARTVIEW ExplicitScaleData +{ + ExplicitScaleData(); + + double Minimum; + double Maximum; + double Origin; + + css::chart2::AxisOrientation Orientation; + + css::uno::Reference<css::chart2::XScaling> Scaling; + + sal_Int32 AxisType; //see css::chart2::AxisType + bool m_bShiftedCategoryPosition; + sal_Int32 TimeResolution; //constant of type <type>css::chart::TimeUnit</type> + Date NullDate; +}; + +struct ExplicitSubIncrement +{ + ExplicitSubIncrement(); + + /** Numbers of intervals between two superior ticks. For an axis + this usually means, that <code>IntervalCount - 1</code> + sub-tick-marks are displayed between two superior ticks. + + */ + sal_Int32 IntervalCount; + + /** If <TRUE/>, the distance between two sub-tick-marks on the + screen is always the same. If <FALSE/>, the distances may + differ depending on the <type>XScaling</type>. + */ + bool PostEquidistant; +}; + +/** describes how tickmarks are positioned on the scale of an axis. +*/ +struct OOO_DLLPUBLIC_CHARTVIEW ExplicitIncrementData +{ + ExplicitIncrementData(); + + /** the following two members are only for date-time axis + */ + css::chart::TimeInterval MajorTimeInterval; + css::chart::TimeInterval MinorTimeInterval; + + /** the other members are for *not* date-time axis + */ + + /** <member>Distance</member> describes the distance between two + neighboring main tickmarks on a <type>Scale</type> of an axis. + All neighboring main tickmarks have the same constant distance. + + <p>If the Scale has a <type>XScaling</type> the <member>Distance</member> + may be measured in two different ways - that is - before or after the + scaling is applied.</p> + + <p>On a logarithmic scale for example the distance between two main + tickmarks is typically measured after the scaling is applied: + Distance = log(tick2)-log(tick1) + ( log(1000)-log(100)==log(100)-log(10)==log(10)-log(1)==1==Distance ). + The resulting tickmarks will always look equidistant on the screen. + The other possibility is to have a Distance = tick2-tick1 measured constant + before a scaling is applied, which may lead to non equidistant tickmarks + on the screen.</p> + + <p><member>PostEquidistant</member> rules whether the <member>Distance</member> + is meant to be a value before or after scaling.</p> + */ + double Distance; + + /** + <member>PostEquidistant</member> rules whether the member <member>Distance</member> + describes a distance before or after the scaling is applied. + + <p>If <member>PostEquidistant</member> equals <TRUE/> <member>Distance</member> + is given in values after <type>XScaling</type> is applied, thus resulting + main tickmarks will always look equidistant on the screen. + If <member>PostEquidistant</member> equals <FALSE/> <member>Distance</member> + is given in values before <type>XScaling</type> is applied.</p> + */ + bool PostEquidistant; + + /** The <member>BaseValue</member> gives a starting point on the scale + to which all further main tickmarks are relatively positioned. + + <p>The <member>BaseValue</member> is always a value on the scale before + a possible scaling is applied. If the given value is not valid in the + associated scaling the minimum of the scaling is assumed, + if there is no minimum any other obvious value will be assumed.</p> + + <p>E.g.: assume a scale from 0 to 6 with identical scaling. + Further assume this Increment to have Distance==2 and PostEquidistant==false. + Setting BaseValue=0 would lead to main tickmarks 0; 2; 4; 6; + Setting BaseValue=1,3 would lead to main tickmarks 1,3; 3,3; 5,3; + Setting BaseValue=-0,7 would also lead to main tickmarks 1,3; 3,3; 5,3; + And setting BaseValue to 2, -2, 4, -4 etc. in this example + leads to the same result as BaseValue=0.</p> + */ + double BaseValue; + + /** <member>SubIncrements</member> describes the positioning of further + sub tickmarks on the scale of an axis. + + <p>The first SubIncrement in this sequence determines how the + distance between two neighboring main tickmarks is divided for positioning + of further sub tickmarks. Every following SubIncrement determines the + positions of subsequent tickmarks in relation to their parent tickmarks + given by the preceding SubIncrement.</p> + */ + std::vector<ExplicitSubIncrement> SubIncrements; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx new file mode 100644 index 0000000000..4370e38cf1 --- /dev/null +++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx @@ -0,0 +1,100 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sal/types.h> +#include <chartview/chartviewdllapi.hxx> +#include <rtl/ref.hxx> +#include <rtl/ustring.hxx> + +#include <memory> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XAxis; } +namespace com::sun::star::chart2 { class XChartDocument; } +namespace com::sun::star::chart2 { class XCoordinateSystem; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::drawing { class XShape; } +namespace com::sun::star::uno { class XInterface; } +namespace com::sun::star::uno { template <typename > class Reference; } +namespace com::sun::star::uno { template <typename > class Sequence; } +namespace com::sun::star::util { class XNumberFormatsSupplier; } +namespace com::sun::star::awt { struct Rectangle; } +class SvxShape; + +namespace chart +{ +class Axis; +class BaseCoordinateSystem; +class DrawModelWrapper; +class ChartModel; +struct ExplicitIncrementData; +struct ExplicitScaleData; + +class OOO_DLLPUBLIC_CHARTVIEW SAL_LOPLUGIN_ANNOTATE("crosscast") ExplicitValueProvider +{ +public: + /** Gives calculated scale and increment values for a given xAxis in the current view. + In contrast to the model data these explicit values are always complete as missing auto properties are calculated. + If the given Axis could not be found or for another reason no correct output can be given false is returned. + */ + virtual bool getExplicitValuesForAxis( + rtl::Reference< ::chart::Axis > xAxis + , ExplicitScaleData& rExplicitScale + , ExplicitIncrementData& rExplicitIncrement )=0; + + /** for rotated objects the shape size and position differs from the visible rectangle + if bSnapRect is set to true you get the resulting visible position (left-top) and size + */ + virtual css::awt::Rectangle + getRectangleOfObject( const OUString& rObjectCID, bool bSnapRect=false )=0; + + virtual css::awt::Rectangle getDiagramRectangleExcludingAxes()=0; + + virtual rtl::Reference< SvxShape > + getShapeForCID( const OUString& rObjectCID )=0; + + virtual std::shared_ptr< DrawModelWrapper > getDrawModelWrapper() = 0; + + static css::awt::Rectangle + AddSubtractAxisTitleSizes( + ChartModel& rModel + , ExplicitValueProvider* pChartView + , const css::awt::Rectangle& rPositionAndSize, bool bSubtract ); + + static sal_Int32 getExplicitNumberFormatKeyForAxis( + const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference< ::chart::BaseCoordinateSystem > & xCorrespondingCoordinateSystem + , const rtl::Reference<::chart::ChartModel>& xChartDoc); + + static sal_Int32 getExplicitNumberFormatKeyForDataLabel( + const css::uno::Reference< css::beans::XPropertySet >& xSeriesOrPointProp ); + + static sal_Int32 getExplicitPercentageNumberFormatKeyForDataLabel( + const css::uno::Reference< css::beans::XPropertySet >& xSeriesOrPointProp + , const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); + +protected: + ~ExplicitValueProvider() = default; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/chartview/chartviewdllapi.hxx b/chart2/source/inc/chartview/chartviewdllapi.hxx new file mode 100644 index 0000000000..533a5cb833 --- /dev/null +++ b/chart2/source/inc/chartview/chartviewdllapi.hxx @@ -0,0 +1,32 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sal/config.h> + +#include <sal/types.h> + +#if defined OOO_DLLIMPLEMENTATION_CHARTVIEW +#define OOO_DLLPUBLIC_CHARTVIEW SAL_DLLPUBLIC_EXPORT +#else +#define OOO_DLLPUBLIC_CHARTVIEW SAL_DLLPUBLIC_IMPORT +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/defines.hxx b/chart2/source/inc/defines.hxx new file mode 100644 index 0000000000..1eb464bc20 --- /dev/null +++ b/chart2/source/inc/defines.hxx @@ -0,0 +1,24 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +constexpr double FIXED_SIZE_FOR_3D_CHART_VOLUME = 10000.0; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/res_BarGeometry.hxx b/chart2/source/inc/res_BarGeometry.hxx new file mode 100644 index 0000000000..9e0c01870f --- /dev/null +++ b/chart2/source/inc/res_BarGeometry.hxx @@ -0,0 +1,45 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <vcl/weld.hxx> + +namespace chart +{ +class BarGeometryResources +{ +public: + explicit BarGeometryResources(weld::Builder* pParent); + + void set_visible(bool bShow); + void set_sensitive(bool bEnable); + + sal_Int32 get_selected_index() const; + void select(sal_Int32 nPos); + + void connect_changed(const Link<weld::TreeView&, void>& rLink); + +private: + std::unique_ptr<weld::Label> m_xFT_Geometry; + std::unique_ptr<weld::TreeView> m_xLB_Geometry; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/servicenames.hxx b/chart2/source/inc/servicenames.hxx new file mode 100644 index 0000000000..0f5cbe2b40 --- /dev/null +++ b/chart2/source/inc/servicenames.hxx @@ -0,0 +1,53 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <rtl/ustring.hxx> + +inline constexpr OUString CHART_MODEL_SERVICE_IMPLEMENTATION_NAME + = u"com.sun.star.comp.chart2.ChartModel"_ustr; +inline constexpr OUString CHART_MODEL_SERVICE_NAME = u"com.sun.star.chart2.ChartDocument"_ustr; +//@todo create your own service containing the service com.sun.star.document.OfficeDocument + +inline constexpr OUString CHART_VIEW_SERVICE_IMPLEMENTATION_NAME + = u"com.sun.star.comp.chart2.ChartView"_ustr; +inline constexpr OUString CHART_VIEW_SERVICE_NAME = u"com.sun.star.chart2.ChartView"_ustr; + +inline constexpr OUString CHART_FRAMELOADER_SERVICE_IMPLEMENTATION_NAME + = u"com.sun.star.comp.chart2.ChartFrameLoader"_ustr; +inline constexpr OUString CHART_FRAMELOADER_SERVICE_NAME + = u"com.sun.star.frame.SynchronousFrameLoader"_ustr; + +inline constexpr OUString CHART_WIZARD_DIALOG_SERVICE_IMPLEMENTATION_NAME + = u"com.sun.star.comp.chart2.WizardDialog"_ustr; +inline constexpr OUString CHART_WIZARD_DIALOG_SERVICE_NAME + = u"com.sun.star.chart2.WizardDialog"_ustr; + +inline constexpr OUString CHART_TYPE_DIALOG_SERVICE_IMPLEMENTATION_NAME + = u"com.sun.star.comp.chart2.ChartTypeDialog"_ustr; +inline constexpr OUString CHART_TYPE_DIALOG_SERVICE_NAME + = u"com.sun.star.chart2.ChartTypeDialog"_ustr; + +// wrapper for old UNO API (com.sun.star.chart) +inline constexpr OUString CHART_CHARTAPIWRAPPER_IMPLEMENTATION_NAME + = u"com.sun.star.comp.chart2.ChartDocumentWrapper"_ustr; +inline constexpr OUString CHART_CHARTAPIWRAPPER_SERVICE_NAME + = u"com.sun.star.chart2.ChartDocumentWrapper"_ustr; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/servicenames_charttypes.hxx b/chart2/source/inc/servicenames_charttypes.hxx new file mode 100644 index 0000000000..5ab2dcbf49 --- /dev/null +++ b/chart2/source/inc/servicenames_charttypes.hxx @@ -0,0 +1,44 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <rtl/ustring.hxx> + +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_AREA + = u"com.sun.star.chart2.AreaChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_BAR + = u"com.sun.star.chart2.BarChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_COLUMN + = u"com.sun.star.chart2.ColumnChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_LINE + = u"com.sun.star.chart2.LineChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_SCATTER + = u"com.sun.star.chart2.ScatterChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_PIE + = u"com.sun.star.chart2.PieChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_NET + = u"com.sun.star.chart2.NetChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET + = u"com.sun.star.chart2.FilledNetChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK + = u"com.sun.star.chart2.CandleStickChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE + = u"com.sun.star.chart2.BubbleChartType"_ustr; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/servicenames_coosystems.hxx b/chart2/source/inc/servicenames_coosystems.hxx new file mode 100644 index 0000000000..065155a8bb --- /dev/null +++ b/chart2/source/inc/servicenames_coosystems.hxx @@ -0,0 +1,26 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <rtl/ustring.hxx> + +inline constexpr OUString CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME = u"com.sun.star.chart2.CoordinateSystems.CartesianView"_ustr; +inline constexpr OUString CHART2_COOSYSTEM_POLAR_VIEW_SERVICE_NAME = u"com.sun.star.chart2.CoordinateSystems.PolarView"_ustr; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |