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
;
57 ScXMLDataPilotTablesContext::ScXMLDataPilotTablesContext( ScXMLImport
& rImport
,
59 const OUString
& rLName
,
60 const ::com::sun::star::uno::Reference
<
61 ::com::sun::star::xml::sax::XAttributeList
>& /* xAttrList */ ) :
62 SvXMLImportContext( rImport
, nPrfx
, rLName
)
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
,
92 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
97 void ScXMLDataPilotTablesContext::EndElement()
101 ScXMLDataPilotTableContext::GrandTotalItem::GrandTotalItem() :
104 ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport
& rImport
,
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()),
112 pDPDimSaveData(NULL
),
113 sDataPilotTableName(),
120 mnDataLayoutType(sheet::DataPilotFieldOrientation_HIDDEN
),
122 bIgnoreEmptyRows(false),
123 bIdentifyCategories(false),
124 bTargetRangeAddress(false),
125 bSourceCellRange(false),
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
));
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
;
147 case XML_TOK_DATA_PILOT_TABLE_ATTR_APPLICATION_DATA
:
149 sApplicationData
= sValue
;
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;
171 maRowGrandTotal
.mbVisible
= false;
172 maColGrandTotal
.mbVisible
= false;
176 case XML_TOK_DATA_PILOT_TABLE_ATTR_IGNORE_EMPTY_ROWS
:
178 bIgnoreEmptyRows
= IsXMLToken(sValue
, XML_TRUE
);
181 case XML_TOK_DATA_PILOT_TABLE_ATTR_IDENTIFY_CATEGORIES
:
183 bIdentifyCategories
= IsXMLToken(sValue
, XML_TRUE
);
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
);
192 case XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS
:
197 case XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON
:
199 bShowFilter
= IsXMLToken(sValue
, XML_TRUE
);
202 case XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN
:
204 bDrillDown
= IsXMLToken(sValue
, XML_TRUE
);
207 case XML_TOK_DATA_PILOT_TABLE_ATTR_HEADER_GRID_LAYOUT
:
209 bHeaderGridLayout
= IsXMLToken(sValue
, XML_TRUE
);
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);
240 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_TABLE
:
242 pContext
= new ScXMLDPSourceTableContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
246 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_QUERY
:
248 pContext
= new ScXMLDPSourceQueryContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
252 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_SERVICE
:
254 pContext
= new ScXMLSourceServiceContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
255 nSourceType
= SERVICE
;
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);
264 case XML_TOK_DATA_PILOT_TABLE_ELEM_SOURCE_CELL_RANGE
:
266 pContext
= new ScXMLSourceCellRangeContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
267 nSourceType
= CELLRANGE
;
270 case XML_TOK_DATA_PILOT_TABLE_ELEM_DATA_PILOT_FIELD
:
271 pContext
= new ScXMLDataPilotFieldContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
276 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
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
)
291 case ScDPOutputGeometry::Column
:
293 if (rColDims
.size() <= nPos
)
296 return rColDims
[nPos
];
298 case ScDPOutputGeometry::Row
:
300 if (rRowDims
.size() <= nPos
)
303 return rRowDims
[nPos
];
305 case ScDPOutputGeometry::Page
:
307 if (rPageDims
.size() <= nPos
)
310 return rPageDims
[nPos
];
312 case ScDPOutputGeometry::Data
:
314 case ScDPOutputGeometry::None
:
322 ScDPOutputGeometry::FieldType
toFieldType(sal_uInt16 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
:
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
);
359 sal_Int32 nOffset
= 0;
360 while( nOffset
>= 0 )
362 ScRangeStringConverter::GetTokenByOffset( sAddress
, sButtons
, nOffset
);
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
;
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
;
386 nMFlag
|= SC_MF_HIDDEN_MEMBER
;
387 pDoc
->ApplyFlagsTab(aScAddress
.Col()+1, aScAddress
.Row(), aScAddress
.Col()+1, aScAddress
.Row(), aScAddress
.Tab(), nMFlag
);
391 sal_Int16 nMFlag
= SC_MF_BUTTON
;
394 // Data layout dimension only has a plain button with no popup.
398 // Normal dimension has a popup arrow button.
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
);
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
)
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
:
438 case sheet::DataPilotFieldOrientation_COLUMN
:
441 case sheet::DataPilotFieldOrientation_PAGE
:
444 case sheet::DataPilotFieldOrientation_DATA
:
447 case sheet::DataPilotFieldOrientation_HIDDEN
:
453 pDPSave
->AddDimension(pDim
);
457 void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveNumGroupDimension
& aNumGroupDim
)
460 pDPDimSaveData
= new ScDPDimensionSaveData();
461 pDPDimSaveData
->AddNumGroupDimension(aNumGroupDim
);
464 void ScXMLDataPilotTableContext::AddGroupDim(const ScDPSaveGroupDimension
& aGroupDim
)
467 pDPDimSaveData
= new ScDPDimensionSaveData();
468 pDPDimSaveData
->AddGroupDimension(aGroupDim
);
471 void ScXMLDataPilotTableContext::EndElement()
473 if (!bTargetRangeAddress
)
476 pDPObject
->SetName(sDataPilotTableName
);
477 pDPObject
->SetTag(sApplicationData
);
478 pDPObject
->SetOutRange(aTargetRangeAddress
);
479 pDPObject
->SetHeaderLayout(bHeaderGridLayout
);
481 sc::PivotTableSources
& rPivotSources
= GetScImport().GetPivotTableSources();
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
);
497 ScImportSourceDesc
aImportDesc(pDoc
);
498 aImportDesc
.aDBName
= sDatabaseName
;
499 aImportDesc
.aObject
= sSourceObject
;
500 aImportDesc
.nType
= sheet::DataImportMode_TABLE
;
501 rPivotSources
.appendDBSource(pDPObject
, aImportDesc
);
506 ScImportSourceDesc
aImportDesc(pDoc
);
507 aImportDesc
.aDBName
= sDatabaseName
;
508 aImportDesc
.aObject
= sSourceObject
;
509 aImportDesc
.nType
= sheet::DataImportMode_QUERY
;
510 rPivotSources
.appendDBSource(pDPObject
, aImportDesc
);
515 ScDPServiceDesc
aServiceDesc(sServiceName
, sServiceSourceName
, sServiceSourceObject
,
516 sServiceUsername
, sServicePassword
);
517 rPivotSources
.appendServiceSource(pDPObject
, aServiceDesc
);
522 if (bSourceCellRange
)
524 ScSheetSourceDesc
aSheetDesc(pDoc
);
525 if (!sSourceRangeName
.isEmpty())
526 // Range name takes precedence.
527 aSheetDesc
.SetRangeName(sSourceRangeName
);
529 aSheetDesc
.SetSourceRange(aSourceCellRangeAddress
);
530 aSheetDesc
.SetQueryParam(aSourceQueryParam
);
531 rPivotSources
.appendSheetSource(pDPObject
, aSheetDesc
);
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
545 pDPSave
->SetGrandTotalName(maRowGrandTotal
.maDisplayName
);
547 pDPSave
->SetIgnoreEmptyRows(bIgnoreEmptyRows
);
548 pDPSave
->SetRepeatIfEmpty(bIdentifyCategories
);
549 pDPSave
->SetFilterButton(bShowFilter
);
550 pDPSave
->SetDrillDown(bDrillDown
);
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
);
570 void ScXMLDataPilotTableContext::SetGrandTotal(
571 XMLTokenEnum eOrientation
, bool bVisible
, const OUString
& rDisplayName
)
573 switch (eOrientation
)
576 maRowGrandTotal
.mbVisible
= bVisible
;
577 maRowGrandTotal
.maDisplayName
= rDisplayName
;
578 maColGrandTotal
.mbVisible
= bVisible
;
579 maColGrandTotal
.maDisplayName
= rDisplayName
;
582 maRowGrandTotal
.mbVisible
= bVisible
;
583 maRowGrandTotal
.maDisplayName
= rDisplayName
;
586 maColGrandTotal
.mbVisible
= bVisible
;
587 maColGrandTotal
.maDisplayName
= rDisplayName
;
594 ScXMLDPSourceSQLContext::ScXMLDPSourceSQLContext( ScXMLImport
& rImport
,
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
));
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
);
620 case XML_TOK_SOURCE_SQL_ATTR_SQL_STATEMENT
:
622 pDataPilotTable
->SetSourceObject(sValue
);
625 case XML_TOK_SOURCE_SQL_ATTR_PARSE_SQL_STATEMENT
:
627 pDataPilotTable
->SetNative(!IsXMLToken(sValue
, XML_TRUE
));
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;
646 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
651 void ScXMLDPSourceSQLContext::EndElement()
655 ScXMLDPSourceTableContext::ScXMLDPSourceTableContext( ScXMLImport
& rImport
,
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
));
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
);
681 case XML_TOK_SOURCE_TABLE_ATTR_TABLE_NAME
:
683 pDataPilotTable
->SetSourceObject(sValue
);
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;
702 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
707 void ScXMLDPSourceTableContext::EndElement()
711 ScXMLDPSourceQueryContext::ScXMLDPSourceQueryContext( ScXMLImport
& rImport
,
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
));
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
);
737 case XML_TOK_SOURCE_QUERY_ATTR_QUERY_NAME
:
739 pDataPilotTable
->SetSourceObject(sValue
);
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;
758 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
763 void ScXMLDPSourceQueryContext::EndElement()
767 ScXMLSourceServiceContext::ScXMLSourceServiceContext( ScXMLImport
& rImport
,
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
));
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
);
793 case XML_TOK_SOURCE_SERVICE_ATTR_SOURCE_NAME
:
795 pDataPilotTable
->SetServiceSourceName(sValue
);
798 case XML_TOK_SOURCE_SERVICE_ATTR_OBJECT_NAME
:
800 pDataPilotTable
->SetServiceSourceObject(sValue
);
803 case XML_TOK_SOURCE_SERVICE_ATTR_USER_NAME
:
805 pDataPilotTable
->SetServiceUsername(sValue
);
808 case XML_TOK_SOURCE_SERVICE_ATTR_PASSWORD
:
810 pDataPilotTable
->SetServicePassword(sValue
);
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;
829 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
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
),
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
);
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
);
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
))
870 else if (IsXMLToken(rAttrValue
, XML_COLUMN
))
871 meOrientation
= COLUMN
;
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
;
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
)
905 eOrient
= XML_COLUMN
;
910 mpTableContext
->SetGrandTotal(eOrient
, mbVisible
, maDisplayName
);
913 ScXMLSourceCellRangeContext::ScXMLSourceCellRangeContext( ScXMLImport
& rImport
,
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
));
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
);
942 case XML_TOK_SOURCE_CELL_RANGE_ATTR_NAME
:
943 pDataPilotTable
->SetSourceRangeName(sValue
);
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
);
969 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
974 void ScXMLSourceCellRangeContext::EndElement()
978 ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport
& rImport
,
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
),
994 bSelectedPage(false),
995 bIsGroupField(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
:
1023 case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME
:
1024 case XML_TOK_DATA_PILOT_FIELD_ATTR_DISPLAY_NAME_EXT
:
1026 aDisplayName
= sValue
;
1029 case XML_TOK_DATA_PILOT_FIELD_ATTR_IS_DATA_LAYOUT_FIELD
:
1031 bDataLayout
= IsXMLToken(sValue
, XML_TRUE
);
1034 case XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION
:
1036 nFunction
= (sal_Int16
) ScXMLConverter::GetFunctionFromString( sValue
);
1039 case XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION
:
1041 nOrientation
= (sal_Int16
) ScXMLConverter::GetOrientationFromString( sValue
);
1044 case XML_TOK_DATA_PILOT_FIELD_ATTR_SELECTED_PAGE
:
1046 sSelectedPage
= sValue
;
1047 bSelectedPage
= true;
1050 case XML_TOK_DATA_PILOT_FIELD_ATTR_IGNORE_SELECTED_PAGE
:
1052 bIgnoreSelectedPage
= true;
1055 case XML_TOK_DATA_PILOT_FIELD_ATTR_USED_HIERARCHY
:
1057 nUsedHierarchy
= sValue
.toInt32();
1063 // use the new extension elements
1064 if (bIgnoreSelectedPage
)
1065 bSelectedPage
= false;
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);
1092 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_REFERENCE
:
1093 pContext
= new ScXMLDataPilotFieldReferenceContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
1095 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_GROUPS
:
1096 pContext
= new ScXMLDataPilotGroupsContext(GetScImport(), nPrefix
, rLName
, xAttrList
, this);
1101 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1106 void ScXMLDataPilotFieldContext::AddMember(ScDPSaveMember
* pMember
)
1110 pDim
->AddMember(pMember
);
1111 if (!pMember
->GetIsVisible())
1112 // This member is hidden.
1113 mbHasHiddenMember
= true;
1119 void ScXMLDataPilotFieldContext::SetSubTotalName(const OUString
& rName
)
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()
1137 pDim
->SetUsedHierarchy(nUsedHierarchy
);
1138 pDim
->SetFunction(nFunction
);
1139 pDim
->SetOrientation(nOrientation
);
1142 pDataPilotTable
->SetSelectedPage(pDim
->GetName(), sSelectedPage
);
1144 pDataPilotTable
->AddDimension(pDim
);
1147 ScDPNumGroupInfo aInfo
;
1148 aInfo
.mbEnable
= true;
1149 aInfo
.mbDateValues
= bDateValue
;
1150 aInfo
.mbAutoStart
= bAutoStart
;
1151 aInfo
.mbAutoEnd
= bAutoEnd
;
1152 aInfo
.mfStart
= fStart
;
1154 aInfo
.mfStep
= fStep
;
1155 if (!sGroupSource
.isEmpty())
1157 ScDPSaveGroupDimension
aGroupDim(sGroupSource
, sName
);
1159 aGroupDim
.SetDateInfo(aInfo
, nGroupPart
);
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
);
1175 aGroupDim
.AddGroupItem(aItem
);
1178 pDataPilotTable
->AddGroupDim(aGroupDim
);
1182 ScDPSaveNumGroupDimension
aNumGroupDim(sName
, aInfo
);
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
,
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
));
1283 case XML_TOK_DATA_PILOT_LEVEL_ATTR_REPEAT_ITEM_LABELS
:
1285 pDataPilotField
->SetRepeatItemLabels(IsXMLToken(sValue
, XML_TRUE
));
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
);
1309 case XML_TOK_DATA_PILOT_LEVEL_ELEM_DATA_PILOT_MEMBERS
:
1310 pContext
= new ScXMLDataPilotMembersContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1312 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_DISPLAY_INFO
:
1313 pContext
= new ScXMLDataPilotDisplayInfoContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1315 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_SORT_INFO
:
1316 pContext
= new ScXMLDataPilotSortInfoContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1318 case XML_TOK_DATA_PILOT_FIELD_ELEM_DATA_PILOT_LAYOUT_INFO
:
1319 pContext
= new ScXMLDataPilotLayoutInfoContext(GetScImport(), nPrefix
, rLName
, xAttrList
, pDataPilotField
);
1324 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
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
;
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
;
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
,
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
),
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);
1513 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1518 void ScXMLDataPilotSubTotalsContext::EndElement()
1520 pDataPilotField
->SetSubTotals(pFunctions
, nFunctionCount
);
1521 if (!maDisplayName
.isEmpty())
1522 pDataPilotField
->SetSubTotalName(maDisplayName
);
1525 void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction
)
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
;
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
,
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
) ) );
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
);
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;
1597 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1602 void ScXMLDataPilotSubTotalContext::EndElement()
1606 ScXMLDataPilotMembersContext::ScXMLDataPilotMembersContext( ScXMLImport
& rImport
,
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
);
1638 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1643 void ScXMLDataPilotMembersContext::EndElement()
1647 ScXMLDataPilotMemberContext::ScXMLDataPilotMemberContext( ScXMLImport
& rImport
,
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
),
1656 bDisplayDetails( true ),
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
:
1677 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME
:
1678 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY_NAME_EXT
:
1680 maDisplayName
= sValue
;
1683 case XML_TOK_DATA_PILOT_MEMBER_ATTR_DISPLAY
:
1685 bDisplay
= IsXMLToken(sValue
, XML_TRUE
);
1688 case XML_TOK_DATA_PILOT_MEMBER_ATTR_SHOW_DETAILS
:
1690 bDisplayDetails
= IsXMLToken(sValue
, XML_TRUE
);
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;
1709 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
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
,
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
;
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
))
1761 if (IsXMLToken(sValue
, XML_AUTO
))
1765 GetScImport().GetMM100UnitConverter().convertDateTime(fStart
, sValue
);
1769 else if (IsXMLToken(aLocalName
, XML_DATE_END
))
1772 if (IsXMLToken(sValue
, XML_AUTO
))
1776 GetScImport().GetMM100UnitConverter().convertDateTime(fEnd
, sValue
);
1780 else if (IsXMLToken(aLocalName
, XML_START
))
1782 if (IsXMLToken(sValue
, XML_AUTO
))
1786 ::sax::Converter::convertDouble(fStart
, sValue
);
1790 else if (IsXMLToken(aLocalName
, XML_END
))
1792 if (IsXMLToken(sValue
, XML_AUTO
))
1796 ::sax::Converter::convertDouble(fEnd
, sValue
);
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
);
1843 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1848 void ScXMLDataPilotGroupsContext::EndElement()
1852 ScXMLDataPilotGroupContext::ScXMLDataPilotGroupContext( ScXMLImport
& rImport
,
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
))
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);
1896 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1901 void ScXMLDataPilotGroupContext::EndElement()
1903 pDataPilotField
->AddGroup(aMembers
, sName
);
1906 ScXMLDataPilotGroupMemberContext::ScXMLDataPilotGroupMemberContext( ScXMLImport
& rImport
,
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
))
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;
1944 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
1949 void ScXMLDataPilotGroupMemberContext::EndElement()
1951 if (!sName
.isEmpty())
1952 pDataPilotGroup
->AddMember(sName
);
1955 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */