26#include <rtl/math.hxx>
27#include <osl/diagnose.h>
30#include <document.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>
60 : rExport(rTempExport),
68 switch (aFilterOperator)
101 OSL_FAIL(
"This FilterOperator is not supported.");
110 if (bIsCaseSensitive)
143 if (nQueryEntryCount <= 0)
148 bool bHasEntries(
true);
152 for ( j = 0; (j < nQueryEntryCount) && bHasEntries; ++j)
169 nQueryEntryCount = nEntries;
170 if (!nQueryEntryCount)
179 OUString sConditionRange;
181 if (!sConditionRange.isEmpty())
188 if (nQueryEntryCount == 1)
192 else if (bOr && !bAnd)
195 for (j = 0; j < nQueryEntryCount; ++j)
200 else if (bAnd && !bOr)
203 for (j = 0; j < nQueryEntryCount; ++j)
213 bool bOpenAndElement;
215 if (aConnection ==
SC_AND)
218 bOpenAndElement =
true;
221 bOpenAndElement =
false;
222 for (j = 1; j < nQueryEntryCount; ++j)
230 bOpenAndElement =
true;
232 aPrevFilterField = aQueryParam.
GetEntry(j);
233 if (j == nQueryEntryCount - 1)
237 bOpenAndElement =
false;
243 aPrevFilterField = aQueryParam.
GetEntry(j);
247 bOpenAndElement =
false;
249 if (j == nQueryEntryCount - 1)
258 aPrevFilterField = aQueryParam.
GetEntry(j);
259 if (j == nQueryEntryCount - 1)
272 switch (pRef->ReferenceType)
277 case sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE :
280 case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE :
283 case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE :
286 case sheet::DataPilotFieldReferenceType::RUNNING_TOTAL :
289 case sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE :
292 case sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE :
295 case sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE :
298 case sheet::DataPilotFieldReferenceType::INDEX :
302 if (!sValueStr.isEmpty())
305 if (!pRef->ReferenceField.isEmpty())
308 if (pRef->ReferenceItemType == sheet::DataPilotFieldReferenceItemType::NAMED)
316 switch(pRef->ReferenceItemType)
318 case sheet::DataPilotFieldReferenceItemType::PREVIOUS :
321 case sheet::DataPilotFieldReferenceItemType::NEXT :
325 if (!sValueStr.isEmpty())
335 const sheet::DataPilotFieldSortInfo* pSortInfo = pDim->
GetSortInfo();
339 if (pSortInfo->IsAscending)
345 switch (pSortInfo->Mode)
350 case sheet::DataPilotFieldSortMode::MANUAL:
353 case sheet::DataPilotFieldSortMode::NAME:
356 case sheet::DataPilotFieldSortMode::DATA:
358 if (!pSortInfo->Field.isEmpty())
362 if (!sValueStr.isEmpty())
369 const sheet::DataPilotFieldAutoShowInfo* pAutoInfo = pDim->
GetAutoShowInfo();
373 if (pAutoInfo->IsEnabled)
379 switch (pAutoInfo->ShowItemsMode)
381 case sheet::DataPilotFieldShowItemsMode::FROM_TOP:
384 case sheet::DataPilotFieldShowItemsMode::FROM_BOTTOM:
388 if (!sValueStr.isEmpty())
400 const sheet::DataPilotFieldLayoutInfo* pLayoutInfo = pDim->
GetLayoutInfo();
404 if (pLayoutInfo->AddEmptyLines)
410 switch (pLayoutInfo->LayoutMode)
412 case sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT:
415 case sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP:
418 case sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM:
421 case sheet::DataPilotFieldLayoutMode::COMPACT_LAYOUT:
426 if (!sValueStr.isEmpty())
429 if (pLayoutInfo->LayoutMode == sheet::DataPilotFieldLayoutMode::COMPACT_LAYOUT)
438 std::optional<OUString> pLayoutName;
443 if (nSubTotalCount <= 0)
448 for (sal_Int32 nSubTotal = 0; nSubTotal < nSubTotalCount; nSubTotal++)
450 sal_Int16 nFunc =
static_cast<sal_Int16
>(pDim->
GetSubTotalFunc(nSubTotal));
453 if (pLayoutName && nFunc == sheet::GeneralFunction2::AUTO)
462 if (rMembers.empty())
467 for (
const auto& rpMember : rMembers)
474 const std::optional<OUString> & pLayoutName = rpMember->GetLayoutName();
479 OUStringBuffer sBuffer;
494 OUStringBuffer sBuffer;
500 OUStringBuffer sBuffer;
518 case css::sheet::DataPilotFieldGroupBy::SECONDS :
523 case css::sheet::DataPilotFieldGroupBy::MINUTES :
528 case css::sheet::DataPilotFieldGroupBy::HOURS :
533 case css::sheet::DataPilotFieldGroupBy::DAYS :
538 case css::sheet::DataPilotFieldGroupBy::MONTHS :
543 case css::sheet::DataPilotFieldGroupBy::QUARTERS :
548 case css::sheet::DataPilotFieldGroupBy::YEARS :
558 OSL_ENSURE(rGroupInfo.
mbEnable,
"group dimension should be enabled");
565 OUStringBuffer sDate;
573 OUStringBuffer sDate;
584 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.
mfStart,
585 rtl_math_StringFormat_Automatic,
586 rtl_math_DecimalPlaces_Max,
'.',
true));
593 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.
mfEnd,
594 rtl_math_StringFormat_Automatic,
595 rtl_math_DecimalPlaces_Max,
'.',
true));
599 OUString sValue( ::rtl::math::doubleToUString( rGroupInfo.
mfStep,
600 rtl_math_StringFormat_Automatic,
601 rtl_math_DecimalPlaces_Max,
'.',
true));
637 OSL_ENSURE((!pGroupDim || !pNumGroupDim),
"there should be no NumGroup and Group at the same field");
640 else if (pNumGroupDim)
643 if (!(pGroupDim || pNumGroupDim))
660 for(sal_Int32 j = 0; j < nElemCount; ++j)
679 const std::optional<OUString> & pLayoutName = pDim->
GetLayoutName();
686 sheet::DataPilotFieldOrientation eOrientation = pDim->
GetOrientation();
688 if( !sValueStr.isEmpty() )
697 if (eOrientation == sheet::DataPilotFieldOrientation_PAGE)
709 if( pDim->
GetOrientation() != sheet::DataPilotFieldOrientation_DATA )
716 for (
auto const& iter : rDimensions)
749 for (
size_t i = 0;
i < nDPCount; ++
i)
755 ScRange aOutRange((*pDPs)[
i].GetOutRange());
756 OUString sTargetRangeAddress;
763 OUString sOUButtonList;
770 for (
SCROW nButtonRow = nRow1; nButtonRow <= nRow2; ++nButtonRow)
777 pAttr = aAttrItr.
GetNext(nCol, nRow1, nRow2);
780 OUString sApplicationData((*pDPs)[
i].GetTag());
787 if (!(bRowGrand && bColumnGrand))
791 else if (bColumnGrand)
806 if ((*pDPs)[
i].GetHeaderLayout())
817 if (bRowGrand && bColumnGrand)
829 if ((*pDPs)[
i].IsSheetData())
844 OUString sCellRangeAddress;
854 else if ((*pDPs)[
i].IsImportData())
857 switch (pImpSource->
nType)
859 case sheet::DataImportMode_NONE :
break;
860 case sheet::DataImportMode_QUERY :
868 case sheet::DataImportMode_TABLE :
876 case sheet::DataImportMode_SQL :
889 else if ((*pDPs)[
i].IsServiceData())
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 ...
SC_DLLPUBLIC size_t GetCount() const
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
const ScDPSaveGroupDimension * GetNamedGroupDim(const OUString &rGroupDimName) const
const ScDPSaveNumGroupDimension * GetNumGroupDim(const OUString &rGroupDimName) const
bool GetDrillDown() const
bool GetFilterButton() const
bool GetIgnoreEmptyRows() const
bool GetRepeatIfEmpty() const
SC_DLLPUBLIC const std::optional< OUString > & GetGrandTotalName() const
bool GetColumnGrand() const
bool GetExpandCollapse() const
std::vector< std::unique_ptr< ScDPSaveDimension > > DimsType
const DimsType & GetDimensions() const
const ScDPDimensionSaveData * GetExistingDimensionData() const
const css::sheet::DataPilotFieldSortInfo * GetSortInfo() const
tools::Long GetUsedHierarchy() const
bool HasShowEmpty() const
OUString GetCurrentPage() const
ScGeneralFunction GetSubTotalFunc(tools::Long nIndex) const
css::sheet::DataPilotFieldOrientation GetOrientation() const
const css::sheet::DataPilotFieldLayoutInfo * GetLayoutInfo() const
const css::sheet::DataPilotFieldAutoShowInfo * GetAutoShowInfo() const
const std::optional< OUString > & GetSubtotalName() const
const std::optional< OUString > & GetLayoutName() const
ScGeneralFunction GetFunction() const
tools::Long GetSubTotalsCount() const
const css::sheet::DataPilotFieldReference * GetReferenceValue() const
const MemberList & GetMembers() const
std::vector< ScDPSaveMember * > MemberList
bool GetRepeatItemLabels() const
bool IsDataLayout() const
const OUString & GetName() const
bool GetShowEmpty() const
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID.
const OUString & GetSourceDimName() const
const ScDPNumGroupInfo & GetDateInfo() const
sal_Int32 GetDatePart() const
tools::Long GetGroupCount() const
const ScDPSaveGroupItem & GetGroupByIndex(tools::Long nIndex) const
Classes to save Data Pilot settings that create new dimensions (fields).
size_t GetElementCount() const
const OUString & GetGroupName() const
const OUString * GetElementByIndex(size_t nIndex) const
Represents a group dimension that introduces a new hierarchy for an existing dimension.
sal_Int32 GetDatePart() const
const ScDPNumGroupInfo & GetDateInfo() const
const ScDPNumGroupInfo & GetInfo() const
static SC_DLLPUBLIC OUString getSourceDimensionName(std::u16string_view rName)
const ScPatternAttr * GetNext(SCCOL &rCol, SCROW &rRow1, SCROW &rRow2)
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
bool HasPivotButton() const
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
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.
This class contains authoritative information on the internal reference used as the data source for d...
const OUString & GetRangeName() const
const ScQueryParam & GetQueryParam() const
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
bool HasRangeName() const
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()
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
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
virtual OUString GetName() const override
XML_DATA_PILOT_FIELD_REFERENCE
XML_DATA_PILOT_DISPLAY_INFO
XML_DATA_PILOT_LAYOUT_INFO
XML_CONDITION_SOURCE_RANGE_ADDRESS
XML_OUTLINE_SUBTOTALS_TOP
XML_MEMBER_PERCENTAGE_DIFFERENCE
XML_DATA_PILOT_GROUP_MEMBER
XML_DATABASE_SOURCE_QUERY
XML_OUTLINE_SUBTOTALS_BOTTOM
XML_SHOW_DRILL_DOWN_BUTTONS
XML_DATABASE_SOURCE_TABLE
XML_DRILL_DOWN_ON_DOUBLE_CLICK
XML_DATA_PILOT_GRAND_TOTAL
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
css::sheet::DataImportMode nType
svl::SharedString maString
Each instance of this struct represents a single filtering criteria.
bool IsQueryByNonEmpty() const
const Item & GetQueryItem() const
bool IsQueryByEmpty() const
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
utl::SearchParam::SearchType eSearchType
SC_DLLPUBLIC SCSIZE GetEntryCount() const
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
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