LibreOffice Module oox (master)  1
converterbase.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
21 #define INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
22 
24 
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; }
32 }
33 namespace oox::core { class XmlFilterBase; }
34 
35 namespace oox::drawingml::chart {
36 
37 class ChartConverter;
38 struct ChartSpaceModel;
39 struct ConverterData;
40 
41 
42 const sal_Int32 API_PRIM_AXESSET = 0;
43 const sal_Int32 API_SECN_AXESSET = 1;
44 
45 const sal_Int32 API_X_AXIS = 0;
46 const sal_Int32 API_Y_AXIS = 1;
47 const sal_Int32 API_Z_AXIS = 2;
48 
49 
51 {
52 public:
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();
60 
61  ConverterRoot(ConverterRoot const &) = default;
62  ConverterRoot(ConverterRoot &&) = default;
63  ConverterRoot & operator =(ConverterRoot const &) = default;
64  ConverterRoot & operator =(ConverterRoot &&) = default;
65 
67  css::uno::Reference< css::uno::XInterface >
68  createInstance( const OUString& rServiceName ) const;
69  css::uno::Reference< css::uno::XComponentContext > const &
70  getComponentContext() const;
71 
72 protected:
78  css::uno::Reference< css::chart2::XChartDocument > const &
79  getChartDocument() const;
81  const css::awt::Size& getChartSize() const;
83  static css::awt::Size getDefaultPageSize() { return css::awt::Size(16000, 9000); }
86 
90  const css::uno::Reference< css::chart2::XTitle >& rxTitle,
91  const ModelRef< LayoutModel >& rxLayout, ObjectType eObjType,
92  sal_Int32 nMainIdx, sal_Int32 nSubIdx );
94  void convertTitlePositions();
95 
96 private:
97  std::shared_ptr< ConverterData > mxData;
98 };
99 
100 
104 template< typename ModelType >
106 {
107 public:
108  const ModelType& getModel() const { return mrModel; }
109 
110 protected:
111  explicit ConverterBase( const ConverterRoot& rParent, ModelType& rModel ) :
112  ConverterRoot( rParent ), mrModel( rModel ) {}
113  virtual ~ConverterBase() override {}
114 
115 protected:
116  ModelType& mrModel;
117 };
118 
119 
122 class LayoutConverter final : public ConverterBase< LayoutModel >
123 {
124 public:
125  explicit LayoutConverter( const ConverterRoot& rParent, LayoutModel& rModel );
126  virtual ~LayoutConverter() override;
127 
130  bool calcAbsRectangle( css::awt::Rectangle& orRect ) const;
131 
134  bool convertFromModel( PropertySet& rPropSet );
135 
137  void convertFromModel(
138  const css::uno::Reference< css::drawing::XShape >& rxShape,
139  double fRotationAngle );
140  bool getAutoLayout() const {return mrModel.mbAutoLayout;}
141 };
142 
143 
144 } // namespace oox::drawingml::chart
145 
146 #endif
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool calcAbsRectangle(css::awt::Rectangle &orRect) const
Tries to calculate the absolute position and size from the contained OOXML layout model...
ConverterBase(const ConverterRoot &rParent, ModelType &rModel)
ConverterRoot & operator=(ConverterRoot const &)=default
void convertTitlePositions()
Converts the positions of the main title and all axis titles.
const sal_Int32 API_Y_AXIS
Base class of all converter classes.
ChartConverter & getChartConverter() const
Returns the chart converter.
exports com.sun.star. awt
ConverterRoot(::oox::core::XmlFilterBase &rFilter, ChartConverter &rChartConverter, const ChartSpaceModel &rChartModel, const css::uno::Reference< css::chart2::XChartDocument > &rxChartDoc, const css::awt::Size &rChartSize)
void registerTitleLayout(const css::uno::Reference< css::chart2::XTitle > &rxTitle, const ModelRef< LayoutModel > &rxLayout, ObjectType eObjType, sal_Int32 nMainIdx, sal_Int32 nSubIdx)
Registers a title object and its layout data, needed for conversion of the title position using the o...
css::uno::Reference< css::uno::XInterface > createInstance(const OUString &rServiceName) const
Creates an instance for the passed service name, using the process service factory.
LayoutConverter(const ConverterRoot &rParent, LayoutModel &rModel)
exports com.sun.star. chart2
ObjectType
Enumerates different object types for specific automatic formatting behaviour.
exports com.sun.star. drawing
const sal_Int32 API_X_AXIS
std::shared_ptr< ConverterData > mxData
const ModelType & getModel() const
css::uno::Reference< css::uno::XComponentContext > const & getComponentContext() const
const css::awt::Size & getChartSize() const
Returns the position and size of the chart shape in 1/100 mm.
A wrapper for a UNO property set.
Definition: propertyset.hxx:57
const sal_Int32 API_Z_AXIS
const sal_Int32 API_SECN_AXESSET
A layout converter calculates positions and sizes for various chart objects.
const sal_Int32 API_PRIM_AXESSET
bool mbAutoLayout
Layout target for plot area.
Definition: modelbase.hxx:116
::oox::core::XmlFilterBase & getFilter() const
Returns the filter object of the imported/exported document.
static css::awt::Size getDefaultPageSize()
Returns the default position and size of the chart shape in 1/100 mm.
css::uno::Reference< css::chart2::XChartDocument > const & getChartDocument() const
Returns the API chart document model.
bool convertFromModel(PropertySet &rPropSet)
Tries to set the position and size from the contained OOXML layout model.
ObjectFormatter & getFormatter() const
Returns the object formatter.