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 <sal/config.h>
11 
12 #include <string_view>
13 
14 #include <xeextlst.hxx>
15 #include <xeroot.hxx>
16 #include <xestyle.hxx>
17 #include <stlpool.hxx>
18 #include <scitems.hxx>
19 #include <svl/itemset.hxx>
20 #include <svl/intitem.hxx>
21 
22 #include <oox/export/utils.hxx>
23 #include <oox/token/namespaces.hxx>
24 
25 using namespace ::oox;
26 
XclExpExt(const XclExpRoot & rRoot)27 XclExpExt::XclExpExt( const XclExpRoot& rRoot ):
28     XclExpRoot(rRoot)
29 {
30 }
31 
XclExtLst(const XclExpRoot & rRoot)32 XclExtLst::XclExtLst( const XclExpRoot& rRoot ):
33     XclExpRoot(rRoot)
34 {
35 }
36 
XclExpExtNegativeColor(const Color & rColor)37 XclExpExtNegativeColor::XclExpExtNegativeColor( const Color& rColor ):
38     maColor(rColor)
39 {
40 }
41 
SaveXml(XclExpXmlStream & rStrm)42 void XclExpExtNegativeColor::SaveXml( XclExpXmlStream& rStrm )
43 {
44     rStrm.GetCurrentStream()->singleElementNS( XML_x14, XML_negativeFillColor,
45                                                XML_rgb, XclXmlUtils::ToOString(maColor) );
46 }
47 
XclExpExtAxisColor(const Color & rColor)48 XclExpExtAxisColor::XclExpExtAxisColor( const Color& rColor ):
49     maAxisColor(rColor)
50 {
51 }
52 
SaveXml(XclExpXmlStream & rStrm)53 void XclExpExtAxisColor::SaveXml( XclExpXmlStream& rStrm )
54 {
55     rStrm.GetCurrentStream()->singleElementNS( XML_x14, XML_axisColor,
56                                                XML_rgb, XclXmlUtils::ToOString(maAxisColor) );
57 }
58 
XclExpExtIcon(const XclExpRoot & rRoot,const std::pair<ScIconSetType,sal_Int32> & rCustomEntry)59 XclExpExtIcon::XclExpExtIcon(const XclExpRoot& rRoot, const std::pair<ScIconSetType, sal_Int32>& rCustomEntry):
60     XclExpRoot(rRoot),
61     nIndex(rCustomEntry.second)
62 {
63     pIconSetName = ScIconSetFormat::getIconSetName(rCustomEntry.first);
64 }
65 
SaveXml(XclExpXmlStream & rStrm)66 void XclExpExtIcon::SaveXml(XclExpXmlStream& rStrm)
67 {
68     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
69 
70     if (nIndex == -1)
71     {
72         nIndex = 0;
73         pIconSetName = "NoIcons";
74     }
75 
76     rWorksheet->singleElementNS(XML_x14, XML_cfIcon,
77             XML_iconSet, pIconSetName,
78             XML_iconId, OString::number(nIndex));
79 }
80 
XclExpExtCfvo(const XclExpRoot & rRoot,const ScColorScaleEntry & rEntry,const ScAddress & rSrcPos,bool bFirst)81 XclExpExtCfvo::XclExpExtCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry& rEntry, const ScAddress& rSrcPos, bool bFirst ):
82     XclExpRoot(rRoot),
83     meType(rEntry.GetType()),
84     mbFirst(bFirst)
85 {
86     if( rEntry.GetType() == COLORSCALE_FORMULA )
87     {
88         const ScTokenArray* pArr = rEntry.GetFormula();
89         OUString aFormula;
90         if(pArr)
91         {
92             aFormula = XclXmlUtils::ToOUString( GetCompileFormulaContext(), rSrcPos, pArr);
93         }
94         maValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
95     }
96     else
97         maValue = OString::number(rEntry.GetValue());
98 }
99 
100 namespace {
101 
getColorScaleType(ScColorScaleEntryType eType,bool bFirst)102 const char* getColorScaleType( ScColorScaleEntryType eType, bool bFirst )
103 {
104     switch(eType)
105     {
106         case COLORSCALE_MIN:
107             return "min";
108         case COLORSCALE_MAX:
109             return "max";
110         case COLORSCALE_PERCENT:
111             return "percent";
112         case COLORSCALE_FORMULA:
113             return "formula";
114         case COLORSCALE_AUTO:
115             if(bFirst)
116                 return "autoMin";
117             else
118                 return "autoMax";
119         case COLORSCALE_PERCENTILE:
120             return "percentile";
121         default:
122             break;
123     }
124     return "num";
125 }
126 
127 }
128 
SaveXml(XclExpXmlStream & rStrm)129 void XclExpExtCfvo::SaveXml( XclExpXmlStream& rStrm )
130 {
131     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
132     rWorksheet->startElementNS(XML_x14, XML_cfvo, XML_type, getColorScaleType(meType, mbFirst));
133 
134     if (meType == COLORSCALE_FORMULA ||
135             meType == COLORSCALE_PERCENT ||
136             meType == COLORSCALE_PERCENTILE ||
137             meType == COLORSCALE_VALUE)
138     {
139         rWorksheet->startElementNS(XML_xm, XML_f);
140         rWorksheet->writeEscaped(maValue.getStr());
141         rWorksheet->endElementNS(XML_xm, XML_f);
142     }
143 
144     rWorksheet->endElementNS(XML_x14, XML_cfvo);
145 }
146 
XclExpExtCF(const XclExpRoot & rRoot,const ScCondFormatEntry & rFormat)147 XclExpExtCF::XclExpExtCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormat ):
148     XclExpRoot(rRoot),
149     mrFormat(rFormat)
150 {
151 }
152 
153 namespace {
154 
RequiresFixedFormula(ScConditionMode eMode)155 bool RequiresFixedFormula(ScConditionMode eMode)
156 {
157     switch (eMode)
158     {
159     case ScConditionMode::BeginsWith:
160     case ScConditionMode::EndsWith:
161     case ScConditionMode::ContainsText:
162     case ScConditionMode::NotContainsText:
163         return true;
164     default:
165         break;
166     }
167 
168     return false;
169 }
170 
GetFixedFormula(ScConditionMode eMode,const ScAddress & rAddress,std::string_view rText)171 OString GetFixedFormula(ScConditionMode eMode, const ScAddress& rAddress, std::string_view rText)
172 {
173     OStringBuffer aBuffer;
174     XclXmlUtils::ToOString(aBuffer, rAddress);
175     OString aPos = aBuffer.makeStringAndClear();
176     switch (eMode)
177     {
178         case ScConditionMode::BeginsWith:
179             return OString("LEFT(" + aPos + ",LEN(" + rText + "))=" + rText);
180         case ScConditionMode::EndsWith:
181             return OString("RIGHT(" + aPos + ",LEN(" + rText + "))=" + rText);
182         case ScConditionMode::ContainsText:
183             return OString(OString::Concat("NOT(ISERROR(SEARCH(") + rText + "," + aPos + ")))");
184         case ScConditionMode::NotContainsText:
185             return OString(OString::Concat("ISERROR(SEARCH(") + rText + "," + aPos + "))");
186         default:
187             break;
188     }
189 
190     return "";
191 }
192 
193 }
194 
SaveXml(XclExpXmlStream & rStrm)195 void XclExpExtCF::SaveXml( XclExpXmlStream& rStrm )
196 {
197     OUString aStyleName = mrFormat.GetStyle();
198     SfxStyleSheetBasePool* pPool = GetDoc().GetStyleSheetPool();
199     SfxStyleSheetBase* pStyle = pPool->Find(aStyleName, SfxStyleFamily::Para);
200     SfxItemSet& rSet = pStyle->GetItemSet();
201 
202     std::unique_ptr<ScTokenArray> pTokenArray(mrFormat.CreateFlatCopiedTokenArray(0));
203     aFormula = XclXmlUtils::ToOUString( GetCompileFormulaContext(), mrFormat.GetValidSrcPos(), pTokenArray.get());
204 
205     std::unique_ptr<XclExpColor> pColor(new XclExpColor);
206     if(!pColor->FillFromItemSet( rSet ))
207         pColor.reset();
208 
209     std::unique_ptr<XclExpCellBorder> pBorder(new XclExpCellBorder);
210     if (!pBorder->FillFromItemSet( rSet, GetPalette(), GetBiff()) )
211         pBorder.reset();
212 
213     std::unique_ptr<XclExpCellAlign> pAlign(new XclExpCellAlign);
214     if (!pAlign->FillFromItemSet(*this, rSet, false, GetBiff()))
215         pAlign.reset();
216 
217     std::unique_ptr<XclExpCellProt> pCellProt(new XclExpCellProt);
218     if (!pCellProt->FillFromItemSet( rSet ))
219         pCellProt.reset();
220 
221     std::unique_ptr<XclExpDxfFont> pFont(new XclExpDxfFont(GetRoot(), rSet));
222 
223     std::unique_ptr<XclExpNumFmt> pNumFormat;
224     const SfxPoolItem *pPoolItem = nullptr;
225     if( rSet.GetItemState( ATTR_VALUE_FORMAT, true, &pPoolItem ) == SfxItemState::SET )
226     {
227         sal_uInt32 nScNumFmt = static_cast< const SfxUInt32Item* >(pPoolItem)->GetValue();
228         XclExpNumFmtBuffer& rNumFmtBuffer = GetRoot().GetNumFmtBuffer();
229         sal_uInt32 nXclNumFmt = rNumFmtBuffer.Insert(nScNumFmt);
230         pNumFormat.reset(new XclExpNumFmt(nScNumFmt, nXclNumFmt, rNumFmtBuffer.GetFormatCode(nScNumFmt)));
231     }
232 
233     XclExpDxf rDxf( GetRoot(),
234                     std::move(pAlign),
235                     std::move(pBorder),
236                     std::move(pFont),
237                     std::move(pNumFormat),
238                     std::move(pCellProt),
239                     std::move(pColor) );
240 
241     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
242 
243     ScConditionMode eOperation = mrFormat.GetOperation();
244     if (RequiresFixedFormula(eOperation))
245     {
246         ScAddress aFixedFormulaPos = mrFormat.GetValidSrcPos();
247         OString aFixedFormulaText = aFormula.toUtf8();
248         OString aFixedFormula = GetFixedFormula(eOperation, aFixedFormulaPos, aFixedFormulaText);
249         rWorksheet->startElementNS( XML_xm, XML_f );
250         rWorksheet->writeEscaped(aFixedFormula.getStr());
251         rWorksheet->endElementNS( XML_xm, XML_f );
252 
253         rWorksheet->startElementNS( XML_xm, XML_f );
254         rWorksheet->writeEscaped( aFormula );
255         rWorksheet->endElementNS( XML_xm, XML_f );
256         rDxf.SaveXmlExt(rStrm);
257     }
258     else
259     {
260         rWorksheet->startElementNS(XML_xm, XML_f);
261         rWorksheet->writeEscaped(aFormula);
262         rWorksheet->endElementNS(XML_xm, XML_f);
263         rDxf.SaveXmlExt(rStrm);
264     }
265 }
266 
XclExpExtDataBar(const XclExpRoot & rRoot,const ScDataBarFormat & rFormat,const ScAddress & rPos)267 XclExpExtDataBar::XclExpExtDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, const ScAddress& rPos ):
268     XclExpRoot(rRoot)
269 {
270     const ScDataBarFormatData& rFormatData = *rFormat.GetDataBarData();
271     mpLowerLimit.reset(new XclExpExtCfvo(*this, *rFormatData.mpLowerLimit, rPos, true));
272     mpUpperLimit.reset(new XclExpExtCfvo(*this, *rFormatData.mpUpperLimit, rPos, false));
273     if (rFormatData.mxNegativeColor)
274         mpNegativeColor.reset(new XclExpExtNegativeColor(*rFormatData.mxNegativeColor));
275     else
276         mpNegativeColor.reset( new XclExpExtNegativeColor( rFormatData.maPositiveColor ) );
277     mpAxisColor.reset( new XclExpExtAxisColor( rFormatData.maAxisColor ) );
278 
279     meAxisPosition = rFormatData.meAxisPosition;
280     mbGradient = rFormatData.mbGradient;
281     mnMinLength = rFormatData.mnMinLength;
282     mnMaxLength = rFormatData.mnMaxLength;
283 }
284 
285 namespace {
286 
getAxisPosition(databar::ScAxisPosition eAxisPosition)287 const char* getAxisPosition(databar::ScAxisPosition eAxisPosition)
288 {
289     switch(eAxisPosition)
290     {
291         case databar::NONE:
292             return "none";
293         case databar::AUTOMATIC:
294             return "automatic";
295         case databar::MIDDLE:
296             return "middle";
297     }
298     return "";
299 }
300 
GetOperatorString(ScConditionMode eMode)301 const char* GetOperatorString(ScConditionMode eMode)
302 {
303     const char* pRet = nullptr;
304     switch(eMode)
305     {
306         case ScConditionMode::Equal:
307             pRet = "equal";
308             break;
309         case ScConditionMode::Less:
310             pRet = "lessThan";
311             break;
312         case ScConditionMode::Greater:
313             pRet = "greaterThan";
314             break;
315         case ScConditionMode::EqLess:
316             pRet = "lessThanOrEqual";
317             break;
318         case ScConditionMode::EqGreater:
319             pRet = "greaterThanOrEqual";
320             break;
321         case ScConditionMode::NotEqual:
322             pRet = "notEqual";
323             break;
324         case ScConditionMode::Between:
325             pRet = "between";
326             break;
327         case ScConditionMode::NotBetween:
328             pRet = "notBetween";
329             break;
330         case ScConditionMode::Duplicate:
331             pRet = nullptr;
332             break;
333         case ScConditionMode::NotDuplicate:
334             pRet = nullptr;
335             break;
336         case ScConditionMode::BeginsWith:
337             pRet = "beginsWith";
338         break;
339         case ScConditionMode::EndsWith:
340             pRet = "endsWith";
341         break;
342         case ScConditionMode::ContainsText:
343             pRet = "containsText";
344         break;
345         case ScConditionMode::NotContainsText:
346             pRet = "notContains";
347         break;
348         case ScConditionMode::Direct:
349             break;
350         case ScConditionMode::NONE:
351         default:
352             break;
353     }
354     return pRet;
355 }
356 
GetTypeString(ScConditionMode eMode)357 const char* GetTypeString(ScConditionMode eMode)
358 {
359     switch(eMode)
360     {
361         case ScConditionMode::Direct:
362             return "expression";
363         case ScConditionMode::BeginsWith:
364             return "beginsWith";
365         case ScConditionMode::EndsWith:
366             return "endsWith";
367         case ScConditionMode::ContainsText:
368             return "containsText";
369         case ScConditionMode::NotContainsText:
370             return "notContainsText";
371         default:
372             return "cellIs";
373     }
374 }
375 
376 }
377 
SaveXml(XclExpXmlStream & rStrm)378 void XclExpExtDataBar::SaveXml( XclExpXmlStream& rStrm )
379 {
380     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
381     rWorksheet->startElementNS( XML_x14, XML_dataBar,
382                                 XML_minLength, OString::number(mnMinLength),
383                                 XML_maxLength, OString::number(mnMaxLength),
384                                 XML_axisPosition, getAxisPosition(meAxisPosition),
385                                 XML_gradient, ToPsz(mbGradient) );
386 
387     mpLowerLimit->SaveXml( rStrm );
388     mpUpperLimit->SaveXml( rStrm );
389     mpNegativeColor->SaveXml( rStrm );
390     mpAxisColor->SaveXml( rStrm );
391 
392     rWorksheet->endElementNS( XML_x14, XML_dataBar );
393 }
394 
XclExpExtIconSet(const XclExpRoot & rRoot,const ScIconSetFormat & rFormat,const ScAddress & rPos)395 XclExpExtIconSet::XclExpExtIconSet(const XclExpRoot& rRoot, const ScIconSetFormat& rFormat, const ScAddress& rPos):
396     XclExpRoot(rRoot)
397 {
398     const ScIconSetFormatData& rData = *rFormat.GetIconSetData();
399     for (auto const& itr : rData.m_Entries)
400     {
401         maCfvos.AppendNewRecord(new XclExpExtCfvo(*this, *itr, rPos, false));
402     }
403     mbCustom = rData.mbCustom;
404     mbReverse = rData.mbReverse;
405     mbShowValue = rData.mbShowValue;
406     mpIconSetName = ScIconSetFormat::getIconSetName(rData.eIconSetType);
407 
408     if (mbCustom)
409     {
410         for (const auto& rItem : rData.maCustomVector)
411         {
412             maCustom.AppendNewRecord(new XclExpExtIcon(*this, rItem));
413         }
414     }
415 }
416 
SaveXml(XclExpXmlStream & rStrm)417 void XclExpExtIconSet::SaveXml(XclExpXmlStream& rStrm)
418 {
419     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
420 
421     rWorksheet->startElementNS(XML_x14, XML_iconSet,
422             XML_iconSet, mpIconSetName,
423             XML_custom, sax_fastparser::UseIf(ToPsz10(mbCustom), mbCustom),
424             XML_reverse, ToPsz10(mbReverse),
425             XML_showValue, ToPsz10(mbShowValue));
426 
427     maCfvos.SaveXml(rStrm);
428 
429     if (mbCustom)
430     {
431         maCustom.SaveXml(rStrm);
432     }
433 
434     rWorksheet->endElementNS(XML_x14, XML_iconSet);
435 }
436 
XclExpExtCfRule(const XclExpRoot & rRoot,const ScFormatEntry & rFormat,const ScAddress & rPos,const OString & rId,sal_Int32 nPriority)437 XclExpExtCfRule::XclExpExtCfRule( const XclExpRoot& rRoot, const ScFormatEntry& rFormat, const ScAddress& rPos, const OString& rId, sal_Int32 nPriority ):
438     XclExpRoot(rRoot),
439     maId(rId),
440     pType(nullptr),
441     mnPriority(nPriority),
442     mOperator(nullptr)
443 {
444     switch (rFormat.GetType())
445     {
446         case ScFormatEntry::Type::Databar:
447         {
448             const ScDataBarFormat& rDataBar = static_cast<const ScDataBarFormat&>(rFormat);
449             mxEntry = new XclExpExtDataBar( *this, rDataBar, rPos );
450             pType = "dataBar";
451         }
452         break;
453         case ScFormatEntry::Type::Iconset:
454         {
455             const ScIconSetFormat& rIconSet = static_cast<const ScIconSetFormat&>(rFormat);
456             mxEntry = new XclExpExtIconSet(*this, rIconSet, rPos);
457             pType = "iconSet";
458         }
459         break;
460         case ScFormatEntry::Type::ExtCondition:
461         {
462             const ScCondFormatEntry& rCondFormat = static_cast<const ScCondFormatEntry&>(rFormat);
463             mxEntry = new XclExpExtCF(*this, rCondFormat);
464             pType = GetTypeString(rCondFormat.GetOperation());
465             mOperator = GetOperatorString( rCondFormat.GetOperation() );
466         }
467         break;
468         default:
469         break;
470     }
471 }
472 
SaveXml(XclExpXmlStream & rStrm)473 void XclExpExtCfRule::SaveXml( XclExpXmlStream& rStrm )
474 {
475     if (!mxEntry)
476         return;
477 
478     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
479     rWorksheet->startElementNS( XML_x14, XML_cfRule,
480                                 XML_type, pType,
481                                 XML_priority, sax_fastparser::UseIf(OString::number(mnPriority + 1), mnPriority != -1),
482                                 XML_operator, mOperator,
483                                 XML_id, maId );
484 
485     mxEntry->SaveXml( rStrm );
486 
487     rWorksheet->endElementNS( XML_x14, XML_cfRule );
488 
489 }
490 
XclExpExtConditionalFormatting(const XclExpRoot & rRoot,std::vector<XclExpExtCondFormatData> & rData,const ScRangeList & rRange)491 XclExpExtConditionalFormatting::XclExpExtConditionalFormatting( const XclExpRoot& rRoot,
492         std::vector<XclExpExtCondFormatData>& rData, const ScRangeList& rRange):
493     XclExpRoot(rRoot),
494     maRange(rRange)
495 {
496     ScAddress aAddr = maRange.front().aStart;
497     for (const auto& rItem : rData)
498     {
499         const ScFormatEntry* pEntry = rItem.pEntry;
500         switch (pEntry->GetType())
501         {
502             case ScFormatEntry::Type::Iconset:
503             {
504                 const ScIconSetFormat& rIconSet = static_cast<const ScIconSetFormat&>(*pEntry);
505                 bool bNeedsExt = false;
506                 switch (rIconSet.GetIconSetData()->eIconSetType)
507                 {
508                     case IconSet_3Triangles:
509                     case IconSet_3Smilies:
510                     case IconSet_3ColorSmilies:
511                     case IconSet_5Boxes:
512                     case IconSet_3Stars:
513                         bNeedsExt = true;
514                     break;
515                     default:
516                     break;
517                 }
518 
519                 if (rIconSet.GetIconSetData()->mbCustom)
520                     bNeedsExt = true;
521 
522                 if (bNeedsExt)
523                 {
524                     maCfRules.AppendNewRecord(new XclExpExtCfRule(*this, *pEntry, aAddr, rItem.aGUID, rItem.nPriority));
525                 }
526             }
527             break;
528             case ScFormatEntry::Type::Databar:
529                 maCfRules.AppendNewRecord(new XclExpExtCfRule( *this, *pEntry, aAddr, rItem.aGUID, rItem.nPriority));
530             break;
531             case ScFormatEntry::Type::ExtCondition:
532                 maCfRules.AppendNewRecord(new XclExpExtCfRule( *this, *pEntry, aAddr, rItem.aGUID, rItem.nPriority));
533             break;
534             default:
535             break;
536         }
537     }
538 }
539 
SaveXml(XclExpXmlStream & rStrm)540 void XclExpExtConditionalFormatting::SaveXml( XclExpXmlStream& rStrm )
541 {
542     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
543     rWorksheet->startElementNS( XML_x14, XML_conditionalFormatting,
544                                 FSNS( XML_xmlns, XML_xm ), rStrm.getNamespaceURL(OOX_NS(xm)) );
545 
546     maCfRules.SaveXml( rStrm );
547     rWorksheet->startElementNS(XML_xm, XML_sqref);
548     rWorksheet->write(XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), maRange));
549 
550     rWorksheet->endElementNS( XML_xm, XML_sqref );
551 
552     rWorksheet->endElementNS( XML_x14, XML_conditionalFormatting );
553 }
554 
XclExpExtCalcPr(const XclExpRoot & rRoot,formula::FormulaGrammar::AddressConvention eConv)555 XclExpExtCalcPr::XclExpExtCalcPr( const XclExpRoot& rRoot, formula::FormulaGrammar::AddressConvention eConv ):
556     XclExpExt( rRoot )
557 {
558     maURI = OString("{7626C862-2A13-11E5-B345-FEFF819CDC9F}");
559 
560     switch (eConv)
561     {
562         case formula::FormulaGrammar::CONV_OOO:
563             maSyntax = OString("CalcA1");
564             break;
565         case formula::FormulaGrammar::CONV_XL_A1:
566             maSyntax = OString("ExcelA1");
567             break;
568         case formula::FormulaGrammar::CONV_XL_R1C1:
569             maSyntax = OString("ExcelR1C1");
570             break;
571         case formula::FormulaGrammar::CONV_A1_XL_A1:
572             maSyntax = OString("CalcA1ExcelA1");
573             break;
574         case formula::FormulaGrammar::CONV_UNSPECIFIED:
575         case formula::FormulaGrammar::CONV_ODF:
576         case formula::FormulaGrammar::CONV_XL_OOX:
577         case formula::FormulaGrammar::CONV_LOTUS_A1:
578         case formula::FormulaGrammar::CONV_LAST:
579             maSyntax = OString("Unspecified");
580             break;
581     }
582 }
583 
SaveXml(XclExpXmlStream & rStrm)584 void XclExpExtCalcPr::SaveXml( XclExpXmlStream& rStrm )
585 {
586     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
587     rWorksheet->startElement( XML_ext,
588                                 FSNS(XML_xmlns, XML_loext), rStrm.getNamespaceURL(OOX_NS(loext)),
589                                 XML_uri, maURI );
590 
591     rWorksheet->singleElementNS(XML_loext, XML_extCalcPr, XML_stringRefSyntax, maSyntax);
592 
593     rWorksheet->endElement( XML_ext );
594 }
595 
XclExpExtCondFormat(const XclExpRoot & rRoot)596 XclExpExtCondFormat::XclExpExtCondFormat( const XclExpRoot& rRoot ):
597     XclExpExt( rRoot )
598 {
599     maURI = OString("{78C0D931-6437-407d-A8EE-F0AAD7539E65}");
600 }
601 
SaveXml(XclExpXmlStream & rStrm)602 void XclExpExtCondFormat::SaveXml( XclExpXmlStream& rStrm )
603 {
604     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
605     rWorksheet->startElement( XML_ext,
606                                 FSNS(XML_xmlns, XML_x14), rStrm.getNamespaceURL(OOX_NS(xls14Lst)),
607                                 XML_uri, maURI );
608 
609     rWorksheet->startElementNS(XML_x14, XML_conditionalFormattings);
610 
611     maCF.SaveXml( rStrm );
612 
613     rWorksheet->endElementNS( XML_x14, XML_conditionalFormattings );
614     rWorksheet->endElement( XML_ext );
615 }
616 
AddRecord(XclExpExtConditionalFormatting * pEntry)617 void XclExpExtCondFormat::AddRecord( XclExpExtConditionalFormatting* pEntry )
618 {
619     maCF.AppendRecord( pEntry );
620 }
621 
SaveXml(XclExpXmlStream & rStrm)622 void XclExtLst::SaveXml( XclExpXmlStream& rStrm )
623 {
624     if(maExtEntries.IsEmpty())
625         return;
626 
627     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
628     rWorksheet->startElement(XML_extLst);
629 
630     maExtEntries.SaveXml(rStrm);
631 
632     rWorksheet->endElement( XML_extLst );
633 }
634 
AddRecord(XclExpExt * pEntry)635 void XclExtLst::AddRecord( XclExpExt* pEntry )
636 {
637     maExtEntries.AppendRecord( pEntry );
638 }
639 
GetItem(XclExpExtType eType)640 XclExpExt* XclExtLst::GetItem( XclExpExtType eType )
641 {
642     size_t n = maExtEntries.GetSize();
643     for( size_t i = 0; i < n; ++i )
644     {
645         if (maExtEntries.GetRecord( i )->GetType() == eType)
646             return maExtEntries.GetRecord( i );
647     }
648 
649     return nullptr;
650 }
651 
652 
653 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
654