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  maStyleName(),
105  maStyleEntry(),
106  mrStylesMap( rStylesMap )
107 {}
108 
110  sal_Int32 nElement,
111  const AttributeList& rAttribs,
112  ShapeStyleRef& o_rStyle )
113 {
114  o_rStyle.mnThemedIdx = (nElement == A_TOKEN(fontRef)) ?
115  rAttribs.getToken( XML_idx, XML_none ) : rAttribs.getInteger( XML_idx, 0 );
116  return new ColorContext( *this, o_rStyle.maPhClr );
117 }
118 
120  const AttributeList& rAttribs )
121 {
122  // state-table like way of navigating the color fragment. we
123  // currently ignore everything except styleLbl in the styleDef
124  // element
125  switch( getCurrentElement() )
126  {
127  case XML_ROOT_CONTEXT:
128  return nElement == DGM_TOKEN(styleDef) ? this : nullptr;
129  case DGM_TOKEN(styleDef):
130  return nElement == DGM_TOKEN(styleLbl) ? this : nullptr;
131  case DGM_TOKEN(styleLbl):
132  return nElement == DGM_TOKEN(style) ? this : nullptr;
133  case DGM_TOKEN(style):
134  {
135  switch( nElement )
136  {
137  case A_TOKEN(lnRef): // CT_StyleMatrixReference
138  return createStyleMatrixContext(nElement,rAttribs,
140  case A_TOKEN(fillRef): // CT_StyleMatrixReference
141  return createStyleMatrixContext(nElement,rAttribs,
143  case A_TOKEN(effectRef): // CT_StyleMatrixReference
144  return createStyleMatrixContext(nElement,rAttribs,
146  case A_TOKEN(fontRef): // CT_FontReference
147  return createStyleMatrixContext(nElement,rAttribs,
149  }
150  return nullptr;
151  }
152  }
153 
154  return nullptr;
155 }
156 
158 {
159  if( getCurrentElement() == DGM_TOKEN( styleLbl ) )
160  {
161  maStyleName = rAttribs.getString( XML_name, OUString() );
163  }
164 }
165 
167 {
168  if( getCurrentElement() == DGM_TOKEN(styleLbl) )
170 }
171 
173  const OUString& rFragmentPath,
174  DiagramColorMap& rColorsMap ) :
175  FragmentHandler2(rFilter,rFragmentPath),
176  maColorName(),
177  maColorEntry(),
178  mrColorsMap(rColorsMap)
179 {}
180 
182  const AttributeList& /*rAttribs*/ )
183 {
184  // state-table like way of navigating the color fragment. we
185  // currently ignore everything except styleLbl in the colorsDef
186  // element
187  switch( getCurrentElement() )
188  {
189  case XML_ROOT_CONTEXT:
190  return nElement == DGM_TOKEN(colorsDef) ? this : nullptr;
191  case DGM_TOKEN(colorsDef):
192  return nElement == DGM_TOKEN(styleLbl) ? this : nullptr;
193  case DGM_TOKEN(styleLbl):
194  {
195  switch( nElement )
196  {
197  // the actual colors - defer to color fragment handlers.
198 
199  case DGM_TOKEN(fillClrLst):
200  return new ColorsContext( *this, maColorEntry.maFillColors );
201  case DGM_TOKEN(linClrLst):
202  return new ColorsContext( *this, maColorEntry.maLineColors );
203  case DGM_TOKEN(effectClrLst):
204  return new ColorsContext( *this, maColorEntry.maEffectColors );
205  case DGM_TOKEN(txFillClrLst):
206  return new ColorsContext( *this, maColorEntry.maTextFillColors );
207  case DGM_TOKEN(txLinClrLst):
208  return new ColorsContext( *this, maColorEntry.maTextLineColors );
209  case DGM_TOKEN(txEffectClrLst):
210  return new ColorsContext( *this, maColorEntry.maTextEffectColors );
211  }
212  break;
213  }
214  }
215 
216  return nullptr;
217 }
218 
220 {
221  if( getCurrentElement() == DGM_TOKEN(styleLbl) )
222  {
223  maColorName = rAttribs.getString( XML_name, OUString() );
225  }
226 }
227 
229 {
230  if( getCurrentElement() == DGM_TOKEN(styleLbl) )
232 }
233 
234 }
235 
236 /* 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.