Update ooo320-m1
[ooovba.git] / oox / source / drawingml / textfieldcontext.cxx
blobe7044f098f3d6ca648775842bb07c570f10ea6dd
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: textfieldcontext.cxx,v $
10 * $Revision: 1.6 $
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/textfieldcontext.hxx"
32 #include "oox/drawingml/textparagraphpropertiescontext.hxx"
33 #include "oox/drawingml/textcharacterpropertiescontext.hxx"
34 #include "oox/drawingml/textfield.hxx"
35 #include "oox/core/namespaces.hxx"
36 #include "tokens.hxx"
38 using ::rtl::OUString;
39 using namespace ::oox::core;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::xml::sax;
43 namespace oox { namespace drawingml {
45 TextFieldContext::TextFieldContext( ContextHandler& rParent,
46 const Reference< XFastAttributeList >& rXAttributes,
47 TextField& rTextField)
48 : ContextHandler( rParent )
49 , mrTextField( rTextField )
50 , mbIsInText( false )
52 mrTextField.setUuid( rXAttributes->getOptionalValue( XML_id ) );
53 mrTextField.setType( rXAttributes->getOptionalValue( XML_type ) );
56 void TextFieldContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
58 if( aElementToken == (NMSP_DRAWINGML|XML_t) )
60 mbIsInText = false;
64 void TextFieldContext::characters( const OUString& aChars ) throw (SAXException, RuntimeException)
66 if( mbIsInText )
68 mrTextField.getText() += aChars;
72 Reference< XFastContextHandler > TextFieldContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
73 throw (SAXException, RuntimeException)
75 Reference< XFastContextHandler > xRet;
76 switch( aElementToken )
78 case NMSP_DRAWINGML|XML_rPr:
79 xRet.set( new TextCharacterPropertiesContext( *this, xAttribs, mrTextField.getTextCharacterProperties() ) );
80 break;
81 case NMSP_DRAWINGML|XML_pPr:
82 xRet.set( new TextParagraphPropertiesContext( *this, xAttribs, mrTextField.getTextParagraphProperties() ) );
83 break;
84 case NMSP_DRAWINGML|XML_t:
85 mbIsInText = true;
86 break;
88 if ( !xRet.is() )
89 xRet.set( this );
90 return xRet;
94 } }