LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/xml - xmlsceni.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 63 1.6 %
Date: 2013-07-09 Functions: 2 7 28.6 %
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             :  * 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             : #include "document.hxx"
      21             : #include "xmlimprt.hxx"
      22             : #include "xmlsceni.hxx"
      23             : #include "docuno.hxx"
      24             : #include "attrib.hxx"
      25             : #include "XMLConverter.hxx"
      26             : #include "rangeutl.hxx"
      27             : 
      28             : #include <xmloff/xmltkmap.hxx>
      29             : #include <xmloff/nmspmap.hxx>
      30             : #include <xmloff/xmltoken.hxx>
      31             : 
      32             : #include <sax/tools/converter.hxx>
      33             : 
      34             : using namespace com::sun::star;
      35             : using namespace xmloff::token;
      36             : 
      37             : 
      38             : //------------------------------------------------------------------
      39             : 
      40           0 : ScXMLTableScenarioContext::ScXMLTableScenarioContext(
      41             :         ScXMLImport& rImport,
      42             :         sal_uInt16 nPrfx,
      43             :         const OUString& rLName,
      44             :         const uno::Reference< xml::sax::XAttributeList >& xAttrList ):
      45             :     SvXMLImportContext( rImport, nPrfx, rLName ),
      46             :     aBorderColor( COL_BLACK ),
      47             :     bDisplayBorder( true ),
      48             :     bCopyBack( true ),
      49             :     bCopyStyles( true ),
      50             :     bCopyFormulas( true ),
      51             :     bIsActive( false ),
      52           0 :     bProtected( false )
      53             : {
      54           0 :     rImport.LockSolarMutex();
      55           0 :     sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
      56           0 :     const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetTableScenarioAttrTokenMap());
      57           0 :     for( sal_Int16 i = 0; i < nAttrCount; ++i )
      58             :     {
      59           0 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
      60           0 :         OUString aLocalName;
      61           0 :         sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
      62           0 :                                             sAttrName, &aLocalName ));
      63           0 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
      64             : 
      65           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
      66             :         {
      67             :             case XML_TOK_TABLE_SCENARIO_ATTR_DISPLAY_BORDER:
      68             :             {
      69           0 :                 bDisplayBorder = IsXMLToken(sValue, XML_TRUE);
      70             :             }
      71           0 :             break;
      72             :             case XML_TOK_TABLE_SCENARIO_ATTR_BORDER_COLOR:
      73             :             {
      74           0 :                 sal_Int32 nColor(0);
      75           0 :                 ::sax::Converter::convertColor(nColor, sValue);
      76           0 :                 aBorderColor.SetColor(nColor);
      77             :             }
      78           0 :             break;
      79             :             case XML_TOK_TABLE_SCENARIO_ATTR_COPY_BACK:
      80             :             {
      81           0 :                 bCopyBack = IsXMLToken(sValue, XML_TRUE);
      82             :             }
      83           0 :             break;
      84             :             case XML_TOK_TABLE_SCENARIO_ATTR_COPY_STYLES:
      85             :             {
      86           0 :                 bCopyStyles = IsXMLToken(sValue, XML_TRUE);
      87             :             }
      88           0 :             break;
      89             :             case XML_TOK_TABLE_SCENARIO_ATTR_COPY_FORMULAS:
      90             :             {
      91           0 :                 bCopyFormulas = IsXMLToken(sValue, XML_TRUE);
      92             :             }
      93           0 :             break;
      94             :             case XML_TOK_TABLE_SCENARIO_ATTR_IS_ACTIVE:
      95             :             {
      96           0 :                 bIsActive = IsXMLToken(sValue, XML_TRUE);
      97             :             }
      98           0 :             break;
      99             :             case XML_TOK_TABLE_SCENARIO_ATTR_SCENARIO_RANGES:
     100             :             {
     101             :                 ScRangeStringConverter::GetRangeListFromString(
     102           0 :                     aScenarioRanges, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO );
     103             :             }
     104           0 :             break;
     105             :             case XML_TOK_TABLE_SCENARIO_ATTR_COMMENT:
     106             :             {
     107           0 :                 sComment = sValue;
     108             :             }
     109           0 :             break;
     110             :             case XML_TOK_TABLE_SCENARIO_ATTR_PROTECTED:
     111             :             {
     112           0 :                 bProtected = IsXMLToken(sValue, XML_TRUE);
     113             :             }
     114           0 :             break;
     115             :         }
     116           0 :     }
     117           0 : }
     118             : 
     119           0 : ScXMLTableScenarioContext::~ScXMLTableScenarioContext()
     120             : {
     121           0 :     GetScImport().UnlockSolarMutex();
     122           0 : }
     123             : 
     124           0 : SvXMLImportContext *ScXMLTableScenarioContext::CreateChildContext(
     125             :         sal_uInt16 nPrefix,
     126             :         const OUString& rLName,
     127             :         const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ )
     128             : {
     129           0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLName );
     130             : }
     131             : 
     132           0 : void ScXMLTableScenarioContext::EndElement()
     133             : {
     134           0 :     SCTAB nCurrTable( GetScImport().GetTables().GetCurrentSheet() );
     135           0 :     ScDocument* pDoc(GetScImport().GetDocument());
     136           0 :     if (pDoc)
     137             :     {
     138           0 :         pDoc->SetScenario( nCurrTable, true );
     139           0 :         sal_uInt16 nFlags( 0 );
     140           0 :         if( bDisplayBorder )
     141           0 :             nFlags |= SC_SCENARIO_SHOWFRAME;
     142           0 :         if( bCopyBack )
     143           0 :             nFlags |= SC_SCENARIO_TWOWAY;
     144           0 :         if( bCopyStyles )
     145           0 :             nFlags |= SC_SCENARIO_ATTRIB;
     146           0 :         if( !bCopyFormulas )
     147           0 :             nFlags |= SC_SCENARIO_VALUE;
     148           0 :         if( bProtected )
     149           0 :             nFlags |= SC_SCENARIO_PROTECT;
     150           0 :         pDoc->SetScenarioData( nCurrTable, String( sComment ), aBorderColor, nFlags );
     151           0 :         for( size_t i = 0; i < aScenarioRanges.size(); ++i )
     152             :         {
     153           0 :             ScRange* pRange(aScenarioRanges[ i ]);
     154           0 :             if( pRange )
     155           0 :                 pDoc->ApplyFlagsTab( pRange->aStart.Col(), pRange->aStart.Row(),
     156           0 :                     pRange->aEnd.Col(), pRange->aEnd.Row(), nCurrTable, SC_MF_SCENARIO );
     157             :         }
     158           0 :         pDoc->SetActiveScenario( nCurrTable, bIsActive );
     159             :     }
     160          93 : }
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10