Branch data 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 "xeextlst.hxx"
11 : : #include "xeroot.hxx"
12 : : #include "xehelper.hxx"
13 : : #include "xestyle.hxx"
14 : : #include "xename.hxx"
15 : : #include "xecontent.hxx"
16 : : #include "tokenarray.hxx"
17 : :
18 : : using namespace ::oox;
19 : :
20 : 0 : XclExpExt::XclExpExt( const XclExpRoot& rRoot ):
21 [ # # ]: 0 : XclExpRoot(rRoot)
22 : : {
23 : 0 : }
24 : :
25 : 0 : XclExtLst::XclExtLst( const XclExpRoot& rRoot ):
26 [ # # ][ # # ]: 0 : XclExpRoot(rRoot)
27 : : {
28 : 0 : }
29 : :
30 : 0 : XclExpExtNegativeColor::XclExpExtNegativeColor( const Color& rColor ):
31 : 0 : maColor(rColor)
32 : : {
33 : 0 : }
34 : :
35 : 0 : void XclExpExtNegativeColor::SaveXml( XclExpXmlStream& rStrm )
36 : : {
37 [ # # ]: 0 : rStrm.GetCurrentStream()->singleElementNS( XML_x14, XML_negativeFillColor,
38 : : XML_rgb, XclXmlUtils::ToOString( maColor ).getStr(),
39 [ # # ]: 0 : FSEND );
40 : 0 : }
41 : :
42 : 0 : XclExpExtAxisColor::XclExpExtAxisColor( const Color& rColor ):
43 : 0 : maAxisColor(rColor)
44 : : {
45 : 0 : }
46 : :
47 : 0 : void XclExpExtAxisColor::SaveXml( XclExpXmlStream& rStrm )
48 : : {
49 [ # # ]: 0 : rStrm.GetCurrentStream()->singleElementNS( XML_x14, XML_axisColor,
50 : : XML_rgb, XclXmlUtils::ToOString( maAxisColor ).getStr(),
51 [ # # ]: 0 : FSEND );
52 : 0 : }
53 : :
54 : 0 : XclExpExtCfvo::XclExpExtCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry& rEntry, const ScAddress& rSrcPos ):
55 : : XclExpRoot(rRoot),
56 [ # # ][ # # ]: 0 : meType(rEntry.GetType())
57 : : {
58 [ # # ][ # # ]: 0 : if( rEntry.GetType() == COLORSCALE_FORMULA )
59 : : {
60 [ # # ][ # # ]: 0 : rtl::OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), rSrcPos, rEntry.GetFormula()->Clone() );
[ # # ]
61 [ # # ]: 0 : maValue = rtl::OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
62 : : }
63 : : else
64 [ # # ]: 0 : maValue = rtl::OString::valueOf(rEntry.GetValue());
65 : 0 : }
66 : :
67 : : namespace {
68 : :
69 : 0 : const char* getColorScaleType( ScColorScaleEntryType eType )
70 : : {
71 [ # # # # : 0 : switch(eType)
# # # # ]
72 : : {
73 : : case COLORSCALE_MIN:
74 : 0 : return "min";
75 : : case COLORSCALE_MAX:
76 : 0 : return "max";
77 : : case COLORSCALE_PERCENT:
78 : 0 : return "percent";
79 : : case COLORSCALE_FORMULA:
80 : 0 : return "formula";
81 : : case COLORSCALE_AUTOMIN:
82 : 0 : return "autoMin";
83 : : case COLORSCALE_AUTOMAX:
84 : 0 : return "autoMax";
85 : : case COLORSCALE_PERCENTILE:
86 : 0 : return "percentile";
87 : : default:
88 : 0 : break;
89 : : }
90 : 0 : return "num";
91 : : }
92 : :
93 : : }
94 : :
95 : 0 : void XclExpExtCfvo::SaveXml( XclExpXmlStream& rStrm )
96 : : {
97 : 0 : sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
98 : : rWorksheet->singleElementNS( XML_x14, XML_cfvo,
99 : : XML_type, getColorScaleType(meType),
100 : : XML_value, maValue.getStr(),
101 : 0 : FSEND );
102 : 0 : }
103 : :
104 : 0 : XclExpExtDataBar::XclExpExtDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, const ScAddress& rPos ):
105 [ # # ]: 0 : XclExpRoot(rRoot)
106 : : {
107 [ # # ]: 0 : const ScDataBarFormatData& rFormatData = *rFormat.GetDataBarData();
108 [ # # ][ # # ]: 0 : mpLowerLimit.reset( new XclExpExtCfvo( *this, *rFormatData.mpLowerLimit.get(), rPos ) );
[ # # ]
109 [ # # ][ # # ]: 0 : mpUpperLimit.reset( new XclExpExtCfvo( *this, *rFormatData.mpUpperLimit.get(), rPos ) );
[ # # ]
110 [ # # ]: 0 : if(rFormatData.mpNegativeColor.get())
111 [ # # ][ # # ]: 0 : mpNegativeColor.reset( new XclExpExtNegativeColor( *rFormatData.mpNegativeColor.get() ) );
112 : : else
113 [ # # ][ # # ]: 0 : mpNegativeColor.reset( new XclExpExtNegativeColor( rFormatData.maPositiveColor ) );
114 [ # # ][ # # ]: 0 : mpAxisColor.reset( new XclExpExtAxisColor( rFormatData.maAxisColor ) );
115 : :
116 : 0 : meAxisPosition = rFormatData.meAxisPosition;
117 : 0 : }
118 : :
119 : : namespace {
120 : :
121 : 0 : const char* getAxisPosition(databar::ScAxisPostion eAxisPosition)
122 : : {
123 [ # # # # ]: 0 : switch(eAxisPosition)
124 : : {
125 : : case databar::NONE:
126 : 0 : return "none";
127 : : case databar::AUTOMATIC:
128 : 0 : return "automatic";
129 : : case databar::MIDDLE:
130 : 0 : return "middle";
131 : : }
132 : 0 : return "";
133 : : }
134 : :
135 : : }
136 : :
137 : 0 : void XclExpExtDataBar::SaveXml( XclExpXmlStream& rStrm )
138 : : {
139 : 0 : sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
140 : : rWorksheet->startElementNS( XML_x14, XML_dataBar,
141 : : XML_minLength, rtl::OString::valueOf(static_cast<sal_Int32>(0)).getStr(),
142 : : XML_maxLength, rtl::OString::valueOf(static_cast<sal_Int32>(100)).getStr(),
143 : : XML_axisPosition, getAxisPosition(meAxisPosition),
144 [ # # ]: 0 : FSEND );
145 : :
146 : 0 : mpLowerLimit->SaveXml( rStrm );
147 : 0 : mpUpperLimit->SaveXml( rStrm );
148 : 0 : mpNegativeColor->SaveXml( rStrm );
149 : 0 : mpAxisColor->SaveXml( rStrm );
150 : :
151 : 0 : rWorksheet->endElementNS( XML_x14, XML_dataBar );
152 : 0 : }
153 : :
154 : 0 : XclExpExtCfRule::XclExpExtCfRule( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, const ScAddress& rPos, const rtl::OString& rId ):
155 : : XclExpRoot(rRoot),
156 [ # # ][ # # ]: 0 : maId(rId)
157 : : {
158 [ # # ][ # # ]: 0 : maDataBar.reset( new XclExpExtDataBar( *this, rFormat, rPos ) );
[ # # ]
159 : 0 : }
160 : :
161 : 0 : void XclExpExtCfRule::SaveXml( XclExpXmlStream& rStrm )
162 : : {
163 : 0 : sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
164 : : rWorksheet->startElementNS( XML_x14, XML_cfRule,
165 : : XML_type, "dataBar",
166 : : XML_id, maId.getStr(),
167 : 0 : FSEND );
168 : :
169 : 0 : maDataBar->SaveXml( rStrm );
170 : :
171 : 0 : rWorksheet->endElementNS( XML_x14, XML_cfRule );
172 : :
173 : 0 : }
174 : :
175 : 0 : XclExpExtConditionalFormatting::XclExpExtConditionalFormatting( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, const ScAddress& rPos, const rtl::OString& rId ):
176 [ # # ][ # # ]: 0 : XclExpRoot(rRoot)
[ # # ]
177 : : {
178 [ # # ][ # # ]: 0 : maCfRule.reset( new XclExpExtCfRule( *this, rFormat, rPos, rId ) );
[ # # ]
179 [ # # ][ # # ]: 0 : maRange = rFormat.GetRange();
180 : 0 : }
181 : :
182 : 0 : void XclExpExtConditionalFormatting::SaveXml( XclExpXmlStream& rStrm )
183 : : {
184 : 0 : sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
185 : : rWorksheet->startElementNS( XML_x14, XML_conditionalFormatting,
186 : : FSNS( XML_xmlns, XML_xm ), "http://schemas.microsoft.com/office/excel/2006/main",
187 : 0 : FSEND );
188 : :
189 : 0 : maCfRule->SaveXml( rStrm );
190 : 0 : rWorksheet->startElementNS( XML_xm, XML_sqref, FSEND );
191 [ # # ]: 0 : rWorksheet->write(XclXmlUtils::ToOString(maRange).getStr());
192 : :
193 : 0 : rWorksheet->endElementNS( XML_xm, XML_sqref );
194 : :
195 : 0 : rWorksheet->endElementNS( XML_x14, XML_conditionalFormatting );
196 : 0 : }
197 : :
198 : 0 : XclExpExtCondFormat::XclExpExtCondFormat( const XclExpRoot& rRoot ):
199 [ # # ]: 0 : XclExpExt( rRoot )
200 : : {
201 : 0 : maURI = rtl::OString("{78C0D931-6437-407d-A8EE-F0AAD7539E65}");
202 : 0 : }
203 : :
204 : 0 : void XclExpExtCondFormat::SaveXml( XclExpXmlStream& rStrm )
205 : : {
206 : 0 : sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
207 : : rWorksheet->startElement( XML_ext,
208 : : FSNS( XML_xmlns, XML_x14 ), "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
209 : : XML_uri, maURI.getStr(),
210 : 0 : FSEND );
211 : :
212 : : rWorksheet->startElementNS( XML_x14, XML_conditionalFormattings,
213 : 0 : FSEND );
214 : :
215 : 0 : maCF.SaveXml( rStrm );
216 : :
217 : 0 : rWorksheet->endElementNS( XML_x14, XML_conditionalFormattings );
218 : 0 : rWorksheet->endElement( XML_ext );
219 : 0 : }
220 : :
221 : 0 : void XclExpExtCondFormat::AddRecord( XclExpExtConditionalFormattingRef aEntry )
222 : : {
223 [ # # ]: 0 : maCF.AppendRecord( aEntry );
224 : 0 : }
225 : :
226 : 0 : void XclExtLst::SaveXml( XclExpXmlStream& rStrm )
227 : : {
228 [ # # ]: 0 : if(maExtEntries.IsEmpty())
229 : 0 : return;
230 : :
231 : 0 : sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
232 : : rWorksheet->startElement( XML_extLst,
233 : 0 : FSEND );
234 : :
235 : 0 : maExtEntries.SaveXml(rStrm);
236 : :
237 : 0 : rWorksheet->endElement( XML_extLst );
238 : : }
239 : :
240 : 0 : void XclExtLst::AddRecord( XclExpExtRef aEntry )
241 : : {
242 [ # # ]: 0 : maExtEntries.AppendRecord( aEntry );
243 : 0 : }
244 : :
245 : 0 : XclExpExtRef XclExtLst::GetItem( XclExpExtType eType )
246 : : {
247 : 0 : size_t n = maExtEntries.GetSize();
248 [ # # ]: 0 : for( size_t i = 0; i < n; ++i )
249 : : {
250 [ # # ][ # # ]: 0 : if (maExtEntries.GetRecord( i )->GetType() == eType)
251 : 0 : return maExtEntries.GetRecord( i );
252 : : }
253 : :
254 : 0 : return XclExpExtRef();
255 [ + - ][ + - ]: 24 : }
256 : :
257 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|