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 case sheet::DataPilotFieldLayoutMode::COMPACT_LAYOUT:
422 sValueStr = GetXMLToken(XML_TABULAR_LAYOUT);
423 break;
424 }
425
426 if (!sValueStr.isEmpty())
428
429 if (pLayoutInfo->LayoutMode == sheet::DataPilotFieldLayoutMode::COMPACT_LAYOUT)
431
433}
434
436{
437 sal_Int32 nSubTotalCount = pDim->GetSubTotalsCount();
438 std::optional<OUString> pLayoutName;
440 // Export display names only for 1.2 extended or later.
441 pLayoutName = pDim->GetSubtotalName();
442
443 if (nSubTotalCount <= 0)
444 return;
445
448 for (sal_Int32 nSubTotal = 0; nSubTotal < nSubTotalCount; nSubTotal++)
449 {
450 sal_Int16 nFunc = static_cast<sal_Int16>(pDim->GetSubTotalFunc(nSubTotal));
451 OUString sFunction = ScXMLConverter::GetStringFromFunction(nFunc);
453 if (pLayoutName && nFunc == sheet::GeneralFunction2::AUTO)
456 }
457}
458
460{
461 const ScDPSaveDimension::MemberList &rMembers = pDim->GetMembers();
462 if (rMembers.empty())
463 return;
464
467 for (const auto& rpMember : rMembers)
468 {
469 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, rpMember->GetName());
470
472 {
473 // Export display names only for ODF 1.2 extended or later.
474 const std::optional<OUString> & pLayoutName = rpMember->GetLayoutName();
475 if (pLayoutName)
477 }
478
479 OUStringBuffer sBuffer;
480 ::sax::Converter::convertBool(sBuffer, rpMember->GetIsVisible());
481 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, sBuffer.makeStringAndClear());
482 ::sax::Converter::convertBool(sBuffer, rpMember->GetShowDetails());
483 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_DETAILS, sBuffer.makeStringAndClear());
486 }
487}
488
490{
491 // #i114202# GetShowEmpty is only valid if HasShowEmpty is true.
492 if (pDim->HasShowEmpty())
493 {
494 OUStringBuffer sBuffer;
496 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_EMPTY, sBuffer.makeStringAndClear());
497 }
499 {
500 OUStringBuffer sBuffer;
503 }
505
506 WriteSubTotals(pDim);
507 WriteMembers(pDim);
508 WriteAutoShowInfo(pDim);
509 WriteSortInfo(pDim);
510 WriteLayoutInfo(pDim);
512}
513
515{
516 switch(nPart)
517 {
518 case css::sheet::DataPilotFieldGroupBy::SECONDS :
519 {
521 }
522 break;
523 case css::sheet::DataPilotFieldGroupBy::MINUTES :
524 {
526 }
527 break;
528 case css::sheet::DataPilotFieldGroupBy::HOURS :
529 {
531 }
532 break;
533 case css::sheet::DataPilotFieldGroupBy::DAYS :
534 {
536 }
537 break;
538 case css::sheet::DataPilotFieldGroupBy::MONTHS :
539 {
541 }
542 break;
543 case css::sheet::DataPilotFieldGroupBy::QUARTERS :
544 {
546 }
547 break;
548 case css::sheet::DataPilotFieldGroupBy::YEARS :
549 {
551 }
552 break;
553 }
554}
555
557{
558 OSL_ENSURE(rGroupInfo.mbEnable, "group dimension should be enabled");
559 if (rGroupInfo.mbDateValues)
560 {
561 if (rGroupInfo.mbAutoStart)
563 else
564 {
565 OUStringBuffer sDate;
567 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_START, sDate.makeStringAndClear());
568 }
569 if (rGroupInfo.mbAutoEnd)
571 else
572 {
573 OUStringBuffer sDate;
575 rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATE_END, sDate.makeStringAndClear());
576 }
577 }
578 else
579 {
580 if (rGroupInfo.mbAutoStart)
582 else
583 {
584 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfStart,
585 rtl_math_StringFormat_Automatic,
586 rtl_math_DecimalPlaces_Max, '.', true));
588 }
589 if (rGroupInfo.mbAutoEnd)
591 else
592 {
593 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfEnd,
594 rtl_math_StringFormat_Automatic,
595 rtl_math_DecimalPlaces_Max, '.', true));
597 }
598 }
599 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.mfStep,
600 rtl_math_StringFormat_Automatic,
601 rtl_math_DecimalPlaces_Max, '.', true));
603}
604
606{
607 OUString aSrcFieldName = ScDPUtil::getSourceDimensionName(rGroupDim.GetSourceDimName());
609 if (rGroupDim.GetDatePart())
610 {
611 WriteDatePart(rGroupDim.GetDatePart());
612 WriteNumGroupInfo(rGroupDim.GetDateInfo());
613 }
614}
615
617{
618 if (rNumGroupDim.GetDatePart())
619 {
620 WriteDatePart(rNumGroupDim.GetDatePart());
621 WriteNumGroupInfo(rNumGroupDim.GetDateInfo());
622 }
623 else
624 {
625 WriteNumGroupInfo(rNumGroupDim.GetInfo());
626 }
627}
628
630{
631 const ScDPSaveGroupDimension* pGroupDim = nullptr;
632 const ScDPSaveNumGroupDimension* pNumGroupDim = nullptr;
633 if (pDimData)
634 {
635 pGroupDim = pDimData->GetNamedGroupDim(pDim->GetName());
636 pNumGroupDim = pDimData->GetNumGroupDim(pDim->GetName());
637 OSL_ENSURE((!pGroupDim || !pNumGroupDim), "there should be no NumGroup and Group at the same field");
638 if (pGroupDim)
639 WriteGroupDimAttributes(*pGroupDim);
640 else if (pNumGroupDim)
641 WriteNumGroupDim(*pNumGroupDim);
642 }
643 if (!(pGroupDim || pNumGroupDim))
644 return;
645
647 if (!pGroupDim)
648 return;
649
650 if (pGroupDim->GetDatePart())
651 return;
652
653 sal_Int32 nCount = pGroupDim->GetGroupCount();
654 for (sal_Int32 i = 0; i < nCount; ++i)
655 {
656 const ScDPSaveGroupItem& rGroup = pGroupDim->GetGroupByIndex( i );
659 sal_Int32 nElemCount = rGroup.GetElementCount();
660 for(sal_Int32 j = 0; j < nElemCount; ++j)
661 {
662 const OUString* pElem = rGroup.GetElementByIndex(j);
663 if (pElem)
664 {
667 }
668 }
669 }
670}
671
673{
674 OUString aSrcDimName = ScDPUtil::getSourceDimensionName(pDim->GetName());
677 {
678 // Export display names only for ODF 1.2 extended or later.
679 const std::optional<OUString> & pLayoutName = pDim->GetLayoutName();
680 if (pLayoutName)
682 }
683
684 if (pDim->IsDataLayout())
686 sheet::DataPilotFieldOrientation eOrientation = pDim->GetOrientation();
687 OUString sValueStr = ScXMLConverter::GetStringFromOrientation(eOrientation);
688 if( !sValueStr.isEmpty() )
690 if (pDim->GetUsedHierarchy() != 1)
691 {
693 }
694 sValueStr = ScXMLConverter::GetStringFromFunction( static_cast<sal_Int16>(pDim->GetFunction()) );
696
697 if (eOrientation == sheet::DataPilotFieldOrientation_PAGE)
698 {
700 {
702 }
704 }
705
707 WriteLevels(pDim);
709 if( pDim->GetOrientation() != sheet::DataPilotFieldOrientation_DATA )
710 WriteGroupDimElements(pDim, pDimData);
711}
712
714{
715 const ScDPSaveData::DimsType& rDimensions = pDPSave->GetDimensions();
716 for (auto const& iter : rDimensions)
717 {
718 WriteDimension(iter.get(),
719 pDPSave->GetExistingDimensionData());
720 }
721}
722
723void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const std::optional<OUString> & pGrandTotal)
724{
727 if (pGrandTotal)
729
731}
732
734{
736 if (!pDoc)
737 return;
738
740 if (!pDPs)
741 return;
742
743 size_t nDPCount = pDPs->GetCount();
744 if (!nDPCount)
745 return;
746
749 for (size_t i = 0; i < nDPCount; ++i)
750 {
751 ScDPSaveData* pDPSave = (*pDPs)[i].GetSaveData();
752 if (!pDPSave)
753 continue;
754
755 ScRange aOutRange((*pDPs)[i].GetOutRange());
756 OUString sTargetRangeAddress;
758 ScDocAttrIterator aAttrItr(*pDoc, aOutRange.aStart.Tab(),
759 aOutRange.aStart.Col(), aOutRange.aStart.Row(),
760 aOutRange.aEnd.Col(), aOutRange.aEnd.Row());
761 SCCOL nCol;
762 SCROW nRow1, nRow2;
763 OUString sOUButtonList;
764 const ScPatternAttr* pAttr = aAttrItr.GetNext(nCol, nRow1, nRow2);
765 while (pAttr)
766 {
767 const ScMergeFlagAttr& rItem = pAttr->GetItem(ATTR_MERGE_FLAG);
768 if (rItem.HasPivotButton())
769 {
770 for (SCROW nButtonRow = nRow1; nButtonRow <= nRow2; ++nButtonRow)
771 {
772 ScAddress aButtonAddr(nCol, nButtonRow, aOutRange.aStart.Tab());
774 sOUButtonList, aButtonAddr, pDoc, ::formula::FormulaGrammar::CONV_OOO, ' ', true );
775 }
776 }
777 pAttr = aAttrItr.GetNext(nCol, nRow1, nRow2);
778 }
779 OUString sName((*pDPs)[i].GetName());
780 OUString sApplicationData((*pDPs)[i].GetTag());
781 bool bRowGrand = pDPSave->GetRowGrand();
782 bool bColumnGrand = pDPSave->GetColumnGrand();
787 if (!(bRowGrand && bColumnGrand))
788 {
789 if (bRowGrand)
791 else if (bColumnGrand)
793 else
795 }
796 if (pDPSave->GetIgnoreEmptyRows())
798 if (pDPSave->GetRepeatIfEmpty())
800 if (!pDPSave->GetFilterButton())
802 if (!pDPSave->GetDrillDown())
804 if (pDPSave->GetExpandCollapse())
806 if ((*pDPs)[i].GetHeaderLayout())
808
810
811 // grand total elements.
812
813 const std::optional<OUString> & pGrandTotalName = pDPSave->GetGrandTotalName();
815 {
816 // Use the new data-pilot-grand-total element.
817 if (bRowGrand && bColumnGrand)
818 {
819 WriteGrandTotal(XML_BOTH, true, pGrandTotalName);
820 }
821 else
822 {
823 WriteGrandTotal(XML_ROW, bRowGrand, pGrandTotalName);
824 WriteGrandTotal(XML_COLUMN, bColumnGrand, pGrandTotalName);
825 }
826 }
827
829 if ((*pDPs)[i].IsSheetData())
830 {
831 const ScSheetSourceDesc* pSheetSource = (*pDPs)[i].GetSheetDesc();
832
834 {
835 if (pSheetSource->HasRangeName())
836 { // ODF 1.3 OFFICE-3665
837 // FIXME this was wrongly exported to TABLE namespace since 2011
838 // so continue doing that in ODF 1.2 extended, for now
840 XML_NAMESPACE_TABLE, XML_NAME, pSheetSource->GetRangeName());
841 }
842 }
843
844 OUString sCellRangeAddress;
846 sCellRangeAddress, pSheetSource->GetSourceRange(), pDoc,
848
852 WriteDPFilter(pSheetSource->GetQueryParam());
853 }
854 else if ((*pDPs)[i].IsImportData())
855 {
856 const ScImportSourceDesc* pImpSource = (*pDPs)[i].GetImportSourceDesc();
857 switch (pImpSource->nType)
858 {
859 case sheet::DataImportMode_NONE : break;
860 case sheet::DataImportMode_QUERY :
861 {
866 }
867 break;
868 case sheet::DataImportMode_TABLE :
869 {
874 }
875 break;
876 case sheet::DataImportMode_SQL :
877 {
880 if (!pImpSource->bNative)
884 }
885 break;
886 default: break;
887 }
888 }
889 else if ((*pDPs)[i].IsServiceData())
890 {
891 const ScDPServiceDesc* pServSource = (*pDPs)[i].GetDPServiceDesc();
896 // #i111754# leave out password attribute as long as DataPilotSource doesn't specify the content
897 // rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_PASSWORD, OUString(pServSource->aParPass));
900 }
901 WriteDimensions(pDPSave);
902 }
903}
904
905/* 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:3717
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:343
bool GetFilterButton() const
Definition: dpsave.hxx:339
bool GetIgnoreEmptyRows() const
Definition: dpsave.hxx:331
bool GetRepeatIfEmpty() const
Definition: dpsave.hxx:335
SC_DLLPUBLIC const std::optional< OUString > & GetGrandTotalName() const
Definition: dpsave.cxx:774
bool GetRowGrand() const
Definition: dpsave.hxx:327
bool GetColumnGrand() const
Definition: dpsave.hxx:323
bool GetExpandCollapse() const
Definition: dpsave.hxx:347
std::vector< std::unique_ptr< ScDPSaveDimension > > DimsType
Definition: dpsave.hxx:238
const DimsType & GetDimensions() const
Definition: dpsave.hxx:271
const ScDPDimensionSaveData * GetExistingDimensionData() const
Definition: dpsave.hxx:353
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:1588
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
Definition: documen3.cxx:365
bool HasPivotButton() const
Definition: attrib.cxx:148
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:73
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
OUString sName
ScQueryConnect
Definition: global.hxx:854
@ SC_AND
Definition: global.hxx:855
ScQueryOp
Definition: global.hxx:834
@ SC_LESS_EQUAL
Definition: global.hxx:838
@ SC_LESS
Definition: global.hxx:836
@ SC_GREATER_EQUAL
Definition: global.hxx:839
@ SC_TOPPERC
Definition: global.hxx:843
@ SC_TOPVAL
Definition: global.hxx:841
@ SC_GREATER
Definition: global.hxx:837
@ SC_EQUAL
Definition: global.hxx:835
@ SC_BOTPERC
Definition: global.hxx:844
@ SC_NOT_EQUAL
Definition: global.hxx:840
@ SC_BOTVAL
Definition: global.hxx:842
OUString aName
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_SHOW_DRILL_DOWN_BUTTONS
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_COMPACT_LAYOUT
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