LibreOffice Module oox (master)  1
drawingmltypes.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_DRAWINGMLTYPES_HXX
21 #define INCLUDED_OOX_DRAWINGML_DRAWINGMLTYPES_HXX
22 
23 #include <memory>
24 #include <string_view>
25 
26 #include <com/sun/star/awt/Point.hpp>
27 #include <com/sun/star/awt/Size.hpp>
28 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
29 #include <com/sun/star/geometry/IntegerRectangle2D.hpp>
30 #include <com/sun/star/style/ParagraphAdjust.hpp>
31 #include <com/sun/star/style/TabAlign.hpp>
32 #include <com/sun/star/uno/Reference.hxx>
33 #include <o3tl/unit_conversion.hxx>
34 #include <oox/dllapi.h>
35 #include <oox/helper/helper.hxx>
36 #include <rtl/ustring.hxx>
37 #include <sal/types.h>
38 
39 namespace com::sun::star {
40  namespace drawing { struct Hatch; }
41  namespace xml::sax { class XFastAttributeList; }
42 }
43 
44 namespace oox::drawingml {
45 
46 
47 const sal_Int32 PER_PERCENT = 1000;
48 const sal_Int32 MAX_PERCENT = 100 * PER_PERCENT;
49 
50 const sal_Int32 PER_DEGREE = 60000;
51 const sal_Int32 MAX_DEGREE = 360 * PER_DEGREE;
52 
53 
55 typedef std::shared_ptr< LineProperties > LinePropertiesPtr;
56 
58 typedef std::shared_ptr< FillProperties > FillPropertiesPtr;
59 
61 typedef std::shared_ptr< GraphicProperties > GraphicPropertiesPtr;
62 
64 typedef std::shared_ptr< Shape3DProperties > Shape3DPropertiesPtr;
65 
67 typedef std::shared_ptr< TextCharacterProperties > TextCharacterPropertiesPtr;
68 
70 typedef std::shared_ptr< EffectProperties > EffectPropertiesPtr;
71 
72 class TextBody;
73 typedef std::shared_ptr< TextBody > TextBodyPtr;
74 
76 typedef std::shared_ptr< TextListStyle > TextListStylePtr;
77 
78 class Shape;
79 typedef std::shared_ptr< Shape > ShapePtr;
80 
81 class Theme;
82 typedef std::shared_ptr< Theme > ThemePtr;
83 
84 
85 namespace table {
86 
88 typedef std::shared_ptr< TableProperties > TablePropertiesPtr;
89 
90 } // namespace table
91 
92 
94 css::awt::Point GetPointPercent( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs );
95 
96 
98 css::awt::Size GetSize2D( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
99 
101 css::geometry::IntegerRectangle2D GetRelativeRect( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
102 
104 sal_Int32 GetCoordinate( sal_Int32 nValue );
105 
107 sal_Int32 GetCoordinate( std::u16string_view sValue );
108 
110 sal_Int32 GetPointFromCoordinate( sal_Int32 nValue );
111 
113 sal_Int32 GetPercent( std::u16string_view sValue );
114 
116 double GetPositiveFixedPercentage( const OUString& sValue );
117 
119 float GetTextSize( std::u16string_view rValue );
120 
122 sal_Int32 GetTextSpacingPoint( std::u16string_view sValue );
123 sal_Int32 GetTextSpacingPoint( const sal_Int32 nValue );
124 
126 css::style::TabAlign GetTabAlign( ::sal_Int32 aToken );
127 
128 float GetFontHeight( sal_Int32 nHeight );
129 
130 sal_Int16 GetFontUnderline( sal_Int32 nToken );
131 
132 sal_Int16 GetFontStrikeout( sal_Int32 nToken );
133 
134 sal_Int16 GetCaseMap( sal_Int32 nToken );
135 
137 css::style::ParagraphAdjust GetParaAdjust( sal_Int32 nAlign );
138 
139 // Converts vertical adjust tokens to a TextVerticalAdjust item
140 css::drawing::TextVerticalAdjust GetTextVerticalAdjust( sal_Int32 nToken );
141 
142 // Converts a TextVerticalAdjust item to string value appearing in ooxml
143 OOX_DLLPUBLIC const char* GetTextVerticalAdjust( css::drawing::TextVerticalAdjust eAdjust );
144 
145 // Converts a Hatch object to an ooxml pattern.
146 const char* GetHatchPattern( const css::drawing::Hatch& rHatch );
147 
148 
149 // CT_IndexRange
150 struct IndexRange {
151  sal_Int32 start;
152  sal_Int32 end;
153 };
154 
156 IndexRange GetIndexRange( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
157 
164 inline OString calcRotationValue(sal_Int32 nRotation)
165 {
166  if (nRotation > 18000) // 180 degree
167  {
168  nRotation -= 36000;
169  }
170  nRotation *= -600;
171  return OString::number(nRotation);
172 }
173 
175 inline sal_Int64 convertHmmToEmu( sal_Int32 nValue )
176 {
178 }
179 
181 inline sal_Int32 convertEmuToHmm( sal_Int64 nValue )
182 {
183  return getLimitedValue<sal_Int32, sal_Int64>(
185  SAL_MAX_INT32);
186 }
187 
189 inline float convertEmuToPoints( sal_Int64 nValue )
190 {
191  return o3tl::convert<double>(nValue, o3tl::Length::emu, o3tl::Length::pt);
192 }
193 
195 inline double convertPointToMms(double fValue)
196 {
198 }
199 
201 struct EmuPoint
202 {
203  sal_Int64 X;
204  sal_Int64 Y;
205 
206  EmuPoint() : X( 0 ), Y( 0 ) {}
207  explicit EmuPoint( sal_Int64 nX, sal_Int64 nY ) : X( nX ), Y( nY ) {}
208 };
209 
210 
212 struct EmuSize
213 {
214  sal_Int64 Width;
215  sal_Int64 Height;
216 
217  EmuSize() : Width( 0 ), Height( 0 ) {}
218  explicit EmuSize( sal_Int64 nWidth, sal_Int64 nHeight ) : Width( nWidth ), Height( nHeight ) {}
219 };
220 
221 
223 struct EmuRectangle : public EmuPoint, public EmuSize
224 {
226  explicit EmuRectangle( sal_Int64 nX, sal_Int64 nY, sal_Int64 nWidth, sal_Int64 nHeight ) : EmuPoint( nX, nY ), EmuSize( nWidth, nHeight ) {}
227 
228  void setPos( const EmuPoint& rPos ) { static_cast< EmuPoint& >( *this ) = rPos; }
229  void setSize( const EmuSize& rSize ) { static_cast< EmuSize& >( *this ) = rSize; }
230 };
231 
232 
233 } // namespace oox::drawingml
234 
235 #endif
236 
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 convertEmuToHmm(sal_Int64 nValue)
Converts the passed 64-bit integer value from EMUs to 1/100 mm.
std::shared_ptr< FillProperties > FillPropertiesPtr
sal_Int16 GetFontStrikeout(sal_Int32 nToken)
sal_Int32 GetTextSpacingPoint(std::u16string_view sValue)
converts the ST_TextSpacingPoint to 1/100mm
const sal_Int32 PER_DEGREE
float convertEmuToPoints(sal_Int64 nValue)
Converts the passed 64-bit integer value from EMUs to Points.
TextVerticalAdjust GetTextVerticalAdjust(sal_Int32 nToken)
const sal_Int32 PER_PERCENT
std::shared_ptr< GraphicProperties > GraphicPropertiesPtr
std::shared_ptr< TableProperties > TablePropertiesPtr
EmuPoint(sal_Int64 nX, sal_Int64 nY)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
exports com.sun.star. table
A structure for a size with 64-bit integer components.
std::shared_ptr< TextCharacterProperties > TextCharacterPropertiesPtr
EmuRectangle(sal_Int64 nX, sal_Int64 nY, sal_Int64 nWidth, sal_Int64 nHeight)
sal_Int32 GetPercent(std::u16string_view sValue)
converts a ST_Percentage % string into 1/1000th of %
exports com.sun.star. drawing
void setPos(const EmuPoint &rPos)
float GetFontHeight(sal_Int32 nHeight)
A structure for a point with 64-bit integer components.
double GetPositiveFixedPercentage(const OUString &sValue)
Converts a ST_PositiveFixedPercentage to a float.
#define SAL_MAX_INT32
double convertPointToMms(double fValue)
Converts the passed double value from points to mm.
OString calcRotationValue(sal_Int32 nRotation)
nRotation is a 100th of a degree and the return value is in a 60,000th of a degree ...
const sal_Int32 MAX_PERCENT
awt::Size GetSize2D(const Reference< XFastAttributeList > &xAttribs)
converts the attributes from a CT_Size2D into an awt Size with 1/100thmm
sal_Int64 convertHmmToEmu(sal_Int32 nValue)
Converts the passed 32-bit integer value from 1/100 mm to EMUs.
EmuSize(sal_Int64 nWidth, sal_Int64 nHeight)
#define SAL_MIN_INT32
const sal_Int32 MAX_DEGREE
std::shared_ptr< EffectProperties > EffectPropertiesPtr
std::shared_ptr< TextBody > TextBodyPtr
IntegerRectangle2D GetRelativeRect(const Reference< XFastAttributeList > &xAttribs)
converts the attributes from a CT_RelativeRect to an IntegerRectangle2D
sal_Int32 GetPointFromCoordinate(sal_Int32 nValue)
converts 1/100mm to EMU
std::shared_ptr< LineProperties > LinePropertiesPtr
std::shared_ptr< TextListStyle > TextListStylePtr
std::shared_ptr< Shape3DProperties > Shape3DPropertiesPtr
sal_Int32 GetCoordinate(sal_Int32 nValue)
converts EMUs into 1/100th mmm
const char * GetHatchPattern(const drawing::Hatch &rHatch)
ParagraphAdjust GetParaAdjust(sal_Int32 nAlign)
converts a paragraph align to a ParaAdjust
awt::Point GetPointPercent(const Reference< XFastAttributeList > &xAttribs)
converts the attributes from a CT_TLPoint into an awt Point with 1/1000%
sal_Int16 GetFontUnderline(sal_Int32 nToken)
A structure for a rectangle with 64-bit integer components.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
IndexRange GetIndexRange(const Reference< XFastAttributeList > &xAttributes)
std::shared_ptr< Shape > ShapePtr
TabAlign GetTabAlign(sal_Int32 aToken)
void setSize(const EmuSize &rSize)
std::shared_ptr< Theme > ThemePtr
float GetTextSize(std::u16string_view sValue)
converts the ST_TextFontSize to point
sal_Int16 GetCaseMap(sal_Int32 nToken)