LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/xml - xmldpimp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 436 964 45.2 %
Date: 2013-07-09 Functions: 61 113 54.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10