1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
; }
35 namespace oox
{ namespace core
{
44 struct ChartSpaceModel
;
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;
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;
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();
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
110 const ModelType
& getModel() const { return mrModel
; }
113 explicit ConverterBase( const ConverterRoot
& rParent
, ModelType
& rModel
) :
114 ConverterRoot( rParent
), mrModel( rModel
) {}
115 virtual ~ConverterBase() {}
123 /** A layout converter calculates positions and sizes for various chart objects.
125 class LayoutConverter
: public ConverterBase
< LayoutModel
>
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
;}
150 } // namespace drawingml
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */