LCOV - code coverage report
Current view: top level - sc/source/filter/xml - xmldpimp.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 529 969 54.6 %
Date: 2014-04-11 Functions: 68 114 59.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 "xmldpimp.hxx"
      21             : #include "xmlimprt.hxx"
      22             : #include "xmlfilti.hxx"
      23             : #include "xmlsorti.hxx"
      24             : #include "document.hxx"
      25             : #include "docuno.hxx"
      26             : #include "dpshttab.hxx"
      27             : #include "dpsdbtab.hxx"
      28             : #include "attrib.hxx"
      29             : #include "XMLConverter.hxx"
      30             : #include "dpgroup.hxx"
      31             : #include "dpdimsave.hxx"
      32             : #include "rangeutl.hxx"
      33             : #include "dpoutputgeometry.hxx"
      34             : 
      35             : #include "pivotsource.hxx"
      36             : 
      37             : #include <xmloff/xmltkmap.hxx>
      38             : #include <xmloff/nmspmap.hxx>
      39             : #include <xmloff/xmltoken.hxx>
      40             : #include <xmloff/xmlnmspe.hxx>
      41             : #include <xmloff/xmluconv.hxx>
      42             : #include <sax/tools/converter.hxx>
      43             : 
      44             : #include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
      45             : #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
      46             : #include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
      47             : #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
      48             : #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
      49             : #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
      50             : #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
      51             : 
      52             : using namespace com::sun::star;
      53             : using namespace xmloff::token;
      54             : using ::com::sun::star::uno::Reference;
      55             : using ::com::sun::star::xml::sax::XAttributeList;
      56             : 
      57             : 
      58           5 : ScXMLDataPilotTablesContext::ScXMLDataPilotTablesContext( ScXMLImport& rImport,
      59             :                                       sal_uInt16 nPrfx,
      60             :                                       const OUString& rLName,
      61             :                                       const ::com::sun::star::uno::Reference<
      62             :                                       ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
      63           5 :     SvXMLImportContext( rImport, nPrfx, rLName )
      64             : {
      65             :     // has no Attributes
      66           5 :     rImport.LockSolarMutex();
      67           5 : }
      68             : 
      69          15 : ScXMLDataPilotTablesContext::~ScXMLDataPilotTablesContext()
      70             : {
      71           5 :     GetScImport().UnlockSolarMutex();
      72          10 : }
      73             : 
      74           7 : SvXMLImportContext *ScXMLDataPilotTablesContext::CreateChildContext( sal_uInt16 nPrefix,
      75             :                                             const OUString& rLName,
      76             :                                             const ::com::sun::star::uno::Reference<
      77             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
      78             : {
      79           7 :     SvXMLImportContext *pContext = 0;
      80             : 
      81           7 :     const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTablesElemTokenMap();
      82           7 :     switch( rTokenMap.Get( nPrefix, rLName ) )
      83             :     {
      84             :         case XML_TOK_DATA_PILOT_TABLE :
      85             :         {
      86             :             pContext = new ScXMLDataPilotTableContext( GetScImport(), nPrefix,
      87           7 :                                                           rLName, xAttrList);
      88             :         }
      89           7 :         break;
      90             :     }
      91             : 
      92           7 :     if( !pContext )
      93           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
      94             : 
      95           7 :     return pContext;
      96             : }
      97             : 
      98           5 : void ScXMLDataPilotTablesContext::EndElement()
      99             : {
     100           5 : }
     101             : 
     102          14 : ScXMLDataPilotTableContext::GrandTotalItem::GrandTotalItem() :
     103          14 :     mbVisible(true) {}
     104             : 
     105           7 : ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport,
     106             :                                       sal_uInt16 nPrfx,
     107             :                                       const OUString& rLName,
     108             :                                       const ::com::sun::star::uno::Reference<
     109             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
     110             :     SvXMLImportContext( rImport, nPrfx, rLName ),
     111           7 :     pDoc(GetScImport().GetDocument()),
     112             :     pDPObject(NULL),
     113             :     pDPDimSaveData(NULL),
     114             :     sDataPilotTableName(),
     115             :     sApplicationData(),
     116             :     mnRowFieldCount(0),
     117             :     mnColFieldCount(0),
     118             :     mnPageFieldCount(0),
     119             :     mnDataFieldCount(0),
     120             :     mnDataLayoutType(sheet::DataPilotFieldOrientation_HIDDEN),
     121             :     bIsNative(true),
     122             :     bIgnoreEmptyRows(false),
     123             :     bIdentifyCategories(false),
     124             :     bTargetRangeAddress(false),
     125             :     bSourceCellRange(false),
     126             :     bShowFilter(true),
     127             :     bDrillDown(true),
     128          14 :     bHeaderGridLayout(false)
     129             : {
     130           7 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     131           7 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableAttrTokenMap();
     132          35 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     133             :     {
     134          28 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
     135          56 :         OUString aLocalName;
     136          28 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
     137          28 :                                             sAttrName, &aLocalName );
     138          56 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
     139             : 
     140          28 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
     141             :         {
     142             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_NAME :
     143             :             {
     144           7 :                 sDataPilotTableName = sValue;
     145             :             }
     146           7 :             break;
     147             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA :
     148             :             {
     149           7 :                 sApplicationData = sValue;
     150             :             }
     151           7 :             break;
     152             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL :
     153             :             {
     154           0 :                 if (IsXMLToken(sValue, XML_BOTH))
     155             :                 {
     156           0 :                     maRowGrandTotal.mbVisible = true;
     157           0 :                     maColGrandTotal.mbVisible = true;
     158             :                 }
     159           0 :                 else if (IsXMLToken(sValue, XML_ROW))
     160             :                 {
     161           0 :                     maRowGrandTotal.mbVisible = true;
     162           0 :                     maColGrandTotal.mbVisible = false;
     163             :                 }
     164           0 :                 else if (IsXMLToken(sValue, XML_COLUMN))
     165             :                 {
     166           0 :                     maRowGrandTotal.mbVisible = false;
     167           0 :                     maColGrandTotal.mbVisible = true;
     168             :                 }
     169             :                 else
     170             :                 {
     171           0 :                     maRowGrandTotal.mbVisible = false;
     172           0 :                     maColGrandTotal.mbVisible = false;
     173             :                 }
     174             :             }
     175           0 :             break;
     176             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS :
     177             :             {
     178           0 :                 bIgnoreEmptyRows = IsXMLToken(sValue, XML_TRUE);
     179             :             }
     180           0 :             break;
     181             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES :
     182             :             {
     183           0 :                 bIdentifyCategories = IsXMLToken(sValue, XML_TRUE);
     184             :             }
     185           0 :             break;
     186             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS :
     187             :             {
     188           7 :                 sal_Int32 nOffset(0);
     189           7 :                 bTargetRangeAddress = ScRangeStringConverter::GetRangeFromString( aTargetRangeAddress, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset );
     190             :             }
     191           7 :             break;
     192             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS :
     193             :             {
     194           7 :                 sButtons = sValue;
     195             :             }
     196           7 :             break;
     197             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON :
     198             :             {
     199           0 :                 bShowFilter = IsXMLToken(sValue, XML_TRUE);
     200             :             }
     201           0 :             break;
     202             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN :
     203             :             {
     204           0 :                 bDrillDown = IsXMLToken(sValue, XML_TRUE);
     205             :             }
     206           0 :             break;
     207             :             case XML_TOK_DATA_PILOT_TABLE_ATTR_HEADER_GRID_LAYOUT :
     208             :             {
     209           0 :                 bHeaderGridLayout = IsXMLToken(sValue, XML_TRUE);
     210             :             }
     211           0 :             break;
     212             :         }
     213          28 :     }
     214             : 
     215           7 :     pDPObject = new ScDPObject(pDoc);
     216           7 :     pDPSave.reset(new ScDPSaveData());
     217           7 : }
     218             : 
     219          21 : ScXMLDataPilotTableContext::~ScXMLDataPilotTableContext()
     220             : {
     221           7 :     delete pDPDimSaveData;
     222          14 : }
     223             : 
     224          45 : SvXMLImportContext *ScXMLDataPilotTableContext::CreateChildContext( sal_uInt16 nPrefix,
     225             :                                             const OUString& rLName,
     226             :                                             const ::com::sun::star::uno::Reference<
     227             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     228             : {
     229          45 :     SvXMLImportContext *pContext = 0;
     230             : 
     231          45 :     const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTableElemTokenMap();
     232          45 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     233             :     {
     234             :         case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL :
     235             :         {
     236           0 :             pContext = new ScXMLDPSourceSQLContext(GetScImport(), nPrefix, rLName, xAttrList, this);
     237           0 :             nSourceType = SQL;
     238             :         }
     239           0 :         break;
     240             :         case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE :
     241             :         {
     242           0 :             pContext = new ScXMLDPSourceTableContext(GetScImport(), nPrefix, rLName, xAttrList, this);
     243           0 :             nSourceType = TABLE;
     244             :         }
     245           0 :         break;
     246             :         case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY :
     247             :         {
     248           0 :             pContext = new ScXMLDPSourceQueryContext(GetScImport(), nPrefix, rLName, xAttrList, this);
     249           0 :             nSourceType = QUERY;
     250             :         }
     251           0 :         break;
     252             :         case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE :
     253             :         {
     254           0 :             pContext = new ScXMLSourceServiceContext(GetScImport(), nPrefix, rLName, xAttrList, this);
     255           0 :             nSourceType = SERVICE;
     256             :         }
     257           0 :         break;
     258             :         case XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL:
     259             :         case XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL_EXT:
     260             :         {
     261           0 :             pContext = new ScXMLDataPilotGrandTotalContext(GetScImport(), nPrefix, rLName, xAttrList, this);
     262             :         }
     263           0 :         break;
     264             :         case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE :
     265             :         {
     266           7 :             pContext = new ScXMLSourceCellRangeContext(GetScImport(), nPrefix, rLName, xAttrList, this);
     267           7 :             nSourceType = CELLRANGE;
     268             :         }
     269           7 :         break;
     270             :         case XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD :
     271          38 :             pContext = new ScXMLDataPilotFieldContext(GetScImport(), nPrefix, rLName, xAttrList, this);
     272          38 :         break;
     273             :     }
     274             : 
     275          45 :     if( !pContext )
     276           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     277             : 
     278          45 :     return pContext;
     279             : }
     280             : 
     281             : namespace {
     282             : 
     283          34 : const ScDPSaveDimension* getDimension(
     284             :     const std::vector<const ScDPSaveDimension*>& rRowDims,
     285             :     const std::vector<const ScDPSaveDimension*>& rColDims,
     286             :     const std::vector<const ScDPSaveDimension*>& rPageDims,
     287             :     ScDPOutputGeometry::FieldType eType, size_t nPos)
     288             : {
     289          34 :     switch (eType)
     290             :     {
     291             :         case ScDPOutputGeometry::Column:
     292             :         {
     293           9 :             if (rColDims.size() <= nPos)
     294           0 :                 return NULL;
     295             : 
     296           9 :             return rColDims[nPos];
     297             :         }
     298             :         case ScDPOutputGeometry::Row:
     299             :         {
     300          11 :             if (rRowDims.size() <= nPos)
     301           0 :                 return NULL;
     302             : 
     303          11 :             return rRowDims[nPos];
     304             :         }
     305             :         case ScDPOutputGeometry::Page:
     306             :         {
     307           6 :             if (rPageDims.size() <= nPos)
     308           0 :                 return NULL;
     309             : 
     310           6 :             return rPageDims[nPos];
     311             :         }
     312             :         case ScDPOutputGeometry::Data:
     313           0 :         break;
     314             :         case ScDPOutputGeometry::None:
     315           8 :         break;
     316             :         default:
     317           0 :             break;
     318             :     }
     319           8 :     return NULL;
     320             : }
     321             : 
     322           7 : ScDPOutputGeometry::FieldType toFieldType(sal_uInt16 nOrient)
     323             : {
     324           7 :     switch (nOrient)
     325             :     {
     326             :         case sheet::DataPilotFieldOrientation_COLUMN:
     327           0 :             return ScDPOutputGeometry::Column;
     328             :         case sheet::DataPilotFieldOrientation_DATA:
     329           0 :             return ScDPOutputGeometry::Data;
     330             :         case sheet::DataPilotFieldOrientation_PAGE:
     331           0 :             return ScDPOutputGeometry::Page;
     332             :         case sheet::DataPilotFieldOrientation_ROW:
     333           5 :             return ScDPOutputGeometry::Row;
     334             :         case sheet::DataPilotFieldOrientation_HIDDEN:
     335           2 :             break;
     336             :         default:
     337           0 :             break;
     338             :     }
     339           2 :     return ScDPOutputGeometry::None;
     340             : }
     341             : 
     342             : }
     343             : 
     344           7 : void ScXMLDataPilotTableContext::SetButtons()
     345             : {
     346           7 :     ScDPOutputGeometry aGeometry(aTargetRangeAddress, bShowFilter);
     347           7 :     aGeometry.setColumnFieldCount(mnColFieldCount);
     348           7 :     aGeometry.setRowFieldCount(mnRowFieldCount);
     349           7 :     aGeometry.setPageFieldCount(mnPageFieldCount);
     350           7 :     aGeometry.setDataFieldCount(mnDataFieldCount);
     351           7 :     aGeometry.setDataLayoutType(toFieldType(mnDataLayoutType));
     352             : 
     353          14 :     std::vector<const ScDPSaveDimension*> aRowDims, aColDims, aPageDims;
     354           7 :     pDPSave->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aRowDims);
     355           7 :     pDPSave->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aColDims);
     356           7 :     pDPSave->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_PAGE, aPageDims);
     357             : 
     358          14 :     OUString sAddress;
     359           7 :     sal_Int32 nOffset = 0;
     360          55 :     while( nOffset >= 0 )
     361             :     {
     362          41 :         ScRangeStringConverter::GetTokenByOffset( sAddress, sButtons, nOffset );
     363          41 :         if( nOffset >= 0 )
     364             :         {
     365          34 :             ScAddress aScAddress;
     366          34 :             sal_Int32 nAddrOffset(0);
     367          34 :             if (pDoc && ScRangeStringConverter::GetAddressFromString( aScAddress, sAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nAddrOffset ))
     368             :             {
     369          34 :                 std::pair<ScDPOutputGeometry::FieldType, size_t> aBtnType = aGeometry.getFieldButtonType(aScAddress);
     370             :                 const ScDPSaveDimension* pDim = getDimension(
     371          34 :                     aRowDims, aColDims, aPageDims, aBtnType.first, aBtnType.second);
     372             : 
     373          34 :                 bool bDimension = pDim != NULL;
     374          34 :                 bool bDataLayout = pDim && pDim->IsDataLayout();
     375          34 :                 bool bHasHidden = pDim && pDim->HasInvisibleMember();
     376          34 :                 bool bPageDim = pDim && pDim->GetOrientation() == sheet::DataPilotFieldOrientation_PAGE;
     377             : 
     378          34 :                 if (bPageDim)
     379             :                 {
     380             :                     // Page dimension needs 2 buttons.
     381             : 
     382           6 :                     pDoc->ApplyFlagsTab(aScAddress.Col(), aScAddress.Row(), aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), SC_MF_BUTTON);
     383             : 
     384           6 :                     sal_Int16 nMFlag = SC_MF_BUTTON_POPUP;
     385           6 :                     if (bHasHidden)
     386           1 :                         nMFlag |= SC_MF_HIDDEN_MEMBER;
     387           6 :                     pDoc->ApplyFlagsTab(aScAddress.Col()+1, aScAddress.Row(), aScAddress.Col()+1, aScAddress.Row(), aScAddress.Tab(), nMFlag);
     388             :                 }
     389             :                 else
     390             :                 {
     391          28 :                     sal_Int16 nMFlag = SC_MF_BUTTON;
     392          28 :                     if (bDataLayout)
     393             :                     {
     394             :                         // Data layout dimension only has a plain button with no popup.
     395             :                     }
     396          28 :                     else if (bDimension)
     397             :                     {
     398             :                         // Normal dimension has a popup arrow button.
     399          20 :                         if (bHasHidden)
     400           1 :                             nMFlag |= SC_MF_HIDDEN_MEMBER;
     401             : 
     402          20 :                         nMFlag |= SC_MF_BUTTON_POPUP;
     403             :                     }
     404             : 
     405          28 :                     pDoc->ApplyFlagsTab(aScAddress.Col(), aScAddress.Row(), aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), nMFlag);
     406             :                 }
     407             :             }
     408             :         }
     409             :     }
     410             : 
     411           7 :     if ( pDPObject )
     412          14 :         pDPObject->RefreshAfterLoad();
     413           7 : }
     414             : 
     415           2 : void ScXMLDataPilotTableContext::SetSelectedPage( const OUString& rDimName, const OUString& rSelected )
     416             : {
     417           2 :     maSelectedPages.insert(SelectedPagesType::value_type(rDimName, rSelected));
     418           2 : }
     419             : 
     420          38 : void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim)
     421             : {
     422          38 :     if (pDPSave)
     423             :     {
     424          38 :         if (pDim->IsDataLayout())
     425           5 :             mnDataLayoutType = pDim->GetOrientation();
     426             : 
     427             :         //  if a dimension with that name has already been inserted,
     428             :         //  mark the new one as duplicate
     429          71 :         if ( !pDim->IsDataLayout() &&
     430          33 :                 pDPSave->GetExistingDimensionByName(pDim->GetName()) )
     431           0 :             pDim->SetDupFlag(true);
     432             : 
     433          38 :         switch (pDim->GetOrientation())
     434             :         {
     435             :             case sheet::DataPilotFieldOrientation_ROW:
     436          17 :                 ++mnRowFieldCount;
     437          17 :             break;
     438             :             case sheet::DataPilotFieldOrientation_COLUMN:
     439           9 :                 ++mnColFieldCount;
     440           9 :             break;
     441             :             case sheet::DataPilotFieldOrientation_PAGE:
     442           6 :                 ++mnPageFieldCount;
     443           6 :             break;
     444             :             case sheet::DataPilotFieldOrientation_DATA:
     445           6 :                 ++mnDataFieldCount;
     446           6 :             break;
     447             :             case sheet::DataPilotFieldOrientation_HIDDEN:
     448           0 :                 break;
     449             :             default:
     450           0 :                 break;
     451             :         }
     452             : 
     453          38 :         pDPSave->AddDimension(pDim);
     454             :     }
     455          38 : }
     456             : 
     457           2 : void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim)
     458             : {
     459           2 :     if (!pDPDimSaveData)
     460           1 :         pDPDimSaveData = new ScDPDimensionSaveData();
     461           2 :     pDPDimSaveData->AddNumGroupDimension(aNumGroupDim);
     462           2 : }
     463             : 
     464           2 : void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveGroupDimension& aGroupDim)
     465             : {
     466           2 :     if (!pDPDimSaveData)
     467           1 :         pDPDimSaveData = new ScDPDimensionSaveData();
     468           2 :     pDPDimSaveData->AddGroupDimension(aGroupDim);
     469           2 : }
     470             : 
     471           7 : void ScXMLDataPilotTableContext::EndElement()
     472             : {
     473           7 :     if (!bTargetRangeAddress)
     474           7 :         return;
     475             : 
     476           7 :     pDPObject->SetName(sDataPilotTableName);
     477           7 :     pDPObject->SetTag(sApplicationData);
     478           7 :     pDPObject->SetOutRange(aTargetRangeAddress);
     479           7 :     pDPObject->SetHeaderLayout(bHeaderGridLayout);
     480             : 
     481           7 :     sc::PivotTableSources& rPivotSources = GetScImport().GetPivotTableSources();
     482             : 
     483           7 :     switch (nSourceType)
     484             :     {
     485             :         case SQL :
     486             :         {
     487           0 :             ScImportSourceDesc aImportDesc(pDoc);
     488           0 :             aImportDesc.aDBName = sDatabaseName;
     489           0 :             aImportDesc.aObject = sSourceObject;
     490           0 :             aImportDesc.nType = sheet::DataImportMode_SQL;
     491           0 :             aImportDesc.bNative = bIsNative;
     492           0 :             rPivotSources.appendDBSource(pDPObject, aImportDesc);
     493             :         }
     494           0 :         break;
     495             :         case TABLE :
     496             :         {
     497           0 :             ScImportSourceDesc aImportDesc(pDoc);
     498           0 :             aImportDesc.aDBName = sDatabaseName;
     499           0 :             aImportDesc.aObject = sSourceObject;
     500           0 :             aImportDesc.nType = sheet::DataImportMode_TABLE;
     501           0 :             rPivotSources.appendDBSource(pDPObject, aImportDesc);
     502             :         }
     503           0 :         break;
     504             :         case QUERY :
     505             :         {
     506           0 :             ScImportSourceDesc aImportDesc(pDoc);
     507           0 :             aImportDesc.aDBName = sDatabaseName;
     508           0 :             aImportDesc.aObject = sSourceObject;
     509           0 :             aImportDesc.nType = sheet::DataImportMode_QUERY;
     510           0 :             rPivotSources.appendDBSource(pDPObject, aImportDesc);
     511             :         }
     512           0 :         break;
     513             :         case SERVICE :
     514             :         {
     515             :             ScDPServiceDesc aServiceDesc(sServiceName, sServiceSourceName, sServiceSourceObject,
     516           0 :                                 sServiceUsername, sServicePassword);
     517           0 :             rPivotSources.appendServiceSource(pDPObject, aServiceDesc);
     518             :         }
     519           0 :         break;
     520             :         case CELLRANGE :
     521             :         {
     522           7 :             if (bSourceCellRange)
     523             :             {
     524           7 :                 ScSheetSourceDesc aSheetDesc(pDoc);
     525           7 :                 if (!sSourceRangeName.isEmpty())
     526             :                     // Range name takes precedence.
     527           1 :                     aSheetDesc.SetRangeName(sSourceRangeName);
     528             :                 else
     529           6 :                     aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
     530           7 :                 aSheetDesc.SetQueryParam(aSourceQueryParam);
     531           7 :                 rPivotSources.appendSheetSource(pDPObject, aSheetDesc);
     532             :             }
     533             :         }
     534           7 :         break;
     535             :     }
     536             : 
     537           7 :     rPivotSources.appendSelectedPages(pDPObject, maSelectedPages);
     538             : 
     539           7 :     pDPSave->SetRowGrand(maRowGrandTotal.mbVisible);
     540           7 :     pDPSave->SetColumnGrand(maColGrandTotal.mbVisible);
     541           7 :     if (!maRowGrandTotal.maDisplayName.isEmpty())
     542             :         // TODO: Right now, we only support one grand total name for both
     543             :         // column and row totals.  Take the value from the row total for
     544             :         // now.
     545           0 :         pDPSave->SetGrandTotalName(maRowGrandTotal.maDisplayName);
     546             : 
     547           7 :     pDPSave->SetIgnoreEmptyRows(bIgnoreEmptyRows);
     548           7 :     pDPSave->SetRepeatIfEmpty(bIdentifyCategories);
     549           7 :     pDPSave->SetFilterButton(bShowFilter);
     550           7 :     pDPSave->SetDrillDown(bDrillDown);
     551           7 :     if (pDPDimSaveData)
     552           2 :         pDPSave->SetDimensionData(pDPDimSaveData);
     553           7 :     pDPObject->SetSaveData(*pDPSave);
     554             : 
     555           7 :     ScDPCollection* pDPCollection = pDoc->GetDPCollection();
     556             : 
     557             :     // #i94570# Names have to be unique, or the tables can't be accessed by API.
     558           7 :     if ( pDPCollection->GetByName(pDPObject->GetName()) )
     559           0 :         pDPObject->SetName( OUString() );     // ignore the invalid name, create a new name in AfterXMLLoading
     560             : 
     561           7 :     pDPCollection->InsertNewTable(pDPObject);
     562           7 :     SetButtons();
     563             : }
     564             : 
     565           0 : void ScXMLDataPilotTableContext::SetGrandTotal(
     566             :     XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName)
     567             : {
     568           0 :     switch (eOrientation)
     569             :     {
     570             :         case XML_BOTH:
     571           0 :             maRowGrandTotal.mbVisible     = bVisible;
     572           0 :             maRowGrandTotal.maDisplayName = rDisplayName;
     573           0 :             maColGrandTotal.mbVisible     = bVisible;
     574           0 :             maColGrandTotal.maDisplayName = rDisplayName;
     575           0 :         break;
     576             :         case XML_ROW:
     577           0 :             maRowGrandTotal.mbVisible     = bVisible;
     578           0 :             maRowGrandTotal.maDisplayName = rDisplayName;
     579           0 :         break;
     580             :         case XML_COLUMN:
     581           0 :             maColGrandTotal.mbVisible     = bVisible;
     582           0 :             maColGrandTotal.maDisplayName = rDisplayName;
     583           0 :         break;
     584             :         default:
     585           0 :             break;
     586             :     }
     587           0 : }
     588             : 
     589           0 : ScXMLDPSourceSQLContext::ScXMLDPSourceSQLContext( ScXMLImport& rImport,
     590             :                                       sal_uInt16 nPrfx,
     591             :                                       const OUString& rLName,
     592             :                                       const ::com::sun::star::uno::Reference<
     593             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     594             :                                         ScXMLDataPilotTableContext* pTempDataPilotTable) :
     595             :     SvXMLImportContext( rImport, nPrfx, rLName ),
     596           0 :     pDataPilotTable(pTempDataPilotTable)
     597             : {
     598           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     599           0 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceSQLAttrTokenMap();
     600           0 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     601             :     {
     602           0 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
     603           0 :         OUString aLocalName;
     604           0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
     605           0 :                                             sAttrName, &aLocalName );
     606           0 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
     607             : 
     608           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
     609             :         {
     610             :             case XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME :
     611             :             {
     612           0 :                 pDataPilotTable->SetDatabaseName(sValue);
     613             :             }
     614           0 :             break;
     615             :             case XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT :
     616             :             {
     617           0 :                 pDataPilotTable->SetSourceObject(sValue);
     618             :             }
     619           0 :             break;
     620             :             case XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT :
     621             :             {
     622           0 :                 pDataPilotTable->SetNative(!IsXMLToken(sValue, XML_TRUE));
     623             :             }
     624           0 :             break;
     625             :         }
     626           0 :     }
     627           0 : }
     628             : 
     629           0 : ScXMLDPSourceSQLContext::~ScXMLDPSourceSQLContext()
     630             : {
     631           0 : }
     632             : 
     633           0 : SvXMLImportContext *ScXMLDPSourceSQLContext::CreateChildContext( sal_uInt16 nPrefix,
     634             :                                             const OUString& rLName,
     635             :                                             const ::com::sun::star::uno::Reference<
     636             :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
     637             : {
     638           0 :     SvXMLImportContext *pContext = 0;
     639             : 
     640           0 :     if( !pContext )
     641           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     642             : 
     643           0 :     return pContext;
     644             : }
     645             : 
     646           0 : void ScXMLDPSourceSQLContext::EndElement()
     647             : {
     648           0 : }
     649             : 
     650           0 : ScXMLDPSourceTableContext::ScXMLDPSourceTableContext( ScXMLImport& rImport,
     651             :                                       sal_uInt16 nPrfx,
     652             :                                       const OUString& rLName,
     653             :                                       const ::com::sun::star::uno::Reference<
     654             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     655             :                                         ScXMLDataPilotTableContext* pTempDataPilotTable) :
     656             :     SvXMLImportContext( rImport, nPrfx, rLName ),
     657           0 :     pDataPilotTable(pTempDataPilotTable)
     658             : {
     659           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     660           0 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceTableAttrTokenMap();
     661           0 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     662             :     {
     663           0 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
     664           0 :         OUString aLocalName;
     665           0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
     666           0 :                                             sAttrName, &aLocalName );
     667           0 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
     668             : 
     669           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
     670             :         {
     671             :             case XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME :
     672             :             {
     673           0 :                 pDataPilotTable->SetDatabaseName(sValue);
     674             :             }
     675           0 :             break;
     676             :             case XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME :
     677             :             {
     678           0 :                 pDataPilotTable->SetSourceObject(sValue);
     679             :             }
     680           0 :             break;
     681             :         }
     682           0 :     }
     683           0 : }
     684             : 
     685           0 : ScXMLDPSourceTableContext::~ScXMLDPSourceTableContext()
     686             : {
     687           0 : }
     688             : 
     689           0 : SvXMLImportContext *ScXMLDPSourceTableContext::CreateChildContext( sal_uInt16 nPrefix,
     690             :                                             const OUString& rLName,
     691             :                                             const ::com::sun::star::uno::Reference<
     692             :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
     693             : {
     694           0 :     SvXMLImportContext *pContext = 0;
     695             : 
     696           0 :     if( !pContext )
     697           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     698             : 
     699           0 :     return pContext;
     700             : }
     701             : 
     702           0 : void ScXMLDPSourceTableContext::EndElement()
     703             : {
     704           0 : }
     705             : 
     706           0 : ScXMLDPSourceQueryContext::ScXMLDPSourceQueryContext( ScXMLImport& rImport,
     707             :                                       sal_uInt16 nPrfx,
     708             :                                       const OUString& rLName,
     709             :                                       const ::com::sun::star::uno::Reference<
     710             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     711             :                                         ScXMLDataPilotTableContext* pTempDataPilotTable) :
     712             :     SvXMLImportContext( rImport, nPrfx, rLName ),
     713           0 :     pDataPilotTable(pTempDataPilotTable)
     714             : {
     715           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     716           0 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceQueryAttrTokenMap();
     717           0 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     718             :     {
     719           0 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
     720           0 :         OUString aLocalName;
     721           0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
     722           0 :                                             sAttrName, &aLocalName );
     723           0 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
     724             : 
     725           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
     726             :         {
     727             :             case XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME :
     728             :             {
     729           0 :                 pDataPilotTable->SetDatabaseName(sValue);
     730             :             }
     731           0 :             break;
     732             :             case XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME :
     733             :             {
     734           0 :                 pDataPilotTable->SetSourceObject(sValue);
     735             :             }
     736           0 :             break;
     737             :         }
     738           0 :     }
     739           0 : }
     740             : 
     741           0 : ScXMLDPSourceQueryContext::~ScXMLDPSourceQueryContext()
     742             : {
     743           0 : }
     744             : 
     745           0 : SvXMLImportContext *ScXMLDPSourceQueryContext::CreateChildContext( sal_uInt16 nPrefix,
     746             :                                             const OUString& rLName,
     747             :                                             const ::com::sun::star::uno::Reference<
     748             :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
     749             : {
     750           0 :     SvXMLImportContext *pContext = 0;
     751             : 
     752           0 :     if( !pContext )
     753           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     754             : 
     755           0 :     return pContext;
     756             : }
     757             : 
     758           0 : void ScXMLDPSourceQueryContext::EndElement()
     759             : {
     760           0 : }
     761             : 
     762           0 : ScXMLSourceServiceContext::ScXMLSourceServiceContext( ScXMLImport& rImport,
     763             :                                       sal_uInt16 nPrfx,
     764             :                                       const OUString& rLName,
     765             :                                       const ::com::sun::star::uno::Reference<
     766             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     767             :                                         ScXMLDataPilotTableContext* pTempDataPilotTable) :
     768             :     SvXMLImportContext( rImport, nPrfx, rLName ),
     769           0 :     pDataPilotTable(pTempDataPilotTable)
     770             : {
     771           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     772           0 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableSourceServiceAttrTokenMap();
     773           0 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     774             :     {
     775           0 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
     776           0 :         OUString aLocalName;
     777           0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
     778           0 :                                             sAttrName, &aLocalName );
     779           0 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
     780             : 
     781           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
     782             :         {
     783             :             case XML_TOK_SOURCE_SERVICE_ATTR_NAME :
     784             :             {
     785           0 :                 pDataPilotTable->SetServiceName(sValue);
     786             :             }
     787           0 :             break;
     788             :             case XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME :
     789             :             {
     790           0 :                 pDataPilotTable->SetServiceSourceName(sValue);
     791             :             }
     792           0 :             break;
     793             :             case XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME :
     794             :             {
     795           0 :                 pDataPilotTable->SetServiceSourceObject(sValue);
     796             :             }
     797           0 :             break;
     798             :             case XML_TOK_SOURCE_SERVICE_ATTR_USER_NAME :
     799             :             {
     800           0 :                 pDataPilotTable->SetServiceUsername(sValue);
     801             :             }
     802           0 :             break;
     803             :             case XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD :
     804             :             {
     805           0 :                 pDataPilotTable->SetServicePassword(sValue);
     806             :             }
     807           0 :             break;
     808             :         }
     809           0 :     }
     810           0 : }
     811             : 
     812           0 : ScXMLSourceServiceContext::~ScXMLSourceServiceContext()
     813             : {
     814           0 : }
     815             : 
     816           0 : SvXMLImportContext *ScXMLSourceServiceContext::CreateChildContext( sal_uInt16 nPrefix,
     817             :                                             const OUString& rLName,
     818             :                                             const ::com::sun::star::uno::Reference<
     819             :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
     820             : {
     821           0 :     SvXMLImportContext *pContext = 0;
     822             : 
     823           0 :     if( !pContext )
     824           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     825             : 
     826           0 :     return pContext;
     827             : }
     828             : 
     829           0 : void ScXMLSourceServiceContext::EndElement()
     830             : {
     831           0 : }
     832             : 
     833           0 : ScXMLImport& ScXMLDataPilotGrandTotalContext::GetScImport()
     834             : {
     835           0 :     return static_cast<ScXMLImport&>(GetImport());
     836             : }
     837             : 
     838           0 : ScXMLDataPilotGrandTotalContext::ScXMLDataPilotGrandTotalContext(
     839             :     ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, const Reference<XAttributeList>& xAttrList,
     840             :     ScXMLDataPilotTableContext* pTableContext ) :
     841             :     SvXMLImportContext( rImport, nPrefix, rLName ),
     842             :     mpTableContext(pTableContext),
     843             :     meOrientation(NONE),
     844           0 :     mbVisible(false)
     845             : {
     846           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     847           0 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotGrandTotalAttrTokenMap();
     848           0 :     for (sal_Int16 i = 0; i < nAttrCount; ++i)
     849             :     {
     850           0 :         const OUString& rAttrName  = xAttrList->getNameByIndex(i);
     851           0 :         const OUString& rAttrValue = xAttrList->getValueByIndex(i);
     852             : 
     853           0 :         OUString aLocalName;
     854           0 :         sal_uInt16 nLocalPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
     855           0 :         switch (rAttrTokenMap.Get(nLocalPrefix, aLocalName))
     856             :         {
     857             :             case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY:
     858           0 :                 mbVisible = IsXMLToken(rAttrValue, XML_TRUE);
     859           0 :             break;
     860             :             case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_ORIENTATION:
     861           0 :                 if (IsXMLToken(rAttrValue, XML_BOTH))
     862           0 :                     meOrientation = BOTH;
     863           0 :                 else if (IsXMLToken(rAttrValue, XML_ROW))
     864           0 :                     meOrientation = ROW;
     865           0 :                 else if (IsXMLToken(rAttrValue, XML_COLUMN))
     866           0 :                     meOrientation = COLUMN;
     867           0 :             break;
     868             :             case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME:
     869             :             case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME_EXT:
     870           0 :                 maDisplayName = rAttrValue;
     871           0 :             break;
     872             :             default:
     873           0 :                 break;
     874             :         }
     875           0 :     }
     876           0 : }
     877             : 
     878           0 : ScXMLDataPilotGrandTotalContext::~ScXMLDataPilotGrandTotalContext()
     879             : {
     880           0 : }
     881             : 
     882           0 : SvXMLImportContext* ScXMLDataPilotGrandTotalContext::CreateChildContext(
     883             :     sal_uInt16 nPrefix, const OUString& rLocalName, const Reference<XAttributeList>& /*xAttrList*/ )
     884             : {
     885           0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     886             : }
     887             : 
     888           0 : void ScXMLDataPilotGrandTotalContext::EndElement()
     889             : {
     890           0 :     XMLTokenEnum eOrient = XML_NONE;
     891           0 :     switch (meOrientation)
     892             :     {
     893             :         case BOTH:
     894           0 :             eOrient = XML_BOTH;
     895           0 :         break;
     896             :         case ROW:
     897           0 :             eOrient = XML_ROW;
     898           0 :         break;
     899             :         case COLUMN:
     900           0 :             eOrient = XML_COLUMN;
     901           0 :         break;
     902             :         default:
     903           0 :             break;
     904             :     }
     905           0 :     mpTableContext->SetGrandTotal(eOrient, mbVisible, maDisplayName);
     906           0 : }
     907             : 
     908           7 : ScXMLSourceCellRangeContext::ScXMLSourceCellRangeContext( ScXMLImport& rImport,
     909             :                                       sal_uInt16 nPrfx,
     910             :                                       const OUString& rLName,
     911             :                                       const ::com::sun::star::uno::Reference<
     912             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     913             :                                         ScXMLDataPilotTableContext* pTempDataPilotTable) :
     914             :     SvXMLImportContext( rImport, nPrfx, rLName ),
     915           7 :     pDataPilotTable(pTempDataPilotTable)
     916             : {
     917           7 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     918           7 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableSourceCellRangeAttrTokenMap();
     919          15 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     920             :     {
     921           8 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
     922          16 :         OUString aLocalName;
     923           8 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
     924           8 :                                             sAttrName, &aLocalName );
     925          16 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
     926             : 
     927           8 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
     928             :         {
     929             :             case XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS :
     930             :             {
     931           7 :                 ScRange aSourceRangeAddress;
     932           7 :                 sal_Int32 nOffset(0);
     933           7 :                 if (ScRangeStringConverter::GetRangeFromString( aSourceRangeAddress, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset ))
     934           7 :                     pDataPilotTable->SetSourceCellRangeAddress(aSourceRangeAddress);
     935             :             }
     936           7 :             break;
     937             :             case XML_TOK_SOURCE_CELL_RANGE_ATTR_NAME:
     938           1 :                 pDataPilotTable->SetSourceRangeName(sValue);
     939           1 :             break;
     940             :         }
     941           8 :     }
     942           7 : }
     943             : 
     944          14 : ScXMLSourceCellRangeContext::~ScXMLSourceCellRangeContext()
     945             : {
     946          14 : }
     947             : 
     948           1 : SvXMLImportContext *ScXMLSourceCellRangeContext::CreateChildContext( sal_uInt16 nPrefix,
     949             :                                             const OUString& rLName,
     950             :                                             const ::com::sun::star::uno::Reference<
     951             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     952             : {
     953           1 :     SvXMLImportContext *pContext = 0;
     954             : 
     955           1 :     const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTableSourceCellRangeElemTokenMap();
     956           1 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     957             :     {
     958             :         case XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER :
     959           1 :             pContext = new ScXMLDPFilterContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotTable);
     960           1 :         break;
     961             :     }
     962             : 
     963           1 :     if( !pContext )
     964           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     965             : 
     966           1 :     return pContext;
     967             : }
     968             : 
     969           7 : void ScXMLSourceCellRangeContext::EndElement()
     970             : {
     971           7 : }
     972             : 
     973          38 : ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
     974             :                                       sal_uInt16 nPrfx,
     975             :                                       const OUString& rLName,
     976             :                                       const ::com::sun::star::uno::Reference<
     977             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     978             :                                         ScXMLDataPilotTableContext* pTempDataPilotTable) :
     979             :     SvXMLImportContext( rImport, nPrfx, rLName ),
     980             :     pDataPilotTable(pTempDataPilotTable),
     981             :     pDim(NULL),
     982             :     fStart(0.0),
     983             :     fEnd(0.0),
     984             :     fStep(0.0),
     985             :     nUsedHierarchy(1),
     986             :     nGroupPart(0),
     987             :     bSelectedPage(false),
     988             :     bIsGroupField(false),
     989             :     bDateValue(false),
     990             :     bAutoStart(false),
     991             :     bAutoEnd(false),
     992          38 :     mbHasHiddenMember(false)
     993             : {
     994          38 :     bool bHasName = false;
     995          38 :     bool bDataLayout = false;
     996          38 :     OUString aDisplayName;
     997          38 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     998          38 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotFieldAttrTokenMap();
     999         197 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
    1000             :     {
    1001         159 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
    1002         318 :         OUString aLocalName;
    1003         159 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1004         159 :                                             sAttrName, &aLocalName );
    1005         318 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
    1006             : 
    1007         159 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
    1008             :         {
    1009             :             case XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME :
    1010             :             {
    1011          38 :                 sName = sValue;
    1012          38 :                 bHasName = true;
    1013             :             }
    1014          38 :             break;
    1015             :             case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME:
    1016             :             case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME_EXT:
    1017             :             {
    1018           0 :                 aDisplayName = sValue;
    1019             :             }
    1020           0 :             break;
    1021             :             case XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD :
    1022             :             {
    1023           5 :                 bDataLayout = IsXMLToken(sValue, XML_TRUE);
    1024             :             }
    1025           5 :             break;
    1026             :             case XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION :
    1027             :             {
    1028          38 :                 nFunction = (sal_Int16) ScXMLConverter::GetFunctionFromString( sValue );
    1029             :             }
    1030          38 :             break;
    1031             :             case XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION :
    1032             :             {
    1033          38 :                 nOrientation = (sal_Int16) ScXMLConverter::GetOrientationFromString( sValue );
    1034             :             }
    1035          38 :             break;
    1036             :             case XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE :
    1037             :             {
    1038           2 :                 sSelectedPage = sValue;
    1039           2 :                 bSelectedPage = true;
    1040             :             }
    1041           2 :             break;
    1042             :             case XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY :
    1043             :             {
    1044          38 :                 nUsedHierarchy = sValue.toInt32();
    1045             :             }
    1046          38 :             break;
    1047             :         }
    1048         159 :     }
    1049          38 :     if (bHasName)
    1050             :     {
    1051          38 :         pDim = new ScDPSaveDimension(sName, bDataLayout);
    1052          38 :         if (!aDisplayName.isEmpty())
    1053           0 :             pDim->SetLayoutName(aDisplayName);
    1054          38 :     }
    1055          38 : }
    1056             : 
    1057          76 : ScXMLDataPilotFieldContext::~ScXMLDataPilotFieldContext()
    1058             : {
    1059          76 : }
    1060             : 
    1061          42 : SvXMLImportContext *ScXMLDataPilotFieldContext::CreateChildContext( sal_uInt16 nPrefix,
    1062             :                                             const OUString& rLName,
    1063             :                                             const ::com::sun::star::uno::Reference<
    1064             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
    1065             : {
    1066          42 :     SvXMLImportContext *pContext = 0;
    1067             : 
    1068          42 :     const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotFieldElemTokenMap();
    1069          42 :     switch( rTokenMap.Get( nPrefix, rLName ) )
    1070             :     {
    1071             :         case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL :
    1072          38 :             pContext = new ScXMLDataPilotLevelContext(GetScImport(), nPrefix, rLName, xAttrList, this);
    1073          38 :         break;
    1074             :         case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_REFERENCE :
    1075           0 :             pContext = new ScXMLDataPilotFieldReferenceContext(GetScImport(), nPrefix, rLName, xAttrList, this);
    1076           0 :         break;
    1077             :         case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_GROUPS :
    1078           4 :             pContext = new ScXMLDataPilotGroupsContext(GetScImport(), nPrefix, rLName, xAttrList, this);
    1079           4 :         break;
    1080             :     }
    1081             : 
    1082          42 :     if( !pContext )
    1083           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1084             : 
    1085          42 :     return pContext;
    1086             : }
    1087             : 
    1088        2916 : void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember* pMember)
    1089             : {
    1090        2916 :     if (pDim)
    1091             :     {
    1092        2916 :         pDim->AddMember(pMember);
    1093        2916 :         if (!pMember->GetIsVisible())
    1094             :             // This member is hidden.
    1095           4 :             mbHasHiddenMember = true;
    1096             :     }
    1097             :     else
    1098           0 :         delete pMember;
    1099        2916 : }
    1100             : 
    1101           0 : void ScXMLDataPilotFieldContext::SetSubTotalName(const OUString& rName)
    1102             : {
    1103           0 :     if (pDim)
    1104           0 :         pDim->SetSubtotalName(rName);
    1105           0 : }
    1106             : 
    1107           0 : void ScXMLDataPilotFieldContext::AddGroup(const ::std::vector<OUString>& rMembers, const OUString& rName)
    1108             : {
    1109           0 :     ScXMLDataPilotGroup aGroup;
    1110           0 :     aGroup.aMembers = rMembers;
    1111           0 :     aGroup.aName = rName;
    1112           0 :     aGroups.push_back(aGroup);
    1113           0 : }
    1114             : 
    1115          38 : void ScXMLDataPilotFieldContext::EndElement()
    1116             : {
    1117          38 :     if (pDim)
    1118             :     {
    1119          38 :         pDim->SetUsedHierarchy(nUsedHierarchy);
    1120          38 :         pDim->SetFunction(nFunction);
    1121          38 :         pDim->SetOrientation(nOrientation);
    1122          38 :         if (bSelectedPage)
    1123             :         {
    1124           2 :             pDataPilotTable->SetSelectedPage(pDim->GetName(), sSelectedPage);
    1125             :         }
    1126          38 :         pDataPilotTable->AddDimension(pDim);
    1127          38 :         if (bIsGroupField)
    1128             :         {
    1129           4 :             ScDPNumGroupInfo aInfo;
    1130           4 :             aInfo.mbEnable = true;
    1131           4 :             aInfo.mbDateValues = bDateValue;
    1132           4 :             aInfo.mbAutoStart = bAutoStart;
    1133           4 :             aInfo.mbAutoEnd = bAutoEnd;
    1134           4 :             aInfo.mfStart = fStart;
    1135           4 :             aInfo.mfEnd = fEnd;
    1136           4 :             aInfo.mfStep = fStep;
    1137           4 :             if (!sGroupSource.isEmpty())
    1138             :             {
    1139           2 :                 ScDPSaveGroupDimension aGroupDim(sGroupSource, sName);
    1140           2 :                 if (nGroupPart)
    1141           2 :                     aGroupDim.SetDateInfo(aInfo, nGroupPart);
    1142             :                 else
    1143             :                 {
    1144           0 :                     ::std::vector<ScXMLDataPilotGroup>::const_iterator aItr(aGroups.begin());
    1145           0 :                     ::std::vector<ScXMLDataPilotGroup>::const_iterator aEndItr(aGroups.end());
    1146           0 :                     while (aItr != aEndItr)
    1147             :                     {
    1148           0 :                         ScDPSaveGroupItem aItem(aItr->aName);
    1149           0 :                         ::std::vector<OUString>::const_iterator aMembersItr(aItr->aMembers.begin());
    1150           0 :                         ::std::vector<OUString>::const_iterator aMembersEndItr(aItr->aMembers.end());
    1151           0 :                         while (aMembersItr != aMembersEndItr)
    1152             :                         {
    1153           0 :                             aItem.AddElement(*aMembersItr);
    1154           0 :                             ++aMembersItr;
    1155             :                         }
    1156           0 :                         ++aItr;
    1157           0 :                         aGroupDim.AddGroupItem(aItem);
    1158           0 :                     }
    1159             :                 }
    1160           2 :                 pDataPilotTable->AddGroupDim(aGroupDim);
    1161             :             }
    1162             :             else //NumGroup
    1163             :             {
    1164           2 :                 ScDPSaveNumGroupDimension aNumGroupDim(sName, aInfo);
    1165           2 :                 if (nGroupPart)
    1166           2 :                     aNumGroupDim.SetDateInfo(aInfo, nGroupPart);
    1167           2 :                 pDataPilotTable->AddGroupDim(aNumGroupDim);
    1168             :             }
    1169             :         }
    1170             :     }
    1171          38 : }
    1172             : 
    1173           0 : ScXMLDataPilotFieldReferenceContext::ScXMLDataPilotFieldReferenceContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
    1174             :                         const OUString& rLName,
    1175             :                         const uno::Reference<xml::sax::XAttributeList>& xAttrList,
    1176             :                         ScXMLDataPilotFieldContext* pDataPilotField) :
    1177           0 :     SvXMLImportContext( rImport, nPrfx, rLName )
    1178             : {
    1179           0 :     sheet::DataPilotFieldReference aReference;
    1180             : 
    1181           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1182           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
    1183             :     {
    1184           0 :         OUString sAttrName(xAttrList->getNameByIndex( i ));
    1185           0 :         OUString aLocalName;
    1186           0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1187           0 :                                             sAttrName, &aLocalName );
    1188           0 :         OUString sValue(xAttrList->getValueByIndex( i ));
    1189             : 
    1190           0 :         if ( nPrefix == XML_NAMESPACE_TABLE )
    1191             :         {
    1192           0 :             if (IsXMLToken(aLocalName, XML_TYPE))
    1193             :             {
    1194           0 :                 if (IsXMLToken(sValue, XML_NONE))
    1195           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::NONE;
    1196           0 :                 else if (IsXMLToken(sValue, XML_MEMBER_DIFFERENCE))
    1197           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE;
    1198           0 :                 else if (IsXMLToken(sValue, XML_MEMBER_PERCENTAGE))
    1199           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE;
    1200           0 :                 else if (IsXMLToken(sValue, XML_MEMBER_PERCENTAGE_DIFFERENCE))
    1201           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
    1202           0 :                 else if (IsXMLToken(sValue, XML_RUNNING_TOTAL))
    1203           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::RUNNING_TOTAL;
    1204           0 :                 else if (IsXMLToken(sValue, XML_ROW_PERCENTAGE))
    1205           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE;
    1206           0 :                 else if (IsXMLToken(sValue, XML_COLUMN_PERCENTAGE))
    1207           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
    1208           0 :                 else if (IsXMLToken(sValue, XML_TOTAL_PERCENTAGE))
    1209           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
    1210           0 :                 else if (IsXMLToken(sValue, XML_INDEX))
    1211           0 :                     aReference.ReferenceType = sheet::DataPilotFieldReferenceType::INDEX;
    1212             :             }
    1213           0 :             else if (IsXMLToken(aLocalName, XML_FIELD_NAME))
    1214             :             {
    1215           0 :                 aReference.ReferenceField = sValue;
    1216             :             }
    1217           0 :             else if (IsXMLToken(aLocalName, XML_MEMBER_TYPE))
    1218             :             {
    1219           0 :                 if (IsXMLToken(sValue, XML_NAMED))
    1220           0 :                     aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NAMED;
    1221           0 :                 else if (IsXMLToken(sValue, XML_PREVIOUS))
    1222           0 :                     aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::PREVIOUS;
    1223           0 :                 else if (IsXMLToken(sValue, XML_NEXT))
    1224           0 :                     aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NEXT;
    1225             :             }
    1226           0 :             else if (IsXMLToken(aLocalName, XML_MEMBER_NAME))
    1227             :             {
    1228           0 :                 aReference.ReferenceItemName = sValue;
    1229             :             }
    1230             :         }
    1231           0 :     }
    1232           0 :     pDataPilotField->SetFieldReference(aReference);
    1233           0 : }
    1234             : 
    1235           0 : ScXMLDataPilotFieldReferenceContext::~ScXMLDataPilotFieldReferenceContext()
    1236             : {
    1237           0 : }
    1238             : 
    1239          38 : ScXMLDataPilotLevelContext::ScXMLDataPilotLevelContext( ScXMLImport& rImport,
    1240             :                                       sal_uInt16 nPrfx,
    1241             :                                       const OUString& rLName,
    1242             :                                       const ::com::sun::star::uno::Reference<
    1243             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1244             :                                         ScXMLDataPilotFieldContext* pTempDataPilotField) :
    1245             :     SvXMLImportContext( rImport, nPrfx, rLName ),
    1246          38 :     pDataPilotField(pTempDataPilotField)
    1247             : {
    1248          38 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1249          38 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotLevelAttrTokenMap();
    1250          70 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
    1251             :     {
    1252          32 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
    1253          64 :         OUString aLocalName;
    1254          32 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1255          32 :                                             sAttrName, &aLocalName );
    1256          64 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
    1257             : 
    1258          32 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
    1259             :         {
    1260             :             case XML_TOK_DATA_PILOT_LEVEL_ATTR_SHOW_EMPTY :
    1261             :             {
    1262          32 :                 pDataPilotField->SetShowEmpty(IsXMLToken(sValue, XML_TRUE));
    1263             :             }
    1264          32 :             break;
    1265             :         }
    1266          32 :     }
    1267          38 : }
    1268             : 
    1269          76 : ScXMLDataPilotLevelContext::~ScXMLDataPilotLevelContext()
    1270             : {
    1271          76 : }
    1272             : 
    1273         110 : SvXMLImportContext *ScXMLDataPilotLevelContext::CreateChildContext( sal_uInt16 nPrefix,
    1274             :                                             const OUString& rLName,
    1275             :                                             const ::com::sun::star::uno::Reference<
    1276             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
    1277             : {
    1278         110 :     SvXMLImportContext *pContext = 0;
    1279             : 
    1280         110 :     const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotLevelElemTokenMap();
    1281         110 :     switch( rTokenMap.Get( nPrefix, rLName ) )
    1282             :     {
    1283             :         case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS :
    1284           3 :             pContext = new ScXMLDataPilotSubTotalsContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
    1285           3 :         break;
    1286             :         case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS :
    1287          26 :             pContext = new ScXMLDataPilotMembersContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
    1288          26 :         break;
    1289             :         case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_DISPLAY_INFO :
    1290          27 :             pContext = new ScXMLDataPilotDisplayInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
    1291          27 :         break;
    1292             :         case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_SORT_INFO :
    1293          27 :             pContext = new ScXMLDataPilotSortInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
    1294          27 :         break;
    1295             :         case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LAYOUT_INFO :
    1296          27 :             pContext = new ScXMLDataPilotLayoutInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
    1297          27 :         break;
    1298             :     }
    1299             : 
    1300         110 :     if( !pContext )
    1301           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1302             : 
    1303         110 :     return pContext;
    1304             : }
    1305             : 
    1306          38 : void ScXMLDataPilotLevelContext::EndElement()
    1307             : {
    1308          38 : }
    1309             : 
    1310          27 : ScXMLDataPilotDisplayInfoContext::ScXMLDataPilotDisplayInfoContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
    1311             :                         const OUString& rLName,
    1312             :                         const ::com::sun::star::uno::Reference<
    1313             :                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1314             :                         ScXMLDataPilotFieldContext* pDataPilotField) :
    1315          27 :     SvXMLImportContext( rImport, nPrfx, rLName )
    1316             : {
    1317          27 :     sheet::DataPilotFieldAutoShowInfo aInfo;
    1318             : 
    1319          27 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1320         135 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
    1321             :     {
    1322         108 :         OUString sAttrName(xAttrList->getNameByIndex( i ));
    1323         216 :         OUString aLocalName;
    1324         108 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1325         108 :                                             sAttrName, &aLocalName );
    1326         216 :         OUString sValue(xAttrList->getValueByIndex( i ));
    1327             : 
    1328         108 :         if ( nPrefix == XML_NAMESPACE_TABLE )
    1329             :         {
    1330         108 :             if (IsXMLToken(aLocalName, XML_ENABLED))
    1331             :             {
    1332          27 :                 if (IsXMLToken(sValue, XML_TRUE))
    1333           0 :                     aInfo.IsEnabled = sal_True;
    1334             :                 else
    1335          27 :                     aInfo.IsEnabled = false;
    1336             :             }
    1337          81 :             else if (IsXMLToken(aLocalName, XML_DISPLAY_MEMBER_MODE))
    1338             :             {
    1339          27 :                 if (IsXMLToken(sValue, XML_FROM_TOP))
    1340          27 :                     aInfo.ShowItemsMode = sheet::DataPilotFieldShowItemsMode::FROM_TOP;
    1341           0 :                 else if (IsXMLToken(sValue, XML_FROM_BOTTOM))
    1342           0 :                     aInfo.ShowItemsMode = sheet::DataPilotFieldShowItemsMode::FROM_BOTTOM;
    1343             :             }
    1344          54 :             else if (IsXMLToken(aLocalName, XML_MEMBER_COUNT))
    1345             :             {
    1346          27 :                 aInfo.ItemCount = sValue.toInt32();
    1347             :             }
    1348          27 :             else if (IsXMLToken(aLocalName, XML_DATA_FIELD))
    1349             :             {
    1350          27 :                 aInfo.DataField = sValue;
    1351             :             }
    1352             :         }
    1353         108 :     }
    1354          27 :     pDataPilotField->SetAutoShowInfo(aInfo);
    1355          27 : }
    1356             : 
    1357          54 : ScXMLDataPilotDisplayInfoContext::~ScXMLDataPilotDisplayInfoContext()
    1358             : {
    1359          54 : }
    1360             : 
    1361          27 : ScXMLDataPilotSortInfoContext::ScXMLDataPilotSortInfoContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
    1362             :                         const OUString& rLName,
    1363             :                         const ::com::sun::star::uno::Reference<
    1364             :                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1365             :                         ScXMLDataPilotFieldContext* pDataPilotField) :
    1366          27 :     SvXMLImportContext( rImport, nPrfx, rLName )
    1367             : {
    1368          27 :     sheet::DataPilotFieldSortInfo aInfo;
    1369             : 
    1370          27 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1371          81 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
    1372             :     {
    1373          54 :         OUString sAttrName(xAttrList->getNameByIndex( i ));
    1374         108 :         OUString aLocalName;
    1375          54 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1376          54 :                                             sAttrName, &aLocalName );
    1377         108 :         OUString sValue(xAttrList->getValueByIndex( i ));
    1378             : 
    1379          54 :         if ( nPrefix == XML_NAMESPACE_TABLE )
    1380             :         {
    1381          54 :             if (IsXMLToken(aLocalName, XML_ORDER))
    1382             :             {
    1383          27 :                 if (IsXMLToken(sValue, XML_ASCENDING))
    1384          27 :                     aInfo.IsAscending = sal_True;
    1385           0 :                 else if (IsXMLToken(sValue, XML_DESCENDING))
    1386           0 :                     aInfo.IsAscending = false;
    1387             :             }
    1388          27 :             else if (IsXMLToken(aLocalName, XML_SORT_MODE))
    1389             :             {
    1390          27 :                 if (IsXMLToken(sValue, XML_NONE))
    1391           0 :                     aInfo.Mode = sheet::DataPilotFieldSortMode::NONE;
    1392          27 :                 else if (IsXMLToken(sValue, XML_MANUAL))
    1393           0 :                     aInfo.Mode = sheet::DataPilotFieldSortMode::MANUAL;
    1394          27 :                 else if (IsXMLToken(sValue, XML_NAME))
    1395          27 :                     aInfo.Mode = sheet::DataPilotFieldSortMode::NAME;
    1396           0 :                 else if (IsXMLToken(sValue, XML_DATA))
    1397           0 :                     aInfo.Mode = sheet::DataPilotFieldSortMode::DATA;
    1398             :             }
    1399           0 :             else if (IsXMLToken(aLocalName, XML_DATA_FIELD))
    1400           0 :                 aInfo.Field = sValue;
    1401             :         }
    1402          54 :     }
    1403          27 :     pDataPilotField->SetSortInfo(aInfo);
    1404          27 : }
    1405             : 
    1406          54 : ScXMLDataPilotSortInfoContext::~ScXMLDataPilotSortInfoContext()
    1407             : {
    1408          54 : }
    1409             : 
    1410          27 : ScXMLDataPilotLayoutInfoContext::ScXMLDataPilotLayoutInfoContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
    1411             :                         const OUString& rLName,
    1412             :                         const ::com::sun::star::uno::Reference<
    1413             :                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1414             :                         ScXMLDataPilotFieldContext* pDataPilotField) :
    1415          27 :     SvXMLImportContext( rImport, nPrfx, rLName )
    1416             : {
    1417          27 :     sheet::DataPilotFieldLayoutInfo aInfo;
    1418             : 
    1419          27 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1420          81 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
    1421             :     {
    1422          54 :         OUString sAttrName(xAttrList->getNameByIndex( i ));
    1423         108 :         OUString aLocalName;
    1424          54 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1425          54 :                                             sAttrName, &aLocalName );
    1426         108 :         OUString sValue(xAttrList->getValueByIndex( i ));
    1427             : 
    1428          54 :         if ( nPrefix == XML_NAMESPACE_TABLE )
    1429             :         {
    1430          54 :             if (IsXMLToken(aLocalName, XML_ADD_EMPTY_LINES))
    1431             :             {
    1432          27 :                 if (IsXMLToken(sValue, XML_TRUE))
    1433           0 :                     aInfo.AddEmptyLines = sal_True;
    1434             :                 else
    1435          27 :                     aInfo.AddEmptyLines = false;
    1436             :             }
    1437          27 :             else if (IsXMLToken(aLocalName, XML_LAYOUT_MODE))
    1438             :             {
    1439          27 :                 if (IsXMLToken(sValue, XML_TABULAR_LAYOUT))
    1440          27 :                     aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
    1441           0 :                 else if (IsXMLToken(sValue, XML_OUTLINE_SUBTOTALS_TOP))
    1442           0 :                     aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
    1443           0 :                 else if (IsXMLToken(sValue, XML_OUTLINE_SUBTOTALS_BOTTOM))
    1444           0 :                     aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
    1445             :             }
    1446             :         }
    1447          54 :     }
    1448          27 :     pDataPilotField->SetLayoutInfo(aInfo);}
    1449             : 
    1450          54 : ScXMLDataPilotLayoutInfoContext::~ScXMLDataPilotLayoutInfoContext()
    1451             : {
    1452          54 : }
    1453             : 
    1454           3 : ScXMLDataPilotSubTotalsContext::ScXMLDataPilotSubTotalsContext( ScXMLImport& rImport,
    1455             :                                       sal_uInt16 nPrfx,
    1456             :                                       const OUString& rLName,
    1457             :                                       const ::com::sun::star::uno::Reference<
    1458             :                                       ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
    1459             :                                         ScXMLDataPilotFieldContext* pTempDataPilotField) :
    1460             :     SvXMLImportContext( rImport, nPrfx, rLName ),
    1461             :     pDataPilotField(pTempDataPilotField),
    1462             :     nFunctionCount(0),
    1463           3 :     pFunctions(NULL)
    1464             : {
    1465             : 
    1466             :     // has no attributes
    1467           3 : }
    1468             : 
    1469           6 : ScXMLDataPilotSubTotalsContext::~ScXMLDataPilotSubTotalsContext()
    1470             : {
    1471           6 : }
    1472             : 
    1473           3 : SvXMLImportContext *ScXMLDataPilotSubTotalsContext::CreateChildContext( sal_uInt16 nPrefix,
    1474             :                                             const OUString& rLName,
    1475             :                                             const ::com::sun::star::uno::Reference<
    1476             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
    1477             : {
    1478           3 :     SvXMLImportContext *pContext = 0;
    1479             : 
    1480           3 :     const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotSubTotalsElemTokenMap();
    1481           3 :     switch( rTokenMap.Get( nPrefix, rLName ) )
    1482             :     {
    1483             :         case XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL :
    1484           3 :             pContext = new ScXMLDataPilotSubTotalContext(GetScImport(), nPrefix, rLName, xAttrList, this);
    1485           3 :         break;
    1486             :     }
    1487             : 
    1488           3 :     if( !pContext )
    1489           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1490             : 
    1491           3 :     return pContext;
    1492             : }
    1493             : 
    1494           3 : void ScXMLDataPilotSubTotalsContext::EndElement()
    1495             : {
    1496           3 :     pDataPilotField->SetSubTotals(pFunctions, nFunctionCount);
    1497           3 :     if (!maDisplayName.isEmpty())
    1498           0 :         pDataPilotField->SetSubTotalName(maDisplayName);
    1499           3 : }
    1500             : 
    1501           3 : void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction)
    1502             : {
    1503           3 :     if (nFunctionCount)
    1504             :     {
    1505           0 :         ++nFunctionCount;
    1506           0 :         sal_uInt16* pTemp = new sal_uInt16[nFunctionCount];
    1507           0 :         for (sal_Int16 i = 0; i < nFunctionCount - 1; ++i)
    1508           0 :             pTemp[i] = pFunctions[i];
    1509           0 :         pTemp[nFunctionCount - 1] = nFunction;
    1510           0 :         delete[] pFunctions;
    1511           0 :         pFunctions = pTemp;
    1512             :     }
    1513             :     else
    1514             :     {
    1515           3 :         nFunctionCount = 1;
    1516           3 :         pFunctions = new sal_uInt16[nFunctionCount];
    1517           3 :         pFunctions[0] = nFunction;
    1518             :     }
    1519           3 : }
    1520             : 
    1521           0 : void ScXMLDataPilotSubTotalsContext::SetDisplayName(const OUString& rName)
    1522             : {
    1523           0 :     maDisplayName = rName;
    1524           0 : }
    1525             : 
    1526           3 : ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport& rImport,
    1527             :                                       sal_uInt16 nPrfx,
    1528             :                                       const OUString& rLName,
    1529             :                                       const ::com::sun::star::uno::Reference<
    1530             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1531             :                                         ScXMLDataPilotSubTotalsContext* pTempDataPilotSubTotals) :
    1532             :     SvXMLImportContext( rImport, nPrfx, rLName ),
    1533           3 :     pDataPilotSubTotals(pTempDataPilotSubTotals)
    1534             : {
    1535           3 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1536           3 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotSubTotalAttrTokenMap();
    1537           6 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
    1538             :     {
    1539           3 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
    1540           6 :         OUString aLocalName;
    1541           3 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1542           3 :                                             sAttrName, &aLocalName );
    1543           6 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
    1544             : 
    1545           3 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
    1546             :         {
    1547             :             case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION :
    1548             :             {
    1549             :                 pDataPilotSubTotals->AddFunction( sal::static_int_cast<sal_Int16>(
    1550           3 :                                 ScXMLConverter::GetFunctionFromString( sValue ) ) );
    1551             :             }
    1552           3 :             break;
    1553             :             case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME:
    1554             :             case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME_EXT:
    1555           0 :                 pDataPilotSubTotals->SetDisplayName(sValue);
    1556           0 :             break;
    1557             :         }
    1558           3 :     }
    1559           3 : }
    1560             : 
    1561           6 : ScXMLDataPilotSubTotalContext::~ScXMLDataPilotSubTotalContext()
    1562             : {
    1563           6 : }
    1564             : 
    1565           0 : SvXMLImportContext *ScXMLDataPilotSubTotalContext::CreateChildContext( sal_uInt16 nPrefix,
    1566             :                                             const OUString& rLName,
    1567             :                                             const ::com::sun::star::uno::Reference<
    1568             :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
    1569             : {
    1570           0 :     SvXMLImportContext *pContext = 0;
    1571             : 
    1572           0 :     if( !pContext )
    1573           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1574             : 
    1575           0 :     return pContext;
    1576             : }
    1577             : 
    1578           3 : void ScXMLDataPilotSubTotalContext::EndElement()
    1579             : {
    1580           3 : }
    1581             : 
    1582          26 : ScXMLDataPilotMembersContext::ScXMLDataPilotMembersContext( ScXMLImport& rImport,
    1583             :                                       sal_uInt16 nPrfx,
    1584             :                                       const OUString& rLName,
    1585             :                                       const ::com::sun::star::uno::Reference<
    1586             :                                       ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
    1587             :                                         ScXMLDataPilotFieldContext* pTempDataPilotField) :
    1588             :     SvXMLImportContext( rImport, nPrfx, rLName ),
    1589          26 :     pDataPilotField(pTempDataPilotField)
    1590             : {
    1591             :     // has no attributes
    1592          26 : }
    1593             : 
    1594          52 : ScXMLDataPilotMembersContext::~ScXMLDataPilotMembersContext()
    1595             : {
    1596          52 : }
    1597             : 
    1598        2916 : SvXMLImportContext *ScXMLDataPilotMembersContext::CreateChildContext( sal_uInt16 nPrefix,
    1599             :                                             const OUString& rLName,
    1600             :                                             const ::com::sun::star::uno::Reference<
    1601             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
    1602             : {
    1603        2916 :     SvXMLImportContext *pContext = 0;
    1604             : 
    1605        2916 :     const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotMembersElemTokenMap();
    1606        2916 :     switch( rTokenMap.Get( nPrefix, rLName ) )
    1607             :     {
    1608             :         case XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER :
    1609        2916 :             pContext = new ScXMLDataPilotMemberContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
    1610        2916 :         break;
    1611             :     }
    1612             : 
    1613        2916 :     if( !pContext )
    1614           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1615             : 
    1616        2916 :     return pContext;
    1617             : }
    1618             : 
    1619          26 : void ScXMLDataPilotMembersContext::EndElement()
    1620             : {
    1621          26 : }
    1622             : 
    1623        2916 : ScXMLDataPilotMemberContext::ScXMLDataPilotMemberContext( ScXMLImport& rImport,
    1624             :                                       sal_uInt16 nPrfx,
    1625             :                                       const OUString& rLName,
    1626             :                                       const ::com::sun::star::uno::Reference<
    1627             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1628             :                                         ScXMLDataPilotFieldContext* pTempDataPilotField) :
    1629             :     SvXMLImportContext( rImport, nPrfx, rLName ),
    1630             :     pDataPilotField(pTempDataPilotField),
    1631             :     bDisplay( true ),
    1632             :     bDisplayDetails( true ),
    1633        2916 :     bHasName( false )
    1634             : {
    1635        2916 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1636        2916 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotMemberAttrTokenMap();
    1637       11664 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
    1638             :     {
    1639        8748 :         const OUString& sAttrName(xAttrList->getNameByIndex( i ));
    1640       17496 :         OUString aLocalName;
    1641        8748 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1642        8748 :                                             sAttrName, &aLocalName );
    1643       17496 :         const OUString& sValue(xAttrList->getValueByIndex( i ));
    1644             : 
    1645        8748 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
    1646             :         {
    1647             :             case XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME :
    1648             :             {
    1649        2916 :                 sName = sValue;
    1650        2916 :                 bHasName = true;
    1651             :             }
    1652        2916 :             break;
    1653             :             case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME:
    1654             :             case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME_EXT:
    1655             :             {
    1656           0 :                 maDisplayName = sValue;
    1657             :             }
    1658           0 :             break;
    1659             :             case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY :
    1660             :             {
    1661        2916 :                 bDisplay = IsXMLToken(sValue, XML_TRUE);
    1662             :             }
    1663        2916 :             break;
    1664             :             case XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS :
    1665             :             {
    1666        2916 :                 bDisplayDetails = IsXMLToken(sValue, XML_TRUE);
    1667             :             }
    1668        2916 :             break;
    1669             :         }
    1670        8748 :     }
    1671        2916 : }
    1672             : 
    1673        5832 : ScXMLDataPilotMemberContext::~ScXMLDataPilotMemberContext()
    1674             : {
    1675        5832 : }
    1676             : 
    1677           0 : SvXMLImportContext *ScXMLDataPilotMemberContext::CreateChildContext( sal_uInt16 nPrefix,
    1678             :                                             const OUString& rLName,
    1679             :                                             const ::com::sun::star::uno::Reference<
    1680             :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
    1681             : {
    1682           0 :     SvXMLImportContext *pContext = 0;
    1683             : 
    1684           0 :     if( !pContext )
    1685           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1686             : 
    1687           0 :     return pContext;
    1688             : }
    1689             : 
    1690        2916 : void ScXMLDataPilotMemberContext::EndElement()
    1691             : {
    1692        2916 :     if (bHasName)   // #i53407# don't check sName, empty name is allowed
    1693             :     {
    1694        2916 :         ScDPSaveMember* pMember = new ScDPSaveMember(sName);
    1695        2916 :         if (!maDisplayName.isEmpty())
    1696           0 :             pMember->SetLayoutName(maDisplayName);
    1697        2916 :         pMember->SetIsVisible(bDisplay);
    1698        2916 :         pMember->SetShowDetails(bDisplayDetails);
    1699        2916 :         pDataPilotField->AddMember(pMember);
    1700             :     }
    1701        2916 : }
    1702             : 
    1703           4 : ScXMLDataPilotGroupsContext::ScXMLDataPilotGroupsContext( ScXMLImport& rImport,
    1704             :                                       sal_uInt16 nPrfx,
    1705             :                                       const OUString& rLName,
    1706             :                                       const ::com::sun::star::uno::Reference<
    1707             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1708             :                                         ScXMLDataPilotFieldContext* pTempDataPilotField) :
    1709             :     SvXMLImportContext( rImport, nPrfx, rLName ),
    1710           4 :     pDataPilotField(pTempDataPilotField)
    1711             : {
    1712           4 :     OUString               sGroupSource;
    1713           4 :     double                      fStart(0.0);
    1714           4 :     double                      fEnd(0.0);
    1715           4 :     double                      fStep(0.0);
    1716           4 :     sal_Int32                   nGroupPart(0);
    1717           4 :     sal_Bool                    bDateValue(false);
    1718           4 :     sal_Bool                    bAutoStart(sal_True);
    1719           4 :     sal_Bool                    bAutoEnd(sal_True);
    1720             : 
    1721           4 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1722          26 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
    1723             :     {
    1724          22 :         OUString sAttrName = xAttrList->getNameByIndex( i );
    1725          44 :         OUString aLocalName;
    1726          22 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1727          22 :                                             sAttrName, &aLocalName );
    1728          44 :         OUString sValue = xAttrList->getValueByIndex( i );
    1729             : 
    1730             :         (void)nPrefix;  //! compare below!
    1731             : 
    1732          22 :         if (IsXMLToken(aLocalName, XML_SOURCE_FIELD_NAME))
    1733           2 :                 sGroupSource = sValue;
    1734          20 :         else if (IsXMLToken(aLocalName, XML_DATE_START))
    1735             :         {
    1736           0 :             bDateValue = sal_True;
    1737           0 :             if (IsXMLToken(sValue, XML_AUTO))
    1738           0 :                 bAutoStart = sal_True;
    1739             :             else
    1740             :             {
    1741           0 :                 GetScImport().GetMM100UnitConverter().convertDateTime(fStart, sValue);
    1742           0 :                 bAutoStart = false;
    1743             :             }
    1744             :         }
    1745          20 :         else if (IsXMLToken(aLocalName, XML_DATE_END))
    1746             :         {
    1747           0 :             bDateValue = sal_True;
    1748           0 :             if (IsXMLToken(sValue, XML_AUTO))
    1749           0 :                 bAutoEnd = sal_True;
    1750             :             else
    1751             :             {
    1752           0 :                 GetScImport().GetMM100UnitConverter().convertDateTime(fEnd, sValue);
    1753           0 :                 bAutoEnd = false;
    1754             :             }
    1755             :         }
    1756          20 :         else if (IsXMLToken(aLocalName, XML_START))
    1757             :         {
    1758           4 :             if (IsXMLToken(sValue, XML_AUTO))
    1759           0 :                 bAutoStart = sal_True;
    1760             :             else
    1761             :             {
    1762           4 :                 ::sax::Converter::convertDouble(fStart, sValue);
    1763           4 :                 bAutoStart = false;
    1764             :             }
    1765             :         }
    1766          16 :         else if (IsXMLToken(aLocalName, XML_END))
    1767             :         {
    1768           4 :             if (IsXMLToken(sValue, XML_AUTO))
    1769           4 :                 bAutoEnd = sal_True;
    1770             :             else
    1771             :             {
    1772           0 :                 ::sax::Converter::convertDouble(fEnd, sValue);
    1773           0 :                 bAutoEnd = false;
    1774             :             }
    1775             :         }
    1776          12 :         else if (IsXMLToken(aLocalName, XML_STEP))
    1777             :         {
    1778           4 :                 ::sax::Converter::convertDouble(fStep, sValue);
    1779             :         }
    1780           8 :         else if (IsXMLToken(aLocalName, XML_GROUPED_BY))
    1781             :         {
    1782           4 :             if (IsXMLToken(sValue, XML_SECONDS))
    1783           0 :                 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS;
    1784           4 :             else if (IsXMLToken(sValue, XML_MINUTES))
    1785           0 :                 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES;
    1786           4 :             else if (IsXMLToken(sValue, XML_HOURS))
    1787           0 :                 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::HOURS;
    1788           4 :             else if (IsXMLToken(sValue, XML_DAYS))
    1789           2 :                 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::DAYS;
    1790           2 :             else if (IsXMLToken(sValue, XML_MONTHS))
    1791           1 :                 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS;
    1792           1 :             else if (IsXMLToken(sValue, XML_QUARTERS))
    1793           0 :                 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS;
    1794           1 :             else if (IsXMLToken(sValue, XML_YEARS))
    1795           1 :                 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::YEARS;
    1796             :         }
    1797          22 :     }
    1798           4 :     pDataPilotField->SetGrouping(sGroupSource, fStart, fEnd, fStep, nGroupPart, bDateValue, bAutoStart, bAutoEnd);
    1799           4 : }
    1800             : 
    1801           8 : ScXMLDataPilotGroupsContext::~ScXMLDataPilotGroupsContext()
    1802             : {
    1803           8 : }
    1804             : 
    1805           0 : SvXMLImportContext *ScXMLDataPilotGroupsContext::CreateChildContext( sal_uInt16 nPrefix,
    1806             :                                             const OUString& rLName,
    1807             :                                             const ::com::sun::star::uno::Reference<
    1808             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
    1809             : {
    1810           0 :     SvXMLImportContext *pContext = 0;
    1811             : 
    1812           0 :     if (nPrefix == XML_NAMESPACE_TABLE)
    1813             :     {
    1814           0 :         if (IsXMLToken(rLName, XML_DATA_PILOT_GROUP))
    1815           0 :             pContext = new ScXMLDataPilotGroupContext(GetScImport(), nPrefix, rLName,  xAttrList, pDataPilotField);
    1816             :     }
    1817             : 
    1818           0 :     if( !pContext )
    1819           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1820             : 
    1821           0 :     return pContext;
    1822             : }
    1823             : 
    1824           4 : void ScXMLDataPilotGroupsContext::EndElement()
    1825             : {
    1826           4 : }
    1827             : 
    1828           0 : ScXMLDataPilotGroupContext::ScXMLDataPilotGroupContext( ScXMLImport& rImport,
    1829             :                                       sal_uInt16 nPrfx,
    1830             :                                       const OUString& rLName,
    1831             :                                       const ::com::sun::star::uno::Reference<
    1832             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1833             :                                         ScXMLDataPilotFieldContext* pTempDataPilotField) :
    1834             :     SvXMLImportContext( rImport, nPrfx, rLName ),
    1835           0 :     pDataPilotField(pTempDataPilotField)
    1836             : {
    1837           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1838           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
    1839             :     {
    1840           0 :         OUString sAttrName = xAttrList->getNameByIndex( i );
    1841           0 :         OUString aLocalName;
    1842           0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1843           0 :                                             sAttrName, &aLocalName );
    1844           0 :         OUString sValue = xAttrList->getValueByIndex( i );
    1845             : 
    1846           0 :         if (nPrefix == XML_NAMESPACE_TABLE)
    1847             :         {
    1848           0 :             if (IsXMLToken(aLocalName, XML_NAME))
    1849           0 :                 sName = sValue;
    1850             :         }
    1851           0 :     }
    1852           0 : }
    1853             : 
    1854           0 : ScXMLDataPilotGroupContext::~ScXMLDataPilotGroupContext()
    1855             : {
    1856           0 : }
    1857             : 
    1858           0 : SvXMLImportContext *ScXMLDataPilotGroupContext::CreateChildContext( sal_uInt16 nPrefix,
    1859             :                                             const OUString& rLName,
    1860             :                                             const ::com::sun::star::uno::Reference<
    1861             :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
    1862             : {
    1863           0 :     SvXMLImportContext *pContext = 0;
    1864             : 
    1865           0 :     if (nPrefix == XML_NAMESPACE_TABLE)
    1866             :     {
    1867           0 :         if (IsXMLToken(rLName, XML_DATA_PILOT_MEMBER))
    1868           0 :             pContext = new ScXMLDataPilotGroupMemberContext(GetScImport(), nPrefix, rLName, xAttrList, this);
    1869             :     }
    1870             : 
    1871           0 :     if( !pContext )
    1872           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1873             : 
    1874           0 :     return pContext;
    1875             : }
    1876             : 
    1877           0 : void ScXMLDataPilotGroupContext::EndElement()
    1878             : {
    1879           0 :     pDataPilotField->AddGroup(aMembers, sName);
    1880           0 : }
    1881             : 
    1882           0 : ScXMLDataPilotGroupMemberContext::ScXMLDataPilotGroupMemberContext( ScXMLImport& rImport,
    1883             :                                       sal_uInt16 nPrfx,
    1884             :                                       const OUString& rLName,
    1885             :                                       const ::com::sun::star::uno::Reference<
    1886             :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
    1887             :                                         ScXMLDataPilotGroupContext* pTempDataPilotGroup) :
    1888             :     SvXMLImportContext( rImport, nPrfx, rLName ),
    1889           0 :     pDataPilotGroup(pTempDataPilotGroup)
    1890             : {
    1891           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    1892           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
    1893             :     {
    1894           0 :         OUString sAttrName = xAttrList->getNameByIndex( i );
    1895           0 :         OUString aLocalName;
    1896           0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
    1897           0 :                                             sAttrName, &aLocalName );
    1898           0 :         OUString sValue = xAttrList->getValueByIndex( i );
    1899             : 
    1900           0 :         if (nPrefix == XML_NAMESPACE_TABLE)
    1901             :         {
    1902           0 :             if (IsXMLToken(aLocalName, XML_NAME))
    1903           0 :                 sName = sValue;
    1904             :         }
    1905           0 :     }
    1906           0 : }
    1907             : 
    1908           0 : ScXMLDataPilotGroupMemberContext::~ScXMLDataPilotGroupMemberContext()
    1909             : {
    1910           0 : }
    1911             : 
    1912           0 : SvXMLImportContext *ScXMLDataPilotGroupMemberContext::CreateChildContext( sal_uInt16 nPrefix,
    1913             :                                             const OUString& rLName,
    1914             :                                             const ::com::sun::star::uno::Reference<
    1915             :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
    1916             : {
    1917           0 :     SvXMLImportContext *pContext = 0;
    1918             : 
    1919           0 :     if( !pContext )
    1920           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
    1921             : 
    1922           0 :     return pContext;
    1923             : }
    1924             : 
    1925           0 : void ScXMLDataPilotGroupMemberContext::EndElement()
    1926             : {
    1927           0 :     if (!sName.isEmpty())
    1928           0 :         pDataPilotGroup->AddMember(sName);
    1929         102 : }
    1930             : 
    1931             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10