1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
26 #include "dpshttab.hxx"
27 #include "dpsdbtab.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
;
58 ScXMLDataPilotTablesContext::ScXMLDataPilotTablesContext( ScXMLImport
& rImport
,
60 const OUString
& rLName
,
61 const ::com::sun::star::uno::Reference
<
62 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ ) :
63 SvXMLImportContext( rImport
, nPrfx
, rLName
)
66 rImport
.LockSolarMutex();
69 ScXMLDataPilotTablesContext::~ScXMLDataPilotTablesContext()
71 GetScImport().UnlockSolarMutex();
74 SvXMLImportContext
*ScXMLDataPilotTablesContext::CreateChildContext( sal_uInt16 nPrefix
,
75 const OUString
& rLName
,
76 const ::com::sun::star::uno::Reference
<
77 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
79 SvXMLImportContext
*pContext
= 0;
81 const SvXMLTokenMap
& rTokenMap
= GetScImport().GetDataPilotTablesElemTokenMap();
82 switch( rTokenMap
.Get( nPrefix
, rLName
) )
84 case XML_TOK_DATA_PILOT_TABLE
:
86 pContext
= new ScXMLDataPilotTableContext( GetScImport(), nPrefix
,
93 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
98 void ScXMLDataPilotTablesContext::EndElement()
102 ScXMLDataPilotTableContext::GrandTotalItem::GrandTotalItem() :
105 ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport
& rImport
,
107 const OUString
& rLName
,
108 const ::com::sun::star::uno::Reference
<
109 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) :
110 SvXMLImportContext( rImport
, nPrfx
, rLName
),
111 pDoc(GetScImport().GetDocument()),
113 pDPDimSaveData(NULL
),
114 sDataPilotTableName(),
121 mnDataLayoutType(sheet::DataPilotFieldOrientation_HIDDEN
),
123 bIgnoreEmptyRows(false),
124 bIdentifyCategories(false),
125 bTargetRangeAddress(false),
126 bSourceCellRange(false),
129 bHeaderGridLayout(false)
131 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
132 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDataPilotTableAttrTokenMap();
133 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
135 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
137 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
138 sAttrName
, &aLocalName
);
139 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
141 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
143 case XML_TOK_DATA_PILOT_TABLE_ATTR_NAME
:
145 sDataPilotTableName
= sValue
;
148 case XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA
:
150 sApplicationData
= sValue
;
153 case XML_TOK_DATA_PILOT_TABLE_ATTR_GRAND_TOTAL
:
155 if (IsXMLToken(sValue
, XML_BOTH
))
157 maRowGrandTotal
.mbVisible
= true;
158 maColGrandTotal
.mbVisible
= true;
160 else if (IsXMLToken(sValue
, XML_ROW
))
162 maRowGrandTotal
.mbVisible
= true;
163 maColGrandTotal
.mbVisible
= false;
165 else if (IsXMLToken(sValue
, XML_COLUMN
))
167 maRowGrandTotal
.mbVisible
= false;
168 maColGrandTotal
.mbVisible
= true;
172 maRowGrandTotal
.mbVisible
= false;
173 maColGrandTotal
.mbVisible
= false;
177 case XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS
:
179 bIgnoreEmptyRows
= IsXMLToken(sValue
, XML_TRUE
);
182 case XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES
:
184 bIdentifyCategories
= IsXMLToken(sValue
, XML_TRUE
);
187 case XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS
:
189 sal_Int32
nOffset(0);
190 bTargetRangeAddress
= ScRangeStringConverter::GetRangeFromString( aTargetRangeAddress
, sValue
, pDoc
, ::formula::FormulaGrammar::CONV_OOO
, nOffset
);
193 case XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS
:
198 case XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON
:
200 bShowFilter
= IsXMLToken(sValue
, XML_TRUE
);
203 case XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN
:
205 bDrillDown
= IsXMLToken(sValue
, XML_TRUE
);
208 case XML_TOK_DATA_PILOT_TABLE_ATTR_HEADER_GRID_LAYOUT
:
210 bHeaderGridLayout
= IsXMLToken(sValue
, XML_TRUE
);
216 pDPObject
= new ScDPObject(pDoc
);
217 pDPSave
.reset(new ScDPSaveData());
220 ScXMLDataPilotTableContext::~ScXMLDataPilotTableContext()
222 delete pDPDimSaveData
;
225 SvXMLImportContext
*ScXMLDataPilotTableContext::CreateChildContext( sal_uInt16 nPrefix
,
226 const OUString
& rLName
,
227 const ::com::sun::star::uno::Reference
<
228 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
230 SvXMLImportContext
*pContext
= 0;
232 const SvXMLTokenMap
& rTokenMap
= GetScImport().GetDataPilotTableElemTokenMap();
233 switch( rTokenMap
.Get( nPrefix
, rLName
) )
235 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SQL
:
237 pContext
= new ScXMLDPSourceSQLContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
241 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE
:
243 pContext
= new ScXMLDPSourceTableContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
247 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY
:
249 pContext
= new ScXMLDPSourceQueryContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
253 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE
:
255 pContext
= new ScXMLSourceServiceContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
256 nSourceType
= SERVICE
;
259 case XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL
:
260 case XML_TOK_DATA_PILOT_TABLE_ELEM_GRAND_TOTAL_EXT
:
262 pContext
= new ScXMLDataPilotGrandTotalContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
265 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE
:
267 pContext
= new ScXMLSourceCellRangeContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
268 nSourceType
= CELLRANGE
;
271 case XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD
:
272 pContext
= new ScXMLDataPilotFieldContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
277 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
284 const ScDPSaveDimension
* getDimension(
285 const std::vector
<const ScDPSaveDimension
*>& rRowDims
,
286 const std::vector
<const ScDPSaveDimension
*>& rColDims
,
287 const std::vector
<const ScDPSaveDimension
*>& rPageDims
,
288 ScDPOutputGeometry::FieldType eType
, size_t nPos
)
292 case ScDPOutputGeometry::Column
:
294 if (rColDims
.size() <= nPos
)
297 return rColDims
[nPos
];
299 case ScDPOutputGeometry::Row
:
301 if (rRowDims
.size() <= nPos
)
304 return rRowDims
[nPos
];
306 case ScDPOutputGeometry::Page
:
308 if (rPageDims
.size() <= nPos
)
311 return rPageDims
[nPos
];
313 case ScDPOutputGeometry::Data
:
315 case ScDPOutputGeometry::None
:
323 ScDPOutputGeometry::FieldType
toFieldType(sal_uInt16 nOrient
)
327 case sheet::DataPilotFieldOrientation_COLUMN
:
328 return ScDPOutputGeometry::Column
;
329 case sheet::DataPilotFieldOrientation_DATA
:
330 return ScDPOutputGeometry::Data
;
331 case sheet::DataPilotFieldOrientation_PAGE
:
332 return ScDPOutputGeometry::Page
;
333 case sheet::DataPilotFieldOrientation_ROW
:
334 return ScDPOutputGeometry::Row
;
335 case sheet::DataPilotFieldOrientation_HIDDEN
:
340 return ScDPOutputGeometry::None
;
345 void ScXMLDataPilotTableContext::SetButtons()
347 ScDPOutputGeometry
aGeometry(aTargetRangeAddress
, bShowFilter
);
348 aGeometry
.setColumnFieldCount(mnColFieldCount
);
349 aGeometry
.setRowFieldCount(mnRowFieldCount
);
350 aGeometry
.setPageFieldCount(mnPageFieldCount
);
351 aGeometry
.setDataFieldCount(mnDataFieldCount
);
352 aGeometry
.setDataLayoutType(toFieldType(mnDataLayoutType
));
354 std::vector
<const ScDPSaveDimension
*> aRowDims
, aColDims
, aPageDims
;
355 pDPSave
->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW
, aRowDims
);
356 pDPSave
->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN
, aColDims
);
357 pDPSave
->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_PAGE
, aPageDims
);
360 sal_Int32 nOffset
= 0;
361 while( nOffset
>= 0 )
363 ScRangeStringConverter::GetTokenByOffset( sAddress
, sButtons
, nOffset
);
366 ScAddress aScAddress
;
367 sal_Int32
nAddrOffset(0);
368 if (pDoc
&& ScRangeStringConverter::GetAddressFromString( aScAddress
, sAddress
, pDoc
, ::formula::FormulaGrammar::CONV_OOO
, nAddrOffset
))
370 std::pair
<ScDPOutputGeometry::FieldType
, size_t> aBtnType
= aGeometry
.getFieldButtonType(aScAddress
);
371 const ScDPSaveDimension
* pDim
= getDimension(
372 aRowDims
, aColDims
, aPageDims
, aBtnType
.first
, aBtnType
.second
);
374 bool bDimension
= pDim
!= NULL
;
375 bool bDataLayout
= pDim
&& pDim
->IsDataLayout();
376 bool bHasHidden
= pDim
&& pDim
->HasInvisibleMember();
377 bool bPageDim
= pDim
&& pDim
->GetOrientation() == sheet::DataPilotFieldOrientation_PAGE
;
381 // Page dimension needs 2 buttons.
383 pDoc
->ApplyFlagsTab(aScAddress
.Col(), aScAddress
.Row(), aScAddress
.Col(), aScAddress
.Row(), aScAddress
.Tab(), SC_MF_BUTTON
);
385 sal_Int16 nMFlag
= SC_MF_BUTTON_POPUP
;
387 nMFlag
|= SC_MF_HIDDEN_MEMBER
;
388 pDoc
->ApplyFlagsTab(aScAddress
.Col()+1, aScAddress
.Row(), aScAddress
.Col()+1, aScAddress
.Row(), aScAddress
.Tab(), nMFlag
);
392 sal_Int16 nMFlag
= SC_MF_BUTTON
;
395 // Data layout dimension only has a plain button with no popup.
399 // Normal dimension has a popup arrow button.
401 nMFlag
|= SC_MF_HIDDEN_MEMBER
;
403 nMFlag
|= SC_MF_BUTTON_POPUP
;
406 pDoc
->ApplyFlagsTab(aScAddress
.Col(), aScAddress
.Row(), aScAddress
.Col(), aScAddress
.Row(), aScAddress
.Tab(), nMFlag
);
413 pDPObject
->RefreshAfterLoad();
416 void ScXMLDataPilotTableContext::SetSelectedPage( const OUString
& rDimName
, const OUString
& rSelected
)
418 maSelectedPages
.insert(SelectedPagesType::value_type(rDimName
, rSelected
));
421 void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension
* pDim
)
425 if (pDim
->IsDataLayout())
426 mnDataLayoutType
= pDim
->GetOrientation();
428 // if a dimension with that name has already been inserted,
429 // mark the new one as duplicate
430 if ( !pDim
->IsDataLayout() &&
431 pDPSave
->GetExistingDimensionByName(pDim
->GetName()) )
432 pDim
->SetDupFlag(true);
434 switch (pDim
->GetOrientation())
436 case sheet::DataPilotFieldOrientation_ROW
:
439 case sheet::DataPilotFieldOrientation_COLUMN
:
442 case sheet::DataPilotFieldOrientation_PAGE
:
445 case sheet::DataPilotFieldOrientation_DATA
:
448 case sheet::DataPilotFieldOrientation_HIDDEN
:
454 pDPSave
->AddDimension(pDim
);
458 void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveNumGroupDimension
& aNumGroupDim
)
461 pDPDimSaveData
= new ScDPDimensionSaveData();
462 pDPDimSaveData
->AddNumGroupDimension(aNumGroupDim
);
465 void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveGroupDimension
& aGroupDim
)
468 pDPDimSaveData
= new ScDPDimensionSaveData();
469 pDPDimSaveData
->AddGroupDimension(aGroupDim
);
472 void ScXMLDataPilotTableContext::EndElement()
474 if (!bTargetRangeAddress
)
477 pDPObject
->SetName(sDataPilotTableName
);
478 pDPObject
->SetTag(sApplicationData
);
479 pDPObject
->SetOutRange(aTargetRangeAddress
);
480 pDPObject
->SetHeaderLayout(bHeaderGridLayout
);
482 sc::PivotTableSources
& rPivotSources
= GetScImport().GetPivotTableSources();
488 ScImportSourceDesc
aImportDesc(pDoc
);
489 aImportDesc
.aDBName
= sDatabaseName
;
490 aImportDesc
.aObject
= sSourceObject
;
491 aImportDesc
.nType
= sheet::DataImportMode_SQL
;
492 aImportDesc
.bNative
= bIsNative
;
493 rPivotSources
.appendDBSource(pDPObject
, aImportDesc
);
498 ScImportSourceDesc
aImportDesc(pDoc
);
499 aImportDesc
.aDBName
= sDatabaseName
;
500 aImportDesc
.aObject
= sSourceObject
;
501 aImportDesc
.nType
= sheet::DataImportMode_TABLE
;
502 rPivotSources
.appendDBSource(pDPObject
, aImportDesc
);
507 ScImportSourceDesc
aImportDesc(pDoc
);
508 aImportDesc
.aDBName
= sDatabaseName
;
509 aImportDesc
.aObject
= sSourceObject
;
510 aImportDesc
.nType
= sheet::DataImportMode_QUERY
;
511 rPivotSources
.appendDBSource(pDPObject
, aImportDesc
);
516 ScDPServiceDesc
aServiceDesc(sServiceName
, sServiceSourceName
, sServiceSourceObject
,
517 sServiceUsername
, sServicePassword
);
518 rPivotSources
.appendServiceSource(pDPObject
, aServiceDesc
);
523 if (bSourceCellRange
)
525 ScSheetSourceDesc
aSheetDesc(pDoc
);
526 if (!sSourceRangeName
.isEmpty())
527 // Range name takes precedence.
528 aSheetDesc
.SetRangeName(sSourceRangeName
);
530 aSheetDesc
.SetSourceRange(aSourceCellRangeAddress
);
531 aSheetDesc
.SetQueryParam(aSourceQueryParam
);
532 rPivotSources
.appendSheetSource(pDPObject
, aSheetDesc
);
538 rPivotSources
.appendSelectedPages(pDPObject
, maSelectedPages
);
540 pDPSave
->SetRowGrand(maRowGrandTotal
.mbVisible
);
541 pDPSave
->SetColumnGrand(maColGrandTotal
.mbVisible
);
542 if (!maRowGrandTotal
.maDisplayName
.isEmpty())
543 // TODO: Right now, we only support one grand total name for both
544 // column and row totals. Take the value from the row total for
546 pDPSave
->SetGrandTotalName(maRowGrandTotal
.maDisplayName
);
548 pDPSave
->SetIgnoreEmptyRows(bIgnoreEmptyRows
);
549 pDPSave
->SetRepeatIfEmpty(bIdentifyCategories
);
550 pDPSave
->SetFilterButton(bShowFilter
);
551 pDPSave
->SetDrillDown(bDrillDown
);
553 pDPSave
->SetDimensionData(pDPDimSaveData
);
554 pDPObject
->SetSaveData(*pDPSave
);
556 ScDPCollection
* pDPCollection
= pDoc
->GetDPCollection();
558 // #i94570# Names have to be unique, or the tables can't be accessed by API.
559 if ( pDPCollection
->GetByName(pDPObject
->GetName()) )
560 pDPObject
->SetName( OUString() ); // ignore the invalid name, create a new name in AfterXMLLoading
562 pDPCollection
->InsertNewTable(pDPObject
);
566 void ScXMLDataPilotTableContext::SetGrandTotal(
567 XMLTokenEnum eOrientation
, bool bVisible
, const OUString
& rDisplayName
)
569 switch (eOrientation
)
572 maRowGrandTotal
.mbVisible
= bVisible
;
573 maRowGrandTotal
.maDisplayName
= rDisplayName
;
574 maColGrandTotal
.mbVisible
= bVisible
;
575 maColGrandTotal
.maDisplayName
= rDisplayName
;
578 maRowGrandTotal
.mbVisible
= bVisible
;
579 maRowGrandTotal
.maDisplayName
= rDisplayName
;
582 maColGrandTotal
.mbVisible
= bVisible
;
583 maColGrandTotal
.maDisplayName
= rDisplayName
;
590 ScXMLDPSourceSQLContext::ScXMLDPSourceSQLContext( ScXMLImport
& rImport
,
592 const OUString
& rLName
,
593 const ::com::sun::star::uno::Reference
<
594 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
595 ScXMLDataPilotTableContext
* pTempDataPilotTable
) :
596 SvXMLImportContext( rImport
, nPrfx
, rLName
),
597 pDataPilotTable(pTempDataPilotTable
)
599 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
600 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDatabaseRangeSourceSQLAttrTokenMap();
601 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
603 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
605 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
606 sAttrName
, &aLocalName
);
607 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
609 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
611 case XML_TOK_SOURCE_SQL_ATTR_DATABASE_NAME
:
613 pDataPilotTable
->SetDatabaseName(sValue
);
616 case XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT
:
618 pDataPilotTable
->SetSourceObject(sValue
);
621 case XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT
:
623 pDataPilotTable
->SetNative(!IsXMLToken(sValue
, XML_TRUE
));
630 ScXMLDPSourceSQLContext::~ScXMLDPSourceSQLContext()
634 SvXMLImportContext
*ScXMLDPSourceSQLContext::CreateChildContext( sal_uInt16 nPrefix
,
635 const OUString
& rLName
,
636 const ::com::sun::star::uno::Reference
<
637 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
639 SvXMLImportContext
*pContext
= 0;
642 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
647 void ScXMLDPSourceSQLContext::EndElement()
651 ScXMLDPSourceTableContext::ScXMLDPSourceTableContext( ScXMLImport
& rImport
,
653 const OUString
& rLName
,
654 const ::com::sun::star::uno::Reference
<
655 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
656 ScXMLDataPilotTableContext
* pTempDataPilotTable
) :
657 SvXMLImportContext( rImport
, nPrfx
, rLName
),
658 pDataPilotTable(pTempDataPilotTable
)
660 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
661 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDatabaseRangeSourceTableAttrTokenMap();
662 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
664 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
666 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
667 sAttrName
, &aLocalName
);
668 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
670 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
672 case XML_TOK_SOURCE_TABLE_ATTR_DATABASE_NAME
:
674 pDataPilotTable
->SetDatabaseName(sValue
);
677 case XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME
:
679 pDataPilotTable
->SetSourceObject(sValue
);
686 ScXMLDPSourceTableContext::~ScXMLDPSourceTableContext()
690 SvXMLImportContext
*ScXMLDPSourceTableContext::CreateChildContext( sal_uInt16 nPrefix
,
691 const OUString
& rLName
,
692 const ::com::sun::star::uno::Reference
<
693 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
695 SvXMLImportContext
*pContext
= 0;
698 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
703 void ScXMLDPSourceTableContext::EndElement()
707 ScXMLDPSourceQueryContext::ScXMLDPSourceQueryContext( ScXMLImport
& rImport
,
709 const OUString
& rLName
,
710 const ::com::sun::star::uno::Reference
<
711 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
712 ScXMLDataPilotTableContext
* pTempDataPilotTable
) :
713 SvXMLImportContext( rImport
, nPrfx
, rLName
),
714 pDataPilotTable(pTempDataPilotTable
)
716 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
717 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDatabaseRangeSourceQueryAttrTokenMap();
718 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
720 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
722 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
723 sAttrName
, &aLocalName
);
724 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
726 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
728 case XML_TOK_SOURCE_QUERY_ATTR_DATABASE_NAME
:
730 pDataPilotTable
->SetDatabaseName(sValue
);
733 case XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME
:
735 pDataPilotTable
->SetSourceObject(sValue
);
742 ScXMLDPSourceQueryContext::~ScXMLDPSourceQueryContext()
746 SvXMLImportContext
*ScXMLDPSourceQueryContext::CreateChildContext( sal_uInt16 nPrefix
,
747 const OUString
& rLName
,
748 const ::com::sun::star::uno::Reference
<
749 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
751 SvXMLImportContext
*pContext
= 0;
754 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
759 void ScXMLDPSourceQueryContext::EndElement()
763 ScXMLSourceServiceContext::ScXMLSourceServiceContext( ScXMLImport
& rImport
,
765 const OUString
& rLName
,
766 const ::com::sun::star::uno::Reference
<
767 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
768 ScXMLDataPilotTableContext
* pTempDataPilotTable
) :
769 SvXMLImportContext( rImport
, nPrfx
, rLName
),
770 pDataPilotTable(pTempDataPilotTable
)
772 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
773 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDataPilotTableSourceServiceAttrTokenMap();
774 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
776 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
778 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
779 sAttrName
, &aLocalName
);
780 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
782 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
784 case XML_TOK_SOURCE_SERVICE_ATTR_NAME
:
786 pDataPilotTable
->SetServiceName(sValue
);
789 case XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME
:
791 pDataPilotTable
->SetServiceSourceName(sValue
);
794 case XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME
:
796 pDataPilotTable
->SetServiceSourceObject(sValue
);
799 case XML_TOK_SOURCE_SERVICE_ATTR_USER_NAME
:
801 pDataPilotTable
->SetServiceUsername(sValue
);
804 case XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD
:
806 pDataPilotTable
->SetServicePassword(sValue
);
813 ScXMLSourceServiceContext::~ScXMLSourceServiceContext()
817 SvXMLImportContext
*ScXMLSourceServiceContext::CreateChildContext( sal_uInt16 nPrefix
,
818 const OUString
& rLName
,
819 const ::com::sun::star::uno::Reference
<
820 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
822 SvXMLImportContext
*pContext
= 0;
825 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
830 void ScXMLSourceServiceContext::EndElement()
834 ScXMLImport
& ScXMLDataPilotGrandTotalContext::GetScImport()
836 return static_cast<ScXMLImport
&>(GetImport());
839 ScXMLDataPilotGrandTotalContext::ScXMLDataPilotGrandTotalContext(
840 ScXMLImport
& rImport
, sal_uInt16 nPrefix
, const OUString
& rLName
, const Reference
<XAttributeList
>& xAttrList
,
841 ScXMLDataPilotTableContext
* pTableContext
) :
842 SvXMLImportContext( rImport
, nPrefix
, rLName
),
843 mpTableContext(pTableContext
),
847 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
848 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDataPilotGrandTotalAttrTokenMap();
849 for (sal_Int16 i
= 0; i
< nAttrCount
; ++i
)
851 const OUString
& rAttrName
= xAttrList
->getNameByIndex(i
);
852 const OUString
& rAttrValue
= xAttrList
->getValueByIndex(i
);
855 sal_uInt16 nLocalPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(rAttrName
, &aLocalName
);
856 switch (rAttrTokenMap
.Get(nLocalPrefix
, aLocalName
))
858 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY
:
859 mbVisible
= IsXMLToken(rAttrValue
, XML_TRUE
);
861 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_ORIENTATION
:
862 if (IsXMLToken(rAttrValue
, XML_BOTH
))
863 meOrientation
= BOTH
;
864 else if (IsXMLToken(rAttrValue
, XML_ROW
))
866 else if (IsXMLToken(rAttrValue
, XML_COLUMN
))
867 meOrientation
= COLUMN
;
869 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME
:
870 case XML_TOK_DATA_PILOT_GRAND_TOTAL_ATTR_DISPLAY_NAME_EXT
:
871 maDisplayName
= rAttrValue
;
879 ScXMLDataPilotGrandTotalContext::~ScXMLDataPilotGrandTotalContext()
883 SvXMLImportContext
* ScXMLDataPilotGrandTotalContext::CreateChildContext(
884 sal_uInt16 nPrefix
, const OUString
& rLocalName
, const Reference
<XAttributeList
>& /*xAttrList*/ )
886 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
889 void ScXMLDataPilotGrandTotalContext::EndElement()
891 XMLTokenEnum eOrient
= XML_NONE
;
892 switch (meOrientation
)
901 eOrient
= XML_COLUMN
;
906 mpTableContext
->SetGrandTotal(eOrient
, mbVisible
, maDisplayName
);
909 ScXMLSourceCellRangeContext::ScXMLSourceCellRangeContext( ScXMLImport
& rImport
,
911 const OUString
& rLName
,
912 const ::com::sun::star::uno::Reference
<
913 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
914 ScXMLDataPilotTableContext
* pTempDataPilotTable
) :
915 SvXMLImportContext( rImport
, nPrfx
, rLName
),
916 pDataPilotTable(pTempDataPilotTable
)
918 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
919 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDataPilotTableSourceCellRangeAttrTokenMap();
920 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
922 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
924 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
925 sAttrName
, &aLocalName
);
926 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
928 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
930 case XML_TOK_SOURCE_CELL_RANGE_ATTR_CELL_RANGE_ADDRESS
:
932 ScRange aSourceRangeAddress
;
933 sal_Int32
nOffset(0);
934 if (ScRangeStringConverter::GetRangeFromString( aSourceRangeAddress
, sValue
, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO
, nOffset
))
935 pDataPilotTable
->SetSourceCellRangeAddress(aSourceRangeAddress
);
938 case XML_TOK_SOURCE_CELL_RANGE_ATTR_NAME
:
939 pDataPilotTable
->SetSourceRangeName(sValue
);
945 ScXMLSourceCellRangeContext::~ScXMLSourceCellRangeContext()
949 SvXMLImportContext
*ScXMLSourceCellRangeContext::CreateChildContext( sal_uInt16 nPrefix
,
950 const OUString
& rLName
,
951 const ::com::sun::star::uno::Reference
<
952 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
954 SvXMLImportContext
*pContext
= 0;
956 const SvXMLTokenMap
& rTokenMap
= GetScImport().GetDataPilotTableSourceCellRangeElemTokenMap();
957 switch( rTokenMap
.Get( nPrefix
, rLName
) )
959 case XML_TOK_SOURCE_CELL_RANGE_ELEM_FILTER
:
960 pContext
= new ScXMLDPFilterContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotTable
);
965 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
970 void ScXMLSourceCellRangeContext::EndElement()
974 ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport
& rImport
,
976 const OUString
& rLName
,
977 const ::com::sun::star::uno::Reference
<
978 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
979 ScXMLDataPilotTableContext
* pTempDataPilotTable
) :
980 SvXMLImportContext( rImport
, nPrfx
, rLName
),
981 pDataPilotTable(pTempDataPilotTable
),
990 bSelectedPage(false),
991 bIsGroupField(false),
995 mbHasHiddenMember(false)
997 bool bHasName
= false;
998 bool bDataLayout
= false;
999 OUString aDisplayName
;
1000 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1001 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDataPilotFieldAttrTokenMap();
1002 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1004 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1005 OUString aLocalName
;
1006 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1007 sAttrName
, &aLocalName
);
1008 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
1010 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
1012 case XML_TOK_DATA_PILOT_FIELD_ATTR_SOURCE_FIELD_NAME
:
1018 case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME
:
1019 case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME_EXT
:
1021 aDisplayName
= sValue
;
1024 case XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD
:
1026 bDataLayout
= IsXMLToken(sValue
, XML_TRUE
);
1029 case XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION
:
1031 nFunction
= (sal_Int16
) ScXMLConverter::GetFunctionFromString( sValue
);
1034 case XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION
:
1036 nOrientation
= (sal_Int16
) ScXMLConverter::GetOrientationFromString( sValue
);
1039 case XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE
:
1041 sSelectedPage
= sValue
;
1042 bSelectedPage
= true;
1045 case XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY
:
1047 nUsedHierarchy
= sValue
.toInt32();
1054 pDim
= new ScDPSaveDimension(sName
, bDataLayout
);
1055 if (!aDisplayName
.isEmpty())
1056 pDim
->SetLayoutName(aDisplayName
);
1060 ScXMLDataPilotFieldContext::~ScXMLDataPilotFieldContext()
1064 SvXMLImportContext
*ScXMLDataPilotFieldContext::CreateChildContext( sal_uInt16 nPrefix
,
1065 const OUString
& rLName
,
1066 const ::com::sun::star::uno::Reference
<
1067 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1069 SvXMLImportContext
*pContext
= 0;
1071 const SvXMLTokenMap
& rTokenMap
= GetScImport().GetDataPilotFieldElemTokenMap();
1072 switch( rTokenMap
.Get( nPrefix
, rLName
) )
1074 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LEVEL
:
1075 pContext
= new ScXMLDataPilotLevelContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
1077 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_REFERENCE
:
1078 pContext
= new ScXMLDataPilotFieldReferenceContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
1080 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_GROUPS
:
1081 pContext
= new ScXMLDataPilotGroupsContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
1086 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1091 void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember
* pMember
)
1095 pDim
->AddMember(pMember
);
1096 if (!pMember
->GetIsVisible())
1097 // This member is hidden.
1098 mbHasHiddenMember
= true;
1104 void ScXMLDataPilotFieldContext::SetSubTotalName(const OUString
& rName
)
1107 pDim
->SetSubtotalName(rName
);
1110 void ScXMLDataPilotFieldContext::AddGroup(const ::std::vector
<OUString
>& rMembers
, const OUString
& rName
)
1112 ScXMLDataPilotGroup aGroup
;
1113 aGroup
.aMembers
= rMembers
;
1114 aGroup
.aName
= rName
;
1115 aGroups
.push_back(aGroup
);
1118 void ScXMLDataPilotFieldContext::EndElement()
1122 pDim
->SetUsedHierarchy(nUsedHierarchy
);
1123 pDim
->SetFunction(nFunction
);
1124 pDim
->SetOrientation(nOrientation
);
1127 pDataPilotTable
->SetSelectedPage(pDim
->GetName(), sSelectedPage
);
1129 pDataPilotTable
->AddDimension(pDim
);
1132 ScDPNumGroupInfo aInfo
;
1133 aInfo
.mbEnable
= true;
1134 aInfo
.mbDateValues
= bDateValue
;
1135 aInfo
.mbAutoStart
= bAutoStart
;
1136 aInfo
.mbAutoEnd
= bAutoEnd
;
1137 aInfo
.mfStart
= fStart
;
1139 aInfo
.mfStep
= fStep
;
1140 if (!sGroupSource
.isEmpty())
1142 ScDPSaveGroupDimension
aGroupDim(sGroupSource
, sName
);
1144 aGroupDim
.SetDateInfo(aInfo
, nGroupPart
);
1147 ::std::vector
<ScXMLDataPilotGroup
>::const_iterator
aItr(aGroups
.begin());
1148 ::std::vector
<ScXMLDataPilotGroup
>::const_iterator
aEndItr(aGroups
.end());
1149 while (aItr
!= aEndItr
)
1151 ScDPSaveGroupItem
aItem(aItr
->aName
);
1152 ::std::vector
<OUString
>::const_iterator
aMembersItr(aItr
->aMembers
.begin());
1153 ::std::vector
<OUString
>::const_iterator
aMembersEndItr(aItr
->aMembers
.end());
1154 while (aMembersItr
!= aMembersEndItr
)
1156 aItem
.AddElement(*aMembersItr
);
1160 aGroupDim
.AddGroupItem(aItem
);
1163 pDataPilotTable
->AddGroupDim(aGroupDim
);
1167 ScDPSaveNumGroupDimension
aNumGroupDim(sName
, aInfo
);
1169 aNumGroupDim
.SetDateInfo(aInfo
, nGroupPart
);
1170 pDataPilotTable
->AddGroupDim(aNumGroupDim
);
1176 ScXMLDataPilotFieldReferenceContext::ScXMLDataPilotFieldReferenceContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
1177 const OUString
& rLName
,
1178 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
1179 ScXMLDataPilotFieldContext
* pDataPilotField
) :
1180 SvXMLImportContext( rImport
, nPrfx
, rLName
)
1182 sheet::DataPilotFieldReference aReference
;
1184 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1185 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1187 OUString
sAttrName(xAttrList
->getNameByIndex( i
));
1188 OUString aLocalName
;
1189 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1190 sAttrName
, &aLocalName
);
1191 OUString
sValue(xAttrList
->getValueByIndex( i
));
1193 if ( nPrefix
== XML_NAMESPACE_TABLE
)
1195 if (IsXMLToken(aLocalName
, XML_TYPE
))
1197 if (IsXMLToken(sValue
, XML_NONE
))
1198 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::NONE
;
1199 else if (IsXMLToken(sValue
, XML_MEMBER_DIFFERENCE
))
1200 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE
;
1201 else if (IsXMLToken(sValue
, XML_MEMBER_PERCENTAGE
))
1202 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE
;
1203 else if (IsXMLToken(sValue
, XML_MEMBER_PERCENTAGE_DIFFERENCE
))
1204 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE
;
1205 else if (IsXMLToken(sValue
, XML_RUNNING_TOTAL
))
1206 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::RUNNING_TOTAL
;
1207 else if (IsXMLToken(sValue
, XML_ROW_PERCENTAGE
))
1208 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE
;
1209 else if (IsXMLToken(sValue
, XML_COLUMN_PERCENTAGE
))
1210 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE
;
1211 else if (IsXMLToken(sValue
, XML_TOTAL_PERCENTAGE
))
1212 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE
;
1213 else if (IsXMLToken(sValue
, XML_INDEX
))
1214 aReference
.ReferenceType
= sheet::DataPilotFieldReferenceType::INDEX
;
1216 else if (IsXMLToken(aLocalName
, XML_FIELD_NAME
))
1218 aReference
.ReferenceField
= sValue
;
1220 else if (IsXMLToken(aLocalName
, XML_MEMBER_TYPE
))
1222 if (IsXMLToken(sValue
, XML_NAMED
))
1223 aReference
.ReferenceItemType
= sheet::DataPilotFieldReferenceItemType::NAMED
;
1224 else if (IsXMLToken(sValue
, XML_PREVIOUS
))
1225 aReference
.ReferenceItemType
= sheet::DataPilotFieldReferenceItemType::PREVIOUS
;
1226 else if (IsXMLToken(sValue
, XML_NEXT
))
1227 aReference
.ReferenceItemType
= sheet::DataPilotFieldReferenceItemType::NEXT
;
1229 else if (IsXMLToken(aLocalName
, XML_MEMBER_NAME
))
1231 aReference
.ReferenceItemName
= sValue
;
1235 pDataPilotField
->SetFieldReference(aReference
);
1238 ScXMLDataPilotFieldReferenceContext::~ScXMLDataPilotFieldReferenceContext()
1242 ScXMLDataPilotLevelContext::ScXMLDataPilotLevelContext( ScXMLImport
& rImport
,
1244 const OUString
& rLName
,
1245 const ::com::sun::star::uno::Reference
<
1246 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1247 ScXMLDataPilotFieldContext
* pTempDataPilotField
) :
1248 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1249 pDataPilotField(pTempDataPilotField
)
1251 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1252 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDataPilotLevelAttrTokenMap();
1253 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1255 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1256 OUString aLocalName
;
1257 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1258 sAttrName
, &aLocalName
);
1259 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
1261 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
1263 case XML_TOK_DATA_PILOT_LEVEL_ATTR_SHOW_EMPTY
:
1265 pDataPilotField
->SetShowEmpty(IsXMLToken(sValue
, XML_TRUE
));
1272 ScXMLDataPilotLevelContext::~ScXMLDataPilotLevelContext()
1276 SvXMLImportContext
*ScXMLDataPilotLevelContext::CreateChildContext( sal_uInt16 nPrefix
,
1277 const OUString
& rLName
,
1278 const ::com::sun::star::uno::Reference
<
1279 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1281 SvXMLImportContext
*pContext
= 0;
1283 const SvXMLTokenMap
& rTokenMap
= GetScImport().GetDataPilotLevelElemTokenMap();
1284 switch( rTokenMap
.Get( nPrefix
, rLName
) )
1286 case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_SUBTOTALS
:
1287 pContext
= new ScXMLDataPilotSubTotalsContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1289 case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS
:
1290 pContext
= new ScXMLDataPilotMembersContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1292 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_DISPLAY_INFO
:
1293 pContext
= new ScXMLDataPilotDisplayInfoContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1295 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_SORT_INFO
:
1296 pContext
= new ScXMLDataPilotSortInfoContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1298 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LAYOUT_INFO
:
1299 pContext
= new ScXMLDataPilotLayoutInfoContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1304 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1309 void ScXMLDataPilotLevelContext::EndElement()
1313 ScXMLDataPilotDisplayInfoContext::ScXMLDataPilotDisplayInfoContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
1314 const OUString
& rLName
,
1315 const ::com::sun::star::uno::Reference
<
1316 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1317 ScXMLDataPilotFieldContext
* pDataPilotField
) :
1318 SvXMLImportContext( rImport
, nPrfx
, rLName
)
1320 sheet::DataPilotFieldAutoShowInfo aInfo
;
1322 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1323 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1325 OUString
sAttrName(xAttrList
->getNameByIndex( i
));
1326 OUString aLocalName
;
1327 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1328 sAttrName
, &aLocalName
);
1329 OUString
sValue(xAttrList
->getValueByIndex( i
));
1331 if ( nPrefix
== XML_NAMESPACE_TABLE
)
1333 if (IsXMLToken(aLocalName
, XML_ENABLED
))
1335 if (IsXMLToken(sValue
, XML_TRUE
))
1336 aInfo
.IsEnabled
= sal_True
;
1338 aInfo
.IsEnabled
= false;
1340 else if (IsXMLToken(aLocalName
, XML_DISPLAY_MEMBER_MODE
))
1342 if (IsXMLToken(sValue
, XML_FROM_TOP
))
1343 aInfo
.ShowItemsMode
= sheet::DataPilotFieldShowItemsMode::FROM_TOP
;
1344 else if (IsXMLToken(sValue
, XML_FROM_BOTTOM
))
1345 aInfo
.ShowItemsMode
= sheet::DataPilotFieldShowItemsMode::FROM_BOTTOM
;
1347 else if (IsXMLToken(aLocalName
, XML_MEMBER_COUNT
))
1349 aInfo
.ItemCount
= sValue
.toInt32();
1351 else if (IsXMLToken(aLocalName
, XML_DATA_FIELD
))
1353 aInfo
.DataField
= sValue
;
1357 pDataPilotField
->SetAutoShowInfo(aInfo
);
1360 ScXMLDataPilotDisplayInfoContext::~ScXMLDataPilotDisplayInfoContext()
1364 ScXMLDataPilotSortInfoContext::ScXMLDataPilotSortInfoContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
1365 const OUString
& rLName
,
1366 const ::com::sun::star::uno::Reference
<
1367 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1368 ScXMLDataPilotFieldContext
* pDataPilotField
) :
1369 SvXMLImportContext( rImport
, nPrfx
, rLName
)
1371 sheet::DataPilotFieldSortInfo aInfo
;
1373 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1374 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1376 OUString
sAttrName(xAttrList
->getNameByIndex( i
));
1377 OUString aLocalName
;
1378 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1379 sAttrName
, &aLocalName
);
1380 OUString
sValue(xAttrList
->getValueByIndex( i
));
1382 if ( nPrefix
== XML_NAMESPACE_TABLE
)
1384 if (IsXMLToken(aLocalName
, XML_ORDER
))
1386 if (IsXMLToken(sValue
, XML_ASCENDING
))
1387 aInfo
.IsAscending
= sal_True
;
1388 else if (IsXMLToken(sValue
, XML_DESCENDING
))
1389 aInfo
.IsAscending
= false;
1391 else if (IsXMLToken(aLocalName
, XML_SORT_MODE
))
1393 if (IsXMLToken(sValue
, XML_NONE
))
1394 aInfo
.Mode
= sheet::DataPilotFieldSortMode::NONE
;
1395 else if (IsXMLToken(sValue
, XML_MANUAL
))
1396 aInfo
.Mode
= sheet::DataPilotFieldSortMode::MANUAL
;
1397 else if (IsXMLToken(sValue
, XML_NAME
))
1398 aInfo
.Mode
= sheet::DataPilotFieldSortMode::NAME
;
1399 else if (IsXMLToken(sValue
, XML_DATA
))
1400 aInfo
.Mode
= sheet::DataPilotFieldSortMode::DATA
;
1402 else if (IsXMLToken(aLocalName
, XML_DATA_FIELD
))
1403 aInfo
.Field
= sValue
;
1406 pDataPilotField
->SetSortInfo(aInfo
);
1409 ScXMLDataPilotSortInfoContext::~ScXMLDataPilotSortInfoContext()
1413 ScXMLDataPilotLayoutInfoContext::ScXMLDataPilotLayoutInfoContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
1414 const OUString
& rLName
,
1415 const ::com::sun::star::uno::Reference
<
1416 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1417 ScXMLDataPilotFieldContext
* pDataPilotField
) :
1418 SvXMLImportContext( rImport
, nPrfx
, rLName
)
1420 sheet::DataPilotFieldLayoutInfo aInfo
;
1422 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1423 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1425 OUString
sAttrName(xAttrList
->getNameByIndex( i
));
1426 OUString aLocalName
;
1427 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1428 sAttrName
, &aLocalName
);
1429 OUString
sValue(xAttrList
->getValueByIndex( i
));
1431 if ( nPrefix
== XML_NAMESPACE_TABLE
)
1433 if (IsXMLToken(aLocalName
, XML_ADD_EMPTY_LINES
))
1435 if (IsXMLToken(sValue
, XML_TRUE
))
1436 aInfo
.AddEmptyLines
= sal_True
;
1438 aInfo
.AddEmptyLines
= false;
1440 else if (IsXMLToken(aLocalName
, XML_LAYOUT_MODE
))
1442 if (IsXMLToken(sValue
, XML_TABULAR_LAYOUT
))
1443 aInfo
.LayoutMode
= sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT
;
1444 else if (IsXMLToken(sValue
, XML_OUTLINE_SUBTOTALS_TOP
))
1445 aInfo
.LayoutMode
= sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP
;
1446 else if (IsXMLToken(sValue
, XML_OUTLINE_SUBTOTALS_BOTTOM
))
1447 aInfo
.LayoutMode
= sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM
;
1451 pDataPilotField
->SetLayoutInfo(aInfo
);}
1453 ScXMLDataPilotLayoutInfoContext::~ScXMLDataPilotLayoutInfoContext()
1457 ScXMLDataPilotSubTotalsContext::ScXMLDataPilotSubTotalsContext( ScXMLImport
& rImport
,
1459 const OUString
& rLName
,
1460 const ::com::sun::star::uno::Reference
<
1461 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */,
1462 ScXMLDataPilotFieldContext
* pTempDataPilotField
) :
1463 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1464 pDataPilotField(pTempDataPilotField
),
1469 // has no attributes
1472 ScXMLDataPilotSubTotalsContext::~ScXMLDataPilotSubTotalsContext()
1474 delete[] pFunctions
;
1477 SvXMLImportContext
*ScXMLDataPilotSubTotalsContext::CreateChildContext( sal_uInt16 nPrefix
,
1478 const OUString
& rLName
,
1479 const ::com::sun::star::uno::Reference
<
1480 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1482 SvXMLImportContext
*pContext
= 0;
1484 const SvXMLTokenMap
& rTokenMap
= GetScImport().GetDataPilotSubTotalsElemTokenMap();
1485 switch( rTokenMap
.Get( nPrefix
, rLName
) )
1487 case XML_TOK_DATA_PILOT_SUBTOTALS_ELEM_DATA_PILOT_SUBTOTAL
:
1488 pContext
= new ScXMLDataPilotSubTotalContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
1493 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1498 void ScXMLDataPilotSubTotalsContext::EndElement()
1500 pDataPilotField
->SetSubTotals(pFunctions
, nFunctionCount
);
1501 if (!maDisplayName
.isEmpty())
1502 pDataPilotField
->SetSubTotalName(maDisplayName
);
1505 void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction
)
1510 sal_uInt16
* pTemp
= new sal_uInt16
[nFunctionCount
];
1511 for (sal_Int16 i
= 0; i
< nFunctionCount
- 1; ++i
)
1512 pTemp
[i
] = pFunctions
[i
];
1513 pTemp
[nFunctionCount
- 1] = nFunction
;
1514 delete[] pFunctions
;
1520 pFunctions
= new sal_uInt16
[nFunctionCount
];
1521 pFunctions
[0] = nFunction
;
1525 void ScXMLDataPilotSubTotalsContext::SetDisplayName(const OUString
& rName
)
1527 maDisplayName
= rName
;
1530 ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport
& rImport
,
1532 const OUString
& rLName
,
1533 const ::com::sun::star::uno::Reference
<
1534 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1535 ScXMLDataPilotSubTotalsContext
* pTempDataPilotSubTotals
) :
1536 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1537 pDataPilotSubTotals(pTempDataPilotSubTotals
)
1539 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1540 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDataPilotSubTotalAttrTokenMap();
1541 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1543 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1544 OUString aLocalName
;
1545 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1546 sAttrName
, &aLocalName
);
1547 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
1549 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
1551 case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION
:
1553 pDataPilotSubTotals
->AddFunction( sal::static_int_cast
<sal_Int16
>(
1554 ScXMLConverter::GetFunctionFromString( sValue
) ) );
1557 case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME
:
1558 case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME_EXT
:
1559 pDataPilotSubTotals
->SetDisplayName(sValue
);
1565 ScXMLDataPilotSubTotalContext::~ScXMLDataPilotSubTotalContext()
1569 SvXMLImportContext
*ScXMLDataPilotSubTotalContext::CreateChildContext( sal_uInt16 nPrefix
,
1570 const OUString
& rLName
,
1571 const ::com::sun::star::uno::Reference
<
1572 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
1574 SvXMLImportContext
*pContext
= 0;
1577 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1582 void ScXMLDataPilotSubTotalContext::EndElement()
1586 ScXMLDataPilotMembersContext::ScXMLDataPilotMembersContext( ScXMLImport
& rImport
,
1588 const OUString
& rLName
,
1589 const ::com::sun::star::uno::Reference
<
1590 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */,
1591 ScXMLDataPilotFieldContext
* pTempDataPilotField
) :
1592 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1593 pDataPilotField(pTempDataPilotField
)
1595 // has no attributes
1598 ScXMLDataPilotMembersContext::~ScXMLDataPilotMembersContext()
1602 SvXMLImportContext
*ScXMLDataPilotMembersContext::CreateChildContext( sal_uInt16 nPrefix
,
1603 const OUString
& rLName
,
1604 const ::com::sun::star::uno::Reference
<
1605 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1607 SvXMLImportContext
*pContext
= 0;
1609 const SvXMLTokenMap
& rTokenMap
= GetScImport().GetDataPilotMembersElemTokenMap();
1610 switch( rTokenMap
.Get( nPrefix
, rLName
) )
1612 case XML_TOK_DATA_PILOT_MEMBERS_ELEM_DATA_PILOT_MEMBER
:
1613 pContext
= new ScXMLDataPilotMemberContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1618 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1623 void ScXMLDataPilotMembersContext::EndElement()
1627 ScXMLDataPilotMemberContext::ScXMLDataPilotMemberContext( ScXMLImport
& rImport
,
1629 const OUString
& rLName
,
1630 const ::com::sun::star::uno::Reference
<
1631 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1632 ScXMLDataPilotFieldContext
* pTempDataPilotField
) :
1633 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1634 pDataPilotField(pTempDataPilotField
),
1636 bDisplayDetails( true ),
1639 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1640 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetDataPilotMemberAttrTokenMap();
1641 for( sal_Int16 i
=0; i
< nAttrCount
; ++i
)
1643 const OUString
& sAttrName(xAttrList
->getNameByIndex( i
));
1644 OUString aLocalName
;
1645 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1646 sAttrName
, &aLocalName
);
1647 const OUString
& sValue(xAttrList
->getValueByIndex( i
));
1649 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
1651 case XML_TOK_DATA_PILOT_MEMBER_ATTR_NAME
:
1657 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME
:
1658 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME_EXT
:
1660 maDisplayName
= sValue
;
1663 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY
:
1665 bDisplay
= IsXMLToken(sValue
, XML_TRUE
);
1668 case XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS
:
1670 bDisplayDetails
= IsXMLToken(sValue
, XML_TRUE
);
1677 ScXMLDataPilotMemberContext::~ScXMLDataPilotMemberContext()
1681 SvXMLImportContext
*ScXMLDataPilotMemberContext::CreateChildContext( sal_uInt16 nPrefix
,
1682 const OUString
& rLName
,
1683 const ::com::sun::star::uno::Reference
<
1684 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
1686 SvXMLImportContext
*pContext
= 0;
1689 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1694 void ScXMLDataPilotMemberContext::EndElement()
1696 if (bHasName
) // #i53407# don't check sName, empty name is allowed
1698 ScDPSaveMember
* pMember
= new ScDPSaveMember(sName
);
1699 if (!maDisplayName
.isEmpty())
1700 pMember
->SetLayoutName(maDisplayName
);
1701 pMember
->SetIsVisible(bDisplay
);
1702 pMember
->SetShowDetails(bDisplayDetails
);
1703 pDataPilotField
->AddMember(pMember
);
1707 ScXMLDataPilotGroupsContext::ScXMLDataPilotGroupsContext( ScXMLImport
& rImport
,
1709 const OUString
& rLName
,
1710 const ::com::sun::star::uno::Reference
<
1711 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1712 ScXMLDataPilotFieldContext
* pTempDataPilotField
) :
1713 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1714 pDataPilotField(pTempDataPilotField
)
1716 OUString sGroupSource
;
1720 sal_Int32
nGroupPart(0);
1721 bool bDateValue(false);
1722 bool bAutoStart(true);
1723 bool bAutoEnd(true);
1725 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1726 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1728 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
1729 OUString aLocalName
;
1730 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1731 sAttrName
, &aLocalName
);
1732 OUString sValue
= xAttrList
->getValueByIndex( i
);
1734 (void)nPrefix
; //! compare below!
1736 if (IsXMLToken(aLocalName
, XML_SOURCE_FIELD_NAME
))
1737 sGroupSource
= sValue
;
1738 else if (IsXMLToken(aLocalName
, XML_DATE_START
))
1741 if (IsXMLToken(sValue
, XML_AUTO
))
1745 GetScImport().GetMM100UnitConverter().convertDateTime(fStart
, sValue
);
1749 else if (IsXMLToken(aLocalName
, XML_DATE_END
))
1752 if (IsXMLToken(sValue
, XML_AUTO
))
1756 GetScImport().GetMM100UnitConverter().convertDateTime(fEnd
, sValue
);
1760 else if (IsXMLToken(aLocalName
, XML_START
))
1762 if (IsXMLToken(sValue
, XML_AUTO
))
1766 ::sax::Converter::convertDouble(fStart
, sValue
);
1770 else if (IsXMLToken(aLocalName
, XML_END
))
1772 if (IsXMLToken(sValue
, XML_AUTO
))
1776 ::sax::Converter::convertDouble(fEnd
, sValue
);
1780 else if (IsXMLToken(aLocalName
, XML_STEP
))
1782 ::sax::Converter::convertDouble(fStep
, sValue
);
1784 else if (IsXMLToken(aLocalName
, XML_GROUPED_BY
))
1786 if (IsXMLToken(sValue
, XML_SECONDS
))
1787 nGroupPart
= com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS
;
1788 else if (IsXMLToken(sValue
, XML_MINUTES
))
1789 nGroupPart
= com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES
;
1790 else if (IsXMLToken(sValue
, XML_HOURS
))
1791 nGroupPart
= com::sun::star::sheet::DataPilotFieldGroupBy::HOURS
;
1792 else if (IsXMLToken(sValue
, XML_DAYS
))
1793 nGroupPart
= com::sun::star::sheet::DataPilotFieldGroupBy::DAYS
;
1794 else if (IsXMLToken(sValue
, XML_MONTHS
))
1795 nGroupPart
= com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS
;
1796 else if (IsXMLToken(sValue
, XML_QUARTERS
))
1797 nGroupPart
= com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS
;
1798 else if (IsXMLToken(sValue
, XML_YEARS
))
1799 nGroupPart
= com::sun::star::sheet::DataPilotFieldGroupBy::YEARS
;
1802 pDataPilotField
->SetGrouping(sGroupSource
, fStart
, fEnd
, fStep
, nGroupPart
, bDateValue
, bAutoStart
, bAutoEnd
);
1805 ScXMLDataPilotGroupsContext::~ScXMLDataPilotGroupsContext()
1809 SvXMLImportContext
*ScXMLDataPilotGroupsContext::CreateChildContext( sal_uInt16 nPrefix
,
1810 const OUString
& rLName
,
1811 const ::com::sun::star::uno::Reference
<
1812 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1814 SvXMLImportContext
*pContext
= 0;
1816 if (nPrefix
== XML_NAMESPACE_TABLE
)
1818 if (IsXMLToken(rLName
, XML_DATA_PILOT_GROUP
))
1819 pContext
= new ScXMLDataPilotGroupContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1823 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1828 void ScXMLDataPilotGroupsContext::EndElement()
1832 ScXMLDataPilotGroupContext::ScXMLDataPilotGroupContext( ScXMLImport
& rImport
,
1834 const OUString
& rLName
,
1835 const ::com::sun::star::uno::Reference
<
1836 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1837 ScXMLDataPilotFieldContext
* pTempDataPilotField
) :
1838 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1839 pDataPilotField(pTempDataPilotField
)
1841 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1842 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1844 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
1845 OUString aLocalName
;
1846 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1847 sAttrName
, &aLocalName
);
1848 OUString sValue
= xAttrList
->getValueByIndex( i
);
1850 if (nPrefix
== XML_NAMESPACE_TABLE
)
1852 if (IsXMLToken(aLocalName
, XML_NAME
))
1858 ScXMLDataPilotGroupContext::~ScXMLDataPilotGroupContext()
1862 SvXMLImportContext
*ScXMLDataPilotGroupContext::CreateChildContext( sal_uInt16 nPrefix
,
1863 const OUString
& rLName
,
1864 const ::com::sun::star::uno::Reference
<
1865 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1867 SvXMLImportContext
*pContext
= 0;
1869 if (nPrefix
== XML_NAMESPACE_TABLE
)
1871 if (IsXMLToken(rLName
, XML_DATA_PILOT_MEMBER
) || IsXMLToken(rLName
, XML_DATA_PILOT_GROUP_MEMBER
))
1872 pContext
= new ScXMLDataPilotGroupMemberContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
1876 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1881 void ScXMLDataPilotGroupContext::EndElement()
1883 pDataPilotField
->AddGroup(aMembers
, sName
);
1886 ScXMLDataPilotGroupMemberContext::ScXMLDataPilotGroupMemberContext( ScXMLImport
& rImport
,
1888 const OUString
& rLName
,
1889 const ::com::sun::star::uno::Reference
<
1890 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1891 ScXMLDataPilotGroupContext
* pTempDataPilotGroup
) :
1892 SvXMLImportContext( rImport
, nPrfx
, rLName
),
1893 pDataPilotGroup(pTempDataPilotGroup
)
1895 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
1896 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
1898 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
1899 OUString aLocalName
;
1900 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName(
1901 sAttrName
, &aLocalName
);
1902 OUString sValue
= xAttrList
->getValueByIndex( i
);
1904 if (nPrefix
== XML_NAMESPACE_TABLE
)
1906 if (IsXMLToken(aLocalName
, XML_NAME
))
1912 ScXMLDataPilotGroupMemberContext::~ScXMLDataPilotGroupMemberContext()
1916 SvXMLImportContext
*ScXMLDataPilotGroupMemberContext::CreateChildContext( sal_uInt16 nPrefix
,
1917 const OUString
& rLName
,
1918 const ::com::sun::star::uno::Reference
<
1919 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ )
1921 SvXMLImportContext
*pContext
= 0;
1924 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1929 void ScXMLDataPilotGroupMemberContext::EndElement()
1931 if (!sName
.isEmpty())
1932 pDataPilotGroup
->AddMember(sName
);
1935 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */