LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/xml - XMLConsolidationContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 60 0.0 %
Date: 2013-07-09 Functions: 0 5 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             :  * 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             : 
      21             : 
      22             : 
      23             : //___________________________________________________________________
      24             : #include "XMLConsolidationContext.hxx"
      25             : #include "document.hxx"
      26             : #include "rangeutl.hxx"
      27             : #include "xmlimprt.hxx"
      28             : #include "XMLConverter.hxx"
      29             : #include <xmloff/nmspmap.hxx>
      30             : #include <xmloff/xmltoken.hxx>
      31             : 
      32             : using namespace ::com::sun::star;
      33             : using namespace xmloff::token;
      34             : 
      35             : 
      36             : //___________________________________________________________________
      37             : 
      38           0 : ScXMLConsolidationContext::ScXMLConsolidationContext(
      39             :         ScXMLImport& rImport,
      40             :         sal_uInt16 nPrfx,
      41             :         const OUString& rLName,
      42             :         const uno::Reference< xml::sax::XAttributeList >& xAttrList ) :
      43             :     SvXMLImportContext( rImport, nPrfx, rLName ),
      44             :     eFunction( SUBTOTAL_FUNC_NONE ),
      45             :     bLinkToSource( false ),
      46           0 :     bTargetAddr(false)
      47             : {
      48           0 :     ScXMLImport::MutexGuard aGuard(GetScImport());
      49           0 :     if( !xAttrList.is() ) return;
      50             : 
      51           0 :     sal_Int16               nAttrCount      = xAttrList->getLength();
      52           0 :     const SvXMLTokenMap&    rAttrTokenMap   = GetScImport().GetConsolidationAttrTokenMap();
      53             : 
      54           0 :     for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
      55             :     {
      56           0 :         const OUString& sAttrName  (xAttrList->getNameByIndex( nIndex ));
      57           0 :         const OUString& sValue     (xAttrList->getValueByIndex( nIndex ));
      58           0 :         OUString aLocalName;
      59           0 :         sal_uInt16 nPrefix      = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
      60             : 
      61           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
      62             :         {
      63             :             case XML_TOK_CONSOLIDATION_ATTR_FUNCTION:
      64           0 :                 eFunction = ScXMLConverter::GetSubTotalFuncFromString( sValue );
      65           0 :             break;
      66             :             case XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES:
      67           0 :                 sSourceList = sValue;
      68           0 :             break;
      69             :             case XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS:
      70             :                 {
      71           0 :                     sal_Int32 nOffset(0);
      72             :                     bTargetAddr = ScRangeStringConverter::GetAddressFromString(
      73           0 :                         aTargetAddr, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset );
      74             :                 }
      75           0 :                 break;
      76             :             case XML_TOK_CONSOLIDATION_ATTR_USE_LABEL:
      77           0 :                 sUseLabel = sValue;
      78           0 :             break;
      79             :             case XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE:
      80           0 :                 bLinkToSource = IsXMLToken(sValue, XML_TRUE);
      81           0 :             break;
      82             :         }
      83           0 :     }
      84             : }
      85             : 
      86           0 : ScXMLConsolidationContext::~ScXMLConsolidationContext()
      87             : {
      88           0 : }
      89             : 
      90           0 : SvXMLImportContext *ScXMLConsolidationContext::CreateChildContext(
      91             :         sal_uInt16 nPrefix,
      92             :         const OUString& rLName,
      93             :         const uno::Reference< xml::sax::XAttributeList>& /* xAttrList */ )
      94             : {
      95           0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLName );
      96             : }
      97             : 
      98           0 : void ScXMLConsolidationContext::EndElement()
      99             : {
     100           0 :     if (bTargetAddr)
     101             :     {
     102           0 :         ScConsolidateParam aConsParam;
     103           0 :         aConsParam.nCol = aTargetAddr.Col();
     104           0 :         aConsParam.nRow = aTargetAddr.Row();
     105           0 :         aConsParam.nTab = aTargetAddr.Tab();
     106           0 :         aConsParam.eFunction = eFunction;
     107             : 
     108           0 :         sal_uInt16 nCount = (sal_uInt16) std::min( ScRangeStringConverter::GetTokenCount( sSourceList ), (sal_Int32)0xFFFF );
     109           0 :         ScArea** ppAreas = nCount ? new ScArea*[ nCount ] : NULL;
     110           0 :         if( ppAreas )
     111             :         {
     112           0 :             sal_Int32 nOffset = 0;
     113             :             sal_uInt16 nIndex;
     114           0 :             for( nIndex = 0; nIndex < nCount; ++nIndex )
     115             :             {
     116           0 :                 ppAreas[ nIndex ] = new ScArea;
     117           0 :                 if ( !ScRangeStringConverter::GetAreaFromString(
     118           0 :                     *ppAreas[ nIndex ], sSourceList, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset ) )
     119             :                 {
     120             :                     //! handle error
     121             :                 }
     122             :             }
     123             : 
     124           0 :             aConsParam.SetAreas( ppAreas, nCount );
     125             : 
     126             :             // array is copied in SetAreas
     127           0 :             for( nIndex = 0; nIndex < nCount; ++nIndex )
     128           0 :                 delete ppAreas[nIndex];
     129           0 :             delete[] ppAreas;
     130             :         }
     131             : 
     132           0 :         aConsParam.bByCol = aConsParam.bByRow = false;
     133           0 :         if( IsXMLToken(sUseLabel, XML_COLUMN ) )
     134           0 :             aConsParam.bByCol = true;
     135           0 :         else if( IsXMLToken( sUseLabel, XML_ROW ) )
     136           0 :             aConsParam.bByRow = true;
     137           0 :         else if( IsXMLToken( sUseLabel, XML_BOTH ) )
     138           0 :             aConsParam.bByCol = aConsParam.bByRow = true;
     139             : 
     140           0 :         aConsParam.bReferenceData = bLinkToSource;
     141             : 
     142           0 :         ScDocument* pDoc = GetScImport().GetDocument();
     143           0 :         if( pDoc )
     144           0 :             pDoc->SetConsolidateDlgData( &aConsParam );
     145             :     }
     146           0 :     GetScImport().UnlockSolarMutex();
     147           0 : }
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10