Update ooo320-m1
[ooovba.git] / sc / source / filter / xml / xmldpimp.cxx
blob0d4d46757182072ce1e8c5c51b415afa17ebc285
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmldpimp.cxx,v $
10 * $Revision: 1.27.134.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include "xmldpimp.hxx"
39 #include "xmlimprt.hxx"
40 #include "xmlfilti.hxx"
41 #include "xmlsorti.hxx"
42 #include "document.hxx"
43 #include "docuno.hxx"
44 #include "dpshttab.hxx"
45 #include "dpsdbtab.hxx"
46 #include "attrib.hxx"
47 #include "XMLConverter.hxx"
48 #include "dpgroup.hxx"
49 #include "dpdimsave.hxx"
50 #include "rangeutl.hxx"
51 #include "dpoutputgeometry.hxx"
53 #include <xmloff/xmltkmap.hxx>
54 #include <xmloff/nmspmap.hxx>
55 #include <xmloff/xmltoken.hxx>
56 #include <xmloff/xmlnmspe.hxx>
57 #include <xmloff/xmluconv.hxx>
58 #include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
59 #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
60 #include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
61 #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
62 #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
63 #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
65 //#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
67 using namespace com::sun::star;
68 using namespace xmloff::token;
69 using ::com::sun::star::uno::Reference;
70 using ::com::sun::star::xml::sax::XAttributeList;
71 using ::rtl::OUString;
73 //------------------------------------------------------------------
75 ScXMLDataPilotTablesContext::ScXMLDataPilotTablesContext( ScXMLImport& rImport,
76 USHORT nPrfx,
77 const ::rtl::OUString& rLName,
78 const ::com::sun::star::uno::Reference<
79 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
80 SvXMLImportContext( rImport, nPrfx, rLName )
82 // has no Attributes
83 rImport.LockSolarMutex();
86 ScXMLDataPilotTablesContext::~ScXMLDataPilotTablesContext()
88 GetScImport().UnlockSolarMutex();
91 SvXMLImportContext *ScXMLDataPilotTablesContext::CreateChildContext( USHORT nPrefix,
92 const ::rtl::OUString& rLName,
93 const ::com::sun::star::uno::Reference<
94 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
96 SvXMLImportContext *pContext = 0;
98 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTablesElemTokenMap();
99 switch( rTokenMap.Get( nPrefix, rLName ) )
101 case XML_TOK_DATA_PILOT_TABLE :
103 pContext = new ScXMLDataPilotTableContext( GetScImport(), nPrefix,
104 rLName, xAttrList);
106 break;
109 if( !pContext )
110 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
112 return pContext;
115 void ScXMLDataPilotTablesContext::EndElement()
119 ScXMLDataPilotTableContext::GrandTotalItem::GrandTotalItem() :
120 mbVisible(false) {}
122 ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport,
123 USHORT nPrfx,
124 const ::rtl::OUString& rLName,
125 const ::com::sun::star::uno::Reference<
126 ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
127 SvXMLImportContext( rImport, nPrfx, rLName ),
128 pDoc(GetScImport().GetDocument()),
129 pDPObject(NULL),
130 pDPSave(NULL),
131 pDPDimSaveData(NULL),
132 sDataPilotTableName(),
133 sApplicationData(),
134 sGrandTotal(GetXMLToken(XML_BOTH)),
135 mnRowFieldCount(0),
136 mnColFieldCount(0),
137 mnPageFieldCount(0),
138 mnDataFieldCount(0),
139 bIsNative(sal_True),
140 bIgnoreEmptyRows(sal_False),
141 bIdentifyCategories(sal_False),
142 bTargetRangeAddress(sal_False),
143 bSourceCellRange(sal_False),
144 bShowFilter(sal_True),
145 bDrillDown(sal_True),
146 bHeaderGridLayout(sal_False)
148 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
149 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableAttrTokenMap();
150 for( sal_Int16 i=0; i < nAttrCount; ++i )
152 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
153 rtl::OUString aLocalName;
154 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
155 sAttrName, &aLocalName );
156 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
158 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
160 case XML_TOK_DATA_PILOT_TABLE_ATTR_NAME :
162 sDataPilotTableName = sValue;
164 break;
165 case XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA :
167 sApplicationData = sValue;
169 break;
170 case XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL :
172 sGrandTotal = sValue;
173 if (IsXMLToken(sValue, XML_BOTH))
175 maRowGrandTotal.mbVisible = true;
176 maColGrandTotal.mbVisible = true;
178 else if (IsXMLToken(sValue, XML_ROW))
180 maRowGrandTotal.mbVisible = true;
182 else if (IsXMLToken(sValue, XML_COLUMN))
184 maColGrandTotal.mbVisible = true;
187 break;
188 case XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS :
190 bIgnoreEmptyRows = IsXMLToken(sValue, XML_TRUE);
192 break;
193 case XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES :
195 bIdentifyCategories = IsXMLToken(sValue, XML_TRUE);
197 break;
198 case XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS :
200 sal_Int32 nOffset(0);
201 bTargetRangeAddress = ScRangeStringConverter::GetRangeFromString( aTargetRangeAddress, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset );
203 break;
204 case XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS :
206 sButtons = sValue;
208 break;
209 case XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON :
211 bShowFilter = IsXMLToken(sValue, XML_TRUE);
213 break;
214 case XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN :
216 bDrillDown = IsXMLToken(sValue, XML_TRUE);
218 break;
219 case XML_TOK_DATA_PILOT_TABLE_ATTR_HEADER_GRID_LAYOUT :
221 bHeaderGridLayout = IsXMLToken(sValue, XML_TRUE);
223 break;
227 pDPObject = new ScDPObject(pDoc);
228 pDPSave = new ScDPSaveData();
231 ScXMLDataPilotTableContext::~ScXMLDataPilotTableContext()
233 delete pDPDimSaveData;
236 SvXMLImportContext *ScXMLDataPilotTableContext::CreateChildContext( USHORT nPrefix,
237 const ::rtl::OUString& rLName,
238 const ::com::sun::star::uno::Reference<
239 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
241 SvXMLImportContext *pContext = 0;
243 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTableElemTokenMap();
244 switch( rTokenMap.Get( nPrefix, rLName ) )
246 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL :
248 pContext = new ScXMLDPSourceSQLContext(GetScImport(), nPrefix, rLName, xAttrList, this);
249 nSourceType = SQL;
251 break;
252 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE :
254 pContext = new ScXMLDPSourceTableContext(GetScImport(), nPrefix, rLName, xAttrList, this);
255 nSourceType = TABLE;
257 break;
258 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY :
260 pContext = new ScXMLDPSourceQueryContext(GetScImport(), nPrefix, rLName, xAttrList, this);
261 nSourceType = QUERY;
263 break;
264 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE :
266 pContext = new ScXMLSourceServiceContext(GetScImport(), nPrefix, rLName, xAttrList, this);
267 nSourceType = SERVICE;
269 break;
270 case XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL:
272 pContext = new ScXMLDataPilotGrandTotalContext(GetScImport(), nPrefix, rLName, xAttrList, this);
274 break;
275 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE :
277 pContext = new ScXMLSourceCellRangeContext(GetScImport(), nPrefix, rLName, xAttrList, this);
278 nSourceType = CELLRANGE;
280 break;
281 case XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD :
282 pContext = new ScXMLDataPilotFieldContext(GetScImport(), nPrefix, rLName, xAttrList, this);
283 break;
286 if( !pContext )
287 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
289 return pContext;
292 void ScXMLDataPilotTableContext::SetButtons()
294 ScDPOutputGeometry aGeometry(aTargetRangeAddress, bShowFilter, ScDPOutputGeometry::ODF);
295 aGeometry.setColumnFieldCount(mnColFieldCount);
296 aGeometry.setRowFieldCount(mnRowFieldCount);
297 aGeometry.setPageFieldCount(mnPageFieldCount);
298 aGeometry.setDataFieldCount(mnDataFieldCount);
300 OUString sAddress;
301 sal_Int32 nOffset = 0;
302 while( nOffset >= 0 )
304 ScRangeStringConverter::GetTokenByOffset( sAddress, sButtons, nOffset );
305 if( nOffset >= 0 )
307 ScAddress aScAddress;
308 sal_Int32 nAddrOffset(0);
309 if (pDoc && ScRangeStringConverter::GetAddressFromString( aScAddress, sAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nAddrOffset ))
311 ScDPOutputGeometry::FieldType eType = aGeometry.getFieldButtonType(aScAddress);
313 sal_Int16 nMFlag = SC_MF_BUTTON;
314 if (eType == ScDPOutputGeometry::Column || eType == ScDPOutputGeometry::Row)
315 nMFlag |= SC_MF_BUTTON_POPUP;
317 // Use the cell's string value to see if this field contains a
318 // hidden member. Isn't there a better way? GetString() is
319 // quite expensive...
320 String aCellStr;
321 pDoc->GetString(aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), aCellStr);
322 if (maHiddenMemberFields.count(aCellStr))
323 nMFlag |= SC_MF_HIDDEN_MEMBER;
325 pDoc->ApplyFlagsTab(aScAddress.Col(), aScAddress.Row(), aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), nMFlag);
330 if ( pDPObject )
331 pDPObject->RefreshAfterLoad();
334 void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim, bool bHasHiddenMember)
336 if (pDPSave)
338 // #91045# if a dimension with that name has already been inserted,
339 // mark the new one as duplicate
340 if ( !pDim->IsDataLayout() &&
341 pDPSave->GetExistingDimensionByName(pDim->GetName()) )
342 pDim->SetDupFlag( TRUE );
344 if (!pDim->IsDataLayout())
346 switch (pDim->GetOrientation())
348 case sheet::DataPilotFieldOrientation_ROW:
349 ++mnRowFieldCount;
350 break;
351 case sheet::DataPilotFieldOrientation_COLUMN:
352 ++mnColFieldCount;
353 break;
354 case sheet::DataPilotFieldOrientation_PAGE:
355 ++mnPageFieldCount;
356 break;
357 case sheet::DataPilotFieldOrientation_DATA:
358 ++mnDataFieldCount;
359 break;
360 case sheet::DataPilotFieldOrientation_HIDDEN:
361 default:
365 if (bHasHiddenMember)
367 // the layout name takes priority over the original name,
368 // since this data is used against cell values.
369 const OUString* pLayoutName = pDim->GetLayoutName();
370 if (pLayoutName)
371 maHiddenMemberFields.insert(*pLayoutName);
372 else
373 maHiddenMemberFields.insert(pDim->GetName());
376 pDPSave->AddDimension(pDim);
380 void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim)
382 if (!pDPDimSaveData)
383 pDPDimSaveData = new ScDPDimensionSaveData();
384 pDPDimSaveData->AddNumGroupDimension(aNumGroupDim);
387 void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveGroupDimension& aGroupDim)
389 if (!pDPDimSaveData)
390 pDPDimSaveData = new ScDPDimensionSaveData();
391 pDPDimSaveData->AddGroupDimension(aGroupDim);
394 void ScXMLDataPilotTableContext::EndElement()
396 if (bTargetRangeAddress)
398 pDPObject->SetName(sDataPilotTableName);
399 pDPObject->SetTag(sApplicationData);
400 pDPObject->SetOutRange(aTargetRangeAddress);
401 pDPObject->SetHeaderLayout(bHeaderGridLayout);
402 switch (nSourceType)
404 case SQL :
406 ScImportSourceDesc aImportDesc;
407 aImportDesc.aDBName = sDatabaseName;
408 aImportDesc.aObject = sSourceObject;
409 aImportDesc.nType = sheet::DataImportMode_SQL;
410 aImportDesc.bNative = bIsNative;
411 pDPObject->SetImportDesc(aImportDesc);
413 break;
414 case TABLE :
416 ScImportSourceDesc aImportDesc;
417 aImportDesc.aDBName = sDatabaseName;
418 aImportDesc.aObject = sSourceObject;
419 aImportDesc.nType = sheet::DataImportMode_TABLE;
420 pDPObject->SetImportDesc(aImportDesc);
422 break;
423 case QUERY :
425 ScImportSourceDesc aImportDesc;
426 aImportDesc.aDBName = sDatabaseName;
427 aImportDesc.aObject = sSourceObject;
428 aImportDesc.nType = sheet::DataImportMode_QUERY;
429 pDPObject->SetImportDesc(aImportDesc);
431 break;
432 case SERVICE :
434 ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceObject, sServiceSourceName,
435 sServiceUsername, sServicePassword);
436 pDPObject->SetServiceData(aServiceDesk);
438 break;
439 case CELLRANGE :
441 if (bSourceCellRange)
443 ScSheetSourceDesc aSheetDesc;
444 aSheetDesc.aSourceRange = aSourceCellRangeAddress;
445 aSheetDesc.aQueryParam = aSourceQueryParam;
446 pDPObject->SetSheetDesc(aSheetDesc);
449 break;
452 pDPSave->SetRowGrand(maRowGrandTotal.mbVisible);
453 pDPSave->SetColumnGrand(maColGrandTotal.mbVisible);
454 if (maRowGrandTotal.maDisplayName.getLength())
455 // TODO: Right now, we only support one grand total name for both
456 // column and row totals. Take the value from the row total for
457 // now.
458 pDPSave->SetGrandTotalName(maRowGrandTotal.maDisplayName);
460 pDPSave->SetIgnoreEmptyRows(bIgnoreEmptyRows);
461 pDPSave->SetRepeatIfEmpty(bIdentifyCategories);
462 pDPSave->SetFilterButton(bShowFilter);
463 pDPSave->SetDrillDown(bDrillDown);
464 if (pDPDimSaveData)
465 pDPSave->SetDimensionData(pDPDimSaveData);
466 pDPObject->SetSaveData(*pDPSave);
467 if (pDoc)
469 ScDPCollection* pDPCollection = pDoc->GetDPCollection();
470 pDPObject->SetAlive(sal_True);
471 pDPCollection->InsertNewTable(pDPObject);
473 SetButtons();
477 void ScXMLDataPilotTableContext::SetGrandTotal(
478 XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName)
480 switch (eOrientation)
482 case XML_BOTH:
483 maRowGrandTotal.mbVisible = bVisible;
484 maRowGrandTotal.maDisplayName = rDisplayName;
485 maColGrandTotal.mbVisible = bVisible;
486 maColGrandTotal.maDisplayName = rDisplayName;
487 break;
488 case XML_ROW:
489 maRowGrandTotal.mbVisible = bVisible;
490 maRowGrandTotal.maDisplayName = rDisplayName;
491 break;
492 case XML_COLUMN:
493 maColGrandTotal.mbVisible = bVisible;
494 maColGrandTotal.maDisplayName = rDisplayName;
495 break;
496 default:
501 ScXMLDPSourceSQLContext::ScXMLDPSourceSQLContext( ScXMLImport& rImport,
502 USHORT nPrfx,
503 const ::rtl::OUString& rLName,
504 const ::com::sun::star::uno::Reference<
505 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
506 ScXMLDataPilotTableContext* pTempDataPilotTable) :
507 SvXMLImportContext( rImport, nPrfx, rLName ),
508 pDataPilotTable(pTempDataPilotTable)
510 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
511 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceSQLAttrTokenMap();
512 for( sal_Int16 i=0; i < nAttrCount; ++i )
514 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
515 rtl::OUString aLocalName;
516 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
517 sAttrName, &aLocalName );
518 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
520 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
522 case XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME :
524 pDataPilotTable->SetDatabaseName(sValue);
526 break;
527 case XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT :
529 pDataPilotTable->SetSourceObject(sValue);
531 break;
532 case XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT :
534 pDataPilotTable->SetNative(!IsXMLToken(sValue, XML_TRUE));
536 break;
541 ScXMLDPSourceSQLContext::~ScXMLDPSourceSQLContext()
545 SvXMLImportContext *ScXMLDPSourceSQLContext::CreateChildContext( USHORT nPrefix,
546 const ::rtl::OUString& rLName,
547 const ::com::sun::star::uno::Reference<
548 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
550 SvXMLImportContext *pContext = 0;
552 if( !pContext )
553 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
555 return pContext;
558 void ScXMLDPSourceSQLContext::EndElement()
562 ScXMLDPSourceTableContext::ScXMLDPSourceTableContext( ScXMLImport& rImport,
563 USHORT nPrfx,
564 const ::rtl::OUString& rLName,
565 const ::com::sun::star::uno::Reference<
566 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
567 ScXMLDataPilotTableContext* pTempDataPilotTable) :
568 SvXMLImportContext( rImport, nPrfx, rLName ),
569 pDataPilotTable(pTempDataPilotTable)
571 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
572 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceTableAttrTokenMap();
573 for( sal_Int16 i=0; i < nAttrCount; ++i )
575 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
576 rtl::OUString aLocalName;
577 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
578 sAttrName, &aLocalName );
579 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
581 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
583 case XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME :
585 pDataPilotTable->SetDatabaseName(sValue);
587 break;
588 case XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME :
590 pDataPilotTable->SetSourceObject(sValue);
592 break;
597 ScXMLDPSourceTableContext::~ScXMLDPSourceTableContext()
601 SvXMLImportContext *ScXMLDPSourceTableContext::CreateChildContext( USHORT nPrefix,
602 const ::rtl::OUString& rLName,
603 const ::com::sun::star::uno::Reference<
604 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
606 SvXMLImportContext *pContext = 0;
608 if( !pContext )
609 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
611 return pContext;
614 void ScXMLDPSourceTableContext::EndElement()
618 ScXMLDPSourceQueryContext::ScXMLDPSourceQueryContext( ScXMLImport& rImport,
619 USHORT nPrfx,
620 const ::rtl::OUString& rLName,
621 const ::com::sun::star::uno::Reference<
622 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
623 ScXMLDataPilotTableContext* pTempDataPilotTable) :
624 SvXMLImportContext( rImport, nPrfx, rLName ),
625 pDataPilotTable(pTempDataPilotTable)
627 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
628 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceQueryAttrTokenMap();
629 for( sal_Int16 i=0; i < nAttrCount; ++i )
631 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
632 rtl::OUString aLocalName;
633 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
634 sAttrName, &aLocalName );
635 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
637 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
639 case XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME :
641 pDataPilotTable->SetDatabaseName(sValue);
643 break;
644 case XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME :
646 pDataPilotTable->SetSourceObject(sValue);
648 break;
653 ScXMLDPSourceQueryContext::~ScXMLDPSourceQueryContext()
657 SvXMLImportContext *ScXMLDPSourceQueryContext::CreateChildContext( USHORT nPrefix,
658 const ::rtl::OUString& rLName,
659 const ::com::sun::star::uno::Reference<
660 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
662 SvXMLImportContext *pContext = 0;
664 if( !pContext )
665 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
667 return pContext;
670 void ScXMLDPSourceQueryContext::EndElement()
674 ScXMLSourceServiceContext::ScXMLSourceServiceContext( ScXMLImport& rImport,
675 USHORT nPrfx,
676 const ::rtl::OUString& rLName,
677 const ::com::sun::star::uno::Reference<
678 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
679 ScXMLDataPilotTableContext* pTempDataPilotTable) :
680 SvXMLImportContext( rImport, nPrfx, rLName ),
681 pDataPilotTable(pTempDataPilotTable)
683 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
684 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableSourceServiceAttrTokenMap();
685 for( sal_Int16 i=0; i < nAttrCount; ++i )
687 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
688 rtl::OUString aLocalName;
689 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
690 sAttrName, &aLocalName );
691 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
693 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
695 case XML_TOK_SOURCE_SERVICE_ATTR_NAME :
697 pDataPilotTable->SetServiceName(sValue);
699 break;
700 case XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME :
702 pDataPilotTable->SetServiceSourceName(sValue);
704 break;
705 case XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME :
707 pDataPilotTable->SetServiceSourceObject(sValue);
709 break;
710 case XML_TOK_SOURCE_SERVICE_ATTR_USER_NAME :
712 pDataPilotTable->SetServiceUsername(sValue);
714 break;
715 case XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD :
717 pDataPilotTable->SetServicePassword(sValue);
719 break;
724 ScXMLSourceServiceContext::~ScXMLSourceServiceContext()
728 SvXMLImportContext *ScXMLSourceServiceContext::CreateChildContext( USHORT nPrefix,
729 const ::rtl::OUString& rLName,
730 const ::com::sun::star::uno::Reference<
731 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
733 SvXMLImportContext *pContext = 0;
735 if( !pContext )
736 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
738 return pContext;
741 void ScXMLSourceServiceContext::EndElement()
745 ScXMLImport& ScXMLDataPilotGrandTotalContext::GetScImport()
747 return static_cast<ScXMLImport&>(GetImport());
750 ScXMLDataPilotGrandTotalContext::ScXMLDataPilotGrandTotalContext(
751 ScXMLImport& rImport, USHORT nPrefix, const OUString& rLName, const Reference<XAttributeList>& xAttrList,
752 ScXMLDataPilotTableContext* pTableContext ) :
753 SvXMLImportContext( rImport, nPrefix, rLName ),
754 mpTableContext(pTableContext),
755 meOrientation(NONE),
756 mbVisible(false)
758 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
759 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotGrandTotalAttrTokenMap();
760 for (sal_Int16 i = 0; i < nAttrCount; ++i)
762 const OUString& rAttrName = xAttrList->getNameByIndex(i);
763 const OUString& rAttrValue = xAttrList->getValueByIndex(i);
765 OUString aLocalName;
766 USHORT nLocalPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
767 switch (rAttrTokenMap.Get(nLocalPrefix, aLocalName))
769 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY:
770 mbVisible = IsXMLToken(rAttrValue, XML_TRUE);
771 break;
772 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_ORIENTATION:
773 if (IsXMLToken(rAttrValue, XML_BOTH))
774 meOrientation = BOTH;
775 else if (IsXMLToken(rAttrValue, XML_ROW))
776 meOrientation = ROW;
777 else if (IsXMLToken(rAttrValue, XML_COLUMN))
778 meOrientation = COLUMN;
779 break;
780 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME:
781 maDisplayName = rAttrValue;
782 break;
783 default:
789 ScXMLDataPilotGrandTotalContext::~ScXMLDataPilotGrandTotalContext()
793 SvXMLImportContext* ScXMLDataPilotGrandTotalContext::CreateChildContext(
794 USHORT /*nPrefix*/, const ::rtl::OUString& /*rLocalName*/, const Reference<XAttributeList>& /*xAttrList*/ )
796 return NULL;
799 void ScXMLDataPilotGrandTotalContext::EndElement()
801 XMLTokenEnum eOrient = XML_NONE;
802 switch (meOrientation)
804 case BOTH:
805 eOrient = XML_BOTH;
806 break;
807 case ROW:
808 eOrient = XML_ROW;
809 break;
810 case COLUMN:
811 eOrient = XML_COLUMN;
812 break;
813 default:
816 mpTableContext->SetGrandTotal(eOrient, mbVisible, maDisplayName);
819 ScXMLSourceCellRangeContext::ScXMLSourceCellRangeContext( ScXMLImport& rImport,
820 USHORT nPrfx,
821 const ::rtl::OUString& rLName,
822 const ::com::sun::star::uno::Reference<
823 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
824 ScXMLDataPilotTableContext* pTempDataPilotTable) :
825 SvXMLImportContext( rImport, nPrfx, rLName ),
826 pDataPilotTable(pTempDataPilotTable)
828 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
829 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableSourceCellRangeAttrTokenMap();
830 for( sal_Int16 i=0; i < nAttrCount; ++i )
832 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
833 rtl::OUString aLocalName;
834 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
835 sAttrName, &aLocalName );
836 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
838 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
840 case XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS :
842 ScRange aSourceRangeAddress;
843 sal_Int32 nOffset(0);
844 if (ScRangeStringConverter::GetRangeFromString( aSourceRangeAddress, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset ))
845 pDataPilotTable->SetSourceCellRangeAddress(aSourceRangeAddress);
847 break;
852 ScXMLSourceCellRangeContext::~ScXMLSourceCellRangeContext()
856 SvXMLImportContext *ScXMLSourceCellRangeContext::CreateChildContext( USHORT nPrefix,
857 const ::rtl::OUString& rLName,
858 const ::com::sun::star::uno::Reference<
859 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
861 SvXMLImportContext *pContext = 0;
863 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTableSourceCellRangeElemTokenMap();
864 switch( rTokenMap.Get( nPrefix, rLName ) )
866 case XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER :
867 pContext = new ScXMLDPFilterContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotTable);
868 break;
871 if( !pContext )
872 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
874 return pContext;
877 void ScXMLSourceCellRangeContext::EndElement()
881 ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
882 USHORT nPrfx,
883 const ::rtl::OUString& rLName,
884 const ::com::sun::star::uno::Reference<
885 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
886 ScXMLDataPilotTableContext* pTempDataPilotTable) :
887 SvXMLImportContext( rImport, nPrfx, rLName ),
888 pDataPilotTable(pTempDataPilotTable),
889 pDim(NULL),
890 fStart(0.0),
891 fEnd(0.0),
892 fStep(0.0),
893 nUsedHierarchy(1),
894 nGroupPart(0),
895 bSelectedPage(sal_False),
896 bIsGroupField(sal_False),
897 bDateValue(sal_False),
898 bAutoStart(sal_False),
899 bAutoEnd(sal_False),
900 mbHasHiddenMember(false)
902 sal_Bool bHasName(sal_False);
903 sal_Bool bDataLayout(sal_False);
904 OUString aDisplayName;
905 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
906 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotFieldAttrTokenMap();
907 for( sal_Int16 i=0; i < nAttrCount; ++i )
909 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
910 rtl::OUString aLocalName;
911 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
912 sAttrName, &aLocalName );
913 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
915 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
917 case XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME :
919 sName = sValue;
920 bHasName = sal_True;
922 break;
923 case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME:
925 aDisplayName = sValue;
927 break;
928 case XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD :
930 bDataLayout = IsXMLToken(sValue, XML_TRUE);
932 break;
933 case XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION :
935 nFunction = (sal_Int16) ScXMLConverter::GetFunctionFromString( sValue );
937 break;
938 case XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION :
940 nOrientation = (sal_Int16) ScXMLConverter::GetOrientationFromString( sValue );
942 break;
943 case XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE :
945 sSelectedPage = sValue;
946 bSelectedPage = sal_True;
948 break;
949 case XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY :
951 nUsedHierarchy = sValue.toInt32();
953 break;
956 if (bHasName)
958 pDim = new ScDPSaveDimension(String(sName), bDataLayout);
959 if (aDisplayName.getLength())
960 pDim->SetLayoutName(aDisplayName);
964 ScXMLDataPilotFieldContext::~ScXMLDataPilotFieldContext()
968 SvXMLImportContext *ScXMLDataPilotFieldContext::CreateChildContext( USHORT nPrefix,
969 const ::rtl::OUString& rLName,
970 const ::com::sun::star::uno::Reference<
971 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
973 SvXMLImportContext *pContext = 0;
975 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotFieldElemTokenMap();
976 switch( rTokenMap.Get( nPrefix, rLName ) )
978 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL :
979 pContext = new ScXMLDataPilotLevelContext(GetScImport(), nPrefix, rLName, xAttrList, this);
980 break;
981 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_REFERENCE :
982 pContext = new ScXMLDataPilotFieldReferenceContext(GetScImport(), nPrefix, rLName, xAttrList, this);
983 break;
984 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_GROUPS :
985 pContext = new ScXMLDataPilotGroupsContext(GetScImport(), nPrefix, rLName, xAttrList, this);
986 break;
989 if( !pContext )
990 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
992 return pContext;
995 void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember* pMember)
997 if (pDim)
998 pDim->AddMember(pMember);
1000 if (!pMember->GetIsVisible())
1001 // This member is hidden.
1002 mbHasHiddenMember = true;
1005 void ScXMLDataPilotFieldContext::SetSubTotalName(const OUString& rName)
1007 if (pDim)
1008 pDim->SetSubtotalName(rName);
1011 void ScXMLDataPilotFieldContext::AddGroup(const ::std::vector<rtl::OUString>& rMembers, const rtl::OUString& rName)
1013 ScXMLDataPilotGroup aGroup;
1014 aGroup.aMembers = rMembers;
1015 aGroup.aName = rName;
1016 aGroups.push_back(aGroup);
1019 void ScXMLDataPilotFieldContext::EndElement()
1021 if (pDim)
1023 pDim->SetUsedHierarchy(nUsedHierarchy);
1024 pDim->SetFunction(nFunction);
1025 pDim->SetOrientation(nOrientation);
1026 if (bSelectedPage)
1028 String sPage(sSelectedPage);
1029 pDim->SetCurrentPage(&sPage);
1031 pDataPilotTable->AddDimension(pDim, mbHasHiddenMember);
1032 if (bIsGroupField)
1034 ScDPNumGroupInfo aInfo;
1035 aInfo.Enable = sal_True;
1036 aInfo.DateValues = bDateValue;
1037 aInfo.AutoStart = bAutoStart;
1038 aInfo.AutoEnd = bAutoEnd;
1039 aInfo.Start = fStart;
1040 aInfo.End = fEnd;
1041 aInfo.Step = fStep;
1042 if (sGroupSource.getLength())
1044 ScDPSaveGroupDimension aGroupDim(sGroupSource, sName);
1045 if (nGroupPart)
1046 aGroupDim.SetDateInfo(aInfo, nGroupPart);
1047 else
1049 ::std::vector<ScXMLDataPilotGroup>::const_iterator aItr(aGroups.begin());
1050 ::std::vector<ScXMLDataPilotGroup>::const_iterator aEndItr(aGroups.end());
1051 while (aItr != aEndItr)
1053 ScDPSaveGroupItem aItem(aItr->aName);
1054 ::std::vector<rtl::OUString>::const_iterator aMembersItr(aItr->aMembers.begin());
1055 ::std::vector<rtl::OUString>::const_iterator aMembersEndItr(aItr->aMembers.end());
1056 while (aMembersItr != aMembersEndItr)
1058 aItem.AddElement(*aMembersItr);
1059 ++aMembersItr;
1061 ++aItr;
1062 aGroupDim.AddGroupItem(aItem);
1065 pDataPilotTable->AddGroupDim(aGroupDim);
1067 else //NumGroup
1069 ScDPSaveNumGroupDimension aNumGroupDim(sName, aInfo);
1070 if (nGroupPart)
1071 aNumGroupDim.SetDateInfo(aInfo, nGroupPart);
1072 pDataPilotTable->AddGroupDim(aNumGroupDim);
1078 ScXMLDataPilotFieldReferenceContext::ScXMLDataPilotFieldReferenceContext( ScXMLImport& rImport, USHORT nPrfx,
1079 const ::rtl::OUString& rLName,
1080 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1081 ScXMLDataPilotFieldContext* pDataPilotField) :
1082 SvXMLImportContext( rImport, nPrfx, rLName )
1084 sheet::DataPilotFieldReference aReference;
1086 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1087 for( sal_Int16 i=0; i < nAttrCount; i++ )
1089 rtl::OUString sAttrName(xAttrList->getNameByIndex( i ));
1090 rtl::OUString aLocalName;
1091 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1092 sAttrName, &aLocalName );
1093 rtl::OUString sValue(xAttrList->getValueByIndex( i ));
1095 if ( nPrefix == XML_NAMESPACE_TABLE )
1097 if (IsXMLToken(aLocalName, XML_TYPE))
1099 if (IsXMLToken(sValue, XML_NONE))
1100 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::NONE;
1101 else if (IsXMLToken(sValue, XML_MEMBER_DIFFERENCE))
1102 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE;
1103 else if (IsXMLToken(sValue, XML_MEMBER_PERCENTAGE))
1104 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE;
1105 else if (IsXMLToken(sValue, XML_MEMBER_PERCENTAGE_DIFFERENCE))
1106 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
1107 else if (IsXMLToken(sValue, XML_RUNNING_TOTAL))
1108 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::RUNNING_TOTAL;
1109 else if (IsXMLToken(sValue, XML_ROW_PERCENTAGE))
1110 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE;
1111 else if (IsXMLToken(sValue, XML_COLUMN_PERCENTAGE))
1112 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
1113 else if (IsXMLToken(sValue, XML_TOTAL_PERCENTAGE))
1114 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
1115 else if (IsXMLToken(sValue, XML_INDEX))
1116 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::INDEX;
1118 else if (IsXMLToken(aLocalName, XML_FIELD_NAME))
1120 aReference.ReferenceField = sValue;
1122 else if (IsXMLToken(aLocalName, XML_MEMBER_TYPE))
1124 if (IsXMLToken(sValue, XML_NAMED))
1125 aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NAMED;
1126 else if (IsXMLToken(sValue, XML_PREVIOUS))
1127 aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::PREVIOUS;
1128 else if (IsXMLToken(sValue, XML_NEXT))
1129 aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NEXT;
1131 else if (IsXMLToken(aLocalName, XML_MEMBER_NAME))
1133 aReference.ReferenceItemName = sValue;
1137 pDataPilotField->SetFieldReference(aReference);
1140 ScXMLDataPilotFieldReferenceContext::~ScXMLDataPilotFieldReferenceContext()
1144 ScXMLDataPilotLevelContext::ScXMLDataPilotLevelContext( ScXMLImport& rImport,
1145 USHORT nPrfx,
1146 const ::rtl::OUString& rLName,
1147 const ::com::sun::star::uno::Reference<
1148 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1149 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1150 SvXMLImportContext( rImport, nPrfx, rLName ),
1151 pDataPilotField(pTempDataPilotField)
1153 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1154 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotLevelAttrTokenMap();
1155 for( sal_Int16 i=0; i < nAttrCount; ++i )
1157 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1158 rtl::OUString aLocalName;
1159 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1160 sAttrName, &aLocalName );
1161 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1163 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
1165 case XML_TOK_DATA_PILOT_LEVEL_ATTR_SHOW_EMPTY :
1167 pDataPilotField->SetShowEmpty(IsXMLToken(sValue, XML_TRUE));
1169 break;
1174 ScXMLDataPilotLevelContext::~ScXMLDataPilotLevelContext()
1178 SvXMLImportContext *ScXMLDataPilotLevelContext::CreateChildContext( USHORT nPrefix,
1179 const ::rtl::OUString& rLName,
1180 const ::com::sun::star::uno::Reference<
1181 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1183 SvXMLImportContext *pContext = 0;
1185 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotLevelElemTokenMap();
1186 switch( rTokenMap.Get( nPrefix, rLName ) )
1188 case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS :
1189 pContext = new ScXMLDataPilotSubTotalsContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1190 break;
1191 case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS :
1192 pContext = new ScXMLDataPilotMembersContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1193 break;
1194 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_DISPLAY_INFO :
1195 pContext = new ScXMLDataPilotDisplayInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1196 break;
1197 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_SORT_INFO :
1198 pContext = new ScXMLDataPilotSortInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1199 break;
1200 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LAYOUT_INFO :
1201 pContext = new ScXMLDataPilotLayoutInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1202 break;
1205 if( !pContext )
1206 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1208 return pContext;
1211 void ScXMLDataPilotLevelContext::EndElement()
1215 ScXMLDataPilotDisplayInfoContext::ScXMLDataPilotDisplayInfoContext( ScXMLImport& rImport, USHORT nPrfx,
1216 const ::rtl::OUString& rLName,
1217 const ::com::sun::star::uno::Reference<
1218 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1219 ScXMLDataPilotFieldContext* pDataPilotField) :
1220 SvXMLImportContext( rImport, nPrfx, rLName )
1222 sheet::DataPilotFieldAutoShowInfo aInfo;
1224 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1225 for( sal_Int16 i=0; i < nAttrCount; i++ )
1227 rtl::OUString sAttrName(xAttrList->getNameByIndex( i ));
1228 rtl::OUString aLocalName;
1229 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1230 sAttrName, &aLocalName );
1231 rtl::OUString sValue(xAttrList->getValueByIndex( i ));
1233 if ( nPrefix == XML_NAMESPACE_TABLE )
1235 if (IsXMLToken(aLocalName, XML_ENABLED))
1237 if (IsXMLToken(sValue, XML_TRUE))
1238 aInfo.IsEnabled = sal_True;
1239 else
1240 aInfo.IsEnabled = sal_False;
1242 else if (IsXMLToken(aLocalName, XML_DISPLAY_MEMBER_MODE))
1244 if (IsXMLToken(sValue, XML_FROM_TOP))
1245 aInfo.ShowItemsMode = sheet::DataPilotFieldShowItemsMode::FROM_TOP;
1246 else if (IsXMLToken(sValue, XML_FROM_BOTTOM))
1247 aInfo.ShowItemsMode = sheet::DataPilotFieldShowItemsMode::FROM_BOTTOM;
1249 else if (IsXMLToken(aLocalName, XML_MEMBER_COUNT))
1251 aInfo.ItemCount = sValue.toInt32();
1253 else if (IsXMLToken(aLocalName, XML_DATA_FIELD))
1255 aInfo.DataField = sValue;
1259 pDataPilotField->SetAutoShowInfo(aInfo);
1262 ScXMLDataPilotDisplayInfoContext::~ScXMLDataPilotDisplayInfoContext()
1266 ScXMLDataPilotSortInfoContext::ScXMLDataPilotSortInfoContext( ScXMLImport& rImport, USHORT nPrfx,
1267 const ::rtl::OUString& rLName,
1268 const ::com::sun::star::uno::Reference<
1269 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1270 ScXMLDataPilotFieldContext* pDataPilotField) :
1271 SvXMLImportContext( rImport, nPrfx, rLName )
1273 sheet::DataPilotFieldSortInfo aInfo;
1275 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1276 for( sal_Int16 i=0; i < nAttrCount; i++ )
1278 rtl::OUString sAttrName(xAttrList->getNameByIndex( i ));
1279 rtl::OUString aLocalName;
1280 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1281 sAttrName, &aLocalName );
1282 rtl::OUString sValue(xAttrList->getValueByIndex( i ));
1284 if ( nPrefix == XML_NAMESPACE_TABLE )
1286 if (IsXMLToken(aLocalName, XML_ORDER))
1288 if (IsXMLToken(sValue, XML_ASCENDING))
1289 aInfo.IsAscending = sal_True;
1290 else if (IsXMLToken(sValue, XML_DESCENDING))
1291 aInfo.IsAscending = sal_False;
1293 else if (IsXMLToken(aLocalName, XML_SORT_MODE))
1295 if (IsXMLToken(sValue, XML_NONE))
1296 aInfo.Mode = sheet::DataPilotFieldSortMode::NONE;
1297 else if (IsXMLToken(sValue, XML_MANUAL))
1298 aInfo.Mode = sheet::DataPilotFieldSortMode::MANUAL;
1299 else if (IsXMLToken(sValue, XML_NAME))
1300 aInfo.Mode = sheet::DataPilotFieldSortMode::NAME;
1301 else if (IsXMLToken(sValue, XML_DATA))
1302 aInfo.Mode = sheet::DataPilotFieldSortMode::DATA;
1304 else if (IsXMLToken(aLocalName, XML_DATA_FIELD))
1305 aInfo.Field = sValue;
1308 pDataPilotField->SetSortInfo(aInfo);
1311 ScXMLDataPilotSortInfoContext::~ScXMLDataPilotSortInfoContext()
1315 ScXMLDataPilotLayoutInfoContext::ScXMLDataPilotLayoutInfoContext( ScXMLImport& rImport, USHORT nPrfx,
1316 const ::rtl::OUString& rLName,
1317 const ::com::sun::star::uno::Reference<
1318 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1319 ScXMLDataPilotFieldContext* pDataPilotField) :
1320 SvXMLImportContext( rImport, nPrfx, rLName )
1322 sheet::DataPilotFieldLayoutInfo aInfo;
1324 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1325 for( sal_Int16 i=0; i < nAttrCount; i++ )
1327 rtl::OUString sAttrName(xAttrList->getNameByIndex( i ));
1328 rtl::OUString aLocalName;
1329 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1330 sAttrName, &aLocalName );
1331 rtl::OUString sValue(xAttrList->getValueByIndex( i ));
1333 if ( nPrefix == XML_NAMESPACE_TABLE )
1335 if (IsXMLToken(aLocalName, XML_ADD_EMPTY_LINES))
1337 if (IsXMLToken(sValue, XML_TRUE))
1338 aInfo.AddEmptyLines = sal_True;
1339 else
1340 aInfo.AddEmptyLines = sal_False;
1342 else if (IsXMLToken(aLocalName, XML_LAYOUT_MODE))
1344 if (IsXMLToken(sValue, XML_TABULAR_LAYOUT))
1345 aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
1346 else if (IsXMLToken(sValue, XML_OUTLINE_SUBTOTALS_TOP))
1347 aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
1348 else if (IsXMLToken(sValue, XML_OUTLINE_SUBTOTALS_BOTTOM))
1349 aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
1353 pDataPilotField->SetLayoutInfo(aInfo);}
1355 ScXMLDataPilotLayoutInfoContext::~ScXMLDataPilotLayoutInfoContext()
1359 ScXMLDataPilotSubTotalsContext::ScXMLDataPilotSubTotalsContext( ScXMLImport& rImport,
1360 USHORT nPrfx,
1361 const ::rtl::OUString& rLName,
1362 const ::com::sun::star::uno::Reference<
1363 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
1364 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1365 SvXMLImportContext( rImport, nPrfx, rLName ),
1366 pDataPilotField(pTempDataPilotField),
1367 nFunctionCount(0),
1368 pFunctions(NULL)
1371 // has no attributes
1374 ScXMLDataPilotSubTotalsContext::~ScXMLDataPilotSubTotalsContext()
1378 SvXMLImportContext *ScXMLDataPilotSubTotalsContext::CreateChildContext( USHORT nPrefix,
1379 const ::rtl::OUString& rLName,
1380 const ::com::sun::star::uno::Reference<
1381 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1383 SvXMLImportContext *pContext = 0;
1385 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotSubTotalsElemTokenMap();
1386 switch( rTokenMap.Get( nPrefix, rLName ) )
1388 case XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL :
1389 pContext = new ScXMLDataPilotSubTotalContext(GetScImport(), nPrefix, rLName, xAttrList, this);
1390 break;
1393 if( !pContext )
1394 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1396 return pContext;
1399 void ScXMLDataPilotSubTotalsContext::EndElement()
1401 pDataPilotField->SetSubTotals(pFunctions, nFunctionCount);
1402 if (maDisplayName.getLength())
1403 pDataPilotField->SetSubTotalName(maDisplayName);
1406 void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction)
1408 if (nFunctionCount)
1410 ++nFunctionCount;
1411 sal_uInt16* pTemp = new sal_uInt16[nFunctionCount];
1412 for (sal_Int16 i = 0; i < nFunctionCount - 1; ++i)
1413 pTemp[i] = pFunctions[i];
1414 pTemp[nFunctionCount - 1] = nFunction;
1415 delete[] pFunctions;
1416 pFunctions = pTemp;
1418 else
1420 nFunctionCount = 1;
1421 pFunctions = new sal_uInt16[nFunctionCount];
1422 pFunctions[0] = nFunction;
1426 void ScXMLDataPilotSubTotalsContext::SetDisplayName(const OUString& rName)
1428 maDisplayName = rName;
1431 ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport& rImport,
1432 USHORT nPrfx,
1433 const ::rtl::OUString& rLName,
1434 const ::com::sun::star::uno::Reference<
1435 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1436 ScXMLDataPilotSubTotalsContext* pTempDataPilotSubTotals) :
1437 SvXMLImportContext( rImport, nPrfx, rLName ),
1438 pDataPilotSubTotals(pTempDataPilotSubTotals)
1440 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1441 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotSubTotalAttrTokenMap();
1442 for( sal_Int16 i=0; i < nAttrCount; ++i )
1444 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1445 rtl::OUString aLocalName;
1446 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1447 sAttrName, &aLocalName );
1448 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1450 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
1452 case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION :
1454 pDataPilotSubTotals->AddFunction( sal::static_int_cast<sal_Int16>(
1455 ScXMLConverter::GetFunctionFromString( sValue ) ) );
1457 case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME:
1458 pDataPilotSubTotals->SetDisplayName(sValue);
1459 break;
1464 ScXMLDataPilotSubTotalContext::~ScXMLDataPilotSubTotalContext()
1468 SvXMLImportContext *ScXMLDataPilotSubTotalContext::CreateChildContext( USHORT nPrefix,
1469 const ::rtl::OUString& rLName,
1470 const ::com::sun::star::uno::Reference<
1471 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1473 SvXMLImportContext *pContext = 0;
1475 if( !pContext )
1476 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1478 return pContext;
1481 void ScXMLDataPilotSubTotalContext::EndElement()
1485 ScXMLDataPilotMembersContext::ScXMLDataPilotMembersContext( ScXMLImport& rImport,
1486 USHORT nPrfx,
1487 const ::rtl::OUString& rLName,
1488 const ::com::sun::star::uno::Reference<
1489 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
1490 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1491 SvXMLImportContext( rImport, nPrfx, rLName ),
1492 pDataPilotField(pTempDataPilotField)
1494 // has no attributes
1497 ScXMLDataPilotMembersContext::~ScXMLDataPilotMembersContext()
1501 SvXMLImportContext *ScXMLDataPilotMembersContext::CreateChildContext( USHORT nPrefix,
1502 const ::rtl::OUString& rLName,
1503 const ::com::sun::star::uno::Reference<
1504 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1506 SvXMLImportContext *pContext = 0;
1508 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotMembersElemTokenMap();
1509 switch( rTokenMap.Get( nPrefix, rLName ) )
1511 case XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER :
1512 pContext = new ScXMLDataPilotMemberContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1513 break;
1516 if( !pContext )
1517 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1519 return pContext;
1522 void ScXMLDataPilotMembersContext::EndElement()
1526 ScXMLDataPilotMemberContext::ScXMLDataPilotMemberContext( ScXMLImport& rImport,
1527 USHORT nPrfx,
1528 const ::rtl::OUString& rLName,
1529 const ::com::sun::star::uno::Reference<
1530 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1531 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1532 SvXMLImportContext( rImport, nPrfx, rLName ),
1533 pDataPilotField(pTempDataPilotField),
1534 bDisplay( sal_True ),
1535 bDisplayDetails( sal_True ),
1536 bHasName( sal_False )
1538 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1539 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotMemberAttrTokenMap();
1540 for( sal_Int16 i=0; i < nAttrCount; ++i )
1542 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1543 rtl::OUString aLocalName;
1544 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1545 sAttrName, &aLocalName );
1546 const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1548 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
1550 case XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME :
1552 sName = sValue;
1553 bHasName = sal_True;
1555 break;
1556 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME:
1558 maDisplayName = sValue;
1560 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY :
1562 bDisplay = IsXMLToken(sValue, XML_TRUE);
1564 break;
1565 case XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS :
1567 bDisplayDetails = IsXMLToken(sValue, XML_TRUE);
1569 break;
1574 ScXMLDataPilotMemberContext::~ScXMLDataPilotMemberContext()
1578 SvXMLImportContext *ScXMLDataPilotMemberContext::CreateChildContext( USHORT nPrefix,
1579 const ::rtl::OUString& rLName,
1580 const ::com::sun::star::uno::Reference<
1581 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1583 SvXMLImportContext *pContext = 0;
1585 if( !pContext )
1586 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1588 return pContext;
1591 void ScXMLDataPilotMemberContext::EndElement()
1593 if (bHasName) // #i53407# don't check sName, empty name is allowed
1595 ScDPSaveMember* pMember = new ScDPSaveMember(String(sName));
1596 if (maDisplayName.getLength())
1597 pMember->SetLayoutName(maDisplayName);
1598 pMember->SetIsVisible(bDisplay);
1599 pMember->SetShowDetails(bDisplayDetails);
1600 pDataPilotField->AddMember(pMember);
1604 ScXMLDataPilotGroupsContext::ScXMLDataPilotGroupsContext( ScXMLImport& rImport,
1605 USHORT nPrfx,
1606 const ::rtl::OUString& rLName,
1607 const ::com::sun::star::uno::Reference<
1608 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1609 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1610 SvXMLImportContext( rImport, nPrfx, rLName ),
1611 pDataPilotField(pTempDataPilotField)
1613 rtl::OUString sGroupSource;
1614 double fStart(0.0);
1615 double fEnd(0.0);
1616 double fStep(0.0);
1617 sal_Int32 nGroupPart(0);
1618 sal_Bool bDateValue(sal_False);
1619 sal_Bool bAutoStart(sal_True);
1620 sal_Bool bAutoEnd(sal_True);
1622 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1623 for( sal_Int16 i=0; i < nAttrCount; i++ )
1625 rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
1626 rtl::OUString aLocalName;
1627 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1628 sAttrName, &aLocalName );
1629 rtl::OUString sValue = xAttrList->getValueByIndex( i );
1631 (void)nPrefix; //! compare below!
1633 if (IsXMLToken(aLocalName, XML_SOURCE_FIELD_NAME))
1634 sGroupSource = sValue;
1635 else if (IsXMLToken(aLocalName, XML_DATE_START))
1637 bDateValue = sal_True;
1638 if (IsXMLToken(sValue, XML_AUTO))
1639 bAutoStart = sal_True;
1640 else
1642 GetScImport().GetMM100UnitConverter().convertDateTime(fStart, sValue);
1643 bAutoStart = sal_False;
1646 else if (IsXMLToken(aLocalName, XML_DATE_END))
1648 bDateValue = sal_True;
1649 if (IsXMLToken(sValue, XML_AUTO))
1650 bAutoEnd = sal_True;
1651 else
1653 GetScImport().GetMM100UnitConverter().convertDateTime(fEnd, sValue);
1654 bAutoEnd = sal_False;
1657 else if (IsXMLToken(aLocalName, XML_START))
1659 if (IsXMLToken(sValue, XML_AUTO))
1660 bAutoStart = sal_True;
1661 else
1663 GetScImport().GetMM100UnitConverter().convertDouble(fStart, sValue);
1664 bAutoStart = sal_False;
1667 else if (IsXMLToken(aLocalName, XML_END))
1669 if (IsXMLToken(sValue, XML_AUTO))
1670 bAutoEnd = sal_True;
1671 else
1673 GetScImport().GetMM100UnitConverter().convertDouble(fEnd, sValue);
1674 bAutoEnd = sal_False;
1677 else if (IsXMLToken(aLocalName, XML_STEP))
1678 GetScImport().GetMM100UnitConverter().convertDouble(fStep, sValue);
1679 else if (IsXMLToken(aLocalName, XML_GROUPED_BY))
1681 if (IsXMLToken(sValue, XML_SECONDS))
1682 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS;
1683 else if (IsXMLToken(sValue, XML_MINUTES))
1684 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES;
1685 else if (IsXMLToken(sValue, XML_HOURS))
1686 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::HOURS;
1687 else if (IsXMLToken(sValue, XML_DAYS))
1688 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::DAYS;
1689 else if (IsXMLToken(sValue, XML_MONTHS))
1690 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS;
1691 else if (IsXMLToken(sValue, XML_QUARTERS))
1692 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS;
1693 else if (IsXMLToken(sValue, XML_YEARS))
1694 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::YEARS;
1697 pDataPilotField->SetGrouping(sGroupSource, fStart, fEnd, fStep, nGroupPart, bDateValue, bAutoStart, bAutoEnd);
1700 ScXMLDataPilotGroupsContext::~ScXMLDataPilotGroupsContext()
1704 SvXMLImportContext *ScXMLDataPilotGroupsContext::CreateChildContext( USHORT nPrefix,
1705 const ::rtl::OUString& rLName,
1706 const ::com::sun::star::uno::Reference<
1707 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1709 SvXMLImportContext *pContext = 0;
1711 if (nPrefix == XML_NAMESPACE_TABLE)
1713 if (IsXMLToken(rLName, XML_DATA_PILOT_GROUP))
1714 pContext = new ScXMLDataPilotGroupContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1717 if( !pContext )
1718 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1720 return pContext;
1723 void ScXMLDataPilotGroupsContext::EndElement()
1727 ScXMLDataPilotGroupContext::ScXMLDataPilotGroupContext( ScXMLImport& rImport,
1728 USHORT nPrfx,
1729 const ::rtl::OUString& rLName,
1730 const ::com::sun::star::uno::Reference<
1731 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1732 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1733 SvXMLImportContext( rImport, nPrfx, rLName ),
1734 pDataPilotField(pTempDataPilotField)
1736 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1737 for( sal_Int16 i=0; i < nAttrCount; i++ )
1739 rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
1740 rtl::OUString aLocalName;
1741 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1742 sAttrName, &aLocalName );
1743 rtl::OUString sValue = xAttrList->getValueByIndex( i );
1745 if (nPrefix == XML_NAMESPACE_TABLE)
1747 if (IsXMLToken(aLocalName, XML_NAME))
1748 sName = sValue;
1753 ScXMLDataPilotGroupContext::~ScXMLDataPilotGroupContext()
1757 SvXMLImportContext *ScXMLDataPilotGroupContext::CreateChildContext( USHORT nPrefix,
1758 const ::rtl::OUString& rLName,
1759 const ::com::sun::star::uno::Reference<
1760 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1762 SvXMLImportContext *pContext = 0;
1764 if (nPrefix == XML_NAMESPACE_TABLE)
1766 if (IsXMLToken(rLName, XML_DATA_PILOT_MEMBER))
1767 pContext = new ScXMLDataPilotGroupMemberContext(GetScImport(), nPrefix, rLName, xAttrList, this);
1770 if( !pContext )
1771 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1773 return pContext;
1776 void ScXMLDataPilotGroupContext::EndElement()
1778 pDataPilotField->AddGroup(aMembers, sName);
1781 ScXMLDataPilotGroupMemberContext::ScXMLDataPilotGroupMemberContext( ScXMLImport& rImport,
1782 USHORT nPrfx,
1783 const ::rtl::OUString& rLName,
1784 const ::com::sun::star::uno::Reference<
1785 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1786 ScXMLDataPilotGroupContext* pTempDataPilotGroup) :
1787 SvXMLImportContext( rImport, nPrfx, rLName ),
1788 pDataPilotGroup(pTempDataPilotGroup)
1790 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1791 for( sal_Int16 i=0; i < nAttrCount; i++ )
1793 rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
1794 rtl::OUString aLocalName;
1795 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1796 sAttrName, &aLocalName );
1797 rtl::OUString sValue = xAttrList->getValueByIndex( i );
1799 if (nPrefix == XML_NAMESPACE_TABLE)
1801 if (IsXMLToken(aLocalName, XML_NAME))
1802 sName = sValue;
1807 ScXMLDataPilotGroupMemberContext::~ScXMLDataPilotGroupMemberContext()
1811 SvXMLImportContext *ScXMLDataPilotGroupMemberContext::CreateChildContext( USHORT nPrefix,
1812 const ::rtl::OUString& rLName,
1813 const ::com::sun::star::uno::Reference<
1814 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1816 SvXMLImportContext *pContext = 0;
1818 if( !pContext )
1819 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1821 return pContext;
1824 void ScXMLDataPilotGroupMemberContext::EndElement()
1826 if (sName.getLength())
1827 pDataPilotGroup->AddMember(sName);