Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / DiagramHelper.hxx
blobc65bce883dd35e06fb1e490e32e1b0889ede1142
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #pragma once
21 #include "StackMode.hxx"
22 #include "charttoolsdllapi.hxx"
23 #include "ChartTypeTemplate.hxx"
24 #include <com/sun/star/awt/Rectangle.hpp>
25 #include <rtl/ref.hxx>
27 #include <vector>
29 namespace chart { class ChartModel; }
30 namespace com::sun::star::chart2 { class XAxis; }
31 namespace com::sun::star::chart2 { class XChartDocument; }
32 namespace com::sun::star::chart2 { class XChartType; }
33 namespace com::sun::star::chart2 { class XCoordinateSystem; }
34 namespace com::sun::star::chart2 { class XDiagram; }
35 namespace com::sun::star::chart2 { class XDataSeries; }
36 namespace com::sun::star::chart2::data { class XLabeledDataSequence; }
37 namespace com::sun::star::frame { class XModel; }
38 namespace com::sun::star::lang { class XMultiServiceFactory; }
39 namespace com::sun::star::uno { class XComponentContext; }
40 namespace com::sun::star::util { class XNumberFormats; }
41 namespace com::sun::star::util { class XNumberFormatsSupplier; }
43 namespace chart
45 class Axis;
46 class BaseCoordinateSystem;
47 class ChartType;
48 class ChartTypeManager;
49 class ChartTypeTemplate;
50 class DataSeries;
51 class Diagram;
52 class LabeledDataSequence;
54 class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper
56 public:
58 /** Retrieves the stackmode of the first DataSeries or none. If the series have differing stack
59 modes, rbAmbiguous is set to true. If no series is there rbFound is set to false.
61 @param xCorrespondingCoordinateSystem
62 The coordinate system in which the given chart type xChartType is
63 located. (This is needed for determining percent stacking. If
64 omitted, the result will just indicate "not stacked", "stacked" or
65 "ambiguous")
67 static StackMode getStackModeFromChartType(
68 const rtl::Reference< ::chart::ChartType > & xChartType,
69 bool& rbFound, bool& rbAmbiguous,
70 const rtl::Reference< ::chart::BaseCoordinateSystem > & xCorrespondingCoordinateSystem
73 static bool isSeriesAttachedToMainAxis(
74 const rtl::Reference< ::chart::DataSeries >& xDataSeries );
76 static css::uno::Sequence< OUString >
77 getExplicitSimpleCategories( ChartModel& rModel );
79 SAL_DLLPRIVATE static css::uno::Sequence< OUString >
80 generateAutomaticCategoriesFromCooSys(
81 const rtl::Reference< ::chart::BaseCoordinateSystem > & xCooSys );
83 static void switchToDateCategories(
84 const rtl::Reference<::chart::ChartModel> & xChartDoc );
86 static void switchToTextCategories(
87 const rtl::Reference<::chart::ChartModel> & xChartDoc );
89 static bool isDateNumberFormat( sal_Int32 nNumberFormat, const css::uno::Reference< css::util::XNumberFormats >& xNumberFormats );
90 static sal_Int32 getDateNumberFormat( const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier );
91 static sal_Int32 getDateTimeInputNumberFormat( const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier, double fNumber );
93 static sal_Int32 getPercentNumberFormat( const css::uno::Reference<
94 css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier );
96 SAL_DLLPRIVATE static bool areChartTypesCompatible(
97 const rtl::Reference< ::chart::ChartType >& xFirstType,
98 const rtl::Reference< ::chart::ChartType >& xSecondType );
100 static bool setDiagramPositioning( const rtl::Reference<::chart::ChartModel>& xChartModel,
101 const css::awt::Rectangle& rPosRect /*100th mm*/ );
103 static css::awt::Rectangle getDiagramRectangleFromModel( const rtl::Reference<::chart::ChartModel>& xChartModel );
105 static bool switchDiagramPositioningToExcludingPositioning( ChartModel& rModel
106 , bool bResetModifiedState //set model back to unchanged if it was unchanged before
107 , bool bConvertAlsoFromAutoPositioning );
109 private:
110 DiagramHelper() = delete;
114 } // namespace chart
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */