Line data Source code
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 :
10 : #include "extlstcontext.hxx"
11 : #include "worksheethelper.hxx"
12 : #include <oox/core/contexthandler.hxx>
13 : #include "colorscale.hxx"
14 : #include "condformatbuffer.hxx"
15 :
16 : using ::oox::core::ContextHandlerRef;
17 :
18 : namespace oox {
19 : namespace xls {
20 :
21 5 : ExtCfRuleContext::ExtCfRuleContext( WorksheetContextBase& rFragment, void* pTarget ):
22 : WorksheetContextBase( rFragment ),
23 : mpTarget( pTarget ),
24 5 : mbFirstEntry(true)
25 : {
26 5 : }
27 :
28 25 : ContextHandlerRef ExtCfRuleContext::onCreateContext( sal_Int32 , const AttributeList& )
29 : {
30 25 : return this;
31 : }
32 :
33 30 : void ExtCfRuleContext::onStartElement( const AttributeList& rAttribs )
34 : {
35 30 : switch( getCurrentElement() )
36 : {
37 : case XLS_EXT_TOKEN( dataBar ):
38 : {
39 5 : ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
40 5 : xRule->importDataBar( rAttribs );
41 5 : break;
42 : }
43 : case XLS_EXT_TOKEN( negativeFillColor ):
44 : {
45 5 : ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
46 5 : xRule->importNegativeFillColor( rAttribs );
47 5 : break;
48 : }
49 : case XLS_EXT_TOKEN( axisColor ):
50 : {
51 5 : ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
52 5 : xRule->importAxisColor( rAttribs );
53 5 : break;
54 : }
55 : case XLS_EXT_TOKEN( cfvo ):
56 : {
57 10 : ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
58 10 : xRule->importCfvo( rAttribs );
59 10 : xRule->getModel().mbIsLower = mbFirstEntry;
60 10 : mbFirstEntry = false;
61 10 : break;
62 : }
63 : default:
64 5 : break;
65 : }
66 30 : }
67 :
68 5 : ExtLstLocalContext::ExtLstLocalContext( WorksheetContextBase& rFragment, void* pTarget ):
69 : WorksheetContextBase(rFragment),
70 5 : mpTarget(pTarget)
71 : {
72 5 : }
73 :
74 10 : ContextHandlerRef ExtLstLocalContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
75 : {
76 10 : switch( getCurrentElement() )
77 : {
78 : case XLS_TOKEN( extLst ):
79 5 : if(nElement == XLS_TOKEN( ext ))
80 5 : return this;
81 : else
82 0 : return 0;
83 : break;
84 : case XLS_TOKEN( ext ):
85 5 : if (nElement == XLS_EXT_TOKEN( id ))
86 5 : return this;
87 : else
88 0 : return 0;
89 : }
90 0 : return 0;
91 : }
92 :
93 15 : void ExtLstLocalContext::onStartElement( const AttributeList& )
94 : {
95 15 : switch( getCurrentElement() )
96 : {
97 : case XLS_EXT_TOKEN( id ):
98 5 : break;
99 : }
100 15 : }
101 :
102 5 : void ExtLstLocalContext::onCharacters( const OUString& rChars )
103 : {
104 5 : if (getCurrentElement() == XLS_EXT_TOKEN( id ))
105 : {
106 5 : getExtLst().insert( std::pair< OUString, void*>(rChars, mpTarget) );
107 : }
108 5 : }
109 :
110 1 : ExtGlobalContext::ExtGlobalContext( WorksheetContextBase& rFragment ):
111 1 : WorksheetContextBase(rFragment)
112 : {
113 1 : }
114 :
115 16 : ContextHandlerRef ExtGlobalContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
116 : {
117 16 : if(!rAttribs.hasAttribute( XML_id))
118 11 : return this;
119 : else
120 : {
121 5 : if(nElement == XLS_EXT_TOKEN( cfRule ))
122 : {
123 5 : OUString aId = rAttribs.getString( XML_id, OUString() );
124 :
125 : // an ext entrie does not need to have an existing corresponding entry
126 5 : ExtLst::const_iterator aExt = getExtLst().find( aId );
127 5 : if(aExt == getExtLst().end())
128 0 : return NULL;
129 :
130 5 : void* pInfo = aExt->second;
131 5 : if (!pInfo)
132 : {
133 0 : return NULL;
134 : }
135 5 : return new ExtCfRuleContext( *this, pInfo );
136 : }
137 : else
138 0 : return this;
139 : }
140 : }
141 :
142 12 : void ExtGlobalContext::onStartElement( const AttributeList& /*rAttribs*/ )
143 : {
144 12 : }
145 :
146 1 : ExtLstGlobalContext::ExtLstGlobalContext( WorksheetFragment& rFragment ):
147 1 : WorksheetContextBase(rFragment)
148 : {
149 1 : }
150 :
151 1 : ContextHandlerRef ExtLstGlobalContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
152 : {
153 1 : if (nElement == XLS_TOKEN( ext ))
154 1 : return new ExtGlobalContext( *this );
155 :
156 0 : return this;
157 : }
158 :
159 : } //namespace oox
160 18 : } //namespace xls
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|