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/objectformatter.hxx>
25 namespace com::sun::star
{
26 namespace awt
{ struct Rectangle
; }
27 namespace awt
{ struct Size
; }
28 namespace chart2
{ class XChartDocument
; }
29 namespace chart2
{ class XTitle
; }
30 namespace drawing
{ class XShape
; }
31 namespace uno
{ class XComponentContext
; }
33 namespace oox::core
{ class XmlFilterBase
; }
35 namespace oox::drawingml::chart
{
38 struct ChartSpaceModel
;
42 const sal_Int32 API_PRIM_AXESSET
= 0;
43 const sal_Int32 API_SECN_AXESSET
= 1;
45 const sal_Int32 API_X_AXIS
= 0;
46 const sal_Int32 API_Y_AXIS
= 1;
47 const sal_Int32 API_Z_AXIS
= 2;
53 explicit ConverterRoot(
54 ::oox::core::XmlFilterBase
& rFilter
,
55 ChartConverter
& rChartConverter
,
56 const ChartSpaceModel
& rChartModel
,
57 const css::uno::Reference
< css::chart2::XChartDocument
>& rxChartDoc
,
58 const css::awt::Size
& rChartSize
);
59 virtual ~ConverterRoot();
61 ConverterRoot(ConverterRoot
const &) = default;
62 ConverterRoot(ConverterRoot
&&) = default;
63 ConverterRoot
& operator =(ConverterRoot
const &) = default;
64 ConverterRoot
& operator =(ConverterRoot
&&) = default;
66 /** Creates an instance for the passed service name, using the process service factory. */
67 css::uno::Reference
< css::uno::XInterface
>
68 createInstance( const OUString
& rServiceName
) const;
69 css::uno::Reference
< css::uno::XComponentContext
> const &
70 getComponentContext() const;
73 /** Returns the filter object of the imported/exported document. */
74 ::oox::core::XmlFilterBase
& getFilter() const;
75 /** Returns the chart converter. */
76 ChartConverter
& getChartConverter() const;
77 /** Returns the API chart document model. */
78 css::uno::Reference
< css::chart2::XChartDocument
> const &
79 getChartDocument() const;
80 /** Returns the position and size of the chart shape in 1/100 mm. */
81 const css::awt::Size
& getChartSize() const;
82 /** Returns the default position and size of the chart shape in 1/100 mm. */
83 static css::awt::Size
getDefaultPageSize() { return css::awt::Size(16000, 9000); }
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 css::uno::Reference
< css::chart2::XTitle
>& rxTitle
,
91 const ModelRef
< LayoutModel
>& rxLayout
, ObjectType eObjType
,
92 sal_Int32 nMainIdx
, sal_Int32 nSubIdx
);
93 /** Converts the positions of the main title and all axis titles. */
94 void convertTitlePositions();
97 std::shared_ptr
< ConverterData
> mxData
;
101 /** Base class of all converter classes. Holds a reference to a model structure
102 of the specified type.
104 template< typename ModelType
>
105 class ConverterBase
: public ConverterRoot
108 const ModelType
& getModel() const { return mrModel
; }
111 explicit ConverterBase( const ConverterRoot
& rParent
, ModelType
& rModel
) :
112 ConverterRoot( rParent
), mrModel( rModel
) {}
113 virtual ~ConverterBase() override
{}
120 /** A layout converter calculates positions and sizes for various chart objects.
122 class LayoutConverter final
: public ConverterBase
< LayoutModel
>
125 explicit LayoutConverter( const ConverterRoot
& rParent
, LayoutModel
& rModel
);
126 virtual ~LayoutConverter() override
;
128 /** Tries to calculate the absolute position and size from the contained
129 OOXML layout model. Returns true, if returned rectangle is valid. */
130 bool calcAbsRectangle( css::awt::Rectangle
& orRect
) const;
132 /** Tries to set the position and size from the contained OOXML layout model.
133 Returns true, if a manual position and size could be calculated. */
134 bool convertFromModel( PropertySet
& rPropSet
);
136 /** Tries to set the position from the contained OOXML layout model. */
137 void convertFromModel(
138 const css::uno::Reference
< css::drawing::XShape
>& rxShape
,
139 double fRotationAngle
);
140 bool getAutoLayout() const {return mrModel
.mbAutoLayout
;}
144 } // namespace oox::drawingml::chart
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */