diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /chart2/source/view/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'chart2/source/view/inc')
23 files changed, 2934 insertions, 0 deletions
diff --git a/chart2/source/view/inc/Clipping.hxx b/chart2/source/view/inc/Clipping.hxx new file mode 100644 index 000000000..e816e7aa7 --- /dev/null +++ b/chart2/source/view/inc/Clipping.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 <basegfx/range/b2drectangle.hxx> + +namespace com::sun::star::drawing { struct PolyPolygonShape3D; } +namespace com::sun::star::drawing { struct Position3D; } + +namespace chart +{ + +class Clipping +{ + /** This class uses the Liang-Biarsky parametric line-clipping algorithm as described in: + Computer Graphics: principles and practice, 2nd ed., + James D. Foley et al., + Section 3.12.4 on page 117. + */ + +public: + /** @descr The intersection between an open polygon and a rectangle is + calculated and the resulting lines are placed into the poly-polygon aResult. + @param rPolygon The polygon is required to be open, ie. its start and end point + have different coordinates and that it is continuous, ie. has no holes. + @param rRectangle The clipping area. + @param aResult The resulting lines that are the parts of the given polygon lying inside + the clipping area are stored into aResult whose prior content is deleted first. + */ + static void clipPolygonAtRectangle( + const css::drawing::PolyPolygonShape3D& rPolygon + , const ::basegfx::B2DRectangle& rRectangle + , css::drawing::PolyPolygonShape3D& aResult + , bool bSplitPiecesToDifferentPolygons = true ); + static void clipPolygonAtRectangle( + const std::vector<std::vector<css::drawing::Position3D>>& rPolygon + , const ::basegfx::B2DRectangle& rRectangle + , std::vector<std::vector<css::drawing::Position3D>>& aResult + , bool bSplitPiecesToDifferentPolygons = true ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/ConfigAccess.hxx b/chart2/source/view/inc/ConfigAccess.hxx new file mode 100644 index 000000000..df59b16a3 --- /dev/null +++ b/chart2/source/view/inc/ConfigAccess.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::ConfigAccess +{ +/** @descr Retrieve the setting for showing errors in charts from the registry + settings of the Calc application. + + If this setting is not found, it is set to false (the default setting). + + @return boolean UseErrorRectangle. + */ +bool getUseErrorRectangle(); + +} //namespace chart::ConfigAccess + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/DateHelper.hxx b/chart2/source/view/inc/DateHelper.hxx new file mode 100644 index 000000000..8c37851b7 --- /dev/null +++ b/chart2/source/view/inc/DateHelper.hxx @@ -0,0 +1,43 @@ +/* -*- 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/date.hxx> +#include <tools/long.hxx> + +namespace chart +{ + +class DateHelper +{ +public: + static bool IsInSameYear( const Date& rD1, const Date& rD2 ); + static bool IsInSameMonth( const Date& rD1, const Date& rD2 ); + + static Date GetDateSomeMonthsAway( const Date& rD, sal_Int32 nMonthDistance ); + static Date GetDateSomeYearsAway( const Date& rD, sal_Int32 nYearDistance ); + static bool IsLessThanOneMonthAway( const Date& rD1, const Date& rD2 ); + static bool IsLessThanOneYearAway( const Date& rD1, const Date& rD2 ); + + static double RasterizeDateValue( double fValue, const Date& rNullDate, tools::Long TimeResolution ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/LabelAlignment.hxx b/chart2/source/view/inc/LabelAlignment.hxx new file mode 100644 index 000000000..425f5c6c3 --- /dev/null +++ b/chart2/source/view/inc/LabelAlignment.hxx @@ -0,0 +1,38 @@ +/* -*- 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 LabelAlignment +{ + LABEL_ALIGN_CENTER, + LABEL_ALIGN_LEFT, + LABEL_ALIGN_TOP, + LABEL_ALIGN_RIGHT, + LABEL_ALIGN_BOTTOM, + LABEL_ALIGN_LEFT_TOP, + LABEL_ALIGN_LEFT_BOTTOM, + LABEL_ALIGN_RIGHT_TOP, + LABEL_ALIGN_RIGHT_BOTTOM +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/LabelPositionHelper.hxx b/chart2/source/view/inc/LabelPositionHelper.hxx new file mode 100644 index 000000000..63125d621 --- /dev/null +++ b/chart2/source/view/inc/LabelPositionHelper.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 "LabelAlignment.hxx" +#include "PropertyMapper.hxx" +#include <com/sun/star/awt/Point.hpp> +#include <rtl/ref.hxx> +#include <svx/unoshape.hxx> + +namespace com::sun::star::drawing { struct Position3D; } +namespace com::sun::star::drawing { class XShapes; } +namespace com::sun::star::awt { struct Size; } +namespace com::sun::star::drawing { class XShape; } + +namespace chart +{ + +class LabelPositionHelper +{ +public: + LabelPositionHelper() = delete; + LabelPositionHelper( + sal_Int32 nDimensionCount + , const rtl::Reference<SvxShapeGroupAnyD>& xLogicTarget ); + virtual ~LabelPositionHelper(); + + css::awt::Point transformSceneToScreenPosition( + const css::drawing::Position3D& rScenePosition3D ) const; + + static void changeTextAdjustment( tAnySequence& rPropValues, const tNameSequence& rPropNames, LabelAlignment eAlignment); + static void doDynamicFontResize( tAnySequence& rPropValues, const tNameSequence& rPropNames + , const css::uno::Reference< css::beans::XPropertySet >& xAxisModelProps + , const css::awt::Size& rNewReferenceSize ); + + static void correctPositionForRotation( const rtl::Reference<SvxShapeText>& xShape2DText + , LabelAlignment eLabelAlignment, const double fRotationAngle, bool bRotateAroundCenter ); + +protected: + sal_Int32 m_nDimensionCount; + +private: + //these members are only necessary for transformation from 3D to 2D + rtl::Reference<SvxShapeGroupAnyD> m_xLogicTarget; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/LegendEntryProvider.hxx b/chart2/source/view/inc/LegendEntryProvider.hxx new file mode 100644 index 000000000..e0133771c --- /dev/null +++ b/chart2/source/view/inc/LegendEntryProvider.hxx @@ -0,0 +1,89 @@ +/* -*- 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/LegendPosition.hpp> +#include <com/sun/star/chart2/XFormattedString2.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.h> +#include <rtl/ref.hxx> +#include <svx/unoshape.hxx> +#include <vector> + +namespace chart { class ChartModel; } +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::drawing { class XShape; } +namespace com::sun::star::drawing { class XShapes; } +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::uno { class XComponentContext; } + +namespace chart +{ + +enum class LegendSymbolStyle +{ + /** A square box with border. + */ + Box, + + /** A line like with a symbol. + */ + Line, + + /** A bordered circle which has the same bounding-box as the + <member>BOX</member>. + */ + Circle +}; + +struct ViewLegendEntry +{ + /** The legend symbol that represents a data series or other + information contained in the legend + */ + rtl::Reference< SvxShapeGroup > xSymbol; + + /** The descriptive text for a legend entry. + */ + css::uno::Sequence< + css::uno::Reference< css::chart2::XFormattedString2 > > aLabel; +}; + +class LegendEntryProvider +{ +public: + virtual css::awt::Size getPreferredLegendKeyAspectRatio()=0; + + virtual std::vector< ViewLegendEntry > createLegendEntries( + const css::awt::Size& rEntryKeyAspectRatio, + css::chart2::LegendPosition eLegendPosition, + const css::uno::Reference< css::beans::XPropertySet >& xTextProperties, + const rtl::Reference<SvxShapeGroupAnyD>& xTarget, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + ChartModel& rModel + ) = 0; + +protected: + ~LegendEntryProvider() {} +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/Linear3DTransformation.hxx b/chart2/source/view/inc/Linear3DTransformation.hxx new file mode 100644 index 000000000..456f6e4c4 --- /dev/null +++ b/chart2/source/view/inc/Linear3DTransformation.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 + +#include "PlottingPositionHelper.hxx" +#include <com/sun/star/drawing/HomogenMatrix.hpp> + +namespace chart +{ + +class Linear3DTransformation final : public XTransformation2 +{ +public: + Linear3DTransformation( const css::drawing::HomogenMatrix& rHomMatrix, bool bSwapXAndY ); + virtual ~Linear3DTransformation() override; + + // ____ XTransformation2 ____ + virtual css::drawing::Position3D transform( + const css::drawing::Position3D& rSourceValues ) const override; + virtual css::drawing::Position3D transform( + const css::uno::Sequence< double >& rSourceValues ) const override; + +private: + css::drawing::HomogenMatrix m_Matrix; + bool m_bSwapXAndY; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx b/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx new file mode 100644 index 000000000..cbb5e55ba --- /dev/null +++ b/chart2/source/view/inc/MinimumAndMaximumSupplier.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 <sal/types.h> +#include <tools/date.hxx> +#include <tools/long.hxx> +#include <set> + +namespace chart +{ + +class MinimumAndMaximumSupplier +{ +public: + virtual double getMinimumX() = 0; + virtual double getMaximumX() = 0; + + //problem y maybe not is always the second border to ask for + virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) = 0; + virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) = 0; + + //problem: z maybe not independent in future + virtual double getMinimumZ() = 0; + virtual double getMaximumZ() = 0; + + virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex ) = 0; + virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) = 0; + virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex ) = 0; + virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ) = 0; + virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) = 0; + + //return a constant out of css::chart::TimeUnit that allows to display the smallest distance between occurring dates + virtual tools::Long calculateTimeResolutionOnXAxis() = 0; + virtual void setTimeResolutionOnXAxis( tools::Long nTimeResolution, const Date& rNullDate ) = 0; + +protected: + ~MinimumAndMaximumSupplier() {} +}; + +class MergedMinimumAndMaximumSupplier final : public MinimumAndMaximumSupplier +{ +public: + MergedMinimumAndMaximumSupplier(); + virtual ~MergedMinimumAndMaximumSupplier(); + + void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); + bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); + void clearMinimumAndMaximumSupplierList(); + + //--MinimumAndMaximumSupplier + virtual double getMinimumX() override; + virtual double getMaximumX() override; + virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override; + virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override; + virtual double getMinimumZ() override; + virtual double getMaximumZ() override; + + virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex ) override; + virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) override; + virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex ) override; + virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ) override; + virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) override; + + virtual tools::Long calculateTimeResolutionOnXAxis() override; + virtual void setTimeResolutionOnXAxis( tools::Long nTimeResolution, const Date& rNullDate ) override; + +private: + typedef std::set< MinimumAndMaximumSupplier* > MinimumAndMaximumSupplierSet; + MinimumAndMaximumSupplierSet m_aMinimumAndMaximumSupplierList; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/PlotterBase.hxx b/chart2/source/view/inc/PlotterBase.hxx new file mode 100644 index 000000000..73695507f --- /dev/null +++ b/chart2/source/view/inc/PlotterBase.hxx @@ -0,0 +1,79 @@ +/* -*- 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 <svx/unoshape.hxx> +#include <vector> + +namespace com::sun::star::drawing { struct HomogenMatrix; } +namespace com::sun::star::drawing { struct Position3D; } +namespace com::sun::star::drawing { class XShapes; } +namespace com::sun::star::lang { class XMultiServiceFactory; } + +namespace chart { struct ExplicitScaleData; } + +namespace chart +{ + +class PlottingPositionHelper; +class ShapeFactory; + +/** This class provides methods for setting axis scales and for performing + * scene to screen transformations. It is used as the base class for all + * plotter classes. + */ +class PlotterBase +{ +public: + PlotterBase( sal_Int32 nDimension ); + virtual ~PlotterBase(); + + /// @throws css::uno::RuntimeException + virtual void initPlotter( + const rtl::Reference<SvxShapeGroupAnyD>& xLogicTarget + , const rtl::Reference<SvxShapeGroupAnyD>& xFinalTarget + , const OUString& rCID + ); + + virtual void setScales( std::vector< ExplicitScaleData >&& rScales, bool bSwapXAndYAxis ); + + virtual void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix ); + + virtual void createShapes() = 0; + + static bool isValidPosition( const css::drawing::Position3D& rPos ); + +protected: //methods + rtl::Reference< SvxShapeGroupAnyD > + createGroupShape( const rtl::Reference< SvxShapeGroupAnyD >& xTarget + , const OUString& rName=OUString() ); + +protected: //member + rtl::Reference< SvxShapeGroupAnyD > m_xLogicTarget; + rtl::Reference< SvxShapeGroupAnyD > m_xFinalTarget; + OUString m_aCID; + + const sal_Int32 m_nDimension; + // needs to be created and deleted by the derived class + PlottingPositionHelper* m_pPosHelper; +}; +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx new file mode 100644 index 000000000..c0480a4e3 --- /dev/null +++ b/chart2/source/view/inc/PlottingPositionHelper.hxx @@ -0,0 +1,467 @@ +/* -*- 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 <memory> + +#include <chartview/ExplicitScaleValues.hxx> + +#include <basegfx/range/b2drectangle.hxx> +#include <tools/long.hxx> +#include <com/sun/star/drawing/Direction3D.hpp> +#include <com/sun/star/drawing/Position3D.hpp> +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <rtl/ref.hxx> +#include <svx/unoshape.hxx> + +namespace com::sun::star::drawing { class XShapes; } +namespace com::sun::star::drawing { struct HomogenMatrix; } +namespace com::sun::star::drawing { struct PolyPolygonShape3D; } + +namespace chart +{ + +class ShapeFactory; + +/** allows the transformation of numeric values from one + coordinate-system into another. Values may be transformed using + any mapping. + This is a non-UNO variant of the css::chart2::XTransformation interface, + but using more efficient calling and returning types. + */ +class XTransformation2 +{ +public: + virtual ~XTransformation2(); + /** transforms the given input data tuple, given in the source + coordinate system, according to the internal transformation + rules, into a tuple of transformed coordinates in the + destination coordinate system. + + <p>Note that both coordinate systems may have different + dimensions, e.g., if a transformation does simply a projection + into a lower-dimensional space.</p> + + @param aValues a source tuple of data that is to be + transformed. The length of this sequence must be + equivalent to the dimension of the source coordinate + system. + + @return the transformed data tuple. The length of this + sequence is equal to the dimension of the output + coordinate system. + + @throws ::com::sun::star::lang::IllegalArgumentException + if the dimension of the input vector is not equal to the + dimension given in getSourceDimension(). + */ + virtual css::drawing::Position3D transform( + const css::drawing::Position3D& rSourceValues ) const = 0; + virtual css::drawing::Position3D transform( + const css::uno::Sequence< double >& rSourceValues ) const = 0; +}; + + +class PlottingPositionHelper +{ +public: + PlottingPositionHelper(); + PlottingPositionHelper( const PlottingPositionHelper& rSource ); + virtual ~PlottingPositionHelper(); + + virtual std::unique_ptr<PlottingPositionHelper> clone() const; + std::unique_ptr<PlottingPositionHelper> createSecondaryPosHelper( const ExplicitScaleData& rSecondaryScale ); + + virtual void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix); + + virtual void setScales( std::vector< ExplicitScaleData >&& rScales, bool bSwapXAndYAxis ); + const std::vector< ExplicitScaleData >& getScales() const { return m_aScales;} + + //better performance for big data + inline void setCoordinateSystemResolution( const css::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution ); + inline bool isSameForGivenResolution( double fX, double fY, double fZ + , double fX2, double fY2, double fZ2 ); + + inline bool isStrongLowerRequested( sal_Int32 nDimensionIndex ) const; + inline bool isLogicVisible( double fX, double fY, double fZ ) const; + inline void doLogicScaling( double* pX, double* pY, double* pZ ) const; + inline void doUnshiftedLogicScaling( double* pX, double* pY, double* pZ ) const; + inline void clipLogicValues( double* pX, double* pY, double* pZ ) const; + void clipScaledLogicValues( double* pX, double* pY, double* pZ ) const; + inline bool clipYRange( double& rMin, double& rMax ) const; + + inline void doLogicScaling( css::drawing::Position3D& rPos ) const; + + virtual ::chart::XTransformation2* + getTransformationScaledLogicToScene() const; + + virtual css::drawing::Position3D + transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const; + + virtual css::drawing::Position3D + transformScaledLogicToScene( double fX, double fY, double fZ, bool bClip ) const; + + void transformScaledLogicToScene( css::drawing::PolyPolygonShape3D& rPoly ) const; + void transformScaledLogicToScene( std::vector<std::vector<css::drawing::Position3D>>& rPoly ) const; + + static css::awt::Point transformSceneToScreenPosition( + const css::drawing::Position3D& rScenePosition3D + , const rtl::Reference<SvxShapeGroupAnyD>& xSceneTarget + , sal_Int32 nDimensionCount ); + + inline double getLogicMinX() const; + inline double getLogicMinY() const; + inline double getLogicMinZ() const; + inline double getLogicMaxX() const; + inline double getLogicMaxY() const; + inline double getLogicMaxZ() const; + + inline bool isMathematicalOrientationX() const; + inline bool isMathematicalOrientationY() const; + inline bool isMathematicalOrientationZ() const; + + ::basegfx::B2DRectangle getScaledLogicClipDoubleRect() const; + css::drawing::Direction3D getScaledLogicWidth() const; + + inline bool isSwapXAndY() const; + + bool isPercentY() const; + + double getBaseValueY() const; + + inline bool maySkipPointsInRegressionCalculation() const; + + void setTimeResolution( tools::Long nTimeResolution, const Date& rNullDate ); + virtual void setScaledCategoryWidth( double fScaledCategoryWidth ); + void AllowShiftXAxisPos( bool bAllowShift ); + void AllowShiftZAxisPos( bool bAllowShift ); + +protected: //member + std::vector< ExplicitScaleData > m_aScales; + ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; + + //this is calculated based on m_aScales and m_aMatrixScreenToScene + mutable std::unique_ptr< ::chart::XTransformation2 > m_xTransformationLogicToScene; + + bool m_bSwapXAndY;//e.g. true for bar chart and false for column chart + + sal_Int32 m_nXResolution; + sal_Int32 m_nYResolution; + sal_Int32 m_nZResolution; + + bool m_bMaySkipPointsInRegressionCalculation; + + bool m_bDateAxis; + tools::Long m_nTimeResolution; + Date m_aNullDate; + + double m_fScaledCategoryWidth; + bool m_bAllowShiftXAxisPos; + bool m_bAllowShiftZAxisPos; +}; + +class PolarPlottingPositionHelper : public PlottingPositionHelper +{ +public: + PolarPlottingPositionHelper(); + PolarPlottingPositionHelper( const PolarPlottingPositionHelper& rSource ); + virtual ~PolarPlottingPositionHelper() override; + + virtual std::unique_ptr<PlottingPositionHelper> clone() const override; + + virtual void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix) override; + virtual void setScales( std::vector< ExplicitScaleData >&& rScales, bool bSwapXAndYAxis ) override; + + const ::basegfx::B3DHomMatrix& getUnitCartesianToScene() const { return m_aUnitCartesianToScene;} + + virtual ::chart::XTransformation2* + getTransformationScaledLogicToScene() const override; + + //the resulting values provided by the following 3 methods should be used + //for input to the transformation received with + //'getTransformationScaledLogicToScene' + + /** Given a value in the radius axis scale range, it returns the normalized + * value. + */ + double transformToRadius( double fLogicValueOnRadiusAxis, bool bDoScaling=true ) const; + + /** Given a value in the angle axis scale range (e.g. [0,1] for pie charts) + * this method returns the related angle in degree. + */ + double transformToAngleDegree( double fLogicValueOnAngleAxis, bool bDoScaling=true ) const; + + /** Given 2 values in the angle axis scale range (e.g. [0,1] for pie charts) + * this method returns the angle between the 2 values keeping into account + * the correct axis orientation; (for instance, this method is used for + * computing the angle width of a pie slice). + */ + double getWidthAngleDegree( double& fStartLogicValueOnAngleAxis, double& fEndLogicValueOnAngleAxis ) const; + + virtual css::drawing::Position3D + transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const override; + virtual css::drawing::Position3D + transformScaledLogicToScene( double fX, double fY, double fZ, bool bClip ) const override; + css::drawing::Position3D + transformAngleRadiusToScene( double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ, bool bDoScaling=true ) const; + + /** It returns the scene coordinates of the passed point: this point is + * described through a normalized cylindrical coordinate system. + * (For a pie chart the origin of the coordinate system is the pie center). + */ + css::drawing::Position3D + transformUnitCircleToScene( double fUnitAngleDegree, double fUnitRadius, double fLogicZ ) const; + + using PlottingPositionHelper::transformScaledLogicToScene; + + double getOuterLogicRadius() const; + + inline bool isMathematicalOrientationAngle() const; + inline bool isMathematicalOrientationRadius() const; +public: + ///m_bSwapXAndY (inherited): by default the X axis (scale[0]) represents + ///the angle axis and the Y axis (scale[1]) represents the radius axis; + ///when this parameter is true, the opposite happens (this is the case for + ///pie charts). + + ///Offset for radius axis in absolute logic scaled values (1.0 == 1 category) + ///For a donut, it represents the non-normalized inner radius (see notes for + ///transformToRadius) + double m_fRadiusOffset; + ///Offset for angle axis in real degree. + ///For a pie it represents the angle offset at which the first slice have to + ///start; + double m_fAngleDegreeOffset; + +private: + ::basegfx::B3DHomMatrix m_aUnitCartesianToScene; + + ::basegfx::B3DHomMatrix impl_calculateMatrixUnitCartesianToScene( const ::basegfx::B3DHomMatrix& rMatrixScreenToScene ) const; +}; + +bool PolarPlottingPositionHelper::isMathematicalOrientationAngle() const +{ + const ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[2]; + if( css::chart2::AxisOrientation_MATHEMATICAL==rScale.Orientation ) + return true; + return false; +} +bool PolarPlottingPositionHelper::isMathematicalOrientationRadius() const +{ + const ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[0] : m_aScales[1]; + if( css::chart2::AxisOrientation_MATHEMATICAL==rScale.Orientation ) + return true; + return false; +} + +//better performance for big data +void PlottingPositionHelper::setCoordinateSystemResolution( const css::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution ) +{ + m_nXResolution = 1000; + m_nYResolution = 1000; + m_nZResolution = 1000; + if( rCoordinateSystemResolution.getLength() > 0 ) + m_nXResolution = rCoordinateSystemResolution[0]; + if( rCoordinateSystemResolution.getLength() > 1 ) + m_nYResolution = rCoordinateSystemResolution[1]; + if( rCoordinateSystemResolution.getLength() > 2 ) + m_nZResolution = rCoordinateSystemResolution[2]; +} + +bool PlottingPositionHelper::isSameForGivenResolution( double fX, double fY, double fZ + , double fX2, double fY2, double fZ2 /*these values are all expected tp be scaled already*/ ) +{ + if( !std::isfinite(fX) || !std::isfinite(fY) || !std::isfinite(fZ) + || !std::isfinite(fX2) || !std::isfinite(fY2) || !std::isfinite(fZ2) ) + return false; + + double fScaledMinX = getLogicMinX(); + double fScaledMinY = getLogicMinY(); + double fScaledMinZ = getLogicMinZ(); + double fScaledMaxX = getLogicMaxX(); + double fScaledMaxY = getLogicMaxY(); + double fScaledMaxZ = getLogicMaxZ(); + + doLogicScaling( &fScaledMinX, &fScaledMinY, &fScaledMinZ ); + doLogicScaling( &fScaledMaxX, &fScaledMaxY, &fScaledMaxZ); + + bool bSameX = ( static_cast<sal_Int32>(m_nXResolution*(fX - fScaledMinX)/(fScaledMaxX-fScaledMinX)) + == static_cast<sal_Int32>(m_nXResolution*(fX2 - fScaledMinX)/(fScaledMaxX-fScaledMinX)) ); + + bool bSameY = ( static_cast<sal_Int32>(m_nYResolution*(fY - fScaledMinY)/(fScaledMaxY-fScaledMinY)) + == static_cast<sal_Int32>(m_nYResolution*(fY2 - fScaledMinY)/(fScaledMaxY-fScaledMinY)) ); + + bool bSameZ = ( static_cast<sal_Int32>(m_nZResolution*(fZ - fScaledMinZ)/(fScaledMaxZ-fScaledMinZ)) + == static_cast<sal_Int32>(m_nZResolution*(fZ2 - fScaledMinZ)/(fScaledMaxZ-fScaledMinZ)) ); + + return (bSameX && bSameY && bSameZ); +} + +bool PlottingPositionHelper::isStrongLowerRequested( sal_Int32 nDimensionIndex ) const +{ + if( m_aScales.empty() ) + return false; + if( 0==nDimensionIndex ) + return m_bAllowShiftXAxisPos && m_aScales[nDimensionIndex].m_bShiftedCategoryPosition; + else if( 2==nDimensionIndex ) + return m_bAllowShiftZAxisPos && m_aScales[nDimensionIndex].m_bShiftedCategoryPosition; + return false; +} + +bool PlottingPositionHelper::isLogicVisible( + double fX, double fY, double fZ ) const +{ + return fX >= m_aScales[0].Minimum && ( isStrongLowerRequested(0) ? fX < m_aScales[0].Maximum : fX <= m_aScales[0].Maximum ) + && fY >= m_aScales[1].Minimum && fY <= m_aScales[1].Maximum + && fZ >= m_aScales[2].Minimum && ( isStrongLowerRequested(2) ? fZ < m_aScales[2].Maximum : fZ <= m_aScales[2].Maximum ); +} + +void PlottingPositionHelper::doLogicScaling( double* pX, double* pY, double* pZ ) const +{ + if(pX) + { + if( m_aScales[0].Scaling.is()) + *pX = m_aScales[0].Scaling->doScaling(*pX); + if( m_bAllowShiftXAxisPos && m_aScales[0].m_bShiftedCategoryPosition ) + (*pX) += m_fScaledCategoryWidth/2.0; + } + if(pY && m_aScales[1].Scaling.is()) + *pY = m_aScales[1].Scaling->doScaling(*pY); + if(pZ) + { + if( m_aScales[2].Scaling.is()) + *pZ = m_aScales[2].Scaling->doScaling(*pZ); + if( m_bAllowShiftZAxisPos && m_aScales[2].m_bShiftedCategoryPosition) + (*pZ) += 0.5; + } +} + +void PlottingPositionHelper::doUnshiftedLogicScaling( double* pX, double* pY, double* pZ ) const +{ + if(pX && m_aScales[0].Scaling.is()) + *pX = m_aScales[0].Scaling->doScaling(*pX); + if(pY && m_aScales[1].Scaling.is()) + *pY = m_aScales[1].Scaling->doScaling(*pY); + if(pZ && m_aScales[2].Scaling.is()) + *pZ = m_aScales[2].Scaling->doScaling(*pZ); +} + +void PlottingPositionHelper::doLogicScaling( css::drawing::Position3D& rPos ) const +{ + doLogicScaling( &rPos.PositionX, &rPos.PositionY, &rPos.PositionZ ); +} + +void PlottingPositionHelper::clipLogicValues( double* pX, double* pY, double* pZ ) const +{ + if(pX) + { + if( *pX < m_aScales[0].Minimum ) + *pX = m_aScales[0].Minimum; + else if( *pX > m_aScales[0].Maximum ) + *pX = m_aScales[0].Maximum; + } + if(pY) + { + if( *pY < m_aScales[1].Minimum ) + *pY = m_aScales[1].Minimum; + else if( *pY > m_aScales[1].Maximum ) + *pY = m_aScales[1].Maximum; + } + if(pZ) + { + if( *pZ < m_aScales[2].Minimum ) + *pZ = m_aScales[2].Minimum; + else if( *pZ > m_aScales[2].Maximum ) + *pZ = m_aScales[2].Maximum; + } +} + +inline bool PlottingPositionHelper::clipYRange( double& rMin, double& rMax ) const +{ + //returns true if something remains + if( rMin > rMax ) + { + double fHelp = rMin; + rMin = rMax; + rMax = fHelp; + } + if( rMin > getLogicMaxY() ) + return false; + if( rMax < getLogicMinY() ) + return false; + if( rMin < getLogicMinY() ) + rMin = getLogicMinY(); + if( rMax > getLogicMaxY() ) + rMax = getLogicMaxY(); + return true; +} + +inline double PlottingPositionHelper::getLogicMinX() const +{ + return m_aScales[0].Minimum; +} +inline double PlottingPositionHelper::getLogicMinY() const +{ + return m_aScales[1].Minimum; +} +inline double PlottingPositionHelper::getLogicMinZ() const +{ + return m_aScales[2].Minimum; +} + +inline double PlottingPositionHelper::getLogicMaxX() const +{ + return m_aScales[0].Maximum; +} +inline double PlottingPositionHelper::getLogicMaxY() const +{ + return m_aScales[1].Maximum; +} +inline double PlottingPositionHelper::getLogicMaxZ() const +{ + return m_aScales[2].Maximum; +} +inline bool PlottingPositionHelper::isMathematicalOrientationX() const +{ + return css::chart2::AxisOrientation_MATHEMATICAL == m_aScales[0].Orientation; +} +inline bool PlottingPositionHelper::isMathematicalOrientationY() const +{ + return css::chart2::AxisOrientation_MATHEMATICAL == m_aScales[1].Orientation; +} +inline bool PlottingPositionHelper::isMathematicalOrientationZ() const +{ + return css::chart2::AxisOrientation_MATHEMATICAL == m_aScales[2].Orientation; +} +inline bool PlottingPositionHelper::isSwapXAndY() const +{ + return m_bSwapXAndY; +} +inline bool PlottingPositionHelper::maySkipPointsInRegressionCalculation() const +{ + return m_bMaySkipPointsInRegressionCalculation; +} + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/PolarLabelPositionHelper.hxx b/chart2/source/view/inc/PolarLabelPositionHelper.hxx new file mode 100644 index 000000000..84f4ff1dc --- /dev/null +++ b/chart2/source/view/inc/PolarLabelPositionHelper.hxx @@ -0,0 +1,70 @@ +/* -*- 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 "LabelPositionHelper.hxx" +#include <com/sun/star/awt/Point.hpp> + +namespace chart +{ + +class PolarPlottingPositionHelper; + +class PolarLabelPositionHelper final : public LabelPositionHelper +{ +public: + PolarLabelPositionHelper( + PolarPlottingPositionHelper* pPosHelper + , sal_Int32 nDimensionCount + , const rtl::Reference<SvxShapeGroupAnyD>& xLogicTarget ); + virtual ~PolarLabelPositionHelper() override; + + css::awt::Point getLabelScreenPositionAndAlignmentForLogicValues( + LabelAlignment& rAlignment + , double fLogicValueOnAngleAxis + , double fLogicValueOnRadiusAxis + , double fLogicZ + , sal_Int32 nScreenValueOffsetInRadiusDirection ) const; + + /** Calculate the anchor point position for a text label. + * When the requested label placement is of `INSIDE` or `OUTSIDE` type the + * returned anchor point for the text label is the middle point of the + * outer arc for the given slice; when the requested label placement is of + * `CENTER` type the returned anchor point for the text label is the + * middle point of the line segment bisecting the slice. + * The text alignment is always centered when the requested label + * placement is of `CENTER` type else it is dependent on the value of the + * angle defined by the horizontal axis and the ray bisecting the slice. + * + */ + css::awt::Point getLabelScreenPositionAndAlignmentForUnitCircleValues( + LabelAlignment& rAlignment, sal_Int32 nLabelPlacement /*see css::chart::DataLabelPlacement*/ + , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree + , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius + , double fLogicZ + , sal_Int32 nScreenValueOffsetInRadiusDirection ) const; + +private: + PolarPlottingPositionHelper* m_pPosHelper; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/PropertyMapper.hxx b/chart2/source/view/inc/PropertyMapper.hxx new file mode 100644 index 000000000..c4d9a1fa2 --- /dev/null +++ b/chart2/source/view/inc/PropertyMapper.hxx @@ -0,0 +1,125 @@ +/* -*- 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 <unordered_map> + +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/Reference.h> + +namespace com::sun::star::beans { class XPropertySet; } +class SvxShape; + +namespace chart +{ + +typedef std::unordered_map<OUString, OUString> tPropertyNameMap; +typedef std::unordered_map<OUString, css::uno::Any> tPropertyNameValueMap; +typedef css::uno::Sequence< OUString > tNameSequence; +typedef css::uno::Sequence< css::uno::Any > tAnySequence; + +/** + * PropertyMapper provides easy mapping of the property names of various + * objects in the chart model, to the property names of the destination + * shape objects (those whose service names begin with + * com.sun.star.drawing.). + */ +class PropertyMapper +{ +public: + static void setMappedProperties( + const css::uno::Reference< css::beans::XPropertySet >& xTarget + , const css::uno::Reference< css::beans::XPropertySet >& xSource + , const tPropertyNameMap& rMap ); + + static void setMappedProperties( + SvxShape& xTarget + , const css::uno::Reference< css::beans::XPropertySet >& xSource + , const tPropertyNameMap& rMap ); + + /** + * Fetch property values from the source object and map it to the + * destination container. Only those properties that are explicitly set + * will be inserted into the destination container. + * + * @param rValueMap destination container + * @param rNameMap property name mapping rule + * @param xSourceProp source object from which the property values are + * pulled. + */ + static void getValueMap( + tPropertyNameValueMap& rValueMap + , const tPropertyNameMap& rNameMap + , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp + ); + + static void getMultiPropertyListsFromValueMap( + tNameSequence& rNames + , tAnySequence& rValues + , const tPropertyNameValueMap& rValueMap + ); + + static css::uno::Any* + getValuePointer( tAnySequence& rPropValues + , const tNameSequence& rPropNames + , std::u16string_view rPropName ); + + static css::uno::Any* + getValuePointerForLimitedSpace( tAnySequence& rPropValues + , const tNameSequence& rPropNames + , bool bLimitedHeight ); + + static void setMultiProperties( + const tNameSequence& rNames + , const tAnySequence& rValues + , SvxShape& xTarget ); + + static const tPropertyNameMap& getPropertyNameMapForCharacterProperties(); + static const tPropertyNameMap& getPropertyNameMapForParagraphProperties(); + static const tPropertyNameMap& getPropertyNameMapForFillProperties(); + static const tPropertyNameMap& getPropertyNameMapForLineProperties(); + static const tPropertyNameMap& getPropertyNameMapForFillAndLineProperties(); + static const tPropertyNameMap& getPropertyNameMapForTextShapeProperties(); + + static const tPropertyNameMap& getPropertyNameMapForFilledSeriesProperties(); + static const tPropertyNameMap& getPropertyNameMapForLineSeriesProperties(); + static const tPropertyNameMap& getPropertyNameMapForTextLabelProperties(); + + static void getTextLabelMultiPropertyLists( + const css::uno::Reference< css::beans::XPropertySet >& xSourceProp + , tNameSequence& rPropNames, tAnySequence& rPropValues + , bool bName=true + , sal_Int32 nLimitedSpace=-1 + , bool bLimitedHeight=false + , bool bSupportsLabelBorder = true); + + /** adds line-, fill- and character properties and sets some suitable + defaults for auto-grow properties + */ + static void getPreparedTextShapePropertyLists( + const css::uno::Reference< css::beans::XPropertySet >& xSourceProp + , tNameSequence& rPropNames + , tAnySequence& rPropValues ); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/ScaleAutomatism.hxx b/chart2/source/view/inc/ScaleAutomatism.hxx new file mode 100644 index 000000000..1141c9e87 --- /dev/null +++ b/chart2/source/view/inc/ScaleAutomatism.hxx @@ -0,0 +1,144 @@ +/* -*- 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/ScaleData.hpp> + +#include <tools/date.hxx> + +namespace chart { struct ExplicitIncrementData; } +namespace chart { struct ExplicitScaleData; } + +namespace chart +{ + +/** This class implements the calculation of automatic axis limits. + * + * This class is used for calculating axis scales and increments in the form + * of instances of `ExplicitScaleData` and `ExplicitIncrementData` classes. + * When a `ScaleAutomatism` instance is created a `ScaleData` object is passed + * to the constructor. Objects of `ScaleData` type are initialized by + * the `createCoordinateSystem` method of some chart type (e.g. + * the `PieChartType` class) and belong to some `Axis` object, they can be + * accessed through the `XAxis` interface (`XAxis::getScaleData`). + */ +class ScaleAutomatism +{ +public: + explicit ScaleAutomatism( + const css::chart2::ScaleData& rSourceScale, const Date& rNullDate ); + + /** Expands own value range with the passed minimum and maximum. + * + * It allows to set up the `m_fValueMinimum` and the `m_fValueMaximum` + * parameters which are used by the `calculateExplicitScaleAndIncrement` + * method for initializing the `Minimum` and `Maximum` properties of the + * explicit scale when the same properties of the `ScaleData` object are + * undefined (that is empty `uno::Any` objects). + */ + void expandValueRange( double fMinimum, double fMaximum ); + void resetValueRange(); + + /** Sets additional auto scaling options. + @param bExpandBorderToIncrementRhythm If true, expands automatic + borders to the fixed or calculated increment rhythm. + @param bExpandIfValuesCloseToBorder If true, expands automatic borders + if values are too close (closer than 1/21 of visible area). + @param bExpandWideValuesToZero If true, expands automatic border to + zero, if source values are positive only or negative only, and if + the absolute values are wide spread (at least one value is less + than 5/6 of absolute maximum), or if all values are equal. + @param bExpandNarrowValuesTowardZero If true, expands automatic border + toward zero (50% of the visible range), if source values are + positive only or negative only, and if the absolute values are + close to the absolute maximum (no value is less than 5/6 of + absolute maximum). */ + void setAutoScalingOptions( + bool bExpandBorderToIncrementRhythm, + bool bExpandIfValuesCloseToBorder, + bool bExpandWideValuesToZero, + bool bExpandNarrowValuesTowardZero ); + + /** Sets the maximum allowed number of automatic main increments. + @descr The number of main increments may be limited e.g. by the length + of the axis and the font size of the axis caption text. */ + void setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMainIncrementCount ); + + /** Sets the time resolution to be used in case it is not set explicitly within the scale + */ + void setAutomaticTimeResolution( sal_Int32 nTimeResolution ); + + /** Fills the passed scale data and increment data according to the own settings. + * + * It performs the initialization of the passed explicit scale and + * explicit increment parameters, mainly the initialization is achieved by + * using the `ScaleData` object as data source. However other parameters + * which affect the behavior of this method can be set through + * the `setAutoScalingOptions` and the `expandValueRange` methods. + */ + void calculateExplicitScaleAndIncrement( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement ) const; + + const css::chart2::ScaleData& getScale() const { return m_aSourceScale;} + const Date& getNullDate() const { return m_aNullDate;} + +private: + /** Fills the passed scale data and increment data for category scaling. */ + void calculateExplicitIncrementAndScaleForCategory( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, + bool bAutoMinimum, bool bAutoMaximum ) const; + + /** Fills the passed scale data and increment data for logarithmic scaling. */ + void calculateExplicitIncrementAndScaleForLogarithmic( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, + bool bAutoMinimum, bool bAutoMaximum ) const; + + /** Fills the passed scale data and increment data for linear scaling. */ + void calculateExplicitIncrementAndScaleForLinear( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, + bool bAutoMinimum, bool bAutoMaximum ) const; + + /** Fills the passed scale data and increment data for date-time axis. */ + void calculateExplicitIncrementAndScaleForDateTimeAxis( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, + bool bAutoMinimum, bool bAutoMaximum ) const; + +private: + css::chart2::ScaleData m_aSourceScale; + + double m_fValueMinimum; /// Minimum of all source values. + double m_fValueMaximum; /// Maximum of all source values. + sal_Int32 m_nMaximumAutoMainIncrementCount; /// Maximum number of automatic main increments. + bool m_bExpandBorderToIncrementRhythm; /// true = Expand to main increments. + bool m_bExpandIfValuesCloseToBorder; /// true = Expand if values are too close to the borders. + bool m_bExpandWideValuesToZero; /// true = Expand wide spread values to zero. + bool m_bExpandNarrowValuesTowardZero; /// true = Expand narrow range toward zero (add half of range). + sal_Int32 m_nTimeResolution;// a constant out of css::chart::TimeUnit + + Date m_aNullDate; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx new file mode 100644 index 000000000..d6c05af04 --- /dev/null +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -0,0 +1,301 @@ +/* -*- 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 "PropertyMapper.hxx" +#include <basegfx/range/b2irectangle.hxx> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> + +#include <rtl/ref.hxx> +#include <rtl/ustring.hxx> +#include <svx/unoshape.hxx> +#include <svx/unodraw/SvxTableShape.hxx> +#include <svx/unopage.hxx> + +namespace chart { struct VLineProperties; } +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XFormattedString; } +namespace com::sun::star::drawing { class XShape; } +namespace com::sun::star::drawing { class XShapes; } +namespace com::sun::star::drawing { struct HomogenMatrix; } +namespace com::sun::star::drawing { struct PolyPolygonShape3D; } +namespace com::sun::star::drawing { struct Position3D; } +namespace com::sun::star::graphic { class XGraphic; } +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::drawing { struct Direction3D; } + +namespace chart +{ +class Stripe; + +// Be careful here not to clash with the SYMBOL_FOO #defines in +// <vcl/vclenum.hxx> +enum SymbolEnum { Symbol_Square=0 + , Symbol_Diamond + , Symbol_DownArrow + , Symbol_UpArrow + , Symbol_RightArrow + , Symbol_LeftArrow + , Symbol_Bowtie + , Symbol_Sandglass + , Symbol_Circle + , Symbol_Star + , Symbol_X + , Symbol_Plus + , Symbol_Asterisk + , Symbol_HorizontalBar + , Symbol_VerticalBar + , Symbol_COUNT +}; + + +class ShapeFactory +{ +public: + enum class StackPosition { Top, Bottom }; + + ShapeFactory() = delete; + + static rtl::Reference< SvxShapeGroup > + createGroup2D( + const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const OUString& aName = OUString() ); + + static rtl::Reference< SvxShapeGroup > + createGroup2D( + const rtl::Reference<SvxDrawPage>& xTarget + , const OUString& aName = OUString() ); + + static rtl::Reference<Svx3DSceneObject> + createGroup3D( + const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const OUString& aName = OUString() ); + + static rtl::Reference<Svx3DExtrudeObject> + createCube( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPosition + , const css::drawing::Direction3D& rSize + , sal_Int32 nRotateZAngleHundredthDegree + , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp + , const tPropertyNameMap& rPropertyNameMap + , bool bRounded = false); + + static rtl::Reference<Svx3DLatheObject> + createCylinder( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPosition + , const css::drawing::Direction3D& rSize + , sal_Int32 nRotateZAngleHundredthDegree ); + + static rtl::Reference<Svx3DSceneObject> + createPyramid( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPosition + , const css::drawing::Direction3D& rSize + , double fTopHeight + , bool bRotateZ + , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp + , const tPropertyNameMap& rPropertyNameMap); + + static rtl::Reference<Svx3DLatheObject> + createCone( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPosition + , const css::drawing::Direction3D& rSize + , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree ); + + static rtl::Reference<SvxShapePolyPolygon> + createPieSegment2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree + , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius + , const css::drawing::Direction3D& rOffset + , const css::drawing::HomogenMatrix& rUnitCircleToScene ); + + static rtl::Reference<Svx3DExtrudeObject> + createPieSegment( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree + , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius + , const css::drawing::Direction3D& rOffset + , const css::drawing::HomogenMatrix& rUnitCircleToScene + , double fDepth ); + + static rtl::Reference<Svx3DPolygonObject> + createStripe( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const Stripe& rStripe + , const css::uno::Reference< css::beans::XPropertySet >& xSourceProp + , const tPropertyNameMap& rPropertyNameMap + , bool bDoubleSided + , short nRotatedTexture = 0 //0 to 7 are the different possibilities + , bool bFlatNormals=true ); + + static rtl::Reference<Svx3DExtrudeObject> + createArea3D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon + , double fDepth); + + static rtl::Reference<SvxShapePolyPolygon> + createArea2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon); + + static rtl::Reference<SvxShapePolyPolygon> + createSymbol2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPos + , const css::drawing::Direction3D& rSize + , sal_Int32 nStandardSymbol + , sal_Int32 nBorderColor + , sal_Int32 nFillColor ); + + static rtl::Reference<SvxGraphicObject> + createGraphic2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPos + , const css::drawing::Direction3D& rSize + , const css::uno::Reference< css::graphic::XGraphic >& xGraphic ); + + static rtl::Reference<SvxShapePolyPolygon> + createLine2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::PointSequenceSequence& rPoints + , const VLineProperties* pLineProperties = nullptr ); + static rtl::Reference<SvxShapePolyPolygon> + createLine2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const std::vector<std::vector<css::drawing::Position3D>>& rPoints + , const VLineProperties* pLineProperties = nullptr ); + + static rtl::Reference<SvxShapePolyPolygon> + createLine ( const rtl::Reference<SvxShapeGroupAnyD>& xTarget, + const css::awt::Size& rSize, const css::awt::Point& rPosition ); + + static rtl::Reference<Svx3DPolygonObject> + createLine3D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const std::vector<std::vector<css::drawing::Position3D>>& rPoints + , const VLineProperties& rLineProperties ); + + static rtl::Reference<SvxShapeCircle> + createCircle2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPos + , const css::drawing::Direction3D& rSize ); + + static rtl::Reference<SvxShapeCircle> + createCircle( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::awt::Size& rSize + , const css::awt::Point& rPosition ); + + static rtl::Reference<SvxShapeText> + createText( const rtl::Reference<SvxShapeGroupAnyD>& xTarget2D + , const OUString& rText + , const tNameSequence& rPropNames + , const tAnySequence& rPropValues + , const css::uno::Any& rATransformation + ); + + static rtl::Reference<SvxShapeText> + createText(const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString + , const tNameSequence& rPropNames + , const tAnySequence& rPropValues + , const css::uno::Any& rATransformation); + + static rtl::Reference<SvxShapeText> + createText( const rtl::Reference<SvxShapeGroupAnyD>& xTarget2D, + const css::awt::Size& rSize, + const css::awt::Point& rPosition, + css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedString, + const css::uno::Reference< css::beans::XPropertySet > & xTextProperties, + double nRotation, const OUString& aName, sal_Int32 nTextMaxWidth ); + + static rtl::Reference<SvxTableShape> createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget); + + static rtl::Reference<SvxShapeRect> + createInvisibleRectangle( + const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::awt::Size& rSize ); + + static rtl::Reference<SvxShapeRect> + createRectangle( + const rtl::Reference<SvxShapeGroupAnyD>& xTarget, + const css::awt::Size& rSize, + const css::awt::Point& rPosition, + const tNameSequence& rPropNames, + const tAnySequence& rPropValues, + StackPosition ePos = StackPosition::Top ); + + static rtl::Reference<SvxShapeRect> + createRectangle( + const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + + static rtl::Reference<SvxShapeGroupAnyD> + getOrCreateChartRootShape( const rtl::Reference<SvxDrawPage>& xPage ); + + static void setPageSize(const rtl::Reference<SvxShapeGroupAnyD>& xChartShapes, + const css::awt::Size& rSize); + + static rtl::Reference<SvxShapeGroupAnyD> + getChartRootShape( const rtl::Reference<SvxDrawPage>& xPage ); + + static void makeShapeInvisible( const rtl::Reference< SvxShape >& rShape ); + + static void setShapeName( const rtl::Reference< SvxShape >& xShape + , const OUString& rName ); + + static OUString getShapeName( const css::uno::Reference< css::drawing::XShape >& xShape ); + + static css::uno::Any makeTransformation( const css::awt::Point& rScreenPosition2D, double fRotationAnglePi=0.0 ); + + static OUString getStackedString( const OUString& rString, bool bStacked ); + + static bool hasPolygonAnyLines( const std::vector<std::vector<css::drawing::Position3D>>& rPoly ); + static bool isPolygonEmptyOrSinglePoint( const css::drawing::PolyPolygonShape3D& rPoly ); + static bool isPolygonEmptyOrSinglePoint( const std::vector<std::vector<css::drawing::Position3D>>& rPoly ); + static void closePolygon( css::drawing::PolyPolygonShape3D& rPoly ); + static void closePolygon( std::vector<std::vector<css::drawing::Position3D>>& rPoly ); + + static css::awt::Size calculateNewSizeRespectingAspectRatio( + const css::awt::Size& rTargetSize + , const css::awt::Size& rSourceSizeWithCorrectAspectRatio ); + + static css::awt::Point calculateTopLeftPositionToCenterObject( + const css::awt::Point& rTargetAreaPosition + , const css::awt::Size& rTargetAreaSize + , const css::awt::Size& rObjectSize ); + + static ::basegfx::B2IRectangle getRectangleOfShape( SvxShape& rShape ); + + static css::awt::Size getSizeAfterRotation( + SvxShape& rShape, double fRotationAngleDegree ); + + static void removeSubShapes( const rtl::Reference<SvxShapeGroupAnyD>& xShapes ); + + static sal_Int32 getSymbolCount() { return Symbol_COUNT; } + +private: + static rtl::Reference<Svx3DExtrudeObject> + impl_createCube( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPosition + , const css::drawing::Direction3D& rSize, sal_Int32 nRotateZAngleHundredthDegree + , bool bRounded ); + + static rtl::Reference<Svx3DLatheObject> + impl_createConeOrCylinder( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D& rPosition + , const css::drawing::Direction3D& rSize + , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree + , bool bCylinder); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/Stripe.hxx b/chart2/source/view/inc/Stripe.hxx new file mode 100644 index 000000000..0da5e0b5d --- /dev/null +++ b/chart2/source/view/inc/Stripe.hxx @@ -0,0 +1,71 @@ +/* -*- 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/Position3D.hpp> +#include <com/sun/star/drawing/Direction3D.hpp> +#include <com/sun/star/uno/Any.h> + +namespace chart +{ + +/** A Stripe represents a 2 dimensional foursquare plane in a 3 dimensional room. + +@todo could: it is not necessary to have 4 point members here; it would be sufficient to have one point and 2 directions +*/ + +class Stripe +{ +public: + Stripe( const css::drawing::Position3D& rPoint1 + , const css::drawing::Direction3D& rDirectionToPoint2 + , const css::drawing::Direction3D& rDirectionToPoint4 ); + + Stripe( const css::drawing::Position3D& rPoint1 + , const css::drawing::Position3D& rPoint2 + , double fDepth ); + + Stripe( const css::drawing::Position3D& rPoint1 + , const css::drawing::Position3D& rPoint2 + , const css::drawing::Position3D& rPoint3 + , const css::drawing::Position3D& rPoint4 ); + + void SetManualNormal( const css::drawing::Direction3D& rNormal ); + css::drawing::Direction3D getNormal() const; + + void InvertNormal( bool bInvertNormal ); + + css::uno::Any getPolyPolygonShape3D() const; + css::uno::Any getNormalsPolygon() const; + static css::uno::Any getTexturePolygon( short nRotatedTexture ); //0 to 7 are the different possibilities + +private: + css::drawing::Position3D m_aPoint1; + css::drawing::Position3D m_aPoint2; + css::drawing::Position3D m_aPoint3; + css::drawing::Position3D m_aPoint4; + + bool m_bInvertNormal; + bool m_bManualNormalSet; + css::drawing::Direction3D m_aManualNormal; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx new file mode 100644 index 000000000..0664a5462 --- /dev/null +++ b/chart2/source/view/inc/VCoordinateSystem.hxx @@ -0,0 +1,205 @@ +/* -*- 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 "MinimumAndMaximumSupplier.hxx" +#include <ThreeDHelper.hxx> +#include <chartview/ExplicitScaleValues.hxx> +#include <com/sun/star/drawing/HomogenMatrix.hpp> +#include <com/sun/star/uno/Sequence.h> +#include <rtl/ref.hxx> +#include <svx/unoshape.hxx> + +#include <map> +#include <memory> +#include <vector> + +namespace chart { class ExplicitCategoriesProvider; } +namespace chart { class ScaleAutomatism; } +namespace chart { class ChartModel; } +namespace com::sun::star::awt { struct Rectangle; } +namespace com::sun::star::awt { struct Size; } +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::drawing { class XShapes; } +namespace com::sun::star::lang { class XMultiServiceFactory; } + + +namespace chart +{ +class Axis; +class BaseCoordinateSystem; +class VAxisBase; + +class VCoordinateSystem +{ +public: + virtual ~VCoordinateSystem(); + + static std::unique_ptr<VCoordinateSystem> createCoordinateSystem( const rtl::Reference< + ::chart::BaseCoordinateSystem >& xCooSysModel ); + + /// @throws css::uno::RuntimeException + void initPlottingTargets( + const rtl::Reference< SvxShapeGroupAnyD >& xLogicTarget + , const rtl::Reference< SvxShapeGroupAnyD >& xFinalTarget + , rtl::Reference<SvxShapeGroupAnyD>& xLogicTargetForSeriesBehindAxis ); + + void setParticle( const OUString& rCooSysParticle ); + + void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix ); + const css::drawing::HomogenMatrix& getTransformationSceneToScreen() const { return m_aMatrixSceneToScreen;} + + //better performance for big data + virtual css::uno::Sequence< sal_Int32 > getCoordinateSystemResolution( const css::awt::Size& rPageSize + , const css::awt::Size& rPageResolution ); + + ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + + void setExplicitCategoriesProvider( ExplicitCategoriesProvider* /*takes ownership*/ ); + ExplicitCategoriesProvider* getExplicitCategoriesProvider(); + + // returns a complete scale set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis + std::vector< ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + // returns a complete increment set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis + std::vector< ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + + void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); + bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); + void clearMinimumAndMaximumSupplierList(); + + /** + * It sets the scaling parameters for the passed `ScaleAutomatism` object. + * Especially it sets the `m_fValueMinimum` and the `m_fValueMaximum` + * parameters (see `ScaleAutomatism::expandValueRange`). + * The value to be assigned to these two parameters is retrieved by + * invoking the `getMinimum` and `getMaximum` methods of the minimum-maximum + * supplier object that belongs to the given coordinate system. + * The minimum-maximum supplier object is set in the + * `SeriesPlotterContainer::initializeCooSysAndSeriesPlotter` method to the + * series plotter which is based on the coordinate system (see notes for + * the method). For instance for a pie chart the `m_fValueMinimum` and the + * `m_fValueMaximum` parameters are initialized by the `PieChart::getMinimum` + * and `PieChart::getMaximum` methods. + */ + void prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ); + + void setExplicitScaleAndIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex + , const ExplicitScaleData& rExplicitScale + , const ExplicitIncrementData& rExplicitIncrement ); + + void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos ); + + const rtl::Reference< ::chart::BaseCoordinateSystem >& + getModel() const { return m_xCooSysModel;} + + /** + * Create "view" axis objects 'VAxis' from the coordinate system model. + */ + virtual void createVAxisList( + const rtl::Reference<::chart::ChartModel> & xChartDoc + , const css::awt::Size& rFontReferenceSize + , const css::awt::Rectangle& rMaximumSpaceForLabels + , bool bLimitSpaceForLabels ); + + virtual void initVAxisInList(); + virtual void updateScalesAndIncrementsOnAxes(); + + void createMaximumAxesLabels(); + void createAxesLabels(); + void updatePositions(); + void createAxesShapes(); + + virtual void createGridShapes(); + + bool getPropertySwapXAndYAxis() const; + + sal_Int32 getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex ) const; + + bool needSeriesNamesForAxis() const; + void setSeriesNamesForAxis( const css::uno::Sequence< OUString >& rSeriesNames ); + +protected: //methods + VCoordinateSystem( const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys ); + + rtl::Reference< ::chart::Axis > + getAxisByDimension( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + static std::vector< css::uno::Reference< css::beans::XPropertySet > > + getGridListFromAxis( const rtl::Reference< ::chart::Axis >& xAxis ); + + VAxisBase* getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); + + OUString createCIDForAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); + OUString createCIDForGrid( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); + + sal_Int32 getNumberFormatKeyForAxis( const rtl::Reference< ::chart::Axis >& xAxis + , const rtl::Reference<::chart::ChartModel>& xChartDoc); + +private: //methods + static void impl_adjustDimension( sal_Int32& rDimensionIndex ); + void impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex, sal_Int32& rAxisIndex ) const; + +protected: //member + rtl::Reference< ::chart::BaseCoordinateSystem > m_xCooSysModel; + + OUString m_aCooSysParticle; + + typedef std::pair< sal_Int32, sal_Int32 > tFullAxisIndex; //first index is the dimension, second index is the axis index that indicates whether this is a main or secondary axis + + rtl::Reference<SvxShapeGroupAnyD> m_xLogicTargetForGrids; + rtl::Reference<SvxShapeGroupAnyD> m_xLogicTargetForAxes; + rtl::Reference<SvxShapeGroupAnyD> m_xFinalTarget; + css::drawing::HomogenMatrix m_aMatrixSceneToScreen; + + CuboidPlanePosition m_eLeftWallPos; + CuboidPlanePosition m_eBackWallPos; + CuboidPlanePosition m_eBottomPos; + + /** + * Collection of min-max suppliers which are basically different chart + * types present in the same coordinate system. This is used only for + * auto-scaling purposes. + */ + MergedMinimumAndMaximumSupplier m_aMergedMinMaxSupplier; + + css::uno::Sequence< OUString > m_aSeriesNamesForZAxis; + + typedef std::map< tFullAxisIndex, std::shared_ptr< VAxisBase > > tVAxisMap; + + tVAxisMap m_aAxisMap; + +private: + std::vector< ExplicitScaleData > m_aExplicitScales; + std::vector< ExplicitIncrementData > m_aExplicitIncrements; + + typedef std::map< tFullAxisIndex, ExplicitScaleData > tFullExplicitScaleMap; + typedef std::map< tFullAxisIndex, ExplicitIncrementData > tFullExplicitIncrementMap; + + tFullExplicitScaleMap m_aSecondaryExplicitScales; + tFullExplicitIncrementMap m_aSecondaryExplicitIncrements; + + std::unique_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx new file mode 100644 index 000000000..29a71918b --- /dev/null +++ b/chart2/source/view/inc/VDataSeries.hxx @@ -0,0 +1,267 @@ +/* -*- 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 "PropertyMapper.hxx" + +#include <com/sun/star/chart2/StackingDirection.hpp> +#include <com/sun/star/drawing/Position3D.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <rtl/ref.hxx> +#include <svx/unoshape.hxx> + +#include <memory> +#include <map> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XChartType; } +namespace com::sun::star::chart2 { class XDataSeries; } +namespace com::sun::star::chart2::data { class XDataSequence; } +namespace com::sun::star::chart2 { struct DataPointLabel; } +namespace com::sun::star::chart2 { struct Symbol; } +namespace com::sun::star::drawing { class XShapes; } + +namespace chart +{ +class ChartType; +class DataSeries; + +class VDataSequence +{ +public: + void init( const css::uno::Reference<css::chart2::data::XDataSequence>& xModel ); + bool is() const; + void clear(); + double getValue( sal_Int32 index ) const; + sal_Int32 detectNumberFormatKey( sal_Int32 index ) const; + sal_Int32 getLength() const; + + css::uno::Reference<css::chart2::data::XDataSequence> m_xModel; + mutable css::uno::Sequence<double> m_aValues; +}; + +class VDataSeries final +{ +public: + VDataSeries( const rtl::Reference<::chart::DataSeries>& xDataSeries ); + + ~VDataSeries(); + + VDataSeries(const VDataSeries&) = delete; + const VDataSeries& operator=(const VDataSeries&) = delete; + + const rtl::Reference<::chart::DataSeries>& getModel() const; + + void setCategoryXAxis(); + void setXValues( const css::uno::Reference<css::chart2::data::XDataSequence>& xValues ); + void setXValuesIfNone( const css::uno::Reference<css::chart2::data::XDataSequence>& xValues ); + void setParticle( const OUString& rSeriesParticle ); + void setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ); + void setPageReferenceSize( const css::awt::Size & rPageRefSize ); + + sal_Int32 getTotalPointCount() const { return m_nPointCount;} + double getXValue( sal_Int32 index ) const; + double getYValue( sal_Int32 index ) const; + + void getMinMaxXValue( double& fMin, double& fMax ) const; + + double getY_Min( sal_Int32 index ) const; + double getY_Max( sal_Int32 index ) const; + double getY_First( sal_Int32 index ) const; + double getY_Last( sal_Int32 index ) const; + + double getBubble_Size( sal_Int32 index ) const; + + double getMinimumofAllDifferentYValues( sal_Int32 index ) const; + double getMaximumofAllDifferentYValues( sal_Int32 index ) const; + + double getValueByProperty( sal_Int32 index, const OUString& rPropName ) const; + + bool hasPropertyMapping( const OUString& rPropName ) const; + + css::uno::Sequence< double > const & getAllX() const; + css::uno::Sequence< double > const & getAllY() const; + + double getXMeanValue() const; + double getYMeanValue() const; + + bool hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const; + sal_Int32 getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const; + sal_Int32 detectNumberFormatKey( sal_Int32 nPointIndex ) const; + + sal_Int32 getLabelPlacement( + sal_Int32 nPointIndex, const rtl::Reference<::chart::ChartType>& xChartType, + bool bSwapXAndY ) const; + + css::awt::Point getLabelPosition( css::awt::Point aTextShapePos, sal_Int32 nPointIndex ) const; + bool isLabelCustomPos( sal_Int32 nPointIndex ) const; + + css::uno::Reference<css::beans::XPropertySet> getPropertiesOfPoint( sal_Int32 index ) const; + + const css::uno::Reference<css::beans::XPropertySet> & getPropertiesOfSeries() const; + + css::chart2::Symbol* getSymbolProperties( sal_Int32 index ) const; + + css::uno::Reference<css::beans::XPropertySet> getXErrorBarProperties( sal_Int32 index ) const; + + css::uno::Reference<css::beans::XPropertySet> getYErrorBarProperties( sal_Int32 index ) const; + + bool hasPointOwnColor( sal_Int32 index ) const; + + css::chart2::StackingDirection getStackingDirection() const; + sal_Int32 getAttachedAxisIndex() const; + void setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex ); + + void doSortByXValues(); + + void setConnectBars( bool bConnectBars ); + bool getConnectBars() const; + + void setGroupBarsPerAxis( bool bGroupBarsPerAxis ); + bool getGroupBarsPerAxis() const; + + void setStartingAngle( sal_Int32 nStartingAngle ); + sal_Int32 getStartingAngle() const; + + void setRoleOfSequenceForDataLabelNumberFormatDetection( std::u16string_view rRole ); + + //this is only temporarily here for area chart: + std::vector<std::vector<css::drawing::Position3D>> m_aPolyPolygonShape3D; + sal_Int32 m_nPolygonIndex; + double m_fLogicMinX; + double m_fLogicMaxX; + + //this is here for deep stacking: + double m_fLogicZPos;//from 0 to series count -1 + + const OUString& getCID() const { return m_aCID;} + const OUString& getSeriesParticle() const { return m_aSeriesParticle;} + const OUString& getPointCID_Stub() const { return m_aPointCID_Stub;} + OUString getErrorBarsCID( bool bYError ) const; + OUString getLabelsCID() const; + const OUString& getLabelCID_Stub() const { return m_aLabelCID_Stub;} + OUString getDataCurveCID( sal_Int32 nCurveIndex, bool bAverageLine ) const; + + css::chart2::DataPointLabel* getDataPointLabelIfLabel( sal_Int32 index ) const; + bool getTextLabelMultiPropertyLists( sal_Int32 index, tNameSequence*& pPropNames, tAnySequence*& pPropValues ) const; + + OUString getDataCurveEquationCID( sal_Int32 nCurveIndex ) const; + bool isAttributedDataPoint( sal_Int32 index ) const; + + bool isVaryColorsByPoint() const; + + void releaseShapes(); + + void setMissingValueTreatment( sal_Int32 nMissingValueTreatment ); + sal_Int32 getMissingValueTreatment() const; + + void setOldTimeBased( VDataSeries* pOldSeries, double nPercent ); + VDataSeries* createCopyForTimeBased() const; + +private: //methods + css::chart2::DataPointLabel* getDataPointLabel( sal_Int32 index ) const; + void adaptPointCache( sal_Int32 nNewPointIndex ) const; + + // for copies for time based charting + VDataSeries(); + +public: //member + rtl::Reference<SvxShapeGroupAnyD> m_xGroupShape; + rtl::Reference<SvxShapeGroup> m_xLabelsGroupShape; + rtl::Reference<SvxShapeGroupAnyD> m_xErrorXBarsGroupShape; + rtl::Reference<SvxShapeGroupAnyD> m_xErrorYBarsGroupShape; + + //the following group shapes will be created as children of m_xGroupShape on demand + //they can be used to assure that some parts of a series shape are always in front of others (e.g. symbols in front of lines) + rtl::Reference<SvxShapeGroupAnyD> m_xFrontSubGroupShape; + rtl::Reference<SvxShapeGroupAnyD> m_xBackSubGroupShape; + +private: //member + rtl::Reference<::chart::DataSeries> m_xDataSeries; + css::uno::Reference<css::beans::XPropertySet> m_xDataSeriesProps; // cached + + //all points given by the model data (here are not only the visible points meant) + sal_Int32 m_nPointCount; + + VDataSequence m_aValues_X; + VDataSequence m_aValues_Y; + VDataSequence m_aValues_Z; + + VDataSequence m_aValues_Y_Min; + VDataSequence m_aValues_Y_Max; + VDataSequence m_aValues_Y_First; + VDataSequence m_aValues_Y_Last; + + VDataSequence m_aValues_Bubble_Size; + + VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection; + + std::map<OUString, VDataSequence> m_PropertyMap; + + mutable double m_fXMeanValue; + mutable double m_fYMeanValue; + + css::uno::Sequence<sal_Int32> m_aAttributedDataPointIndexList; + + css::chart2::StackingDirection m_eStackingDirection; + + sal_Int32 m_nAxisIndex;//indicates whether this is attached to a main or secondary axis + + bool m_bConnectBars; + + bool m_bGroupBarsPerAxis; + + sal_Int32 m_nStartingAngle; + + OUString m_aSeriesParticle; + OUString m_aCID; + OUString m_aPointCID_Stub; + OUString m_aLabelCID_Stub; + + sal_Int32 m_nGlobalSeriesIndex; + + //some cached values for data labels as they are very expensive + mutable std::unique_ptr<css::chart2::DataPointLabel> + m_apLabel_Series; + mutable std::unique_ptr<tNameSequence> m_apLabelPropNames_Series; + mutable std::unique_ptr<tAnySequence> m_apLabelPropValues_Series; + mutable std::unique_ptr<css::chart2::Symbol> m_apSymbolProperties_Series; + + mutable std::unique_ptr<css::chart2::DataPointLabel> + m_apLabel_AttributedPoint; + mutable std::unique_ptr<tNameSequence> m_apLabelPropNames_AttributedPoint; + mutable std::unique_ptr<tAnySequence> m_apLabelPropValues_AttributedPoint; + mutable std::unique_ptr<css::chart2::Symbol> m_apSymbolProperties_AttributedPoint; + mutable std::unique_ptr<css::chart2::Symbol> + m_apSymbolProperties_InvisibleSymbolForSelection; + mutable sal_Int32 m_nCurrentAttributedPoint; + css::awt::Size m_aReferenceSize; + + sal_Int32 m_nMissingValueTreatment; + bool m_bAllowPercentValueInDataLabel; + + // for time based charting + VDataSeries* mpOldSeries; + double mnPercent; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/VDiagram.hxx b/chart2/source/view/inc/VDiagram.hxx new file mode 100644 index 000000000..ab391f7bc --- /dev/null +++ b/chart2/source/view/inc/VDiagram.hxx @@ -0,0 +1,117 @@ +/* -*- 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/range/b2irectangle.hxx> +#include <com/sun/star/drawing/Direction3D.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <svx/unoshape.hxx> +#include <rtl/ref.hxx> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::chart2 { class XDiagram; } +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::drawing { class XShape; } + + +namespace chart +{ +class Diagram; +class ShapeFactory; + +/** The VDiagram is responsible to generate the visible parts of the Diagram +that is wall, floor, axes and data series. +The axes and data series are subobjects which are created and managed by the +diagram. +*/ + +class VDiagram final +{ +public: //methods + VDiagram( const rtl::Reference<::chart::Diagram>& xDiagram, + const css::drawing::Direction3D& rPreferredAspectRatio, + sal_Int32 nDimension ); + ~VDiagram(); + + void init( + const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + + void createShapes( const css::awt::Point& rPos + , const css::awt::Size& rSize ); + + const rtl::Reference<SvxShapeGroupAnyD> & + getCoordinateRegion() const { return m_xCoordinateRegionShape; } + + /** + * Get current bounding rectangle for the diagram without axes. + */ + basegfx::B2IRectangle getCurrentRectangle() const; + + void reduceToMinimumSize(); + + ::basegfx::B2IRectangle adjustPosAndSize( const css::awt::Point& rPos + , const css::awt::Size& rAvailableSize ); + + ::basegfx::B2IRectangle adjustInnerSize( const ::basegfx::B2IRectangle& rConsumedOuterRect ); + +private: //methods + void createShapes_2d(); + void createShapes_3d(); + + ::basegfx::B2IRectangle adjustPosAndSize_2d( const css::awt::Point& rPos + , const css::awt::Size& rAvailableSize ); + ::basegfx::B2IRectangle adjustPosAndSize_3d( const css::awt::Point& rPos + , const css::awt::Size& rAvailableSize ); + + void adjustAspectRatio3d( const css::awt::Size& rAvailableSize ); + +private: //members + VDiagram(const VDiagram& rD) = delete; + + rtl::Reference<SvxShapeGroupAnyD> m_xTarget; + + // this is the surrounding shape which contains floor, wall and coordinate + rtl::Reference<SvxShapeGroupAnyD> m_xOuterGroupShape; + // this is an additional inner shape that represents the coordinate region - that is - where to place data points + rtl::Reference<SvxShapeGroupAnyD> m_xCoordinateRegionShape; + rtl::Reference<SvxShapeRect> m_xWall2D; + + sal_Int32 m_nDimensionCount; + rtl::Reference< ::chart::Diagram > m_xDiagram; + + css::drawing::Direction3D m_aPreferredAspectRatio; + css::uno::Reference< css::beans::XPropertySet > m_xAspectRatio3D; + + double m_fXAnglePi; + double m_fYAnglePi; + double m_fZAnglePi; + + css::awt::Point m_aAvailablePosIncludingAxes; + css::awt::Size m_aAvailableSizeIncludingAxes; + + css::awt::Point m_aCurrentPosWithoutAxes; + css::awt::Size m_aCurrentSizeWithoutAxes; + + bool m_bRightAngledAxes; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/VLegendSymbolFactory.hxx b/chart2/source/view/inc/VLegendSymbolFactory.hxx new file mode 100644 index 000000000..f637a5894 --- /dev/null +++ b/chart2/source/view/inc/VLegendSymbolFactory.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 "LegendEntryProvider.hxx" +#include <com/sun/star/uno/Reference.h> +#include <rtl/ref.hxx> +#include <svx/unoshape.hxx> + +namespace com::sun::star::awt { struct Size; } +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::drawing { class XShape; } +namespace com::sun::star::drawing { class XShapes; } +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::uno { class Any; } + +namespace chart::VLegendSymbolFactory +{ + enum class PropertyType + { + FilledSeries, + LineSeries, + Line, + }; + + rtl::Reference< SvxShapeGroup > + createSymbol( + const css::awt::Size& rEntryKeyAspectRatio, + const rtl::Reference<SvxShapeGroupAnyD>& rSymbolContainer, + LegendSymbolStyle eStyle, + const css::uno::Reference< css::beans::XPropertySet > & xLegendEntryProperties, + PropertyType ePropertyType, + const css::uno::Any& rExplicitSymbol /*should contain a css::chart2::Symbol without automatic symbol if the charttype does support symbols else empty*/); + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/VLineProperties.hxx b/chart2/source/view/inc/VLineProperties.hxx new file mode 100644 index 000000000..aa1c88ce7 --- /dev/null +++ b/chart2/source/view/inc/VLineProperties.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/Any.h> +#include <com/sun/star/uno/Reference.h> + +namespace com::sun::star::beans +{ +class XPropertySet; +} + +namespace chart +{ +struct VLineProperties +{ + css::uno::Any Color; //type sal_Int32 UNO_NAME_LINECOLOR + css::uno::Any LineStyle; //type drawing::LineStyle for property UNO_NAME_LINESTYLE + css::uno::Any Transparence; //type sal_Int16 for property UNO_NAME_LINETRANSPARENCE + css::uno::Any Width; //type sal_Int32 for property UNO_NAME_LINEWIDTH + css::uno::Any DashName; //type OUString for property "LineDashName" + css::uno::Any LineCap; //type drawing::LineCap for property UNO_NAME_LINECAP + + VLineProperties(); + void initFromPropertySet(const css::uno::Reference<css::beans::XPropertySet>& xProp); + + bool isLineVisible() const; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/VPolarTransformation.hxx b/chart2/source/view/inc/VPolarTransformation.hxx new file mode 100644 index 000000000..23f3c3b71 --- /dev/null +++ b/chart2/source/view/inc/VPolarTransformation.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 "PlottingPositionHelper.hxx" + +namespace chart +{ + +class VPolarTransformation final : public XTransformation2 +{ +public: + VPolarTransformation( const PolarPlottingPositionHelper& rPositionHelper ); + virtual ~VPolarTransformation() override; + + // ____ XTransformation2 ____ + virtual css::drawing::Position3D transform( + const css::uno::Sequence< double >& rSourceValues ) const override; + virtual css::drawing::Position3D transform( + const css::drawing::Position3D& rSourceValues ) const override; + +private: + PolarPlottingPositionHelper m_aPositionHelper; + ::basegfx::B3DHomMatrix m_aUnitCartesianToScene; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx new file mode 100644 index 000000000..ac911be46 --- /dev/null +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -0,0 +1,436 @@ +/* -*- 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 <memory> +#include "PlotterBase.hxx" +#include "VDataSeries.hxx" +#include "LabelAlignment.hxx" +#include "MinimumAndMaximumSupplier.hxx" +#include "LegendEntryProvider.hxx" +#include <basegfx/range/b2irectangle.hxx> +#include <com/sun/star/drawing/Direction3D.hpp> +#include <rtl/ref.hxx> +#include <svx/unoshape.hxx> + +namespace com::sun::star::awt { struct Point; } +namespace com::sun::star::chart2 { class XChartType; } + + +namespace chart { class ExplicitCategoriesProvider; } +namespace chart { struct ExplicitScaleData; } +namespace chart { class ChartModel; } + +namespace com::sun::star { + namespace util { + class XNumberFormatsSupplier; + } + namespace chart2 { + class XColorScheme; + class XRegressionCurveCalculator; + } +} + +namespace chart { + +class ChartType; +class NumberFormatterWrapper; + +class AxesNumberFormats +{ +public: + AxesNumberFormats() {}; + + void setFormat( sal_Int32 nFormatKey, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ) + { + m_aNumberFormatMap[tFullAxisIndex(nDimIndex,nAxisIndex)] = nFormatKey; + } + +private: + typedef std::pair< sal_Int32, sal_Int32 > tFullAxisIndex; + std::map< tFullAxisIndex, sal_Int32 > m_aNumberFormatMap; +}; + +/** + * A list of series that have the same CoordinateSystem. They are used to be + * plotted maybe in a stacked manner by a plotter. + */ +class VDataSeriesGroup final +{ +public: + VDataSeriesGroup() = delete; + VDataSeriesGroup( std::unique_ptr<VDataSeries> pSeries ); + VDataSeriesGroup(VDataSeriesGroup&&) noexcept; + ~VDataSeriesGroup(); + + void addSeries( std::unique_ptr<VDataSeries> pSeries );//takes ownership of pSeries + sal_Int32 getSeriesCount() const; + void deleteSeries(); + + sal_Int32 getPointCount() const; + sal_Int32 getAttachedAxisIndexForFirstSeries() const; + + void getMinimumAndMaximumX( double& rfMinimum, double& rfMaximum ) const; + void getMinimumAndMaximumYInContinuousXRange( double& rfMinY, double& rfMaxY, double fMinX, double fMaxX, sal_Int32 nAxisIndex ) const; + + void calculateYMinAndMaxForCategory( sal_Int32 nCategoryIndex + , bool bSeparateStackingForDifferentSigns + , double& rfMinimumY, double& rfMaximumY, sal_Int32 nAxisIndex ) const; + void calculateYMinAndMaxForCategoryRange( sal_Int32 nStartCategoryIndex, sal_Int32 nEndCategoryIndex + , bool bSeparateStackingForDifferentSigns + , double& rfMinimumY, double& rfMaximumY, sal_Int32 nAxisIndex ); + + std::vector< std::unique_ptr<VDataSeries> > m_aSeriesVector; + +private: + //cached values + struct CachedYValues + { + CachedYValues(); + + bool m_bValuesDirty; + double m_fMinimumY; + double m_fMaximumY; + }; + + mutable bool m_bMaxPointCountDirty; + mutable sal_Int32 m_nMaxPointCount; + typedef std::map< sal_Int32, CachedYValues > tCachedYValuesPerAxisIndexMap; + mutable std::vector< tCachedYValuesPerAxisIndexMap > m_aListOfCachedYValues; +}; + +class VSeriesPlotter : public PlotterBase, public MinimumAndMaximumSupplier, public LegendEntryProvider +{ +public: + VSeriesPlotter() = delete; + + virtual ~VSeriesPlotter() override; + + /** + * A new series can be positioned relative to other series in a chart. + * This positioning has two dimensions. First a series can be placed + * next to each other on the category axis. This position is indicated by xSlot. + * Second a series can be stacked on top of another. This position is indicated by ySlot. + * The positions are counted from 0 on. + * xSlot < 0 : append the series to already existing x series + * xSlot > occupied : append the series to already existing x series + * + * If the xSlot is already occupied the given ySlot decides what should happen: + * ySlot < -1 : move all existing series in the xSlot to next slot + * ySlot == -1 : stack on top at given x position + * ySlot == already occupied : insert at given y and x position + * ySlot > occupied : stack on top at given x position + */ + virtual void addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ); + + /** a value <= 0 for a directions means that this direction can be stretched arbitrary + */ + virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const; + + /** this enables you to handle series on the same x axis with different y axis + the property AttachedAxisIndex at a dataseries indicates which value scale is to use + (0==AttachedAxisIndex or a not set AttachedAxisIndex property indicates that this series should be scaled at the main y-axis; + 1==AttachedAxisIndex indicates that the series should be scaled at the first secondary axis if there is any otherwise at the main y axis + and so on. + The parameter nAxisIndex matches this DataSeries property 'AttachedAxisIndex'. + nAxisIndex must be greater than 0. nAxisIndex==1 refers to the first secondary axis. + ) + + @throws css::uno::RuntimeException + */ + + void addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex ); + + // MinimumAndMaximumSupplier + + virtual double getMinimumX() override; + virtual double getMaximumX() override; + + virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override; + virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override; + + virtual double getMinimumZ() override; + virtual double getMaximumZ() override; + + virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex ) override; + virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) override; + virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex ) override; + virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ) override; + virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) override; + + virtual tools::Long calculateTimeResolutionOnXAxis() override; + virtual void setTimeResolutionOnXAxis( tools::Long nTimeResolution, const Date& rNullDate ) override; + + void getMinimumAndMaximumX( double& rfMinimum, double& rfMaximum ) const; + void getMinimumAndMaximumYInContinuousXRange( double& rfMinY, double& rfMaxY, double fMinX, double fMaxX, sal_Int32 nAxisIndex ) const; + + + // Methods for handling legends and legend entries. + + virtual std::vector< ViewLegendEntry > createLegendEntries( + const css::awt::Size& rEntryKeyAspectRatio, + css::chart2::LegendPosition eLegendPosition, + const css::uno::Reference< css::beans::XPropertySet >& xTextProperties, + const rtl::Reference<SvxShapeGroupAnyD>& xTarget, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + ChartModel& rModel + ) override; + + virtual LegendSymbolStyle getLegendSymbolStyle(); + virtual css::awt::Size getPreferredLegendKeyAspectRatio() override; + + virtual css::uno::Any getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex/*-1 for series symbol*/ ); + + rtl::Reference<SvxShapeGroup> createLegendSymbolForSeries( + const css::awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + + rtl::Reference< SvxShapeGroup > createLegendSymbolForPoint( + const css::awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries + , sal_Int32 nPointIndex + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + + std::vector< ViewLegendEntry > createLegendEntriesForSeries( + const css::awt::Size& rEntryKeyAspectRatio, + const VDataSeries& rSeries, + const css::uno::Reference< css::beans::XPropertySet >& xTextProperties, + const rtl::Reference<SvxShapeGroupAnyD>& xTarget, + const css::uno::Reference< css::uno::XComponentContext >& xContext + ); + + std::vector<VDataSeries*> getAllSeries(); + std::vector<VDataSeries const*> getAllSeries() const; + + // This method creates a series plotter of the requested type; e.g. : return new PieChart... + static VSeriesPlotter* createSeriesPlotter( const rtl::Reference< ::chart::ChartType >& xChartTypeModel + , sal_Int32 nDimensionCount + , bool bExcludingPositioning /*for pie and donut charts labels and exploded segments are excluded from the given size*/); + + sal_Int32 getPointCount() const; + + // Methods for number formats and color schemes + + void setNumberFormatsSupplier( const css::uno::Reference< css::util::XNumberFormatsSupplier > & xNumFmtSupplier ); + + void setColorScheme( const css::uno::Reference< css::chart2::XColorScheme >& xColorScheme ); + + void setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider ); + + ExplicitCategoriesProvider* getExplicitCategoriesProvider() { return m_pExplicitCategoriesProvider; } + + //get series names for the z axis labels + css::uno::Sequence<OUString> getSeriesNames() const; + + void setPageReferenceSize( const css::awt::Size & rPageRefSize ); + //better performance for big data + void setCoordinateSystemResolution( const css::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution ); + bool PointsWereSkipped() const { return m_bPointsWereSkipped;} + void setPieLabelsAllowToMove( bool bIsPieOrDonut ) { m_bPieLabelsAllowToMove = bIsPieOrDonut; }; + void setAvailableOuterRect( const basegfx::B2IRectangle& aAvailableOuterRect ) { m_aAvailableOuterRect = aAvailableOuterRect; }; + + //return the depth for a logic 1 + double getTransformedDepth() const; + + void releaseShapes(); + + virtual void rearrangeLabelToAvoidOverlapIfRequested( const css::awt::Size& rPageSize ); + + bool WantToPlotInFrontOfAxisLine(); + virtual bool shouldSnapRectToUsedArea(); + +protected: + + VSeriesPlotter( const rtl::Reference< ::chart::ChartType >& xChartTypeModel + , sal_Int32 nDimensionCount + , bool bCategoryXAxis=true ); + + // Methods for group shapes. + + rtl::Reference<SvxShapeGroupAnyD> + getSeriesGroupShape( VDataSeries* pDataSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + + //the following group shapes will be created as children of SeriesGroupShape on demand + //they can be used to assure that some parts of a series shape are always in front of others (e.g. symbols in front of lines) + //parameter xTarget will be used as parent for the series group shape + rtl::Reference<SvxShapeGroupAnyD> + getSeriesGroupShapeFrontChild( VDataSeries* pDataSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + rtl::Reference<SvxShapeGroupAnyD> + getSeriesGroupShapeBackChild( VDataSeries* pDataSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + + /// This method creates a 2D group shape for containing all text shapes + /// needed for this series; the group is added to the text target; + static rtl::Reference<SvxShapeGroup> + getLabelsGroupShape( VDataSeries& rDataSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + + rtl::Reference<SvxShapeGroupAnyD> + getErrorBarsGroupShape( VDataSeries& rDataSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget, bool bYError ); + + /** This method creates a text shape for a label related to a data point + * and append it to the root text shape group (xTarget). + * + * @param xTarget + * the main root text shape group. + * @param rDataSeries + * the data series, the data point belongs to. + * @param nPointIndex + * the index of the data point the label is related to. + * @param fValue + * the value of the data point. + * @param fSumValue + * the sum of all data point values in the data series. + * @param rScreenPosition2D + * the anchor point position for the label. + * @param eAlignment + * the required alignment of the label. + * @param offset + * an optional offset depending on the label alignment. + * @param nTextWidth + * the maximum width of a text label (used for text wrapping). + * + * @return + * a reference to the created text shape. + */ + rtl::Reference<SvxShapeText> + createDataLabel( const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , VDataSeries& rDataSeries + , sal_Int32 nPointIndex + , double fValue + , double fSumValue + , const css::awt::Point& rScreenPosition2D + , LabelAlignment eAlignment + , sal_Int32 nOffset=0 + , sal_Int32 nTextWidth = 0 ); + + /// This method returns a text string representation of the passed numeric + /// value by exploiting a NumberFormatterWrapper object. + OUString getLabelTextForValue( VDataSeries const & rDataSeries + , sal_Int32 nPointIndex + , double fValue + , bool bAsPercentage ); + + /** creates two T-shaped error bars in both directions (up/down or + left/right depending on the bVertical parameter) + + @param rPos + logic coordinates + + @param xErrorBarProperties + the XPropertySet returned by the DataPoint-property "ErrorBarX" or + "ErrorBarY". + + @param nIndex + the index of the data point in rData for which the calculation is + done. + + @param bVertical + for y-error bars this is true, for x-error-bars it is false. + */ + void createErrorBar( + const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::drawing::Position3D & rPos + , const css::uno::Reference< css::beans::XPropertySet > & xErrorBarProperties + , const VDataSeries& rVDataSeries + , sal_Int32 nIndex + , bool bVertical + , const double* pfScaledLogicX + ); + + void createErrorRectangle( + const css::drawing::Position3D& rUnscaledLogicPosition + , VDataSeries& rVDataSeries + , sal_Int32 nIndex + , const rtl::Reference<SvxShapeGroupAnyD>& rTarget + , bool bUseXErrorData + , bool bUseYErrorData + ); + + static void addErrorBorder( + const css::drawing::Position3D& rPos0 + , const css::drawing::Position3D& rPos1 + , const rtl::Reference<SvxShapeGroupAnyD>& rTarget + , const css::uno::Reference< css::beans::XPropertySet >& rErrorBorderProp ); + + void createErrorBar_X( const css::drawing::Position3D& rUnscaledLogicPosition + , VDataSeries& rVDataSeries, sal_Int32 nPointIndex + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget ); + + void createErrorBar_Y( const css::drawing::Position3D& rUnscaledLogicPosition + , VDataSeries& rVDataSeries, sal_Int32 nPointIndex + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , double const * pfScaledLogicX ); + + void createRegressionCurvesShapes( VDataSeries const & rVDataSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const rtl::Reference<SvxShapeGroupAnyD>& xEquationTarget + , bool bMaySkipPointsInRegressionCalculation ); + + void createRegressionCurveEquationShapes( const OUString & rEquationCID + , const css::uno::Reference< css::beans::XPropertySet > & xEquationProperties + , const rtl::Reference<SvxShapeGroupAnyD>& xEquationTarget + , const css::uno::Reference< css::chart2::XRegressionCurveCalculator > & xRegressionCurveCalculator + , css::awt::Point aDefaultPos ); + + virtual PlottingPositionHelper& getPlottingPositionHelper( sal_Int32 nAxisIndex ) const;//nAxisIndex indicates whether the position belongs to the main axis ( nAxisIndex==0 ) or secondary axis ( nAxisIndex==1 ) + + VDataSeries* getFirstSeries() const; + + OUString getCategoryName( sal_Int32 nPointIndex ) const; + +protected: + PlottingPositionHelper* m_pMainPosHelper; + + rtl::Reference< ::chart::ChartType > m_xChartTypeModel; + + std::vector< std::vector< VDataSeriesGroup > > m_aZSlots; + + bool m_bCategoryXAxis;//true->xvalues are indices (this would not be necessary if series for category chart wouldn't have x-values) + tools::Long m_nTimeResolution; + Date m_aNullDate; + + std::unique_ptr< NumberFormatterWrapper > m_apNumberFormatterWrapper; + + css::uno::Reference< css::chart2::XColorScheme > m_xColorScheme; + + ExplicitCategoriesProvider* m_pExplicitCategoriesProvider; + + //better performance for big data + css::uno::Sequence< sal_Int32 > m_aCoordinateSystemResolution; + bool m_bPointsWereSkipped; + bool m_bPieLabelsAllowToMove; + basegfx::B2IRectangle m_aAvailableOuterRect; + css::awt::Size m_aPageReferenceSize; + +private: + typedef std::map< sal_Int32 , ExplicitScaleData > tSecondaryValueScales; + tSecondaryValueScales m_aSecondaryValueScales; + + typedef std::map< sal_Int32 , std::unique_ptr<PlottingPositionHelper> > tSecondaryPosHelperMap; + mutable tSecondaryPosHelperMap m_aSecondaryPosHelperMap; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/ViewDefines.hxx b/chart2/source/view/inc/ViewDefines.hxx new file mode 100644 index 000000000..b8b82be95 --- /dev/null +++ b/chart2/source/view/inc/ViewDefines.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 + +#include <sal/types.h> + +namespace chart +{ +#define CHART_3DOBJECT_SEGMENTCOUNT (sal_Int32(32)) +//There needs to be a little distance between grid lines and walls in 3D, otherwise the lines are partly hidden by the walls +#define GRID_TO_WALL_DISTANCE (1.0) + +const double ZDIRECTION = 1.0; +const sal_Int32 AXIS2D_TICKLENGTH = 150; //value like in old chart +const sal_Int32 AXIS2D_TICKLABELSPACING = 100; //value like in old chart + +} //end namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |