LibreOffice Module sc (master) 1
XMLExportDataPilot.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <xmloff/xmltoken.hxx>
23#include <xmloff/xmluconv.hxx>
26#include <rtl/math.hxx>
27#include <osl/diagnose.h>
28#include "xmlexprt.hxx"
29#include "XMLConverter.hxx"
30#include <document.hxx>
31#include <dpobject.hxx>
32#include <dociter.hxx>
33#include <attrib.hxx>
34#include <patattr.hxx>
35#include <scitems.hxx>
36#include <dpsave.hxx>
37#include <dpshttab.hxx>
38#include <dpsdbtab.hxx>
39#include <dpdimsave.hxx>
40#include <dputil.hxx>
41#include <rangeutl.hxx>
42#include <queryentry.hxx>
43#include <com/sun/star/sheet/DataImportMode.hpp>
44#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
45#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
46#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
47#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
48#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
49#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
50#include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
51#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
52#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
53#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
54#include <com/sun/star/sheet/GeneralFunction2.hpp>
55
56using namespace com::sun::star;
57using namespace xmloff::token;
58
60 : rExport(rTempExport),
61 pDoc( nullptr )
62{
63}
64
66 const ScQueryOp aFilterOperator, const utl::SearchParam::SearchType eSearchType)
67{
68 switch (aFilterOperator)
69 {
70 case SC_EQUAL :
71 {
72 if (eSearchType == utl::SearchParam::SearchType::Regexp)
73 return GetXMLToken(XML_MATCH);
74 else
75 return "=";
76 }
77 case SC_NOT_EQUAL :
78 {
79 if (eSearchType == utl::SearchParam::SearchType::Regexp)
81 else
82 return "!=";
83 }
84 case SC_BOTPERC :
86 case SC_BOTVAL :
88 case SC_GREATER :
89 return ">";
90 case SC_GREATER_EQUAL :
91 return ">=";
92 case SC_LESS :
93 return "<";
94 case SC_LESS_EQUAL :
95 return "<=";
96 case SC_TOPPERC :
98 case SC_TOPVAL :
100 default:
101 OSL_FAIL("This FilterOperator is not supported.");
102 }
103 return "=";
104}
105
106void ScXMLExportDataPilot::WriteDPCondition(const ScQueryEntry& aQueryEntry, bool bIsCaseSensitive,
108{
109 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, OUString::number(aQueryEntry.nField));
110 if (bIsCaseSensitive)
112 const ScQueryEntry::Item& rItem = aQueryEntry.GetQueryItem();
113 OUString aQueryStr = rItem.maString.getString();
114 if (rItem.meType == ScQueryEntry::ByString)
115 {
117 }
118 else
119 {
122 }
123
124 if (aQueryEntry.IsQueryByEmpty())
125 {
127 }
128 else if (aQueryEntry.IsQueryByNonEmpty())
129 {
131 }
132 else
135 getDPOperatorXML(aQueryEntry.eOp, eSearchType));
136
138}
139
141{
142 SCSIZE nQueryEntryCount = aQueryParam.GetEntryCount();
143 if (nQueryEntryCount <= 0)
144 return;
145
146 bool bAnd(false);
147 bool bOr(false);
148 bool bHasEntries(true);
149 SCSIZE nEntries(0);
150 SCSIZE j;
151
152 for ( j = 0; (j < nQueryEntryCount) && bHasEntries; ++j)
153 {
154 ScQueryEntry aEntry = aQueryParam.GetEntry(j);
155 if (aEntry.bDoQuery)
156 {
157 if (nEntries > 0)
158 {
159 if (aEntry.eConnect == SC_AND)
160 bAnd = true;
161 else
162 bOr = true;
163 }
164 ++nEntries;
165 }
166 else
167 bHasEntries = false;
168 }
169 nQueryEntryCount = nEntries;
170 if (!nQueryEntryCount)
171 return;
172
173 if(!((aQueryParam.nCol1 == aQueryParam.nCol2) && (aQueryParam.nRow1 == aQueryParam.nRow2) &&
174 (static_cast<SCCOLROW>(aQueryParam.nCol1) == static_cast<SCCOLROW>(aQueryParam.nRow1)) &&
175 (aQueryParam.nCol1 == 0) && (aQueryParam.nTab == SCTAB_MAX)))
176 {
177 ScRange aConditionRange(aQueryParam.nCol1, aQueryParam.nRow1, aQueryParam.nTab,
178 aQueryParam.nCol2, aQueryParam.nRow2, aQueryParam.nTab);
179 OUString sConditionRange;
181 if (!sConditionRange.isEmpty())
183 }
184 if (!aQueryParam.bDuplicate)
188 if (nQueryEntryCount == 1)
189 {
190 WriteDPCondition(aQueryParam.GetEntry(0), aQueryParam.bCaseSens, aQueryParam.eSearchType);
191 }
192 else if (bOr && !bAnd)
193 {
195 for (j = 0; j < nQueryEntryCount; ++j)
196 {
197 WriteDPCondition(aQueryParam.GetEntry(j), aQueryParam.bCaseSens, aQueryParam.eSearchType);
198 }
199 }
200 else if (bAnd && !bOr)
201 {
203 for (j = 0; j < nQueryEntryCount; ++j)
204 {
205 WriteDPCondition(aQueryParam.GetEntry(j), aQueryParam.bCaseSens, aQueryParam.eSearchType);
206 }
207 }
208 else
209 {
211 ScQueryEntry aPrevFilterField(aQueryParam.GetEntry(0));
212 ScQueryConnect aConnection = aQueryParam.GetEntry(1).eConnect;
213 bool bOpenAndElement;
215 if (aConnection == SC_AND)
216 {
217 rExport.StartElement( aName, true );
218 bOpenAndElement = true;
219 }
220 else
221 bOpenAndElement = false;
222 for (j = 1; j < nQueryEntryCount; ++j)
223 {
224 if (aConnection != aQueryParam.GetEntry(j).eConnect)
225 {
226 aConnection = aQueryParam.GetEntry(j).eConnect;
227 if (aQueryParam.GetEntry(j).eConnect == SC_AND)
228 {
229 rExport.StartElement( aName, true );
230 bOpenAndElement = true;
231 WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType);
232 aPrevFilterField = aQueryParam.GetEntry(j);
233 if (j == nQueryEntryCount - 1)
234 {
235 WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType);
236 rExport.EndElement(aName, true);
237 bOpenAndElement = false;
238 }
239 }
240 else
241 {
242 WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType);
243 aPrevFilterField = aQueryParam.GetEntry(j);
244 if (bOpenAndElement)
245 {
246 rExport.EndElement(aName, true);
247 bOpenAndElement = false;
248 }
249 if (j == nQueryEntryCount - 1)
250 {
251 WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType);
252 }
253 }
254 }
255 else
256 {
257 WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType);
258 aPrevFilterField = aQueryParam.GetEntry(j);
259 if (j == nQueryEntryCount - 1)
260 WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType);
261 }
262 }
263 }
264}
265
267{
268 const sheet::DataPilotFieldReference* pRef = pDim->GetReferenceValue();
269 if (pRef)
270 {
271 OUString sValueStr;
272 switch (pRef->ReferenceType)
273 {
275 sValueStr = GetXMLToken(XML_NONE);
276 break;
277 case sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE :
279 break;
280 case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE :
282 break;
283 case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE :
285 break;
286 case sheet::DataPilotFieldReferenceType::RUNNING_TOTAL :
287 sValueStr = GetXMLToken(XML_RUNNING_TOTAL);
288 break;
289 case sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE :
290 sValueStr = GetXMLToken(XML_ROW_PERCENTAGE);
291 break;
292 case sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE :
294 break;
295 case sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE :
297 break;
298 case sheet::DataPilotFieldReferenceType::INDEX :
299 sValueStr = GetXMLToken(XML_INDEX);
300 break;
301 }
302 if (!sValueStr.isEmpty())
304
305 if (!pRef->ReferenceField.isEmpty())
307
308 if (pRef->ReferenceItemType == sheet::DataPilotFieldReferenceItemType::NAMED)
309 {
311 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MEMBER_NAME, pRef->ReferenceItemName);
312 }
313 else
314 {
315 sValueStr.clear();
316 switch(pRef->ReferenceItemType)
317 {
318 case sheet::DataPilotFieldReferenceItemType::PREVIOUS :
319 sValueStr = GetXMLToken(XML_PREVIOUS);
320 break;
321 case sheet::DataPilotFieldReferenceItemType::NEXT :
322 sValueStr = GetXMLToken(XML_NEXT);
323 break;
324 }
325 if (!sValueStr.isEmpty())
327 }
329 }
331}
332
334{
335 const sheet::DataPilotFieldSortInfo* pSortInfo = pDim->GetSortInfo();
336 if (!pSortInfo)
337 return;
338
339 if (pSortInfo->IsAscending)
341 else
343
344 OUString sValueStr;
345 switch (pSortInfo->Mode)
346 {
348 sValueStr = GetXMLToken(XML_NONE);
349 break;
350 case sheet::DataPilotFieldSortMode::MANUAL:
351 sValueStr = GetXMLToken(XML_MANUAL);
352 break;
353 case sheet::DataPilotFieldSortMode::NAME:
354 sValueStr = GetXMLToken(XML_NAME);
355 break;
356 case sheet::DataPilotFieldSortMode::DATA:
357 sValueStr = GetXMLToken(XML_DATA);
358 if (!pSortInfo->Field.isEmpty())
360 break;
361 }
362 if (!sValueStr.isEmpty())
365}
366
368{
369 const sheet::DataPilotFieldAutoShowInfo* pAutoInfo = pDim->GetAutoShowInfo();
370 if (!pAutoInfo)
371 return;
372
373 if (pAutoInfo->IsEnabled)
375 else
377
378 OUString sValueStr;
379 switch (pAutoInfo->ShowItemsMode)
380 {
381 case sheet::DataPilotFieldShowItemsMode::FROM_TOP:
382 sValueStr = GetXMLToken(XML_FROM_TOP);
383 break;
384 case sheet::DataPilotFieldShowItemsMode::FROM_BOTTOM:
385 sValueStr = GetXMLToken(XML_FROM_BOTTOM);
386 break;
387 }
388 if (!sValueStr.isEmpty())
390
391 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MEMBER_COUNT, OUString::number(pAutoInfo->ItemCount));
392
394
396}
397
399{
400 const sheet::DataPilotFieldLayoutInfo* pLayoutInfo = pDim->GetLayoutInfo();
401 if (!pLayoutInfo)
402 return;
403
404 if (pLayoutInfo->AddEmptyLines)
406 else
408
409 OUString sValueStr;
410 switch (pLayoutInfo->LayoutMode)
411 {
412 case sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT:
413 sValueStr = GetXMLToken(XML_TABULAR_LAYOUT);
414 break;
415 case sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP:
417 break;
418 case sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM:
420 break;
421 }
422 if (!sValueStr.isEmpty())
425}
426
428{
429 sal_Int32 nSubTotalCount = pDim->GetSubTotalsCount();
430 std::optional<OUString> pLayoutName;
432 // Export display names only for 1.2 extended or later.
433 pLayoutName = pDim->GetSubtotalName();
434
435 if (nSubTotalCount <= 0)
436 return;
437
440 for (sal_Int32 nSubTotal = 0; nSubTotal < nSubTotalCount; nSubTotal++)
441 {
442 sal_Int16 nFunc = static_cast<sal_Int16>(pDim->GetSubTotalFunc(nSubTotal));
443 OUString sFunction = ScXMLConverter::GetStringFromFunction(nFunc);
445 if (pLayoutName && nFunc == sheet::GeneralFunction2::AUTO)
448 }
449}
450
452{
453 const ScDPSaveDimension::MemberList &rMembers = pDim->GetMembers();
454 if (rMembers.empty())
455 return;
456
459 for (const auto& rpMember : rMembers)
460 {
461 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, rpMember->GetName());
462
464 {
465 // Export display names only for ODF 1.2 extended or later.
466 const std::optional<OUString> & pLayoutName = rpMember->GetLayoutName();
467 if (pLayoutName)
469 }
470
471 OUStringBuffer sBuffer;
472 ::sax::Converter::convertBool(sBuffer, rpMember->GetIsVisible());
473 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, sBuffer.makeStringAndClear());
474 ::sax::Converter::convertBool(sBuffer, rpMember->GetShowDetails());
475 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_DETAILS, sBuffer.makeStringAndClear());
478 }
479}
480
482{
483 // #i114202# GetShowEmpty is only valid if HasShowEmpty is true.
484 if (pDim->HasShowEmpty())
485 {
486 OUStringBuffer sBuffer;
488 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_EMPTY, sBuffer.makeStringAndClear());
489 }
491 {
492 OUStringBuffer sBuffer;
495 }
497
498 WriteSubTotals(pDim);
499 WriteMembers(pDim);
500 WriteAutoShowInfo(pDim);
501 WriteSortInfo(pDim);
502 WriteLayoutInfo(pDim);
504}
505
507{
508 switch(nPart)
509 {
510 case css::sheet::DataPilotFieldGroupBy::SECONDS :
511 {
513 }
514 break;
515 case css::sheet::DataPilotFieldGroupBy::MINUTES :
516 {
518 }
519 break;
520 case css::sheet::DataPilotFieldGroupBy::HOURS :
521 {
523 }
524 break;
525 case css::sheet::DataPilotFieldGroupBy::DAYS :
526 {
528 }
529 break;
530 case css::sheet::DataPilotFieldGroupBy::MONTHS :
531 {
533 }
534 break;
535 case css::sheet::DataPilotFieldGroupBy::QUARTERS :
536 {
538 }
539 break;
540 case css::sheet::DataPilotFieldGroupBy::YEARS :
541 {
543 }
544 break;
545 }
546}
547
549{
550 OSL_ENSURE(rGroupInfo.mbEnable, "group dimension should be enabled");
551 if (rGroupInfo.mbDateValues)
552 {
553 if (rGroupInfo.mbAutoStart)
555 else
556 {
557 OUStringBuffer sDate;
559 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_START, sDate.makeStringAndClear());
560 }
561 if (rGroupInfo.mbAutoEnd)
563 else
564 {
565 OUStringBuffer sDate;
567 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_END, sDate.makeStringAndClear());
568 }
569 }
570 else
571 {
572 if (rGroupInfo.mbAutoStart)
574 else
575 {
576 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfStart,
577 rtl_math_StringFormat_Automatic,
578 rtl_math_DecimalPlaces_Max, '.', true));
580 }
581 if (rGroupInfo.mbAutoEnd)
583 else
584 {
585 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfEnd,
586 rtl_math_StringFormat_Automatic,
587 rtl_math_DecimalPlaces_Max, '.', true));
589 }
590 }
591 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfStep,
592 rtl_math_StringFormat_Automatic,
593 rtl_math_DecimalPlaces_Max, '.', true));
595}
596
598{
599 OUString aSrcFieldName = ScDPUtil::getSourceDimensionName(rGroupDim.GetSourceDimName());
601 if (rGroupDim.GetDatePart())
602 {
603 WriteDatePart(rGroupDim.GetDatePart());
604 WriteNumGroupInfo(rGroupDim.GetDateInfo());
605 }
606}
607
609{
610 if (rNumGroupDim.GetDatePart())
611 {
612 WriteDatePart(rNumGroupDim.GetDatePart());
613 WriteNumGroupInfo(rNumGroupDim.GetDateInfo());
614 }
615 else
616 {
617 WriteNumGroupInfo(rNumGroupDim.GetInfo());
618 }
619}
620
622{
623 const ScDPSaveGroupDimension* pGroupDim = nullptr;
624 const ScDPSaveNumGroupDimension* pNumGroupDim = nullptr;
625 if (pDimData)
626 {
627 pGroupDim = pDimData->GetNamedGroupDim(pDim->GetName());
628 pNumGroupDim = pDimData->GetNumGroupDim(pDim->GetName());
629 OSL_ENSURE((!pGroupDim || !pNumGroupDim), "there should be no NumGroup and Group at the same field");
630 if (pGroupDim)
631 WriteGroupDimAttributes(*pGroupDim);
632 else if (pNumGroupDim)
633 WriteNumGroupDim(*pNumGroupDim);
634 }
635 if (!(pGroupDim || pNumGroupDim))
636 return;
637
639 if (!pGroupDim)
640 return;
641
642 if (pGroupDim->GetDatePart())
643 return;
644
645 sal_Int32 nCount = pGroupDim->GetGroupCount();
646 for (sal_Int32 i = 0; i < nCount; ++i)
647 {
648 const ScDPSaveGroupItem& rGroup = pGroupDim->GetGroupByIndex( i );
651 sal_Int32 nElemCount = rGroup.GetElementCount();
652 for(sal_Int32 j = 0; j < nElemCount; ++j)
653 {
654 const OUString* pElem = rGroup.GetElementByIndex(j);
655 if (pElem)
656 {
659 }
660 }
661 }
662}
663
665{
666 OUString aSrcDimName = ScDPUtil::getSourceDimensionName(pDim->GetName());
669 {
670 // Export display names only for ODF 1.2 extended or later.
671 const std::optional<OUString> & pLayoutName = pDim->GetLayoutName();
672 if (pLayoutName)
674 }
675
676 if (pDim->IsDataLayout())
678 sheet::DataPilotFieldOrientation eOrientation = pDim->GetOrientation();
679 OUString sValueStr = ScXMLConverter::GetStringFromOrientation(eOrientation);
680 if( !sValueStr.isEmpty() )
682 if (pDim->GetUsedHierarchy() != 1)
683 {
685 }
686 sValueStr = ScXMLConverter::GetStringFromFunction( static_cast<sal_Int16>(pDim->GetFunction()) );
688
689 if (eOrientation == sheet::DataPilotFieldOrientation_PAGE)
690 {
692 {
694 }
696 }
697
699 WriteLevels(pDim);
701 if( pDim->GetOrientation() != sheet::DataPilotFieldOrientation_DATA )
702 WriteGroupDimElements(pDim, pDimData);
703}
704
706{
707 const ScDPSaveData::DimsType& rDimensions = pDPSave->GetDimensions();
708 for (auto const& iter : rDimensions)
709 {
710 WriteDimension(iter.get(),
711 pDPSave->GetExistingDimensionData());
712 }
713}
714
715void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const std::optional<OUString> & pGrandTotal)
716{
719 if (pGrandTotal)
721
723}
724
726{
728 if (!pDoc)
729 return;
730
732 if (!pDPs)
733 return;
734
735 size_t nDPCount = pDPs->GetCount();
736 if (!nDPCount)
737 return;
738
741 for (size_t i = 0; i < nDPCount; ++i)
742 {
743 ScDPSaveData* pDPSave = (*pDPs)[i].GetSaveData();
744 if (!pDPSave)
745 continue;
746
747 ScRange aOutRange((*pDPs)[i].GetOutRange());
748 OUString sTargetRangeAddress;
750 ScDocAttrIterator aAttrItr(*pDoc, aOutRange.aStart.Tab(),
751 aOutRange.aStart.Col(), aOutRange.aStart.Row(),
752 aOutRange.aEnd.Col(), aOutRange.aEnd.Row());
753 SCCOL nCol;
754 SCROW nRow1, nRow2;
755 OUString sOUButtonList;
756 const ScPatternAttr* pAttr = aAttrItr.GetNext(nCol, nRow1, nRow2);
757 while (pAttr)
758 {
759 const ScMergeFlagAttr& rItem = pAttr->GetItem(ATTR_MERGE_FLAG);
760 if (rItem.HasPivotButton())
761 {
762 for (SCROW nButtonRow = nRow1; nButtonRow <= nRow2; ++nButtonRow)
763 {
764 ScAddress aButtonAddr(nCol, nButtonRow, aOutRange.aStart.Tab());
766 sOUButtonList, aButtonAddr, pDoc, ::formula::FormulaGrammar::CONV_OOO, ' ', true );
767 }
768 }
769 pAttr = aAttrItr.GetNext(nCol, nRow1, nRow2);
770 }
771 OUString sName((*pDPs)[i].GetName());
772 OUString sApplicationData((*pDPs)[i].GetTag());
773 bool bRowGrand = pDPSave->GetRowGrand();
774 bool bColumnGrand = pDPSave->GetColumnGrand();
779 if (!(bRowGrand && bColumnGrand))
780 {
781 if (bRowGrand)
783 else if (bColumnGrand)
785 else
787 }
788 if (pDPSave->GetIgnoreEmptyRows())
790 if (pDPSave->GetRepeatIfEmpty())
792 if (!pDPSave->GetFilterButton())
794 if (!pDPSave->GetDrillDown())
796 if ((*pDPs)[i].GetHeaderLayout())
798
800
801 // grand total elements.
802
803 const std::optional<OUString> & pGrandTotalName = pDPSave->GetGrandTotalName();
805 {
806 // Use the new data-pilot-grand-total element.
807 if (bRowGrand && bColumnGrand)
808 {
809 WriteGrandTotal(XML_BOTH, true, pGrandTotalName);
810 }
811 else
812 {
813 WriteGrandTotal(XML_ROW, bRowGrand, pGrandTotalName);
814 WriteGrandTotal(XML_COLUMN, bColumnGrand, pGrandTotalName);
815 }
816 }
817
819 if ((*pDPs)[i].IsSheetData())
820 {
821 const ScSheetSourceDesc* pSheetSource = (*pDPs)[i].GetSheetDesc();
822
824 {
825 if (pSheetSource->HasRangeName())
826 { // ODF 1.3 OFFICE-3665
827 // FIXME this was wrongly exported to TABLE namespace since 2011
828 // so continue doing that in ODF 1.2 extended, for now
830 XML_NAMESPACE_TABLE, XML_NAME, pSheetSource->GetRangeName());
831 }
832 }
833
834 OUString sCellRangeAddress;
836 sCellRangeAddress, pSheetSource->GetSourceRange(), pDoc,
838
842 WriteDPFilter(pSheetSource->GetQueryParam());
843 }
844 else if ((*pDPs)[i].IsImportData())
845 {
846 const ScImportSourceDesc* pImpSource = (*pDPs)[i].GetImportSourceDesc();
847 switch (pImpSource->nType)
848 {
849 case sheet::DataImportMode_NONE : break;
850 case sheet::DataImportMode_QUERY :
851 {
856 }
857 break;
858 case sheet::DataImportMode_TABLE :
859 {
864 }
865 break;
866 case sheet::DataImportMode_SQL :
867 {
870 if (!pImpSource->bNative)
874 }
875 break;
876 default: break;
877 }
878 }
879 else if ((*pDPs)[i].IsServiceData())
880 {
881 const ScDPServiceDesc* pServSource = (*pDPs)[i].GetDPServiceDesc();
886 // #i111754# leave out password attribute as long as DataPilotSource doesn't specify the content
887 // rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_PASSWORD, OUString(pServSource->aParPass));
890 }
891 WriteDimensions(pDPSave);
892 }
893}
894
895/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
const SCTAB SCTAB_MAX
Definition: address.hxx:57
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
SC_DLLPUBLIC size_t GetCount() const
Definition: dpobject.cxx:3689
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:164
const ScDPSaveGroupDimension * GetNamedGroupDim(const OUString &rGroupDimName) const
Definition: dpdimsave.cxx:636
const ScDPSaveNumGroupDimension * GetNumGroupDim(const OUString &rGroupDimName) const
Definition: dpdimsave.cxx:651
bool GetDrillDown() const
Definition: dpsave.hxx:342
bool GetFilterButton() const
Definition: dpsave.hxx:338
bool GetIgnoreEmptyRows() const
Definition: dpsave.hxx:330
bool GetRepeatIfEmpty() const
Definition: dpsave.hxx:334
SC_DLLPUBLIC const std::optional< OUString > & GetGrandTotalName() const
Definition: dpsave.cxx:772
bool GetRowGrand() const
Definition: dpsave.hxx:326
bool GetColumnGrand() const
Definition: dpsave.hxx:322
std::vector< std::unique_ptr< ScDPSaveDimension > > DimsType
Definition: dpsave.hxx:238
const DimsType & GetDimensions() const
Definition: dpsave.hxx:270
const ScDPDimensionSaveData * GetExistingDimensionData() const
Definition: dpsave.hxx:348
const css::sheet::DataPilotFieldSortInfo * GetSortInfo() const
Definition: dpsave.hxx:186
tools::Long GetUsedHierarchy() const
Definition: dpsave.hxx:169
bool HasShowEmpty() const
Definition: dpsave.cxx:330
OUString GetCurrentPage() const
Definition: dpsave.cxx:440
ScGeneralFunction GetSubTotalFunc(tools::Long nIndex) const
Definition: dpsave.hxx:152
css::sheet::DataPilotFieldOrientation GetOrientation() const
Definition: dpsave.hxx:202
const css::sheet::DataPilotFieldLayoutInfo * GetLayoutInfo() const
Definition: dpsave.hxx:194
const css::sheet::DataPilotFieldAutoShowInfo * GetAutoShowInfo() const
Definition: dpsave.hxx:190
const std::optional< OUString > & GetSubtotalName() const
Definition: dpsave.cxx:360
const std::optional< OUString > & GetLayoutName() const
Definition: dpsave.cxx:386
ScGeneralFunction GetFunction() const
Definition: dpsave.hxx:165
tools::Long GetSubTotalsCount() const
Definition: dpsave.hxx:149
const css::sheet::DataPilotFieldReference * GetReferenceValue() const
Definition: dpsave.hxx:181
const MemberList & GetMembers() const
Definition: dpsave.hxx:128
std::vector< ScDPSaveMember * > MemberList
Definition: dpsave.hxx:115
bool GetRepeatItemLabels() const
Definition: dpsave.hxx:161
bool IsDataLayout() const
Definition: dpsave.hxx:142
const OUString & GetName() const
Definition: dpsave.hxx:139
bool GetShowEmpty() const
Definition: dpsave.hxx:157
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID.
Definition: dpdimsave.hxx:91
const OUString & GetSourceDimName() const
Definition: dpdimsave.hxx:108
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:111
sal_Int32 GetDatePart() const
Definition: dpdimsave.hxx:110
tools::Long GetGroupCount() const
Definition: dpdimsave.cxx:199
const ScDPSaveGroupItem & GetGroupByIndex(tools::Long nIndex) const
Definition: dpdimsave.cxx:204
Classes to save Data Pilot settings that create new dimensions (fields).
Definition: dpdimsave.hxx:47
size_t GetElementCount() const
Definition: dpdimsave.cxx:72
const OUString & GetGroupName() const
Definition: dpdimsave.hxx:65
const OUString * GetElementByIndex(size_t nIndex) const
Definition: dpdimsave.cxx:77
Represents a group dimension that introduces a new hierarchy for an existing dimension.
Definition: dpdimsave.hxx:136
sal_Int32 GetDatePart() const
Definition: dpdimsave.hxx:152
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:153
const ScDPNumGroupInfo & GetInfo() const
Definition: dpdimsave.hxx:150
static SC_DLLPUBLIC OUString getSourceDimensionName(std::u16string_view rName)
Definition: dputil.cxx:66
const ScPatternAttr * GetNext(SCCOL &rCol, SCROW &rRow1, SCROW &rRow2)
Definition: dociter.cxx:1584
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
Definition: documen3.cxx:371
bool HasPivotButton() const
Definition: attrib.cxx:148
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:72
static void GetStringFromRange(OUString &rString, const ScRange &rRange, const ScDocument *pDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator=' ', bool bAppendStr=false, ScRefFlags nFormatFlags=ScRefFlags::VALID|ScRefFlags::TAB_3D)
static void GetStringFromAddress(OUString &rString, const ScAddress &rAddress, const ScDocument *pDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator=' ', bool bAppendStr=false, ScRefFlags nFormatFlags=ScRefFlags::VALID|ScRefFlags::TAB_3D)
Range to String core.
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:40
const OUString & GetRangeName() const
Definition: dpshttab.hxx:60
const ScQueryParam & GetQueryParam() const
Definition: dpshttab.hxx:63
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
Definition: dpshttab.cxx:230
bool HasRangeName() const
Definition: dpshttab.cxx:265
static OUString GetStringFromOrientation(const css::sheet::DataPilotFieldOrientation eOrientation)
static OUString GetStringFromFunction(const sal_Int16 eFunction)
void WriteDatePart(sal_Int32 nPart)
ScXMLExportDataPilot(ScXMLExport &rExport)
static OUString getDPOperatorXML(const ScQueryOp aFilterOperator, const utl::SearchParam::SearchType eSearchType)
void WriteDPCondition(const ScQueryEntry &aQueryEntry, bool bIsCaseSensitive, utl::SearchParam::SearchType eSearchType)
void WriteFieldReference(const ScDPSaveDimension *pDim)
void WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const std::optional< OUString > &pGrandTotal)
void WriteNumGroupInfo(const ScDPNumGroupInfo &pGroupInfo)
void WriteLayoutInfo(const ScDPSaveDimension *pDim)
void WriteSortInfo(const ScDPSaveDimension *pDim)
void WriteMembers(const ScDPSaveDimension *pDim)
void WriteLevels(const ScDPSaveDimension *pDim)
void WriteAutoShowInfo(const ScDPSaveDimension *pDim)
void WriteNumGroupDim(const ScDPSaveNumGroupDimension &rNumGroupDim)
void WriteDPFilter(const ScQueryParam &aQueryParam)
void WriteDimension(const ScDPSaveDimension *pDim, const ScDPDimensionSaveData *pDimData)
void WriteSubTotals(const ScDPSaveDimension *pDim)
void WriteGroupDimAttributes(const ScDPSaveGroupDimension &rGroupDim)
void WriteGroupDimElements(const ScDPSaveDimension *pDim, const ScDPDimensionSaveData *pDimData)
void WriteDimensions(const ScDPSaveData *pDPSave)
ScDocument * GetDocument()
Definition: xmlexprt.hxx:240
const SvXMLNamespaceMap & GetNamespaceMap() const
void StartElement(sal_uInt16 nPrefix, enum ::xmloff::token::XMLTokenEnum eName, bool bIgnWSOutside)
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
void CheckAttrList()
const SvXMLUnitConverter & GetMM100UnitConverter() const
void EndElement(sal_uInt16 nPrefix, enum ::xmloff::token::XMLTokenEnum eName, bool bIgnWSInside)
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
void convertDateTime(OUStringBuffer &rBuffer, const double &fDateTime, bool const bAddTimeIf0AM=false)
static bool convertBool(bool &rBool, std::u16string_view rString)
const OUString & getString() const
int nCount
virtual OUString GetName() const override
ScQueryConnect
Definition: global.hxx:853
@ SC_AND
Definition: global.hxx:854
ScQueryOp
Definition: global.hxx:833
@ SC_LESS_EQUAL
Definition: global.hxx:837
@ SC_LESS
Definition: global.hxx:835
@ SC_GREATER_EQUAL
Definition: global.hxx:838
@ SC_TOPPERC
Definition: global.hxx:842
@ SC_TOPVAL
Definition: global.hxx:840
@ SC_GREATER
Definition: global.hxx:836
@ SC_EQUAL
Definition: global.hxx:834
@ SC_BOTPERC
Definition: global.hxx:843
@ SC_NOT_EQUAL
Definition: global.hxx:839
@ SC_BOTVAL
Definition: global.hxx:841
OUString aName
const char * sName
int i
XML_DATA_PILOT_FIELD_REFERENCE
XML_IDENTIFY_CATEGORIES
XML_COLUMN_PERCENTAGE
XML_DATA_PILOT_DISPLAY_INFO
XML_QUARTERS
XML_ORDER
XML_NOMATCH
XML_FIELD_NUMBER
XML_DATA_PILOT_LAYOUT_INFO
XML_MEMBER_NAME
XML_ASCENDING
XML_PARSE_SQL_STATEMENT
XML_START
XML_CONDITION_SOURCE_RANGE_ADDRESS
XML_MEMBER_COUNT
XML_DATA_PILOT_GROUP
XML_FILTER
XML_AUTO
XML_OBJECT_NAME
XML_CELL_RANGE_ADDRESS
XML_COLUMN
XML_PREVIOUS
XML_DATABASE_NAME
XML_DATE_END
XML_QUERY_NAME
XML_OUTLINE_SUBTOTALS_TOP
XML_FIELD_NAME
XML_OPERATOR
XML_CASE_SENSITIVE
XML_MEMBER_PERCENTAGE_DIFFERENCE
XML_ENABLED
XML_DATA_FIELD
XML_ROW
XML_DATA_PILOT_GROUPS
XML_HEADER_GRID_LAYOUT
XML_DATA_PILOT_SUBTOTAL
XML_DATA_PILOT_GROUP_MEMBER
XML_YEARS
XML_END
XML_MANUAL
XML_DISPLAY
XML_TRUE
XML_LAYOUT_MODE
XML_DATABASE_TABLE_NAME
XML_SOURCE_NAME
XML_NONE
XML_MEMBER_DIFFERENCE
XML_USED_HIERARCHY
XML_DATA
XML_SOURCE_SERVICE
XML_TOP_PERCENT
XML_FUNCTION
XML_DATABASE_SOURCE_QUERY
XML_HOURS
XML_USER_NAME
XML_OUTLINE_SUBTOTALS_BOTTOM
XML_SORT_MODE
XML_MINUTES
XML_DATA_PILOT_SUBTOTALS
XML_DATA_PILOT_MEMBER
XML_DATA_PILOT_FIELD
XML_NOEMPTY
XML_MONTHS
XML_REPEAT_ITEM_LABELS
XML_SELECTED_PAGE
XML_SOURCE_FIELD_NAME
XML_DAYS
XML_BUTTONS
XML_NUMBER
XML_MATCH
XML_APPLICATION_DATA
XML_SHOW_FILTER_BUTTON
XML_SECONDS
XML_TOTAL_PERCENTAGE
XML_GROUPED_BY
XML_SHOW_EMPTY
XML_DISPLAY_MEMBER_MODE
XML_TOP_VALUES
XML_DATA_PILOT_SORT_INFO
XML_VALUE
XML_DISPLAY_NAME
XML_FALSE
XML_IS_DATA_LAYOUT_FIELD
XML_EMPTY
XML_DATE_START
XML_BOTTOM_VALUES
XML_RUNNING_TOTAL
XML_FILTER_CONDITION
XML_SQL_STATEMENT
XML_SHOW_DETAILS
XML_INDEX
XML_NAME
XML_FILTER_OR
XML_TARGET_RANGE_ADDRESS
XML_FILTER_AND
XML_MEMBER_PERCENTAGE
XML_STEP
XML_IGNORE_EMPTY_ROWS
XML_BOTTOM_PERCENT
XML_FROM_BOTTOM
XML_DATA_PILOT_LEVEL
XML_DATA_PILOT_TABLES
XML_GRAND_TOTAL
XML_DATA_PILOT_MEMBERS
XML_ADD_EMPTY_LINES
XML_DISPLAY_DUPLICATES
XML_DATA_TYPE
XML_NAMED
XML_IGNORE_SELECTED_PAGE
XML_SOURCE_CELL_RANGE
XML_DATABASE_SOURCE_TABLE
XML_DESCENDING
XML_DRILL_DOWN_ON_DOUBLE_CLICK
XML_ORIENTATION
XML_DATABASE_SOURCE_SQL
XML_MEMBER_TYPE
XML_ROW_PERCENTAGE
XML_TABULAR_LAYOUT
XML_FROM_TOP
XML_NEXT
XML_DATA_PILOT_GRAND_TOTAL
XML_DATA_PILOT_TABLE
XML_BOTH
XML_TYPE
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
OUString aParName
Definition: dpobject.hxx:73
OUString aParSource
Definition: dpobject.hxx:72
OUString aParUser
Definition: dpobject.hxx:74
OUString aServiceName
Definition: dpobject.hxx:71
css::sheet::DataImportMode nType
Definition: dpsdbtab.hxx:37
OUString aObject
Definition: dpsdbtab.hxx:36
OUString aDBName
Definition: dpsdbtab.hxx:35
svl::SharedString maString
Definition: queryentry.hxx:49
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:34
SCCOLROW nField
Definition: queryentry.hxx:61
bool IsQueryByNonEmpty() const
Definition: queryentry.cxx:109
const Item & GetQueryItem() const
Definition: queryentry.hxx:85
ScQueryConnect eConnect
Definition: queryentry.hxx:63
bool IsQueryByEmpty() const
Definition: queryentry.cxx:87
ScQueryOp eOp
Definition: queryentry.hxx:62
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
Definition: queryparam.cxx:116
utl::SearchParam::SearchType eSearchType
Definition: queryparam.hxx:43
SC_DLLPUBLIC SCSIZE GetEntryCount() const
Definition: queryparam.cxx:111
bool bVisible
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
constexpr sal_uInt16 XML_NAMESPACE_TABLE_EXT
constexpr sal_uInt16 XML_NAMESPACE_TABLE
constexpr sal_uInt16 XML_NAMESPACE_CALC_EXT
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT