1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "oox/drawingml/textfieldcontext.hxx"
25 #include "oox/drawingml/textparagraphpropertiescontext.hxx"
26 #include "oox/drawingml/textcharacterpropertiescontext.hxx"
27 #include "oox/drawingml/textfield.hxx"
28
29 using ::rtl::OUString;
30 using namespace ::oox::core;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::xml::sax;
33
34 namespace oox { namespace drawingml {
35
TextFieldContext(ContextHandler & rParent,const Reference<XFastAttributeList> & rXAttributes,TextField & rTextField)36 TextFieldContext::TextFieldContext( ContextHandler& rParent,
37 const Reference< XFastAttributeList >& rXAttributes,
38 TextField& rTextField)
39 : ContextHandler( rParent )
40 , mrTextField( rTextField )
41 , mbIsInText( false )
42 {
43 mrTextField.setUuid( rXAttributes->getOptionalValue( XML_id ) );
44 mrTextField.setType( rXAttributes->getOptionalValue( XML_type ) );
45 }
46
endFastElement(sal_Int32 aElementToken)47 void TextFieldContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
48 {
49 if( aElementToken == (A_TOKEN( t )) )
50 {
51 mbIsInText = false;
52 }
53 }
54
characters(const OUString & aChars)55 void TextFieldContext::characters( const OUString& aChars ) throw (SAXException, RuntimeException)
56 {
57 if( mbIsInText )
58 {
59 mrTextField.getText() += aChars;
60 }
61 }
62
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)63 Reference< XFastContextHandler > TextFieldContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
64 throw (SAXException, RuntimeException)
65 {
66 Reference< XFastContextHandler > xRet;
67 switch( aElementToken )
68 {
69 case A_TOKEN( rPr ):
70 xRet.set( new TextCharacterPropertiesContext( *this, xAttribs, mrTextField.getTextCharacterProperties() ) );
71 break;
72 case A_TOKEN( pPr ):
73 xRet.set( new TextParagraphPropertiesContext( *this, xAttribs, mrTextField.getTextParagraphProperties() ) );
74 break;
75 case A_TOKEN( t ):
76 mbIsInText = true;
77 break;
78 }
79 if ( !xRet.is() )
80 xRet.set( this );
81 return xRet;
82 }
83
84
85 } }
86