LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xeextlst.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 130 0.0 %
Date: 2014-04-14 Functions: 0 24 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10