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
;
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;
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;
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 default position and size of the chart shape in 1/100 mm. */
89 static css::awt::Size
getDefaultPageSize() { return css::awt::Size(16000, 9000); }
90 /** Returns the object formatter. */
91 ObjectFormatter
& getFormatter() const;
93 /** Registers a title object and its layout data, needed for conversion of
94 the title position using the old Chart1 API. */
95 void registerTitleLayout(
96 const css::uno::Reference
< css::chart2::XTitle
>& rxTitle
,
97 const ModelRef
< LayoutModel
>& rxLayout
, ObjectType eObjType
,
98 sal_Int32 nMainIdx
, sal_Int32 nSubIdx
);
99 /** Converts the positions of the main title and all axis titles. */
100 void convertTitlePositions();
103 std::shared_ptr
< ConverterData
> mxData
;
107 /** Base class of all converter classes. Holds a reference to a model structure
108 of the specified type.
110 template< typename ModelType
>
111 class ConverterBase
: public ConverterRoot
114 const ModelType
& getModel() const { return mrModel
; }
117 explicit ConverterBase( const ConverterRoot
& rParent
, ModelType
& rModel
) :
118 ConverterRoot( rParent
), mrModel( rModel
) {}
119 virtual ~ConverterBase() override
{}
126 /** A layout converter calculates positions and sizes for various chart objects.
128 class LayoutConverter
: public ConverterBase
< LayoutModel
>
131 explicit LayoutConverter( const ConverterRoot
& rParent
, LayoutModel
& rModel
);
132 virtual ~LayoutConverter() override
;
134 /** Tries to calculate the absolute position and size from the contained
135 OOXML layout model. Returns true, if returned rectangle is valid. */
136 bool calcAbsRectangle( css::awt::Rectangle
& orRect
) const;
138 /** Tries to set the position and size from the contained OOXML layout model.
139 Returns true, if a manual position and size could be calculated. */
140 bool convertFromModel( PropertySet
& rPropSet
);
142 /** Tries to set the position from the contained OOXML layout model. */
143 void convertFromModel(
144 const css::uno::Reference
< css::drawing::XShape
>& rxShape
,
145 double fRotationAngle
);
146 bool getAutoLayout() const {return mrModel
.mbAutoLayout
;}
151 } // namespace drawingml
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */