fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / xml / xmldpimp.cxx
blob0ee00a0320fc89172f863ea0f8816da0c6acaa3a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
35 #include "pivotsource.hxx"
37 #include <xmloff/xmltkmap.hxx>
38 #include <xmloff/nmspmap.hxx>
39 #include <xmloff/xmltoken.hxx>
40 #include <xmloff/xmlnmspe.hxx>
41 #include <xmloff/xmluconv.hxx>
42 #include <sax/tools/converter.hxx>
44 #include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
45 #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
46 #include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
47 #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
48 #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
49 #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
50 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
52 using namespace com::sun::star;
53 using namespace xmloff::token;
54 using ::com::sun::star::uno::Reference;
55 using ::com::sun::star::xml::sax::XAttributeList;
57 ScXMLDataPilotTablesContext::ScXMLDataPilotTablesContext( ScXMLImport& rImport,
58 sal_uInt16 nPrfx,
59 const OUString& rLName,
60 const ::com::sun::star::uno::Reference<
61 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
62 SvXMLImportContext( rImport, nPrfx, rLName )
64 // has no Attributes
65 rImport.LockSolarMutex();
68 ScXMLDataPilotTablesContext::~ScXMLDataPilotTablesContext()
70 GetScImport().UnlockSolarMutex();
73 SvXMLImportContext *ScXMLDataPilotTablesContext::CreateChildContext( sal_uInt16 nPrefix,
74 const OUString& rLName,
75 const ::com::sun::star::uno::Reference<
76 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
78 SvXMLImportContext *pContext = 0;
80 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTablesElemTokenMap();
81 switch( rTokenMap.Get( nPrefix, rLName ) )
83 case XML_TOK_DATA_PILOT_TABLE :
85 pContext = new ScXMLDataPilotTableContext( GetScImport(), nPrefix,
86 rLName, xAttrList);
88 break;
91 if( !pContext )
92 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
94 return pContext;
97 void ScXMLDataPilotTablesContext::EndElement()
101 ScXMLDataPilotTableContext::GrandTotalItem::GrandTotalItem() :
102 mbVisible(true) {}
104 ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport,
105 sal_uInt16 nPrfx,
106 const OUString& rLName,
107 const ::com::sun::star::uno::Reference<
108 ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
109 SvXMLImportContext( rImport, nPrfx, rLName ),
110 pDoc(GetScImport().GetDocument()),
111 pDPObject(NULL),
112 pDPDimSaveData(NULL),
113 sDataPilotTableName(),
114 sApplicationData(),
115 nSourceType(SQL),
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 bHeaderGridLayout(false)
130 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
131 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableAttrTokenMap();
132 for( sal_Int16 i=0; i < nAttrCount; ++i )
134 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
135 OUString aLocalName;
136 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
137 sAttrName, &aLocalName );
138 const OUString& sValue(xAttrList->getValueByIndex( i ));
140 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
142 case XML_TOK_DATA_PILOT_TABLE_ATTR_NAME :
144 sDataPilotTableName = sValue;
146 break;
147 case XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA :
149 sApplicationData = sValue;
151 break;
152 case XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL :
154 if (IsXMLToken(sValue, XML_BOTH))
156 maRowGrandTotal.mbVisible = true;
157 maColGrandTotal.mbVisible = true;
159 else if (IsXMLToken(sValue, XML_ROW))
161 maRowGrandTotal.mbVisible = true;
162 maColGrandTotal.mbVisible = false;
164 else if (IsXMLToken(sValue, XML_COLUMN))
166 maRowGrandTotal.mbVisible = false;
167 maColGrandTotal.mbVisible = true;
169 else
171 maRowGrandTotal.mbVisible = false;
172 maColGrandTotal.mbVisible = false;
175 break;
176 case XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS :
178 bIgnoreEmptyRows = IsXMLToken(sValue, XML_TRUE);
180 break;
181 case XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES :
183 bIdentifyCategories = IsXMLToken(sValue, XML_TRUE);
185 break;
186 case XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS :
188 sal_Int32 nOffset(0);
189 bTargetRangeAddress = ScRangeStringConverter::GetRangeFromString( aTargetRangeAddress, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset );
191 break;
192 case XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS :
194 sButtons = sValue;
196 break;
197 case XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON :
199 bShowFilter = IsXMLToken(sValue, XML_TRUE);
201 break;
202 case XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN :
204 bDrillDown = IsXMLToken(sValue, XML_TRUE);
206 break;
207 case XML_TOK_DATA_PILOT_TABLE_ATTR_HEADER_GRID_LAYOUT :
209 bHeaderGridLayout = IsXMLToken(sValue, XML_TRUE);
211 break;
215 pDPObject = new ScDPObject(pDoc);
216 pDPSave.reset(new ScDPSaveData());
219 ScXMLDataPilotTableContext::~ScXMLDataPilotTableContext()
221 delete pDPDimSaveData;
224 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 )
229 SvXMLImportContext *pContext = 0;
231 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTableElemTokenMap();
232 switch( rTokenMap.Get( nPrefix, rLName ) )
234 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL :
236 pContext = new ScXMLDPSourceSQLContext(GetScImport(), nPrefix, rLName, xAttrList, this);
237 nSourceType = SQL;
239 break;
240 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE :
242 pContext = new ScXMLDPSourceTableContext(GetScImport(), nPrefix, rLName, xAttrList, this);
243 nSourceType = TABLE;
245 break;
246 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY :
248 pContext = new ScXMLDPSourceQueryContext(GetScImport(), nPrefix, rLName, xAttrList, this);
249 nSourceType = QUERY;
251 break;
252 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE :
254 pContext = new ScXMLSourceServiceContext(GetScImport(), nPrefix, rLName, xAttrList, this);
255 nSourceType = SERVICE;
257 break;
258 case XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL:
259 case XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL_EXT:
261 pContext = new ScXMLDataPilotGrandTotalContext(GetScImport(), nPrefix, rLName, xAttrList, this);
263 break;
264 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE :
266 pContext = new ScXMLSourceCellRangeContext(GetScImport(), nPrefix, rLName, xAttrList, this);
267 nSourceType = CELLRANGE;
269 break;
270 case XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD :
271 pContext = new ScXMLDataPilotFieldContext(GetScImport(), nPrefix, rLName, xAttrList, this);
272 break;
275 if( !pContext )
276 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
278 return pContext;
281 namespace {
283 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)
289 switch (eType)
291 case ScDPOutputGeometry::Column:
293 if (rColDims.size() <= nPos)
294 return NULL;
296 return rColDims[nPos];
298 case ScDPOutputGeometry::Row:
300 if (rRowDims.size() <= nPos)
301 return NULL;
303 return rRowDims[nPos];
305 case ScDPOutputGeometry::Page:
307 if (rPageDims.size() <= nPos)
308 return NULL;
310 return rPageDims[nPos];
312 case ScDPOutputGeometry::Data:
313 break;
314 case ScDPOutputGeometry::None:
315 break;
316 default:
317 break;
319 return NULL;
322 ScDPOutputGeometry::FieldType toFieldType(sal_uInt16 nOrient)
324 switch (nOrient)
326 case sheet::DataPilotFieldOrientation_COLUMN:
327 return ScDPOutputGeometry::Column;
328 case sheet::DataPilotFieldOrientation_DATA:
329 return ScDPOutputGeometry::Data;
330 case sheet::DataPilotFieldOrientation_PAGE:
331 return ScDPOutputGeometry::Page;
332 case sheet::DataPilotFieldOrientation_ROW:
333 return ScDPOutputGeometry::Row;
334 case sheet::DataPilotFieldOrientation_HIDDEN:
335 break;
336 default:
337 break;
339 return ScDPOutputGeometry::None;
344 void ScXMLDataPilotTableContext::SetButtons()
346 ScDPOutputGeometry aGeometry(aTargetRangeAddress, bShowFilter);
347 aGeometry.setColumnFieldCount(mnColFieldCount);
348 aGeometry.setRowFieldCount(mnRowFieldCount);
349 aGeometry.setPageFieldCount(mnPageFieldCount);
350 aGeometry.setDataFieldCount(mnDataFieldCount);
351 aGeometry.setDataLayoutType(toFieldType(mnDataLayoutType));
353 std::vector<const ScDPSaveDimension*> aRowDims, aColDims, aPageDims;
354 pDPSave->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aRowDims);
355 pDPSave->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aColDims);
356 pDPSave->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_PAGE, aPageDims);
358 OUString sAddress;
359 sal_Int32 nOffset = 0;
360 while( nOffset >= 0 )
362 ScRangeStringConverter::GetTokenByOffset( sAddress, sButtons, nOffset );
363 if( nOffset >= 0 )
365 ScAddress aScAddress;
366 sal_Int32 nAddrOffset(0);
367 if (pDoc && ScRangeStringConverter::GetAddressFromString( aScAddress, sAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nAddrOffset ))
369 std::pair<ScDPOutputGeometry::FieldType, size_t> aBtnType = aGeometry.getFieldButtonType(aScAddress);
370 const ScDPSaveDimension* pDim = getDimension(
371 aRowDims, aColDims, aPageDims, aBtnType.first, aBtnType.second);
373 bool bDimension = pDim != NULL;
374 bool bDataLayout = pDim && pDim->IsDataLayout();
375 bool bHasHidden = pDim && pDim->HasInvisibleMember();
376 bool bPageDim = pDim && pDim->GetOrientation() == sheet::DataPilotFieldOrientation_PAGE;
378 if (bPageDim)
380 // Page dimension needs 2 buttons.
382 pDoc->ApplyFlagsTab(aScAddress.Col(), aScAddress.Row(), aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), SC_MF_BUTTON);
384 sal_Int16 nMFlag = SC_MF_BUTTON_POPUP;
385 if (bHasHidden)
386 nMFlag |= SC_MF_HIDDEN_MEMBER;
387 pDoc->ApplyFlagsTab(aScAddress.Col()+1, aScAddress.Row(), aScAddress.Col()+1, aScAddress.Row(), aScAddress.Tab(), nMFlag);
389 else
391 sal_Int16 nMFlag = SC_MF_BUTTON;
392 if (bDataLayout)
394 // Data layout dimension only has a plain button with no popup.
396 else if (bDimension)
398 // Normal dimension has a popup arrow button.
399 if (bHasHidden)
400 nMFlag |= SC_MF_HIDDEN_MEMBER;
402 nMFlag |= SC_MF_BUTTON_POPUP;
405 pDoc->ApplyFlagsTab(aScAddress.Col(), aScAddress.Row(), aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), nMFlag);
411 if ( pDPObject )
412 pDPObject->RefreshAfterLoad();
415 void ScXMLDataPilotTableContext::SetSelectedPage( const OUString& rDimName, const OUString& rSelected )
417 maSelectedPages.insert(SelectedPagesType::value_type(rDimName, rSelected));
420 void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim)
422 if (pDPSave)
424 if (pDim->IsDataLayout())
425 mnDataLayoutType = pDim->GetOrientation();
427 // if a dimension with that name has already been inserted,
428 // mark the new one as duplicate
429 if ( !pDim->IsDataLayout() &&
430 pDPSave->GetExistingDimensionByName(pDim->GetName()) )
431 pDim->SetDupFlag(true);
433 switch (pDim->GetOrientation())
435 case sheet::DataPilotFieldOrientation_ROW:
436 ++mnRowFieldCount;
437 break;
438 case sheet::DataPilotFieldOrientation_COLUMN:
439 ++mnColFieldCount;
440 break;
441 case sheet::DataPilotFieldOrientation_PAGE:
442 ++mnPageFieldCount;
443 break;
444 case sheet::DataPilotFieldOrientation_DATA:
445 ++mnDataFieldCount;
446 break;
447 case sheet::DataPilotFieldOrientation_HIDDEN:
448 break;
449 default:
450 break;
453 pDPSave->AddDimension(pDim);
457 void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim)
459 if (!pDPDimSaveData)
460 pDPDimSaveData = new ScDPDimensionSaveData();
461 pDPDimSaveData->AddNumGroupDimension(aNumGroupDim);
464 void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveGroupDimension& aGroupDim)
466 if (!pDPDimSaveData)
467 pDPDimSaveData = new ScDPDimensionSaveData();
468 pDPDimSaveData->AddGroupDimension(aGroupDim);
471 void ScXMLDataPilotTableContext::EndElement()
473 if (!bTargetRangeAddress)
474 return;
476 pDPObject->SetName(sDataPilotTableName);
477 pDPObject->SetTag(sApplicationData);
478 pDPObject->SetOutRange(aTargetRangeAddress);
479 pDPObject->SetHeaderLayout(bHeaderGridLayout);
481 sc::PivotTableSources& rPivotSources = GetScImport().GetPivotTableSources();
483 switch (nSourceType)
485 case SQL :
487 ScImportSourceDesc aImportDesc(pDoc);
488 aImportDesc.aDBName = sDatabaseName;
489 aImportDesc.aObject = sSourceObject;
490 aImportDesc.nType = sheet::DataImportMode_SQL;
491 aImportDesc.bNative = bIsNative;
492 rPivotSources.appendDBSource(pDPObject, aImportDesc);
494 break;
495 case TABLE :
497 ScImportSourceDesc aImportDesc(pDoc);
498 aImportDesc.aDBName = sDatabaseName;
499 aImportDesc.aObject = sSourceObject;
500 aImportDesc.nType = sheet::DataImportMode_TABLE;
501 rPivotSources.appendDBSource(pDPObject, aImportDesc);
503 break;
504 case QUERY :
506 ScImportSourceDesc aImportDesc(pDoc);
507 aImportDesc.aDBName = sDatabaseName;
508 aImportDesc.aObject = sSourceObject;
509 aImportDesc.nType = sheet::DataImportMode_QUERY;
510 rPivotSources.appendDBSource(pDPObject, aImportDesc);
512 break;
513 case SERVICE :
515 ScDPServiceDesc aServiceDesc(sServiceName, sServiceSourceName, sServiceSourceObject,
516 sServiceUsername, sServicePassword);
517 rPivotSources.appendServiceSource(pDPObject, aServiceDesc);
519 break;
520 case CELLRANGE :
522 if (bSourceCellRange)
524 ScSheetSourceDesc aSheetDesc(pDoc);
525 if (!sSourceRangeName.isEmpty())
526 // Range name takes precedence.
527 aSheetDesc.SetRangeName(sSourceRangeName);
528 else
529 aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
530 aSheetDesc.SetQueryParam(aSourceQueryParam);
531 rPivotSources.appendSheetSource(pDPObject, aSheetDesc);
534 break;
537 rPivotSources.appendSelectedPages(pDPObject, maSelectedPages);
539 pDPSave->SetRowGrand(maRowGrandTotal.mbVisible);
540 pDPSave->SetColumnGrand(maColGrandTotal.mbVisible);
541 if (!maRowGrandTotal.maDisplayName.isEmpty())
542 // TODO: Right now, we only support one grand total name for both
543 // column and row totals. Take the value from the row total for
544 // now.
545 pDPSave->SetGrandTotalName(maRowGrandTotal.maDisplayName);
547 pDPSave->SetIgnoreEmptyRows(bIgnoreEmptyRows);
548 pDPSave->SetRepeatIfEmpty(bIdentifyCategories);
549 pDPSave->SetFilterButton(bShowFilter);
550 pDPSave->SetDrillDown(bDrillDown);
551 if (pDPDimSaveData)
552 pDPSave->SetDimensionData(pDPDimSaveData);
553 pDPObject->SetSaveData(*pDPSave);
555 ScDPCollection* pDPCollection = pDoc->GetDPCollection();
557 // #i94570# Names have to be unique, or the tables can't be accessed by API.
558 if ( pDPCollection->GetByName(pDPObject->GetName()) )
559 pDPObject->SetName( OUString() ); // ignore the invalid name, create a new name in AfterXMLLoading
561 if (!pDPCollection->InsertNewTable(pDPObject))
563 OSL_FAIL("cannot insert DPObject");
564 DELETEZ( pDPObject );
567 SetButtons();
570 void ScXMLDataPilotTableContext::SetGrandTotal(
571 XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName)
573 switch (eOrientation)
575 case XML_BOTH:
576 maRowGrandTotal.mbVisible = bVisible;
577 maRowGrandTotal.maDisplayName = rDisplayName;
578 maColGrandTotal.mbVisible = bVisible;
579 maColGrandTotal.maDisplayName = rDisplayName;
580 break;
581 case XML_ROW:
582 maRowGrandTotal.mbVisible = bVisible;
583 maRowGrandTotal.maDisplayName = rDisplayName;
584 break;
585 case XML_COLUMN:
586 maColGrandTotal.mbVisible = bVisible;
587 maColGrandTotal.maDisplayName = rDisplayName;
588 break;
589 default:
590 break;
594 ScXMLDPSourceSQLContext::ScXMLDPSourceSQLContext( ScXMLImport& rImport,
595 sal_uInt16 nPrfx,
596 const OUString& rLName,
597 const ::com::sun::star::uno::Reference<
598 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
599 ScXMLDataPilotTableContext* pTempDataPilotTable) :
600 SvXMLImportContext( rImport, nPrfx, rLName ),
601 pDataPilotTable(pTempDataPilotTable)
603 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
604 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceSQLAttrTokenMap();
605 for( sal_Int16 i=0; i < nAttrCount; ++i )
607 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
608 OUString aLocalName;
609 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
610 sAttrName, &aLocalName );
611 const OUString& sValue(xAttrList->getValueByIndex( i ));
613 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
615 case XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME :
617 pDataPilotTable->SetDatabaseName(sValue);
619 break;
620 case XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT :
622 pDataPilotTable->SetSourceObject(sValue);
624 break;
625 case XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT :
627 pDataPilotTable->SetNative(!IsXMLToken(sValue, XML_TRUE));
629 break;
634 ScXMLDPSourceSQLContext::~ScXMLDPSourceSQLContext()
638 SvXMLImportContext *ScXMLDPSourceSQLContext::CreateChildContext( sal_uInt16 nPrefix,
639 const OUString& rLName,
640 const ::com::sun::star::uno::Reference<
641 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
643 SvXMLImportContext *pContext = 0;
645 if( !pContext )
646 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
648 return pContext;
651 void ScXMLDPSourceSQLContext::EndElement()
655 ScXMLDPSourceTableContext::ScXMLDPSourceTableContext( ScXMLImport& rImport,
656 sal_uInt16 nPrfx,
657 const OUString& rLName,
658 const ::com::sun::star::uno::Reference<
659 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
660 ScXMLDataPilotTableContext* pTempDataPilotTable) :
661 SvXMLImportContext( rImport, nPrfx, rLName ),
662 pDataPilotTable(pTempDataPilotTable)
664 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
665 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceTableAttrTokenMap();
666 for( sal_Int16 i=0; i < nAttrCount; ++i )
668 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
669 OUString aLocalName;
670 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
671 sAttrName, &aLocalName );
672 const OUString& sValue(xAttrList->getValueByIndex( i ));
674 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
676 case XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME :
678 pDataPilotTable->SetDatabaseName(sValue);
680 break;
681 case XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME :
683 pDataPilotTable->SetSourceObject(sValue);
685 break;
690 ScXMLDPSourceTableContext::~ScXMLDPSourceTableContext()
694 SvXMLImportContext *ScXMLDPSourceTableContext::CreateChildContext( sal_uInt16 nPrefix,
695 const OUString& rLName,
696 const ::com::sun::star::uno::Reference<
697 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
699 SvXMLImportContext *pContext = 0;
701 if( !pContext )
702 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
704 return pContext;
707 void ScXMLDPSourceTableContext::EndElement()
711 ScXMLDPSourceQueryContext::ScXMLDPSourceQueryContext( ScXMLImport& rImport,
712 sal_uInt16 nPrfx,
713 const OUString& rLName,
714 const ::com::sun::star::uno::Reference<
715 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
716 ScXMLDataPilotTableContext* pTempDataPilotTable) :
717 SvXMLImportContext( rImport, nPrfx, rLName ),
718 pDataPilotTable(pTempDataPilotTable)
720 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
721 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeSourceQueryAttrTokenMap();
722 for( sal_Int16 i=0; i < nAttrCount; ++i )
724 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
725 OUString aLocalName;
726 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
727 sAttrName, &aLocalName );
728 const OUString& sValue(xAttrList->getValueByIndex( i ));
730 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
732 case XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME :
734 pDataPilotTable->SetDatabaseName(sValue);
736 break;
737 case XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME :
739 pDataPilotTable->SetSourceObject(sValue);
741 break;
746 ScXMLDPSourceQueryContext::~ScXMLDPSourceQueryContext()
750 SvXMLImportContext *ScXMLDPSourceQueryContext::CreateChildContext( sal_uInt16 nPrefix,
751 const OUString& rLName,
752 const ::com::sun::star::uno::Reference<
753 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
755 SvXMLImportContext *pContext = 0;
757 if( !pContext )
758 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
760 return pContext;
763 void ScXMLDPSourceQueryContext::EndElement()
767 ScXMLSourceServiceContext::ScXMLSourceServiceContext( ScXMLImport& rImport,
768 sal_uInt16 nPrfx,
769 const OUString& rLName,
770 const ::com::sun::star::uno::Reference<
771 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
772 ScXMLDataPilotTableContext* pTempDataPilotTable) :
773 SvXMLImportContext( rImport, nPrfx, rLName ),
774 pDataPilotTable(pTempDataPilotTable)
776 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
777 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableSourceServiceAttrTokenMap();
778 for( sal_Int16 i=0; i < nAttrCount; ++i )
780 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
781 OUString aLocalName;
782 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
783 sAttrName, &aLocalName );
784 const OUString& sValue(xAttrList->getValueByIndex( i ));
786 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
788 case XML_TOK_SOURCE_SERVICE_ATTR_NAME :
790 pDataPilotTable->SetServiceName(sValue);
792 break;
793 case XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME :
795 pDataPilotTable->SetServiceSourceName(sValue);
797 break;
798 case XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME :
800 pDataPilotTable->SetServiceSourceObject(sValue);
802 break;
803 case XML_TOK_SOURCE_SERVICE_ATTR_USER_NAME :
805 pDataPilotTable->SetServiceUsername(sValue);
807 break;
808 case XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD :
810 pDataPilotTable->SetServicePassword(sValue);
812 break;
817 ScXMLSourceServiceContext::~ScXMLSourceServiceContext()
821 SvXMLImportContext *ScXMLSourceServiceContext::CreateChildContext( sal_uInt16 nPrefix,
822 const OUString& rLName,
823 const ::com::sun::star::uno::Reference<
824 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
826 SvXMLImportContext *pContext = 0;
828 if( !pContext )
829 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
831 return pContext;
834 void ScXMLSourceServiceContext::EndElement()
838 ScXMLImport& ScXMLDataPilotGrandTotalContext::GetScImport()
840 return static_cast<ScXMLImport&>(GetImport());
843 ScXMLDataPilotGrandTotalContext::ScXMLDataPilotGrandTotalContext(
844 ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLName, const Reference<XAttributeList>& xAttrList,
845 ScXMLDataPilotTableContext* pTableContext ) :
846 SvXMLImportContext( rImport, nPrefix, rLName ),
847 mpTableContext(pTableContext),
848 meOrientation(NONE),
849 mbVisible(false)
851 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
852 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotGrandTotalAttrTokenMap();
853 for (sal_Int16 i = 0; i < nAttrCount; ++i)
855 const OUString& rAttrName = xAttrList->getNameByIndex(i);
856 const OUString& rAttrValue = xAttrList->getValueByIndex(i);
858 OUString aLocalName;
859 sal_uInt16 nLocalPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
860 switch (rAttrTokenMap.Get(nLocalPrefix, aLocalName))
862 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY:
863 mbVisible = IsXMLToken(rAttrValue, XML_TRUE);
864 break;
865 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_ORIENTATION:
866 if (IsXMLToken(rAttrValue, XML_BOTH))
867 meOrientation = BOTH;
868 else if (IsXMLToken(rAttrValue, XML_ROW))
869 meOrientation = ROW;
870 else if (IsXMLToken(rAttrValue, XML_COLUMN))
871 meOrientation = COLUMN;
872 break;
873 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME:
874 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME_EXT:
875 maDisplayName = rAttrValue;
876 break;
877 default:
878 break;
883 ScXMLDataPilotGrandTotalContext::~ScXMLDataPilotGrandTotalContext()
887 SvXMLImportContext* ScXMLDataPilotGrandTotalContext::CreateChildContext(
888 sal_uInt16 nPrefix, const OUString& rLocalName, const Reference<XAttributeList>& /*xAttrList*/ )
890 return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
893 void ScXMLDataPilotGrandTotalContext::EndElement()
895 XMLTokenEnum eOrient = XML_NONE;
896 switch (meOrientation)
898 case BOTH:
899 eOrient = XML_BOTH;
900 break;
901 case ROW:
902 eOrient = XML_ROW;
903 break;
904 case COLUMN:
905 eOrient = XML_COLUMN;
906 break;
907 default:
908 break;
910 mpTableContext->SetGrandTotal(eOrient, mbVisible, maDisplayName);
913 ScXMLSourceCellRangeContext::ScXMLSourceCellRangeContext( ScXMLImport& rImport,
914 sal_uInt16 nPrfx,
915 const OUString& rLName,
916 const ::com::sun::star::uno::Reference<
917 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
918 ScXMLDataPilotTableContext* pTempDataPilotTable) :
919 SvXMLImportContext( rImport, nPrfx, rLName ),
920 pDataPilotTable(pTempDataPilotTable)
922 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
923 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotTableSourceCellRangeAttrTokenMap();
924 for( sal_Int16 i=0; i < nAttrCount; ++i )
926 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
927 OUString aLocalName;
928 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
929 sAttrName, &aLocalName );
930 const OUString& sValue(xAttrList->getValueByIndex( i ));
932 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
934 case XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS :
936 ScRange aSourceRangeAddress;
937 sal_Int32 nOffset(0);
938 if (ScRangeStringConverter::GetRangeFromString( aSourceRangeAddress, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset ))
939 pDataPilotTable->SetSourceCellRangeAddress(aSourceRangeAddress);
941 break;
942 case XML_TOK_SOURCE_CELL_RANGE_ATTR_NAME:
943 pDataPilotTable->SetSourceRangeName(sValue);
944 break;
949 ScXMLSourceCellRangeContext::~ScXMLSourceCellRangeContext()
953 SvXMLImportContext *ScXMLSourceCellRangeContext::CreateChildContext( sal_uInt16 nPrefix,
954 const OUString& rLName,
955 const ::com::sun::star::uno::Reference<
956 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
958 SvXMLImportContext *pContext = 0;
960 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotTableSourceCellRangeElemTokenMap();
961 switch( rTokenMap.Get( nPrefix, rLName ) )
963 case XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER :
964 pContext = new ScXMLDPFilterContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotTable);
965 break;
968 if( !pContext )
969 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
971 return pContext;
974 void ScXMLSourceCellRangeContext::EndElement()
978 ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
979 sal_uInt16 nPrfx,
980 const OUString& rLName,
981 const ::com::sun::star::uno::Reference<
982 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
983 ScXMLDataPilotTableContext* pTempDataPilotTable) :
984 SvXMLImportContext( rImport, nPrfx, rLName ),
985 pDataPilotTable(pTempDataPilotTable),
986 pDim(NULL),
987 fStart(0.0),
988 fEnd(0.0),
989 fStep(0.0),
990 nUsedHierarchy(1),
991 nGroupPart(0),
992 nFunction(0),
993 nOrientation(0),
994 bSelectedPage(false),
995 bIsGroupField(false),
996 bDateValue(false),
997 bAutoStart(false),
998 bAutoEnd(false),
999 mbHasHiddenMember(false)
1001 bool bHasName = false;
1002 bool bDataLayout = false;
1003 bool bIgnoreSelectedPage = false;
1004 OUString aDisplayName;
1005 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1006 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotFieldAttrTokenMap();
1007 for( sal_Int16 i=0; i < nAttrCount; ++i )
1009 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1010 OUString aLocalName;
1011 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1012 sAttrName, &aLocalName );
1013 const OUString& sValue(xAttrList->getValueByIndex( i ));
1015 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
1017 case XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME :
1019 sName = sValue;
1020 bHasName = true;
1022 break;
1023 case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME:
1024 case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME_EXT:
1026 aDisplayName = sValue;
1028 break;
1029 case XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD :
1031 bDataLayout = IsXMLToken(sValue, XML_TRUE);
1033 break;
1034 case XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION :
1036 nFunction = (sal_Int16) ScXMLConverter::GetFunctionFromString( sValue );
1038 break;
1039 case XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION :
1041 nOrientation = (sal_Int16) ScXMLConverter::GetOrientationFromString( sValue );
1043 break;
1044 case XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE :
1046 sSelectedPage = sValue;
1047 bSelectedPage = true;
1049 break;
1050 case XML_TOK_DATA_PILOT_FIELD_ATTR_IGNORE_SELECTED_PAGE:
1052 bIgnoreSelectedPage = true;
1054 break;
1055 case XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY :
1057 nUsedHierarchy = sValue.toInt32();
1059 break;
1063 // use the new extension elements
1064 if (bIgnoreSelectedPage)
1065 bSelectedPage = false;
1067 if (bHasName)
1069 pDim = new ScDPSaveDimension(sName, bDataLayout);
1070 if (!aDisplayName.isEmpty())
1071 pDim->SetLayoutName(aDisplayName);
1075 ScXMLDataPilotFieldContext::~ScXMLDataPilotFieldContext()
1079 SvXMLImportContext *ScXMLDataPilotFieldContext::CreateChildContext( sal_uInt16 nPrefix,
1080 const OUString& rLName,
1081 const ::com::sun::star::uno::Reference<
1082 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1084 SvXMLImportContext *pContext = 0;
1086 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotFieldElemTokenMap();
1087 switch( rTokenMap.Get( nPrefix, rLName ) )
1089 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL :
1090 pContext = new ScXMLDataPilotLevelContext(GetScImport(), nPrefix, rLName, xAttrList, this);
1091 break;
1092 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_REFERENCE :
1093 pContext = new ScXMLDataPilotFieldReferenceContext(GetScImport(), nPrefix, rLName, xAttrList, this);
1094 break;
1095 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_GROUPS :
1096 pContext = new ScXMLDataPilotGroupsContext(GetScImport(), nPrefix, rLName, xAttrList, this);
1097 break;
1100 if( !pContext )
1101 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1103 return pContext;
1106 void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember* pMember)
1108 if (pDim)
1110 pDim->AddMember(pMember);
1111 if (!pMember->GetIsVisible())
1112 // This member is hidden.
1113 mbHasHiddenMember = true;
1115 else
1116 delete pMember;
1119 void ScXMLDataPilotFieldContext::SetSubTotalName(const OUString& rName)
1121 if (pDim)
1122 pDim->SetSubtotalName(rName);
1125 void ScXMLDataPilotFieldContext::AddGroup(const ::std::vector<OUString>& rMembers, const OUString& rName)
1127 ScXMLDataPilotGroup aGroup;
1128 aGroup.aMembers = rMembers;
1129 aGroup.aName = rName;
1130 aGroups.push_back(aGroup);
1133 void ScXMLDataPilotFieldContext::EndElement()
1135 if (pDim)
1137 pDim->SetUsedHierarchy(nUsedHierarchy);
1138 pDim->SetFunction(nFunction);
1139 pDim->SetOrientation(nOrientation);
1140 if (bSelectedPage)
1142 pDataPilotTable->SetSelectedPage(pDim->GetName(), sSelectedPage);
1144 pDataPilotTable->AddDimension(pDim);
1145 if (bIsGroupField)
1147 ScDPNumGroupInfo aInfo;
1148 aInfo.mbEnable = true;
1149 aInfo.mbDateValues = bDateValue;
1150 aInfo.mbAutoStart = bAutoStart;
1151 aInfo.mbAutoEnd = bAutoEnd;
1152 aInfo.mfStart = fStart;
1153 aInfo.mfEnd = fEnd;
1154 aInfo.mfStep = fStep;
1155 if (!sGroupSource.isEmpty())
1157 ScDPSaveGroupDimension aGroupDim(sGroupSource, sName);
1158 if (nGroupPart)
1159 aGroupDim.SetDateInfo(aInfo, nGroupPart);
1160 else
1162 ::std::vector<ScXMLDataPilotGroup>::const_iterator aItr(aGroups.begin());
1163 ::std::vector<ScXMLDataPilotGroup>::const_iterator aEndItr(aGroups.end());
1164 while (aItr != aEndItr)
1166 ScDPSaveGroupItem aItem(aItr->aName);
1167 ::std::vector<OUString>::const_iterator aMembersItr(aItr->aMembers.begin());
1168 ::std::vector<OUString>::const_iterator aMembersEndItr(aItr->aMembers.end());
1169 while (aMembersItr != aMembersEndItr)
1171 aItem.AddElement(*aMembersItr);
1172 ++aMembersItr;
1174 ++aItr;
1175 aGroupDim.AddGroupItem(aItem);
1178 pDataPilotTable->AddGroupDim(aGroupDim);
1180 else //NumGroup
1182 ScDPSaveNumGroupDimension aNumGroupDim(sName, aInfo);
1183 if (nGroupPart)
1184 aNumGroupDim.SetDateInfo(aInfo, nGroupPart);
1185 pDataPilotTable->AddGroupDim(aNumGroupDim);
1191 ScXMLDataPilotFieldReferenceContext::ScXMLDataPilotFieldReferenceContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
1192 const OUString& rLName,
1193 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1194 ScXMLDataPilotFieldContext* pDataPilotField) :
1195 SvXMLImportContext( rImport, nPrfx, rLName )
1197 sheet::DataPilotFieldReference aReference;
1199 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1200 for( sal_Int16 i=0; i < nAttrCount; i++ )
1202 OUString sAttrName(xAttrList->getNameByIndex( i ));
1203 OUString aLocalName;
1204 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1205 sAttrName, &aLocalName );
1206 OUString sValue(xAttrList->getValueByIndex( i ));
1208 if ( nPrefix == XML_NAMESPACE_TABLE )
1210 if (IsXMLToken(aLocalName, XML_TYPE))
1212 if (IsXMLToken(sValue, XML_NONE))
1213 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::NONE;
1214 else if (IsXMLToken(sValue, XML_MEMBER_DIFFERENCE))
1215 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE;
1216 else if (IsXMLToken(sValue, XML_MEMBER_PERCENTAGE))
1217 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE;
1218 else if (IsXMLToken(sValue, XML_MEMBER_PERCENTAGE_DIFFERENCE))
1219 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
1220 else if (IsXMLToken(sValue, XML_RUNNING_TOTAL))
1221 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::RUNNING_TOTAL;
1222 else if (IsXMLToken(sValue, XML_ROW_PERCENTAGE))
1223 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE;
1224 else if (IsXMLToken(sValue, XML_COLUMN_PERCENTAGE))
1225 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
1226 else if (IsXMLToken(sValue, XML_TOTAL_PERCENTAGE))
1227 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
1228 else if (IsXMLToken(sValue, XML_INDEX))
1229 aReference.ReferenceType = sheet::DataPilotFieldReferenceType::INDEX;
1231 else if (IsXMLToken(aLocalName, XML_FIELD_NAME))
1233 aReference.ReferenceField = sValue;
1235 else if (IsXMLToken(aLocalName, XML_MEMBER_TYPE))
1237 if (IsXMLToken(sValue, XML_NAMED))
1238 aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NAMED;
1239 else if (IsXMLToken(sValue, XML_PREVIOUS))
1240 aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::PREVIOUS;
1241 else if (IsXMLToken(sValue, XML_NEXT))
1242 aReference.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NEXT;
1244 else if (IsXMLToken(aLocalName, XML_MEMBER_NAME))
1246 aReference.ReferenceItemName = sValue;
1250 pDataPilotField->SetFieldReference(aReference);
1253 ScXMLDataPilotFieldReferenceContext::~ScXMLDataPilotFieldReferenceContext()
1257 ScXMLDataPilotLevelContext::ScXMLDataPilotLevelContext( ScXMLImport& rImport,
1258 sal_uInt16 nPrfx,
1259 const OUString& rLName,
1260 const ::com::sun::star::uno::Reference<
1261 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1262 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1263 SvXMLImportContext( rImport, nPrfx, rLName ),
1264 pDataPilotField(pTempDataPilotField)
1266 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1267 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotLevelAttrTokenMap();
1268 for( sal_Int16 i=0; i < nAttrCount; ++i )
1270 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1271 OUString aLocalName;
1272 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1273 sAttrName, &aLocalName );
1274 const OUString& sValue(xAttrList->getValueByIndex( i ));
1276 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
1278 case XML_TOK_DATA_PILOT_LEVEL_ATTR_SHOW_EMPTY :
1280 pDataPilotField->SetShowEmpty(IsXMLToken(sValue, XML_TRUE));
1282 break;
1283 case XML_TOK_DATA_PILOT_LEVEL_ATTR_REPEAT_ITEM_LABELS :
1285 pDataPilotField->SetRepeatItemLabels(IsXMLToken(sValue, XML_TRUE));
1287 break;
1292 ScXMLDataPilotLevelContext::~ScXMLDataPilotLevelContext()
1296 SvXMLImportContext *ScXMLDataPilotLevelContext::CreateChildContext( sal_uInt16 nPrefix,
1297 const OUString& rLName,
1298 const ::com::sun::star::uno::Reference<
1299 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1301 SvXMLImportContext *pContext = 0;
1303 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotLevelElemTokenMap();
1304 switch( rTokenMap.Get( nPrefix, rLName ) )
1306 case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS :
1307 pContext = new ScXMLDataPilotSubTotalsContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1308 break;
1309 case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS :
1310 pContext = new ScXMLDataPilotMembersContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1311 break;
1312 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_DISPLAY_INFO :
1313 pContext = new ScXMLDataPilotDisplayInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1314 break;
1315 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_SORT_INFO :
1316 pContext = new ScXMLDataPilotSortInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1317 break;
1318 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LAYOUT_INFO :
1319 pContext = new ScXMLDataPilotLayoutInfoContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1320 break;
1323 if( !pContext )
1324 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1326 return pContext;
1329 void ScXMLDataPilotLevelContext::EndElement()
1333 ScXMLDataPilotDisplayInfoContext::ScXMLDataPilotDisplayInfoContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
1334 const OUString& rLName,
1335 const ::com::sun::star::uno::Reference<
1336 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1337 ScXMLDataPilotFieldContext* pDataPilotField) :
1338 SvXMLImportContext( rImport, nPrfx, rLName )
1340 sheet::DataPilotFieldAutoShowInfo aInfo;
1342 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1343 for( sal_Int16 i=0; i < nAttrCount; i++ )
1345 OUString sAttrName(xAttrList->getNameByIndex( i ));
1346 OUString aLocalName;
1347 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1348 sAttrName, &aLocalName );
1349 OUString sValue(xAttrList->getValueByIndex( i ));
1351 if ( nPrefix == XML_NAMESPACE_TABLE )
1353 if (IsXMLToken(aLocalName, XML_ENABLED))
1355 if (IsXMLToken(sValue, XML_TRUE))
1356 aInfo.IsEnabled = sal_True;
1357 else
1358 aInfo.IsEnabled = false;
1360 else if (IsXMLToken(aLocalName, XML_DISPLAY_MEMBER_MODE))
1362 if (IsXMLToken(sValue, XML_FROM_TOP))
1363 aInfo.ShowItemsMode = sheet::DataPilotFieldShowItemsMode::FROM_TOP;
1364 else if (IsXMLToken(sValue, XML_FROM_BOTTOM))
1365 aInfo.ShowItemsMode = sheet::DataPilotFieldShowItemsMode::FROM_BOTTOM;
1367 else if (IsXMLToken(aLocalName, XML_MEMBER_COUNT))
1369 aInfo.ItemCount = sValue.toInt32();
1371 else if (IsXMLToken(aLocalName, XML_DATA_FIELD))
1373 aInfo.DataField = sValue;
1377 pDataPilotField->SetAutoShowInfo(aInfo);
1380 ScXMLDataPilotDisplayInfoContext::~ScXMLDataPilotDisplayInfoContext()
1384 ScXMLDataPilotSortInfoContext::ScXMLDataPilotSortInfoContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
1385 const OUString& rLName,
1386 const ::com::sun::star::uno::Reference<
1387 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1388 ScXMLDataPilotFieldContext* pDataPilotField) :
1389 SvXMLImportContext( rImport, nPrfx, rLName )
1391 sheet::DataPilotFieldSortInfo aInfo;
1393 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1394 for( sal_Int16 i=0; i < nAttrCount; i++ )
1396 OUString sAttrName(xAttrList->getNameByIndex( i ));
1397 OUString aLocalName;
1398 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1399 sAttrName, &aLocalName );
1400 OUString sValue(xAttrList->getValueByIndex( i ));
1402 if ( nPrefix == XML_NAMESPACE_TABLE )
1404 if (IsXMLToken(aLocalName, XML_ORDER))
1406 if (IsXMLToken(sValue, XML_ASCENDING))
1407 aInfo.IsAscending = sal_True;
1408 else if (IsXMLToken(sValue, XML_DESCENDING))
1409 aInfo.IsAscending = false;
1411 else if (IsXMLToken(aLocalName, XML_SORT_MODE))
1413 if (IsXMLToken(sValue, XML_NONE))
1414 aInfo.Mode = sheet::DataPilotFieldSortMode::NONE;
1415 else if (IsXMLToken(sValue, XML_MANUAL))
1416 aInfo.Mode = sheet::DataPilotFieldSortMode::MANUAL;
1417 else if (IsXMLToken(sValue, XML_NAME))
1418 aInfo.Mode = sheet::DataPilotFieldSortMode::NAME;
1419 else if (IsXMLToken(sValue, XML_DATA))
1420 aInfo.Mode = sheet::DataPilotFieldSortMode::DATA;
1422 else if (IsXMLToken(aLocalName, XML_DATA_FIELD))
1423 aInfo.Field = sValue;
1426 pDataPilotField->SetSortInfo(aInfo);
1429 ScXMLDataPilotSortInfoContext::~ScXMLDataPilotSortInfoContext()
1433 ScXMLDataPilotLayoutInfoContext::ScXMLDataPilotLayoutInfoContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
1434 const OUString& rLName,
1435 const ::com::sun::star::uno::Reference<
1436 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1437 ScXMLDataPilotFieldContext* pDataPilotField) :
1438 SvXMLImportContext( rImport, nPrfx, rLName )
1440 sheet::DataPilotFieldLayoutInfo aInfo;
1442 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1443 for( sal_Int16 i=0; i < nAttrCount; i++ )
1445 OUString sAttrName(xAttrList->getNameByIndex( i ));
1446 OUString aLocalName;
1447 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1448 sAttrName, &aLocalName );
1449 OUString sValue(xAttrList->getValueByIndex( i ));
1451 if ( nPrefix == XML_NAMESPACE_TABLE )
1453 if (IsXMLToken(aLocalName, XML_ADD_EMPTY_LINES))
1455 if (IsXMLToken(sValue, XML_TRUE))
1456 aInfo.AddEmptyLines = sal_True;
1457 else
1458 aInfo.AddEmptyLines = false;
1460 else if (IsXMLToken(aLocalName, XML_LAYOUT_MODE))
1462 if (IsXMLToken(sValue, XML_TABULAR_LAYOUT))
1463 aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
1464 else if (IsXMLToken(sValue, XML_OUTLINE_SUBTOTALS_TOP))
1465 aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
1466 else if (IsXMLToken(sValue, XML_OUTLINE_SUBTOTALS_BOTTOM))
1467 aInfo.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
1471 pDataPilotField->SetLayoutInfo(aInfo);}
1473 ScXMLDataPilotLayoutInfoContext::~ScXMLDataPilotLayoutInfoContext()
1477 ScXMLDataPilotSubTotalsContext::ScXMLDataPilotSubTotalsContext( ScXMLImport& rImport,
1478 sal_uInt16 nPrfx,
1479 const OUString& rLName,
1480 const ::com::sun::star::uno::Reference<
1481 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
1482 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1483 SvXMLImportContext( rImport, nPrfx, rLName ),
1484 pDataPilotField(pTempDataPilotField),
1485 nFunctionCount(0),
1486 pFunctions(NULL)
1489 // has no attributes
1492 ScXMLDataPilotSubTotalsContext::~ScXMLDataPilotSubTotalsContext()
1494 delete[] pFunctions;
1497 SvXMLImportContext *ScXMLDataPilotSubTotalsContext::CreateChildContext( sal_uInt16 nPrefix,
1498 const OUString& rLName,
1499 const ::com::sun::star::uno::Reference<
1500 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1502 SvXMLImportContext *pContext = 0;
1504 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotSubTotalsElemTokenMap();
1505 switch( rTokenMap.Get( nPrefix, rLName ) )
1507 case XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL :
1508 pContext = new ScXMLDataPilotSubTotalContext(GetScImport(), nPrefix, rLName, xAttrList, this);
1509 break;
1512 if( !pContext )
1513 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1515 return pContext;
1518 void ScXMLDataPilotSubTotalsContext::EndElement()
1520 pDataPilotField->SetSubTotals(pFunctions, nFunctionCount);
1521 if (!maDisplayName.isEmpty())
1522 pDataPilotField->SetSubTotalName(maDisplayName);
1525 void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction)
1527 if (nFunctionCount)
1529 ++nFunctionCount;
1530 sal_uInt16* pTemp = new sal_uInt16[nFunctionCount];
1531 for (sal_Int16 i = 0; i < nFunctionCount - 1; ++i)
1532 pTemp[i] = pFunctions[i];
1533 pTemp[nFunctionCount - 1] = nFunction;
1534 delete[] pFunctions;
1535 pFunctions = pTemp;
1537 else
1539 nFunctionCount = 1;
1540 pFunctions = new sal_uInt16[nFunctionCount];
1541 pFunctions[0] = nFunction;
1545 void ScXMLDataPilotSubTotalsContext::SetDisplayName(const OUString& rName)
1547 maDisplayName = rName;
1550 ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport& rImport,
1551 sal_uInt16 nPrfx,
1552 const OUString& rLName,
1553 const ::com::sun::star::uno::Reference<
1554 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1555 ScXMLDataPilotSubTotalsContext* pTempDataPilotSubTotals) :
1556 SvXMLImportContext( rImport, nPrfx, rLName ),
1557 pDataPilotSubTotals(pTempDataPilotSubTotals)
1559 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1560 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotSubTotalAttrTokenMap();
1561 for( sal_Int16 i=0; i < nAttrCount; ++i )
1563 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1564 OUString aLocalName;
1565 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1566 sAttrName, &aLocalName );
1567 const OUString& sValue(xAttrList->getValueByIndex( i ));
1569 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
1571 case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION :
1573 pDataPilotSubTotals->AddFunction( sal::static_int_cast<sal_Int16>(
1574 ScXMLConverter::GetFunctionFromString( sValue ) ) );
1576 break;
1577 case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME:
1578 case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME_EXT:
1579 pDataPilotSubTotals->SetDisplayName(sValue);
1580 break;
1585 ScXMLDataPilotSubTotalContext::~ScXMLDataPilotSubTotalContext()
1589 SvXMLImportContext *ScXMLDataPilotSubTotalContext::CreateChildContext( sal_uInt16 nPrefix,
1590 const OUString& rLName,
1591 const ::com::sun::star::uno::Reference<
1592 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1594 SvXMLImportContext *pContext = 0;
1596 if( !pContext )
1597 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1599 return pContext;
1602 void ScXMLDataPilotSubTotalContext::EndElement()
1606 ScXMLDataPilotMembersContext::ScXMLDataPilotMembersContext( ScXMLImport& rImport,
1607 sal_uInt16 nPrfx,
1608 const OUString& rLName,
1609 const ::com::sun::star::uno::Reference<
1610 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
1611 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1612 SvXMLImportContext( rImport, nPrfx, rLName ),
1613 pDataPilotField(pTempDataPilotField)
1615 // has no attributes
1618 ScXMLDataPilotMembersContext::~ScXMLDataPilotMembersContext()
1622 SvXMLImportContext *ScXMLDataPilotMembersContext::CreateChildContext( sal_uInt16 nPrefix,
1623 const OUString& rLName,
1624 const ::com::sun::star::uno::Reference<
1625 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1627 SvXMLImportContext *pContext = 0;
1629 const SvXMLTokenMap& rTokenMap = GetScImport().GetDataPilotMembersElemTokenMap();
1630 switch( rTokenMap.Get( nPrefix, rLName ) )
1632 case XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER :
1633 pContext = new ScXMLDataPilotMemberContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1634 break;
1637 if( !pContext )
1638 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1640 return pContext;
1643 void ScXMLDataPilotMembersContext::EndElement()
1647 ScXMLDataPilotMemberContext::ScXMLDataPilotMemberContext( ScXMLImport& rImport,
1648 sal_uInt16 nPrfx,
1649 const OUString& rLName,
1650 const ::com::sun::star::uno::Reference<
1651 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1652 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1653 SvXMLImportContext( rImport, nPrfx, rLName ),
1654 pDataPilotField(pTempDataPilotField),
1655 bDisplay( true ),
1656 bDisplayDetails( true ),
1657 bHasName( false )
1659 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1660 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataPilotMemberAttrTokenMap();
1661 for( sal_Int16 i=0; i < nAttrCount; ++i )
1663 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1664 OUString aLocalName;
1665 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1666 sAttrName, &aLocalName );
1667 const OUString& sValue(xAttrList->getValueByIndex( i ));
1669 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
1671 case XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME :
1673 sName = sValue;
1674 bHasName = true;
1676 break;
1677 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME:
1678 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME_EXT:
1680 maDisplayName = sValue;
1682 break;
1683 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY :
1685 bDisplay = IsXMLToken(sValue, XML_TRUE);
1687 break;
1688 case XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS :
1690 bDisplayDetails = IsXMLToken(sValue, XML_TRUE);
1692 break;
1697 ScXMLDataPilotMemberContext::~ScXMLDataPilotMemberContext()
1701 SvXMLImportContext *ScXMLDataPilotMemberContext::CreateChildContext( sal_uInt16 nPrefix,
1702 const OUString& rLName,
1703 const ::com::sun::star::uno::Reference<
1704 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1706 SvXMLImportContext *pContext = 0;
1708 if( !pContext )
1709 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1711 return pContext;
1714 void ScXMLDataPilotMemberContext::EndElement()
1716 if (bHasName) // #i53407# don't check sName, empty name is allowed
1718 ScDPSaveMember* pMember = new ScDPSaveMember(sName);
1719 if (!maDisplayName.isEmpty())
1720 pMember->SetLayoutName(maDisplayName);
1721 pMember->SetIsVisible(bDisplay);
1722 pMember->SetShowDetails(bDisplayDetails);
1723 pDataPilotField->AddMember(pMember);
1727 ScXMLDataPilotGroupsContext::ScXMLDataPilotGroupsContext( ScXMLImport& rImport,
1728 sal_uInt16 nPrfx,
1729 const 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 OUString sGroupSource;
1737 double fStart(0.0);
1738 double fEnd(0.0);
1739 double fStep(0.0);
1740 sal_Int32 nGroupPart(0);
1741 bool bDateValue(false);
1742 bool bAutoStart(true);
1743 bool bAutoEnd(true);
1745 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1746 for( sal_Int16 i=0; i < nAttrCount; i++ )
1748 OUString sAttrName = xAttrList->getNameByIndex( i );
1749 OUString aLocalName;
1750 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1751 sAttrName, &aLocalName );
1752 OUString sValue = xAttrList->getValueByIndex( i );
1754 (void)nPrefix; //! compare below!
1756 if (IsXMLToken(aLocalName, XML_SOURCE_FIELD_NAME))
1757 sGroupSource = sValue;
1758 else if (IsXMLToken(aLocalName, XML_DATE_START))
1760 bDateValue = true;
1761 if (IsXMLToken(sValue, XML_AUTO))
1762 bAutoStart = true;
1763 else
1765 GetScImport().GetMM100UnitConverter().convertDateTime(fStart, sValue);
1766 bAutoStart = false;
1769 else if (IsXMLToken(aLocalName, XML_DATE_END))
1771 bDateValue = true;
1772 if (IsXMLToken(sValue, XML_AUTO))
1773 bAutoEnd = true;
1774 else
1776 GetScImport().GetMM100UnitConverter().convertDateTime(fEnd, sValue);
1777 bAutoEnd = false;
1780 else if (IsXMLToken(aLocalName, XML_START))
1782 if (IsXMLToken(sValue, XML_AUTO))
1783 bAutoStart = true;
1784 else
1786 ::sax::Converter::convertDouble(fStart, sValue);
1787 bAutoStart = false;
1790 else if (IsXMLToken(aLocalName, XML_END))
1792 if (IsXMLToken(sValue, XML_AUTO))
1793 bAutoEnd = true;
1794 else
1796 ::sax::Converter::convertDouble(fEnd, sValue);
1797 bAutoEnd = false;
1800 else if (IsXMLToken(aLocalName, XML_STEP))
1802 ::sax::Converter::convertDouble(fStep, sValue);
1804 else if (IsXMLToken(aLocalName, XML_GROUPED_BY))
1806 if (IsXMLToken(sValue, XML_SECONDS))
1807 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS;
1808 else if (IsXMLToken(sValue, XML_MINUTES))
1809 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES;
1810 else if (IsXMLToken(sValue, XML_HOURS))
1811 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::HOURS;
1812 else if (IsXMLToken(sValue, XML_DAYS))
1813 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::DAYS;
1814 else if (IsXMLToken(sValue, XML_MONTHS))
1815 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS;
1816 else if (IsXMLToken(sValue, XML_QUARTERS))
1817 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS;
1818 else if (IsXMLToken(sValue, XML_YEARS))
1819 nGroupPart = com::sun::star::sheet::DataPilotFieldGroupBy::YEARS;
1822 pDataPilotField->SetGrouping(sGroupSource, fStart, fEnd, fStep, nGroupPart, bDateValue, bAutoStart, bAutoEnd);
1825 ScXMLDataPilotGroupsContext::~ScXMLDataPilotGroupsContext()
1829 SvXMLImportContext *ScXMLDataPilotGroupsContext::CreateChildContext( sal_uInt16 nPrefix,
1830 const OUString& rLName,
1831 const ::com::sun::star::uno::Reference<
1832 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1834 SvXMLImportContext *pContext = 0;
1836 if (nPrefix == XML_NAMESPACE_TABLE)
1838 if (IsXMLToken(rLName, XML_DATA_PILOT_GROUP))
1839 pContext = new ScXMLDataPilotGroupContext(GetScImport(), nPrefix, rLName, xAttrList, pDataPilotField);
1842 if( !pContext )
1843 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1845 return pContext;
1848 void ScXMLDataPilotGroupsContext::EndElement()
1852 ScXMLDataPilotGroupContext::ScXMLDataPilotGroupContext( ScXMLImport& rImport,
1853 sal_uInt16 nPrfx,
1854 const OUString& rLName,
1855 const ::com::sun::star::uno::Reference<
1856 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1857 ScXMLDataPilotFieldContext* pTempDataPilotField) :
1858 SvXMLImportContext( rImport, nPrfx, rLName ),
1859 pDataPilotField(pTempDataPilotField)
1861 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1862 for( sal_Int16 i=0; i < nAttrCount; i++ )
1864 OUString sAttrName = xAttrList->getNameByIndex( i );
1865 OUString aLocalName;
1866 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1867 sAttrName, &aLocalName );
1868 OUString sValue = xAttrList->getValueByIndex( i );
1870 if (nPrefix == XML_NAMESPACE_TABLE)
1872 if (IsXMLToken(aLocalName, XML_NAME))
1873 sName = sValue;
1878 ScXMLDataPilotGroupContext::~ScXMLDataPilotGroupContext()
1882 SvXMLImportContext *ScXMLDataPilotGroupContext::CreateChildContext( sal_uInt16 nPrefix,
1883 const OUString& rLName,
1884 const ::com::sun::star::uno::Reference<
1885 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1887 SvXMLImportContext *pContext = 0;
1889 if (nPrefix == XML_NAMESPACE_TABLE)
1891 if (IsXMLToken(rLName, XML_DATA_PILOT_MEMBER) || IsXMLToken(rLName, XML_DATA_PILOT_GROUP_MEMBER))
1892 pContext = new ScXMLDataPilotGroupMemberContext(GetScImport(), nPrefix, rLName, xAttrList, this);
1895 if( !pContext )
1896 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1898 return pContext;
1901 void ScXMLDataPilotGroupContext::EndElement()
1903 pDataPilotField->AddGroup(aMembers, sName);
1906 ScXMLDataPilotGroupMemberContext::ScXMLDataPilotGroupMemberContext( ScXMLImport& rImport,
1907 sal_uInt16 nPrfx,
1908 const OUString& rLName,
1909 const ::com::sun::star::uno::Reference<
1910 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
1911 ScXMLDataPilotGroupContext* pTempDataPilotGroup) :
1912 SvXMLImportContext( rImport, nPrfx, rLName ),
1913 pDataPilotGroup(pTempDataPilotGroup)
1915 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1916 for( sal_Int16 i=0; i < nAttrCount; i++ )
1918 OUString sAttrName = xAttrList->getNameByIndex( i );
1919 OUString aLocalName;
1920 sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
1921 sAttrName, &aLocalName );
1922 OUString sValue = xAttrList->getValueByIndex( i );
1924 if (nPrefix == XML_NAMESPACE_TABLE)
1926 if (IsXMLToken(aLocalName, XML_NAME))
1927 sName = sValue;
1932 ScXMLDataPilotGroupMemberContext::~ScXMLDataPilotGroupMemberContext()
1936 SvXMLImportContext *ScXMLDataPilotGroupMemberContext::CreateChildContext( sal_uInt16 nPrefix,
1937 const OUString& rLName,
1938 const ::com::sun::star::uno::Reference<
1939 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1941 SvXMLImportContext *pContext = 0;
1943 if( !pContext )
1944 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1946 return pContext;
1949 void ScXMLDataPilotGroupMemberContext::EndElement()
1951 if (!sName.isEmpty())
1952 pDataPilotGroup->AddMember(sName);
1955 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */