fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / textbodypropertiescontext.cxx
blobcc274377c46645607e6bfa3434eab2ecf7442759
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 #include "drawingml/textbodypropertiescontext.hxx"
22 #include <com/sun/star/text/WritingMode.hpp>
23 #include <com/sun/star/drawing/TextFitToSizeType.hpp>
24 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
25 #include "drawingml/textbodyproperties.hxx"
26 #include "oox/drawingml/drawingmltypes.hxx"
27 #include "oox/helper/attributelist.hxx"
28 #include "oox/helper/propertymap.hxx"
30 using namespace ::oox::core;
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::drawing;
33 using namespace ::com::sun::star::text;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::xml::sax;
37 namespace oox { namespace drawingml {
39 // CT_TextBodyProperties
40 TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper& rParent,
41 const AttributeList& rAttribs, TextBodyProperties& rTextBodyProp )
42 : ContextHandler2( rParent )
43 , mrTextBodyProp( rTextBodyProp )
45 // ST_TextWrappingType
46 sal_Int32 nWrappingType = rAttribs.getToken( XML_wrap, XML_square );
47 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWordWrap, nWrappingType == XML_square );
49 // ST_Coordinate
50 OUString sValue;
51 sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
52 for( sal_Int32 i = 0; i < ( sal_Int32 )( sizeof( aIns ) / sizeof( sal_Int32 ) ); i++)
54 sValue = rAttribs.getString( aIns[i] ).get();
55 if( !sValue.isEmpty() )
56 mrTextBodyProp.moInsets[i] = GetCoordinate( sValue );
59 mrTextBodyProp.mbAnchorCtr = rAttribs.getBool( XML_anchorCtr, false );
60 if( mrTextBodyProp.mbAnchorCtr )
61 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextHorizontalAdjust, TextHorizontalAdjust_CENTER );
63 // bool bCompatLineSpacing = rAttribs.getBool( XML_compatLnSpc, false );
64 // bool bForceAA = rAttribs.getBool( XML_forceAA, false );
65 // bool bFromWordArt = rAttribs.getBool( XML_fromWordArt, false );
67 // ST_TextHorzOverflowType
68 // sal_Int32 nHorzOverflow = rAttribs.getToken( XML_horzOverflow, XML_overflow );
69 // ST_TextVertOverflowType
70 // sal_Int32 nVertOverflow = rAttribs.getToken( XML_vertOverflow, XML_overflow );
72 // ST_TextColumnCount
73 // sal_Int32 nNumCol = rAttribs.getInteger( XML_numCol, 1 );
75 // ST_Angle
76 mrTextBodyProp.moRotation = rAttribs.getInteger( XML_rot );
78 // bool bRtlCol = rAttribs.getBool( XML_rtlCol, false );
79 // ST_PositiveCoordinate
80 // sal_Int32 nSpcCol = rAttribs.getInteger( XML_spcCol, 0 );
81 // bool bSpcFirstLastPara = rAttribs.getBool( XML_spcFirstLastPara, 0 );
82 // bool bUpRight = rAttribs.getBool( XML_upright, 0 );
84 // ST_TextVerticalType
85 if( rAttribs.hasAttribute( XML_vert ) ) {
86 mrTextBodyProp.moVert = rAttribs.getToken( XML_vert );
87 sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz );
88 if (tVert == XML_vert || tVert == XML_eaVert || tVert == XML_mongolianVert)
89 mrTextBodyProp.moRotation = 5400000;
90 else if (tVert == XML_vert270)
91 mrTextBodyProp.moRotation = 5400000 * 3;
92 else {
93 bool bRtl = rAttribs.getBool( XML_rtl, false );
94 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWritingMode,
95 ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB ));
99 // ST_TextAnchoringType
100 if( rAttribs.hasAttribute( XML_anchor ) )
102 mrTextBodyProp.meVA = GetTextVerticalAdjust( rAttribs.getToken( XML_anchor, XML_t ) );
103 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextVerticalAdjust, mrTextBodyProp.meVA);
106 // Push defaults
107 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false);
108 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, drawing::TextFitToSizeType_NONE);
111 ContextHandlerRef TextBodyPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& /*rAttribs*/)
113 switch( aElementToken )
115 // Sequence
116 case A_TOKEN( prstTxWarp ): // CT_PresetTextShape
117 case A_TOKEN( prot ): // CT_TextProtectionProperty
118 break;
120 // EG_TextAutofit
121 case A_TOKEN( noAutofit ):
122 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false); // CT_TextNoAutofit
123 break;
124 case A_TOKEN( normAutofit ): // CT_TextNormalAutofit
125 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, TextFitToSizeType_AUTOFIT);
126 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false);
127 break;
128 case A_TOKEN( spAutoFit ):
130 const sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz );
131 if( tVert != XML_vert && tVert != XML_eaVert && tVert != XML_vert270 && tVert != XML_mongolianVert )
132 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, true);
134 break;
136 case A_TOKEN( scene3d ): // CT_Scene3D
138 // EG_Text3D
139 case A_TOKEN( sp3d ): // CT_Shape3D
140 case A_TOKEN( flatTx ): // CT_FlatText
142 break;
145 return 0;
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */