LCOV - code coverage report
Current view: top level - sc/source/filter/xml - XMLConsolidationContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 60 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 88 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : 
      31                 :            : 
      32                 :            : //___________________________________________________________________
      33                 :            : #include "XMLConsolidationContext.hxx"
      34                 :            : #include "document.hxx"
      35                 :            : #include "rangeutl.hxx"
      36                 :            : #include "xmlimprt.hxx"
      37                 :            : #include "XMLConverter.hxx"
      38                 :            : #include <xmloff/nmspmap.hxx>
      39                 :            : #include <xmloff/xmltoken.hxx>
      40                 :            : 
      41                 :            : using ::rtl::OUString;
      42                 :            : using namespace ::com::sun::star;
      43                 :            : using namespace xmloff::token;
      44                 :            : 
      45                 :            : 
      46                 :            : //___________________________________________________________________
      47                 :            : 
      48                 :          0 : ScXMLConsolidationContext::ScXMLConsolidationContext(
      49                 :            :         ScXMLImport& rImport,
      50                 :            :         sal_uInt16 nPrfx,
      51                 :            :         const OUString& rLName,
      52                 :            :         const uno::Reference< xml::sax::XAttributeList >& xAttrList ) :
      53                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
      54                 :            :     eFunction( SUBTOTAL_FUNC_NONE ),
      55                 :            :     bLinkToSource( false ),
      56                 :          0 :     bTargetAddr(false)
      57                 :            : {
      58         [ #  # ]:          0 :     ScXMLImport::MutexGuard aGuard(GetScImport());
      59         [ #  # ]:          0 :     if( !xAttrList.is() ) return;
      60                 :            : 
      61 [ #  # ][ #  # ]:          0 :     sal_Int16               nAttrCount      = xAttrList->getLength();
      62         [ #  # ]:          0 :     const SvXMLTokenMap&    rAttrTokenMap   = GetScImport().GetConsolidationAttrTokenMap();
      63                 :            : 
      64         [ #  # ]:          0 :     for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
      65                 :            :     {
      66 [ #  # ][ #  # ]:          0 :         const rtl::OUString& sAttrName  (xAttrList->getNameByIndex( nIndex ));
      67 [ #  # ][ #  # ]:          0 :         const rtl::OUString& sValue     (xAttrList->getValueByIndex( nIndex ));
      68                 :          0 :         OUString aLocalName;
      69         [ #  # ]:          0 :         sal_uInt16 nPrefix      = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
      70                 :            : 
      71 [ #  # ][ #  #  :          0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
             #  #  #  # ]
      72                 :            :         {
      73                 :            :             case XML_TOK_CONSOLIDATION_ATTR_FUNCTION:
      74         [ #  # ]:          0 :                 eFunction = ScXMLConverter::GetSubTotalFuncFromString( sValue );
      75                 :          0 :             break;
      76                 :            :             case XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES:
      77                 :          0 :                 sSourceList = sValue;
      78                 :          0 :             break;
      79                 :            :             case XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS:
      80                 :            :                 {
      81                 :          0 :                     sal_Int32 nOffset(0);
      82                 :            :                     bTargetAddr = ScRangeStringConverter::GetAddressFromString(
      83         [ #  # ]:          0 :                         aTargetAddr, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset );
      84                 :            :                 }
      85                 :          0 :                 break;
      86                 :            :             case XML_TOK_CONSOLIDATION_ATTR_USE_LABEL:
      87                 :          0 :                 sUseLabel = sValue;
      88                 :          0 :             break;
      89                 :            :             case XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE:
      90         [ #  # ]:          0 :                 bLinkToSource = IsXMLToken(sValue, XML_TRUE);
      91                 :          0 :             break;
      92                 :            :         }
      93 [ #  # ][ #  # ]:          0 :     }
      94                 :            : }
      95                 :            : 
      96                 :          0 : ScXMLConsolidationContext::~ScXMLConsolidationContext()
      97                 :            : {
      98         [ #  # ]:          0 : }
      99                 :            : 
     100                 :          0 : SvXMLImportContext *ScXMLConsolidationContext::CreateChildContext(
     101                 :            :         sal_uInt16 nPrefix,
     102                 :            :         const OUString& rLName,
     103                 :            :         const uno::Reference< xml::sax::XAttributeList>& /* xAttrList */ )
     104                 :            : {
     105         [ #  # ]:          0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLName );
     106                 :            : }
     107                 :            : 
     108                 :          0 : void ScXMLConsolidationContext::EndElement()
     109                 :            : {
     110         [ #  # ]:          0 :     if (bTargetAddr)
     111                 :            :     {
     112         [ #  # ]:          0 :         ScConsolidateParam aConsParam;
     113                 :          0 :         aConsParam.nCol = aTargetAddr.Col();
     114                 :          0 :         aConsParam.nRow = aTargetAddr.Row();
     115                 :          0 :         aConsParam.nTab = aTargetAddr.Tab();
     116                 :          0 :         aConsParam.eFunction = eFunction;
     117                 :            : 
     118         [ #  # ]:          0 :         sal_uInt16 nCount = (sal_uInt16) Min( ScRangeStringConverter::GetTokenCount( sSourceList ), (sal_Int32)0xFFFF );
     119 [ #  # ][ #  # ]:          0 :         ScArea** ppAreas = nCount ? new ScArea*[ nCount ] : NULL;
     120         [ #  # ]:          0 :         if( ppAreas )
     121                 :            :         {
     122                 :          0 :             sal_Int32 nOffset = 0;
     123                 :            :             sal_uInt16 nIndex;
     124         [ #  # ]:          0 :             for( nIndex = 0; nIndex < nCount; ++nIndex )
     125                 :            :             {
     126 [ #  # ][ #  # ]:          0 :                 ppAreas[ nIndex ] = new ScArea;
     127                 :          0 :                 if ( !ScRangeStringConverter::GetAreaFromString(
     128         [ #  # ]:          0 :                     *ppAreas[ nIndex ], sSourceList, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset ) )
     129                 :            :                 {
     130                 :            :                     //! handle error
     131                 :            :                 }
     132                 :            :             }
     133                 :            : 
     134         [ #  # ]:          0 :             aConsParam.SetAreas( ppAreas, nCount );
     135                 :            : 
     136                 :            :             // array is copied in SetAreas
     137         [ #  # ]:          0 :             for( nIndex = 0; nIndex < nCount; ++nIndex )
     138                 :          0 :                 delete ppAreas[nIndex];
     139         [ #  # ]:          0 :             delete[] ppAreas;
     140                 :            :         }
     141                 :            : 
     142                 :          0 :         aConsParam.bByCol = aConsParam.bByRow = false;
     143 [ #  # ][ #  # ]:          0 :         if( IsXMLToken(sUseLabel, XML_COLUMN ) )
     144                 :          0 :             aConsParam.bByCol = true;
     145 [ #  # ][ #  # ]:          0 :         else if( IsXMLToken( sUseLabel, XML_ROW ) )
     146                 :          0 :             aConsParam.bByRow = true;
     147 [ #  # ][ #  # ]:          0 :         else if( IsXMLToken( sUseLabel, XML_BOTH ) )
     148                 :          0 :             aConsParam.bByCol = aConsParam.bByRow = true;
     149                 :            : 
     150                 :          0 :         aConsParam.bReferenceData = bLinkToSource;
     151                 :            : 
     152                 :          0 :         ScDocument* pDoc = GetScImport().GetDocument();
     153         [ #  # ]:          0 :         if( pDoc )
     154 [ #  # ][ #  # ]:          0 :             pDoc->SetConsolidateDlgData( &aConsParam );
     155                 :            :     }
     156                 :          0 :     GetScImport().UnlockSolarMutex();
     157                 :          0 : }
     158                 :            : 
     159                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10