bump product version to 4.1.6.2
[LibreOffice.git] / include / oox / drawingml / chart / converterbase.hxx
blob21a03441e8030a287981e5cff8b63c24b75b3b48
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 OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
21 #define OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
23 #include "oox/drawingml/chart/chartcontextbase.hxx"
24 #include "oox/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 } } }
34 namespace oox { namespace core {
35 class XmlFilterBase;
36 } }
38 namespace oox {
39 namespace drawingml {
40 namespace chart {
42 class ChartConverter;
43 struct ChartSpaceModel;
44 struct ConverterData;
46 // ============================================================================
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;
55 // ============================================================================
57 class ConverterRoot
59 public:
60 explicit ConverterRoot(
61 ::oox::core::XmlFilterBase& rFilter,
62 ChartConverter& rChartConverter,
63 const ChartSpaceModel& rChartModel,
64 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& rxChartDoc,
65 const ::com::sun::star::awt::Size& rChartSize );
66 virtual ~ConverterRoot();
68 /** Creates an instance for the passed service name, using the process service factory. */
69 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
70 createInstance( const OUString& rServiceName ) const;
71 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
72 getComponentContext() const;
74 protected:
75 /** Returns the filter object of the imported/exported document. */
76 ::oox::core::XmlFilterBase& getFilter() const;
77 /** Returns the chart converter. */
78 ChartConverter* getChartConverter() const;
79 /** Returns the API chart document model. */
80 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >
81 getChartDocument() const;
82 /** Returns the position and size of the chart shape in 1/100 mm. */
83 const ::com::sun::star::awt::Size& getChartSize() const;
84 /** Returns the object formatter. */
85 ObjectFormatter& getFormatter() const;
87 /** Registers a title object and its layout data, needed for conversion of
88 the title position using the old Chart1 API. */
89 void registerTitleLayout(
90 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >& rxTitle,
91 const ModelRef< LayoutModel >& rxLayout, ObjectType eObjType,
92 sal_Int32 nMainIdx = -1, sal_Int32 nSubIdx = -1 );
93 /** Converts the positions of the main title and all axis titles. */
94 void convertTitlePositions();
96 private:
97 ::boost::shared_ptr< ConverterData > mxData;
100 // ============================================================================
102 /** Base class of all converter classes. Holds a reference to a model structure
103 of the specified type.
105 template< typename ModelType >
106 class ConverterBase : public ConverterRoot
108 public:
109 inline const ModelType& getModel() const { return mrModel; }
111 protected:
112 inline explicit ConverterBase( const ConverterRoot& rParent, ModelType& rModel ) :
113 ConverterRoot( rParent ), mrModel( rModel ) {}
114 virtual ~ConverterBase() {}
116 protected:
117 ModelType& mrModel;
120 // ============================================================================
122 /** A layout converter calculates positions and sizes for various chart objects.
124 class LayoutConverter : public ConverterBase< LayoutModel >
126 public:
127 explicit LayoutConverter( const ConverterRoot& rParent, LayoutModel& rModel );
128 virtual ~LayoutConverter();
130 /** Tries to calculate the absolute position and size from the contained
131 OOXML layout model. Returns true, if returned rectangle is valid. */
132 bool calcAbsRectangle( ::com::sun::star::awt::Rectangle& orRect ) const;
134 /** Tries to set the position and size from the contained OOXML layout model.
135 Returns true, if a manual position and size could be calculated. */
136 bool convertFromModel( PropertySet& rPropSet );
138 /** Tries to set the position from the contained OOXML layout model.
139 Returns true, if a manual position could be calculated. */
140 bool convertFromModel(
141 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
142 double fRotationAngle );
145 // ============================================================================
147 } // namespace chart
148 } // namespace drawingml
149 } // namespace oox
151 #endif
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */