fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / inc / drawingml / chart / converterbase.hxx
blobbf3f7b5a303e0f7c9b7b19b07ce0573bcdafa7d1
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;
49 const sal_Int32 API_PRIM_AXESSET = 0;
50 const sal_Int32 API_SECN_AXESSET = 1;
52 const sal_Int32 API_X_AXIS = 0;
53 const sal_Int32 API_Y_AXIS = 1;
54 const sal_Int32 API_Z_AXIS = 2;
58 class ConverterRoot
60 public:
61 explicit ConverterRoot(
62 ::oox::core::XmlFilterBase& rFilter,
63 ChartConverter& rChartConverter,
64 const ChartSpaceModel& rChartModel,
65 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& rxChartDoc,
66 const ::com::sun::star::awt::Size& rChartSize );
67 virtual ~ConverterRoot();
69 /** Creates an instance for the passed service name, using the process service factory. */
70 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
71 createInstance( const OUString& rServiceName ) const;
72 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
73 getComponentContext() const;
75 protected:
76 /** Returns the filter object of the imported/exported document. */
77 ::oox::core::XmlFilterBase& getFilter() const;
78 /** Returns the chart converter. */
79 ChartConverter* getChartConverter() const;
80 /** Returns the API chart document model. */
81 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >
82 getChartDocument() const;
83 /** Returns the position and size of the chart shape in 1/100 mm. */
84 const ::com::sun::star::awt::Size& getChartSize() const;
85 /** Returns the object formatter. */
86 ObjectFormatter& getFormatter() const;
88 /** Registers a title object and its layout data, needed for conversion of
89 the title position using the old Chart1 API. */
90 void registerTitleLayout(
91 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >& rxTitle,
92 const ModelRef< LayoutModel >& rxLayout, ObjectType eObjType,
93 sal_Int32 nMainIdx = -1, sal_Int32 nSubIdx = -1 );
94 /** Converts the positions of the main title and all axis titles. */
95 void convertTitlePositions();
97 private:
98 std::shared_ptr< ConverterData > mxData;
103 /** Base class of all converter classes. Holds a reference to a model structure
104 of the specified type.
106 template< typename ModelType >
107 class ConverterBase : public ConverterRoot
109 public:
110 const ModelType& getModel() const { return mrModel; }
112 protected:
113 explicit ConverterBase( const ConverterRoot& rParent, ModelType& rModel ) :
114 ConverterRoot( rParent ), mrModel( rModel ) {}
115 virtual ~ConverterBase() {}
117 protected:
118 ModelType& mrModel;
123 /** A layout converter calculates positions and sizes for various chart objects.
125 class LayoutConverter : public ConverterBase< LayoutModel >
127 public:
128 explicit LayoutConverter( const ConverterRoot& rParent, LayoutModel& rModel );
129 virtual ~LayoutConverter();
131 /** Tries to calculate the absolute position and size from the contained
132 OOXML layout model. Returns true, if returned rectangle is valid. */
133 bool calcAbsRectangle( ::com::sun::star::awt::Rectangle& orRect ) const;
135 /** Tries to set the position and size from the contained OOXML layout model.
136 Returns true, if a manual position and size could be calculated. */
137 bool convertFromModel( PropertySet& rPropSet );
139 /** Tries to set the position from the contained OOXML layout model.
140 Returns true, if a manual position could be calculated. */
141 bool convertFromModel(
142 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
143 double fRotationAngle );
144 bool getAutoLayout(){return mrModel.mbAutoLayout;}
149 } // namespace chart
150 } // namespace drawingml
151 } // namespace oox
153 #endif
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */