update dev300-m58
[ooovba.git] / oox / source / drawingml / textbodypropertiescontext.cxx
blob24ea459a3b919c8ac882306120a61bd061202023
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textbodypropertiescontext.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/textbodypropertiescontext.hxx"
33 #include <com/sun/star/text/ControlCharacter.hpp>
34 #include "oox/drawingml/textbodyproperties.hxx"
35 #include "oox/drawingml/drawingmltypes.hxx"
36 #include "oox/helper/attributelist.hxx"
37 #include "oox/helper/propertymap.hxx"
38 #include "oox/core/namespaces.hxx"
39 #include "properties.hxx"
40 #include "tokens.hxx"
42 using ::rtl::OUString;
43 using namespace ::oox::core;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::text;
46 using namespace ::com::sun::star::xml::sax;
48 namespace oox { namespace drawingml {
50 // --------------------------------------------------------------------
52 // CT_TextBodyProperties
53 TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent,
54 const Reference< XFastAttributeList >& xAttributes, TextBodyProperties& rTextBodyProp )
55 : ContextHandler( rParent )
56 , mrTextBodyProp( rTextBodyProp )
58 AttributeList aAttribs( xAttributes );
60 // ST_TextWrappingType
61 sal_Int32 nWrappingType = aAttribs.getToken( XML_wrap, XML_square );
62 mrTextBodyProp.maPropertyMap[ PROP_TextWordWrap ] <<= (nWrappingType == XML_square);
64 // ST_Coordinate
65 OUString sValue;
66 sValue = xAttributes->getOptionalValue( XML_lIns );
67 sal_Int32 nLeftInset = ( sValue.getLength() != 0 ? GetCoordinate( sValue ) : 91440 / 360 );
68 mrTextBodyProp.maPropertyMap[ PROP_TextLeftDistance ] <<= static_cast< sal_Int32 >( nLeftInset );
70 sValue = xAttributes->getOptionalValue( XML_tIns );
71 sal_Int32 nTopInset = ( sValue.getLength() != 0 ? GetCoordinate( sValue ) : 91440 / 360 );
72 mrTextBodyProp.maPropertyMap[ PROP_TextUpperDistance ] <<= static_cast< sal_Int32 >( nTopInset );
74 sValue = xAttributes->getOptionalValue( XML_rIns );
75 sal_Int32 nRightInset = ( sValue.getLength() != 0 ? GetCoordinate( sValue ) : 91440 / 360 );
76 mrTextBodyProp.maPropertyMap[ PROP_TextRightDistance ] <<= static_cast< sal_Int32 >( nRightInset );
78 sValue = xAttributes->getOptionalValue( XML_bIns );
79 sal_Int32 nBottonInset = ( sValue.getLength() != 0 ? GetCoordinate( sValue ) : 45720 / 360 );
80 mrTextBodyProp.maPropertyMap[ PROP_TextLowerDistance ] <<= static_cast< sal_Int32 >( nBottonInset );
83 // ST_TextAnchoringType
84 // sal_Int32 nAnchoringType = xAttributes->getOptionalValueToken( XML_anchor, XML_t );
86 // bool bAnchorCenter = aAttribs.getBool( XML_anchorCtr, false );
88 // bool bCompatLineSpacing = aAttribs.getBool( XML_compatLnSpc, false );
89 // bool bForceAA = aAttribs.getBool( XML_forceAA, false );
90 // bool bFromWordArt = aAttribs.getBool( XML_fromWordArt, false );
92 // ST_TextHorzOverflowType
93 // sal_Int32 nHorzOverflow = xAttributes->getOptionalValueToken( XML_horzOverflow, XML_overflow );
94 // ST_TextVertOverflowType
95 // sal_Int32 nVertOverflow = xAttributes->getOptionalValueToken( XML_vertOverflow, XML_overflow );
97 // ST_TextColumnCount
98 // sal_Int32 nNumCol = aAttribs.getInteger( XML_numCol, 1 );
100 // ST_Angle
101 mrTextBodyProp.moRotation = aAttribs.getInteger( XML_rot );
103 // bool bRtlCol = aAttribs.getBool( XML_rtlCol, false );
104 // ST_PositiveCoordinate
105 // sal_Int32 nSpcCol = aAttribs.getInteger( XML_spcCol, 0 );
106 // bool bSpcFirstLastPara = aAttribs.getBool( XML_spcFirstLastPara, 0 );
107 // bool bUpRight = aAttribs.getBool( XML_upright, 0 );
109 // ST_TextVerticalType
110 mrTextBodyProp.moVert = aAttribs.getToken( XML_vert );
113 // --------------------------------------------------------------------
115 void TextBodyPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
119 // --------------------------------------------------------------------
121 Reference< XFastContextHandler > TextBodyPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /*xAttributes*/) throw (SAXException, RuntimeException)
123 Reference< XFastContextHandler > xRet;
124 switch( aElementToken )
126 // Sequence
127 case NMSP_DRAWINGML|XML_prstTxWarp: // CT_PresetTextShape
128 case NMSP_DRAWINGML|XML_prot: // CT_TextProtectionProperty
129 break;
131 // EG_TextAutofit
132 case NMSP_DRAWINGML|XML_noAutofit:
133 mrTextBodyProp.maPropertyMap[ PROP_TextAutoGrowHeight ] <<= false; // CT_TextNoAutofit
134 break;
135 case NMSP_DRAWINGML|XML_normAutofit: // CT_TextNormalAutofit
136 case NMSP_DRAWINGML|XML_spAutoFit:
137 mrTextBodyProp.maPropertyMap[ PROP_TextAutoGrowHeight ] <<= true;
138 break;
140 case NMSP_DRAWINGML|XML_scene3d: // CT_Scene3D
142 // EG_Text3D
143 case NMSP_DRAWINGML|XML_sp3d: // CT_Shape3D
144 case NMSP_DRAWINGML|XML_flatTx: // CT_FlatText
146 break;
149 return xRet;
152 // --------------------------------------------------------------------