bump product version to 6.3.0.0.beta1
[LibreOffice.git] / oox / inc / drawingml / chart / converterbase.hxx
blobafd0f097f63c0a648a5337376df0b720ac723d28
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 .
20 #ifndef INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
21 #define INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
23 #include <drawingml/chart/chartcontextbase.hxx>
24 #include <drawingml/chart/objectformatter.hxx>
26 namespace com { namespace sun { namespace star {
27 namespace awt { struct Rectangle; }
28 namespace awt { struct Size; }
29 namespace chart2 { class XChartDocument; }
30 namespace chart2 { class XTitle; }
31 namespace drawing { class XShape; }
32 namespace uno { class XComponentContext; }
33 } } }
35 namespace oox { namespace core {
36 class XmlFilterBase;
37 } }
39 namespace oox {
40 namespace drawingml {
41 namespace chart {
43 class ChartConverter;
44 struct ChartSpaceModel;
45 struct ConverterData;
48 const sal_Int32 API_PRIM_AXESSET = 0;
49 const sal_Int32 API_SECN_AXESSET = 1;
51 const sal_Int32 API_X_AXIS = 0;
52 const sal_Int32 API_Y_AXIS = 1;
53 const sal_Int32 API_Z_AXIS = 2;
56 class ConverterRoot
58 public:
59 explicit ConverterRoot(
60 ::oox::core::XmlFilterBase& rFilter,
61 ChartConverter& rChartConverter,
62 const ChartSpaceModel& rChartModel,
63 const css::uno::Reference< css::chart2::XChartDocument >& rxChartDoc,
64 const css::awt::Size& rChartSize );
65 virtual ~ConverterRoot();
67 ConverterRoot(ConverterRoot const &) = default;
68 ConverterRoot(ConverterRoot &&) = default;
69 ConverterRoot & operator =(ConverterRoot const &) = default;
70 ConverterRoot & operator =(ConverterRoot &&) = default;
72 /** Creates an instance for the passed service name, using the process service factory. */
73 css::uno::Reference< css::uno::XInterface >
74 createInstance( const OUString& rServiceName ) const;
75 css::uno::Reference< css::uno::XComponentContext > const &
76 getComponentContext() const;
78 protected:
79 /** Returns the filter object of the imported/exported document. */
80 ::oox::core::XmlFilterBase& getFilter() const;
81 /** Returns the chart converter. */
82 ChartConverter& getChartConverter() const;
83 /** Returns the API chart document model. */
84 css::uno::Reference< css::chart2::XChartDocument > const &
85 getChartDocument() const;
86 /** Returns the position and size of the chart shape in 1/100 mm. */
87 const css::awt::Size& getChartSize() const;
88 /** Returns the object formatter. */
89 ObjectFormatter& getFormatter() const;
91 /** Registers a title object and its layout data, needed for conversion of
92 the title position using the old Chart1 API. */
93 void registerTitleLayout(
94 const css::uno::Reference< css::chart2::XTitle >& rxTitle,
95 const ModelRef< LayoutModel >& rxLayout, ObjectType eObjType,
96 sal_Int32 nMainIdx, sal_Int32 nSubIdx );
97 /** Converts the positions of the main title and all axis titles. */
98 void convertTitlePositions();
100 private:
101 std::shared_ptr< ConverterData > mxData;
105 /** Base class of all converter classes. Holds a reference to a model structure
106 of the specified type.
108 template< typename ModelType >
109 class ConverterBase : public ConverterRoot
111 public:
112 const ModelType& getModel() const { return mrModel; }
114 protected:
115 explicit ConverterBase( const ConverterRoot& rParent, ModelType& rModel ) :
116 ConverterRoot( rParent ), mrModel( rModel ) {}
117 virtual ~ConverterBase() override {}
119 protected:
120 ModelType& mrModel;
124 /** A layout converter calculates positions and sizes for various chart objects.
126 class LayoutConverter : public ConverterBase< LayoutModel >
128 public:
129 explicit LayoutConverter( const ConverterRoot& rParent, LayoutModel& rModel );
130 virtual ~LayoutConverter() override;
132 /** Tries to calculate the absolute position and size from the contained
133 OOXML layout model. Returns true, if returned rectangle is valid. */
134 bool calcAbsRectangle( css::awt::Rectangle& orRect ) const;
136 /** Tries to set the position and size from the contained OOXML layout model.
137 Returns true, if a manual position and size could be calculated. */
138 bool convertFromModel( PropertySet& rPropSet );
140 /** Tries to set the position from the contained OOXML layout model. */
141 void convertFromModel(
142 const css::uno::Reference< css::drawing::XShape >& rxShape,
143 double fRotationAngle );
144 bool getAutoLayout(){return mrModel.mbAutoLayout;}
148 } // namespace chart
149 } // namespace drawingml
150 } // namespace oox
152 #endif
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */