fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / textbodycontext.cxx
blobbaf6b0e538badbea012787535e4f9a9b9e3df7a2
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/textbodycontext.hxx"
21 #include "drawingml/textbodypropertiescontext.hxx"
22 #include "drawingml/textparagraph.hxx"
23 #include "drawingml/textparagraphpropertiescontext.hxx"
24 #include "drawingml/textcharacterpropertiescontext.hxx"
25 #include "drawingml/textliststylecontext.hxx"
26 #include "drawingml/textfield.hxx"
27 #include "drawingml/textfieldcontext.hxx"
29 using namespace ::oox::core;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::text;
32 using namespace ::com::sun::star::xml::sax;
34 namespace oox { namespace drawingml {
36 // CT_TextParagraph
37 class TextParagraphContext : public ContextHandler2
39 public:
40 TextParagraphContext( ContextHandler2Helper& rParent, TextParagraph& rPara );
42 virtual ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) SAL_OVERRIDE;
44 protected:
45 TextParagraph& mrParagraph;
48 TextParagraphContext::TextParagraphContext( ContextHandler2Helper& rParent, TextParagraph& rPara )
49 : ContextHandler2( rParent )
50 , mrParagraph( rPara )
52 mbEnableTrimSpace = false;
55 ContextHandlerRef TextParagraphContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
57 // EG_TextRun
58 switch( aElementToken )
60 case A_TOKEN( r ): // "CT_RegularTextRun" Regular Text Run.
61 case W_TOKEN( r ):
63 TextRunPtr pRun( new TextRun );
64 mrParagraph.addRun( pRun );
65 return new RegularTextRunContext( *this, pRun );
67 case A_TOKEN( br ): // "CT_TextLineBreak" Soft return line break (vertical tab).
69 TextRunPtr pRun( new TextRun );
70 pRun->setLineBreak();
71 mrParagraph.addRun( pRun );
72 return new RegularTextRunContext( *this, pRun );
74 case A_TOKEN( fld ): // "CT_TextField" Text Field.
76 TextFieldPtr pField( new TextField );
77 mrParagraph.addRun( pField );
78 return new TextFieldContext( *this, rAttribs, *pField );
80 case A_TOKEN( pPr ):
81 case W_TOKEN( pPr ):
82 return new TextParagraphPropertiesContext( *this, rAttribs, mrParagraph.getProperties() );
83 case A_TOKEN( endParaRPr ):
84 return new TextCharacterPropertiesContext( *this, rAttribs, mrParagraph.getEndProperties() );
85 case W_TOKEN( sdt ):
86 case W_TOKEN( sdtContent ):
87 return this;
88 case W_TOKEN( del ):
89 break;
90 case W_TOKEN( ins ):
91 return this;
92 break;
93 default:
94 SAL_WARN("oox", "TextParagraphContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
97 return 0;
100 RegularTextRunContext::RegularTextRunContext( ContextHandler2Helper& rParent, TextRunPtr pRunPtr )
101 : ContextHandler2( rParent )
102 , mpRunPtr( pRunPtr )
103 , mbIsInText( false )
107 void RegularTextRunContext::onEndElement( )
109 switch( getCurrentElement() )
111 case A_TOKEN( t ):
112 case W_TOKEN( t ):
114 mbIsInText = false;
115 break;
117 case A_TOKEN( r ):
118 break;
122 void RegularTextRunContext::onCharacters( const OUString& aChars )
124 if( mbIsInText )
126 mpRunPtr->getText() += aChars;
130 ContextHandlerRef RegularTextRunContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs)
132 switch( aElementToken )
134 case A_TOKEN( rPr ): // "CT_TextCharPropertyBag" The text char properties of this text run.
135 case W_TOKEN( rPr ):
136 return new TextCharacterPropertiesContext( *this, rAttribs, mpRunPtr->getTextCharacterProperties() );
137 case A_TOKEN( t ): // "xsd:string" minOccurs="1" The actual text string.
138 case W_TOKEN( t ):
139 mbIsInText = true;
140 break;
141 case W_TOKEN( drawing ):
142 break;
143 default:
144 SAL_WARN("oox", "RegularTextRunContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
145 break;
148 return this;
151 TextBodyContext::TextBodyContext( ContextHandler2Helper& rParent, TextBody& rTextBody )
152 : ContextHandler2( rParent )
153 , mrTextBody( rTextBody )
157 ContextHandlerRef TextBodyContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
159 switch( aElementToken )
161 case A_TOKEN( bodyPr ): // CT_TextBodyPropertyBag
162 return new TextBodyPropertiesContext( *this, rAttribs, mrTextBody.getTextProperties() );
163 case A_TOKEN( lstStyle ): // CT_TextListStyle
164 return new TextListStyleContext( *this, mrTextBody.getTextListStyle() );
165 case A_TOKEN( p ): // CT_TextParagraph
166 case W_TOKEN( p ):
167 return new TextParagraphContext( *this, mrTextBody.addParagraph() );
168 case W_TOKEN( sdt ):
169 case W_TOKEN( sdtContent ):
170 return this;
171 case W_TOKEN( sdtPr ):
172 case W_TOKEN( sdtEndPr ):
173 break;
174 case W_TOKEN( tbl ):
175 break;
176 default:
177 SAL_WARN("oox", "TextBodyContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
180 return 0;
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */