fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / chart / titlecontext.cxx
blob4e9f4a3952156a6c9b5137e993ebc4cb22f3291e
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/chart/titlecontext.hxx"
22 #include "drawingml/shapepropertiescontext.hxx"
23 #include "drawingml/textbodycontext.hxx"
24 #include "drawingml/chart/datasourcecontext.hxx"
25 #include "drawingml/chart/titlemodel.hxx"
27 #include "rtl/ustrbuf.hxx"
28 #include <osl/diagnose.h>
31 namespace oox {
32 namespace drawingml {
33 namespace chart {
35 using ::oox::core::ContextHandler2Helper;
36 using ::oox::core::ContextHandlerRef;
38 TextContext::TextContext( ContextHandler2Helper& rParent, TextModel& rModel ) :
39 ContextBase< TextModel >( rParent, rModel )
43 TextContext::~TextContext()
47 ContextHandlerRef TextContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
49 // this context handler is used for <c:tx> and embedded <c:v> elements
50 if( isCurrentElement( C_TOKEN( tx ) ) ) switch( nElement )
52 case C_TOKEN( rich ):
53 return new TextBodyContext( *this, mrModel.mxTextBody.create() );
55 case C_TOKEN( strRef ):
56 OSL_ENSURE( !mrModel.mxDataSeq, "TextContext::onCreateContext - multiple data sequences" );
57 return new StringSequenceContext( *this, mrModel.mxDataSeq.create() );
59 case C_TOKEN( v ):
60 OSL_ENSURE( !mrModel.mxDataSeq, "TextContext::onCreateContext - multiple data sequences" );
61 return this; // collect value in onCharacters()
63 return 0;
66 void TextContext::onCharacters( const OUString& rChars )
68 if( isCurrentElement( C_TOKEN( v ) ) )
70 // Static text is stored as a single string formula token for Excel document.
71 OUStringBuffer aBuf;
72 aBuf.append('"').append(rChars).append('"');
73 mrModel.mxDataSeq.create().maFormula = aBuf.makeStringAndClear();
75 // Also store it as a single element type for non-Excel document.
76 mrModel.mxDataSeq->maData[0] <<= rChars;
80 TitleContext::TitleContext( ContextHandler2Helper& rParent, TitleModel& rModel ) :
81 ContextBase< TitleModel >( rParent, rModel )
85 TitleContext::~TitleContext()
89 ContextHandlerRef TitleContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
91 bool bMSO2007Doc = getFilter().isMSO2007Document();
92 // this context handler is used for <c:title> only
93 switch( nElement )
95 case C_TOKEN( layout ):
96 return new LayoutContext( *this, mrModel.mxLayout.create() );
98 case C_TOKEN( overlay ):
99 mrModel.mbOverlay = rAttribs.getBool( XML_val, !bMSO2007Doc );
100 return 0;
102 case C_TOKEN( spPr ):
103 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
105 case C_TOKEN( tx ):
106 return new TextContext( *this, mrModel.mxText.create() );
108 case C_TOKEN( txPr ):
109 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
111 return 0;
114 LegendContext::LegendContext( ContextHandler2Helper& rParent, LegendModel& rModel ) :
115 ContextBase< LegendModel >( rParent, rModel )
119 LegendContext::~LegendContext()
123 ContextHandlerRef LegendContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
125 bool bMSO2007Doc = getFilter().isMSO2007Document();
126 // this context handler is used for <c:legend> only
127 switch( nElement )
129 case C_TOKEN( layout ):
130 return new LayoutContext( *this, mrModel.mxLayout.create() );
132 case C_TOKEN( legendPos ):
133 mrModel.mnPosition = rAttribs.getToken( XML_val, XML_r );
134 return 0;
136 case C_TOKEN( overlay ):
137 mrModel.mbOverlay = rAttribs.getBool( XML_val, !bMSO2007Doc );
138 return 0;
140 case C_TOKEN( spPr ):
141 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
143 case C_TOKEN( txPr ):
144 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
146 return 0;
149 } // namespace chart
150 } // namespace drawingml
151 } // namespace oox
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */