Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / drawingml / drawingmltypes.hxx
blob0b1ea4be7c72636522589ce00323f4d1a74562f9
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 INCLUDED_OOX_DRAWINGML_DRAWINGMLTYPES_HXX
21 #define INCLUDED_OOX_DRAWINGML_DRAWINGMLTYPES_HXX
23 #include <memory>
25 #include <com/sun/star/awt/Point.hpp>
26 #include <com/sun/star/awt/Size.hpp>
27 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
28 #include <com/sun/star/geometry/IntegerRectangle2D.hpp>
29 #include <com/sun/star/style/ParagraphAdjust.hpp>
30 #include <com/sun/star/style/TabAlign.hpp>
31 #include <com/sun/star/uno/Reference.hxx>
32 #include <oox/dllapi.h>
33 #include <oox/helper/helper.hxx>
34 #include <rtl/ustring.hxx>
35 #include <sal/types.h>
37 namespace com { namespace sun { namespace star {
38 namespace drawing { struct Hatch; }
39 namespace xml { namespace sax { class XFastAttributeList; } }
40 } } }
42 namespace oox {
43 namespace drawingml {
46 const sal_Int32 PER_PERCENT = 1000;
47 const sal_Int32 MAX_PERCENT = 100 * PER_PERCENT;
49 const sal_Int32 PER_DEGREE = 60000;
50 const sal_Int32 MAX_DEGREE = 360 * PER_DEGREE;
53 struct LineProperties;
54 typedef std::shared_ptr< LineProperties > LinePropertiesPtr;
56 struct FillProperties;
57 typedef std::shared_ptr< FillProperties > FillPropertiesPtr;
59 struct GraphicProperties;
60 typedef std::shared_ptr< GraphicProperties > GraphicPropertiesPtr;
62 struct Shape3DProperties;
63 typedef std::shared_ptr< Shape3DProperties > Shape3DPropertiesPtr;
65 struct TextCharacterProperties;
66 typedef std::shared_ptr< TextCharacterProperties > TextCharacterPropertiesPtr;
68 struct EffectProperties;
69 typedef std::shared_ptr< EffectProperties > EffectPropertiesPtr;
71 class TextBody;
72 typedef std::shared_ptr< TextBody > TextBodyPtr;
74 class TextListStyle;
75 typedef std::shared_ptr< TextListStyle > TextListStylePtr;
77 class Shape;
78 typedef std::shared_ptr< Shape > ShapePtr;
80 class Theme;
81 typedef std::shared_ptr< Theme > ThemePtr;
84 namespace table {
86 class TableProperties;
87 typedef std::shared_ptr< TableProperties > TablePropertiesPtr;
89 } // namespace table
92 /** converts the attributes from an CT_TLPoint into an awt Point with 1/1000% */
93 css::awt::Point GetPointPercent( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs );
96 /** converts the attributes from an CT_Size2D into an awt Size with 1/100th mm */
97 css::awt::Size GetSize2D( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
99 /** converts the attributes from a CT_RelativeRect to an IntegerRectangle2D */
100 css::geometry::IntegerRectangle2D GetRelativeRect( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
102 /** converts EMUs into 1/100th mmm */
103 sal_Int32 GetCoordinate( sal_Int32 nValue );
105 /** converts an emu string into 1/100th mmm */
106 sal_Int32 GetCoordinate( const OUString& sValue );
108 /** converts a ST_Percentage % string into 1/1000th of % */
109 sal_Int32 GetPercent( const OUString& sValue );
111 /** Converts a ST_PositiveFixedPercentage to a float. 1.0 == 100% */
112 double GetPositiveFixedPercentage( const OUString& sValue );
114 /** converts the ST_TextFontSize to point */
115 float GetTextSize( const OUString& rValue );
117 /** converts the ST_TextSpacingPoint to 1/100mm */
118 sal_Int32 GetTextSpacingPoint( const OUString& sValue );
119 sal_Int32 GetTextSpacingPoint( const sal_Int32 nValue );
121 /** */
122 css::style::TabAlign GetTabAlign( ::sal_Int32 aToken );
124 float GetFontHeight( sal_Int32 nHeight );
126 sal_Int16 GetFontUnderline( sal_Int32 nToken );
128 sal_Int16 GetFontStrikeout( sal_Int32 nToken );
130 sal_Int16 GetCaseMap( sal_Int32 nToken );
132 /** converts a paragraph align to a ParaAdjust */
133 css::style::ParagraphAdjust GetParaAdjust( sal_Int32 nAlign );
135 // Converts vertical adjust tokens to a TextVerticalAdjust item
136 css::drawing::TextVerticalAdjust GetTextVerticalAdjust( sal_Int32 nToken );
138 // Converts a TextVerticalAdjust item to string value appearing in ooxml
139 OOX_DLLPUBLIC const char* GetTextVerticalAdjust( css::drawing::TextVerticalAdjust eAdjust );
141 // Converts a Hatch object to an ooxml pattern.
142 const char* GetHatchPattern( const css::drawing::Hatch& rHatch );
145 // CT_IndexRange
146 struct IndexRange {
147 sal_Int32 start;
148 sal_Int32 end;
151 /** retrieve the content of CT_IndexRange */
152 IndexRange GetIndexRange( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
155 const sal_Int32 EMU_PER_HMM = 360; /// 360 EMUs per 1/100 mm.
156 const sal_Int32 EMU_PER_PT = 12700;
158 /** Converts the passed 32-bit integer value from 1/100 mm to EMUs. */
159 inline sal_Int64 convertHmmToEmu( sal_Int32 nValue )
161 return static_cast< sal_Int64 >( nValue ) * EMU_PER_HMM;
164 /** Converts the passed 64-bit integer value from EMUs to 1/100 mm. */
165 inline sal_Int32 convertEmuToHmm( sal_Int64 nValue )
167 sal_Int32 nCorrection = (nValue > 0 ? 1 : -1) * EMU_PER_HMM / 2; // So that the implicit floor will round.
168 return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + nCorrection) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32 );
171 /** Converts the passed 64-bit integer value from EMUs to Points. */
172 inline float convertEmuToPoints( sal_Int64 nValue )
174 return (float) nValue / EMU_PER_PT;
177 /** A structure for a point with 64-bit integer components. */
178 struct EmuPoint
180 sal_Int64 X;
181 sal_Int64 Y;
183 EmuPoint() : X( 0 ), Y( 0 ) {}
184 explicit EmuPoint( sal_Int64 nX, sal_Int64 nY ) : X( nX ), Y( nY ) {}
188 /** A structure for a size with 64-bit integer components. */
189 struct EmuSize
191 sal_Int64 Width;
192 sal_Int64 Height;
194 EmuSize() : Width( 0 ), Height( 0 ) {}
195 explicit EmuSize( sal_Int64 nWidth, sal_Int64 nHeight ) : Width( nWidth ), Height( nHeight ) {}
199 /** A structure for a rectangle with 64-bit integer components. */
200 struct EmuRectangle : public EmuPoint, public EmuSize
202 EmuRectangle() {}
203 explicit EmuRectangle( sal_Int64 nX, sal_Int64 nY, sal_Int64 nWidth, sal_Int64 nHeight ) : EmuPoint( nX, nY ), EmuSize( nWidth, nHeight ) {}
205 void setPos( const EmuPoint& rPos ) { static_cast< EmuPoint& >( *this ) = rPos; }
206 void setSize( const EmuSize& rSize ) { static_cast< EmuSize& >( *this ) = rSize; }
210 } // namespace drawingml
211 } // namespace oox
213 #endif
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */