LibreOffice Module oox (master)  1
diagramfragmenthandler.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
23 #include "datamodelcontext.hxx"
26 #include <oox/token/namespaces.hxx>
27 
28 using namespace ::oox::core;
29 using namespace ::com::sun::star::xml::sax;
30 using namespace ::com::sun::star::uno;
31 
32 namespace oox::drawingml {
33 
35  const OUString& rFragmentPath,
36  const DiagramDataPtr& rDataPtr )
37  : FragmentHandler2( rFilter, rFragmentPath )
38  , mpDataPtr( rDataPtr )
39 {
40 }
41 
43 {
44 
45 }
46 
48 {
49 
50 }
51 
54  const AttributeList& )
55 {
56  switch( aElement )
57  {
58  case DGM_TOKEN( dataModel ):
59  return new DataModelContext( *this, mpDataPtr );
60  default:
61  break;
62  }
63 
64  return this;
65 }
66 
68  const OUString& rFragmentPath,
69  const DiagramLayoutPtr& rDataPtr )
70  : FragmentHandler2( rFilter, rFragmentPath )
71  , mpDataPtr( rDataPtr )
72 {
73 }
74 
76 {
77 
78 }
79 
81 {
82 
83 }
84 
87  const AttributeList& rAttribs )
88 {
89  switch( aElement )
90  {
91  case DGM_TOKEN( layoutDef ):
92  return new DiagramDefinitionContext( *this, rAttribs, mpDataPtr );
93  default:
94  break;
95  }
96 
97  return this;
98 }
99 
101  const OUString& rFragmentPath,
102  DiagramQStyleMap& rStylesMap ) :
103  FragmentHandler2( rFilter, rFragmentPath ),
104  maStyleEntry(),
105  mrStylesMap( rStylesMap )
106 {}
107 
109  sal_Int32 nElement,
110  const AttributeList& rAttribs,
111  ShapeStyleRef& o_rStyle )
112 {
113  o_rStyle.mnThemedIdx = (nElement == A_TOKEN(fontRef)) ?
114  rAttribs.getToken( XML_idx, XML_none ) : rAttribs.getInteger( XML_idx, 0 );
115  return new ColorContext( *this, o_rStyle.maPhClr );
116 }
117 
119  const AttributeList& rAttribs )
120 {
121  // state-table like way of navigating the color fragment. we
122  // currently ignore everything except styleLbl in the styleDef
123  // element
124  switch( getCurrentElement() )
125  {
126  case XML_ROOT_CONTEXT:
127  return nElement == DGM_TOKEN(styleDef) ? this : nullptr;
128  case DGM_TOKEN(styleDef):
129  return nElement == DGM_TOKEN(styleLbl) ? this : nullptr;
130  case DGM_TOKEN(styleLbl):
131  return nElement == DGM_TOKEN(style) ? this : nullptr;
132  case DGM_TOKEN(style):
133  {
134  switch( nElement )
135  {
136  case A_TOKEN(lnRef): // CT_StyleMatrixReference
137  return createStyleMatrixContext(nElement,rAttribs,
139  case A_TOKEN(fillRef): // CT_StyleMatrixReference
140  return createStyleMatrixContext(nElement,rAttribs,
142  case A_TOKEN(effectRef): // CT_StyleMatrixReference
143  return createStyleMatrixContext(nElement,rAttribs,
145  case A_TOKEN(fontRef): // CT_FontReference
146  return createStyleMatrixContext(nElement,rAttribs,
148  }
149  return nullptr;
150  }
151  }
152 
153  return nullptr;
154 }
155 
157 {
158  if( getCurrentElement() == DGM_TOKEN( styleLbl ) )
159  {
160  maStyleName = rAttribs.getString( XML_name, OUString() );
162  }
163 }
164 
166 {
167  if( getCurrentElement() == DGM_TOKEN(styleLbl) )
169 }
170 
172  const OUString& rFragmentPath,
173  DiagramColorMap& rColorsMap ) :
174  FragmentHandler2(rFilter,rFragmentPath),
175  maColorEntry(),
176  mrColorsMap(rColorsMap)
177 {}
178 
180  const AttributeList& /*rAttribs*/ )
181 {
182  // state-table like way of navigating the color fragment. we
183  // currently ignore everything except styleLbl in the colorsDef
184  // element
185  switch( getCurrentElement() )
186  {
187  case XML_ROOT_CONTEXT:
188  return nElement == DGM_TOKEN(colorsDef) ? this : nullptr;
189  case DGM_TOKEN(colorsDef):
190  return nElement == DGM_TOKEN(styleLbl) ? this : nullptr;
191  case DGM_TOKEN(styleLbl):
192  {
193  switch( nElement )
194  {
195  // the actual colors - defer to color fragment handlers.
196 
197  case DGM_TOKEN(fillClrLst):
198  return new ColorsContext( *this, maColorEntry.maFillColors );
199  case DGM_TOKEN(linClrLst):
200  return new ColorsContext( *this, maColorEntry.maLineColors );
201  case DGM_TOKEN(effectClrLst):
202  return new ColorsContext( *this, maColorEntry.maEffectColors );
203  case DGM_TOKEN(txFillClrLst):
204  return new ColorsContext( *this, maColorEntry.maTextFillColors );
205  case DGM_TOKEN(txLinClrLst):
206  return new ColorsContext( *this, maColorEntry.maTextLineColors );
207  case DGM_TOKEN(txEffectClrLst):
208  return new ColorsContext( *this, maColorEntry.maTextEffectColors );
209  }
210  break;
211  }
212  }
213 
214  return nullptr;
215 }
216 
218 {
219  if( getCurrentElement() == DGM_TOKEN(styleLbl) )
220  {
221  maColorName = rAttribs.getString( XML_name, OUString() );
223  }
224 }
225 
227 {
228  if( getCurrentElement() == DGM_TOKEN(styleLbl) )
230 }
231 
232 }
233 
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::oox::core::ContextHandlerRef createStyleMatrixContext(sal_Int32 nElement, const AttributeList &rAttribs, ShapeStyleRef &o_rStyle)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
std::vector< oox::drawingml::Color > maTextLineColors
ColorFragmentHandler(::oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, DiagramColorMap &rColorMap)
std::shared_ptr< DiagramData > DiagramDataPtr
Definition: datamodel.hxx:199
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::map< OUString, DiagramStyle > DiagramQStyleMap
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
DiagramQStylesFragmentHandler(oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, DiagramQStyleMap &rStylesMap)
std::vector< oox::drawingml::Color > maEffectColors
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
virtual void onStartElement(const AttributeList &rAttribs) override
Will be called when a new element has been started.
DiagramLayoutFragmentHandler(oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, const DiagramLayoutPtr &rDataPtr)
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
virtual void onStartElement(const AttributeList &rAttribs) override
Will be called when a new element has been started.
Context handler for elements that contain a color value element (a:scrgbClr, a:srgbClr, a:hslClr, a:sysClr, a:schemeClr, a:prstClr).
sal_Int32 getCurrentElement() const
Returns the identifier of the currently processed element.
std::shared_ptr< DiagramLayout > DiagramLayoutPtr
Provides access to attribute values of an element.
exports com.sun.star. style
std::vector< oox::drawingml::Color > maTextEffectColors
Same as ColorContext, but handles multiple colors.
std::map< OUString, DiagramColor > DiagramColorMap
std::vector< oox::drawingml::Color > maFillColors
DiagramDataFragmentHandler(oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, const DiagramDataPtr &rDataPtr)
virtual void SAL_CALL endDocument() override
const sal_Int32 XML_ROOT_CONTEXT
virtual void onEndElement() override
Will be called when the current element is about to be left.
std::vector< oox::drawingml::Color > maTextFillColors
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
virtual ~DiagramDataFragmentHandler() noexcept override
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
std::vector< oox::drawingml::Color > maLineColors
virtual void onEndElement() override
Will be called when the current element is about to be left.