30 #include <document.hxx>
37 #include <unonames.hxx>
39 #include <globstr.hrc>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/sdb/XCompletedExecution.hpp>
45 #include <com/sun/star/sdbc/DataType.hpp>
46 #include <com/sun/star/sdbc/SQLException.hpp>
47 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
48 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
49 #include <com/sun/star/sdbc/XRow.hpp>
50 #include <com/sun/star/sdbc/XRowSet.hpp>
51 #include <com/sun/star/sheet/GeneralFunction2.hpp>
52 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
53 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
54 #include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
55 #include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
56 #include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
57 #include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
58 #include <com/sun/star/sheet/DimensionFlags.hpp>
59 #include <com/sun/star/task/InteractionHandler.hpp>
60 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
61 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
62 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
63 #include <com/sun/star/lang/XInitialization.hpp>
64 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
65 #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
72 #include <rtl/math.hxx>
85 using ::std::shared_ptr;
86 using ::com::sun::star::uno::Sequence;
87 using ::com::sun::star::uno::Reference;
88 using ::com::sun::star::uno::UNO_QUERY;
89 using ::com::sun::star::uno::Any;
90 using ::com::sun::star::uno::Exception;
91 using ::com::sun::star::lang::XComponent;
92 using ::com::sun::star::sheet::DataPilotTableHeaderData;
93 using ::com::sun::star::sheet::DataPilotTablePositionData;
94 using ::com::sun::star::sheet::XDimensionsSupplier;
95 using ::com::sun::star::beans::XPropertySet;
97 #define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet"
99 #define SC_DBPROP_DATASOURCENAME "DataSourceName"
100 #define SC_DBPROP_COMMAND "Command"
101 #define SC_DBPROP_COMMANDTYPE "CommandType"
103 #define SCDPSOURCE_SERVICE "com.sun.star.sheet.DataPilotSource"
116 uno::Reference<sdbc::XRowSet> mxRowSet;
117 uno::Reference<sdbc::XRow> mxRow;
118 uno::Reference<sdbc::XResultSetMetaData> mxMetaData;
122 DBConnector(
ScDPCache& rCache,
const uno::Reference<sdbc::XRowSet>& xRowSet,
const Date& rNullDate);
124 bool isValid()
const;
127 virtual OUString getColumnLabel(
tools::Long nCol)
const override;
128 virtual tools::Long getColumnCount()
const override;
129 virtual bool first()
override;
130 virtual bool next()
override;
131 virtual void finish()
override;
134 DBConnector::DBConnector(
ScDPCache& rCache,
const uno::Reference<sdbc::XRowSet>& xRowSet,
const Date& rNullDate) :
135 mrCache(rCache), mxRowSet(xRowSet), maNullDate(rNullDate)
137 Reference<sdbc::XResultSetMetaDataSupplier> xMetaSupp(mxRowSet, UNO_QUERY);
139 mxMetaData = xMetaSupp->getMetaData();
141 mxRow.set(mxRowSet, UNO_QUERY);
144 bool DBConnector::isValid()
const
146 return mxRowSet.is() && mxRow.is() && mxMetaData.is();
149 bool DBConnector::first()
151 return mxRowSet->first();
154 bool DBConnector::next()
156 return mxRowSet->next();
159 void DBConnector::finish()
161 mxRowSet->beforeFirst();
166 return mxMetaData->getColumnCount();
169 OUString DBConnector::getColumnLabel(
tools::Long nCol)
const
171 return mxMetaData->getColumnLabel(nCol+1);
176 rNumType = SvNumFormatType::NUMBER;
177 sal_Int32
nType = mxMetaData->getColumnType(nCol+1);
184 case sdbc::DataType::BIT:
185 case sdbc::DataType::BOOLEAN:
187 rNumType = SvNumFormatType::LOGICAL;
188 fValue = mxRow->getBoolean(nCol+1) ? 1 : 0;
192 case sdbc::DataType::TINYINT:
193 case sdbc::DataType::SMALLINT:
194 case sdbc::DataType::INTEGER:
195 case sdbc::DataType::BIGINT:
196 case sdbc::DataType::FLOAT:
197 case sdbc::DataType::REAL:
198 case sdbc::DataType::DOUBLE:
199 case sdbc::DataType::NUMERIC:
200 case sdbc::DataType::DECIMAL:
203 fValue = mxRow->getDouble(nCol+1);
209 rNumType = SvNumFormatType::DATE;
211 util::Date aDate = mxRow->getDate(nCol+1);
212 fValue =
Date(aDate.Day, aDate.Month, aDate.Year) - maNullDate;
216 case sdbc::DataType::TIME:
218 rNumType = SvNumFormatType::TIME;
220 util::Time aTime = mxRow->getTime(nCol+1);
228 case sdbc::DataType::TIMESTAMP:
230 rNumType = SvNumFormatType::DATETIME;
232 util::DateTime aStamp = mxRow->getTimestamp(nCol+1);
233 fValue = (
Date( aStamp.Day, aStamp.Month, aStamp.Year ) - maNullDate ) +
241 case sdbc::DataType::CHAR:
242 case sdbc::DataType::VARCHAR:
243 case sdbc::DataType::LONGVARCHAR:
244 case sdbc::DataType::SQLNULL:
245 case sdbc::DataType::BINARY:
246 case sdbc::DataType::VARBINARY:
247 case sdbc::DataType::LONGVARBINARY:
251 mrCache.InternString(nCol, mxRow->getString(nCol+1)));
254 catch (uno::Exception&)
264 sheet::DataPilotFieldOrientation nRet = sheet::DataPilotFieldOrientation_HIDDEN;
267 uno::Reference<container::XNameAccess> xDimNameAccess = xSource->getDimensions();
268 const uno::Sequence<OUString> aDimNames = xDimNameAccess->getElementNames();
269 for (
const OUString& rDimName : aDimNames)
271 uno::Reference<beans::XPropertySet> xDimProp(xDimNameAccess->getByName(rDimName),
282 sheet::DataPilotFieldOrientation_HIDDEN );
292 const OUString& rServ,
const OUString& rSrc,
const OUString& rNam,
293 const OUString& rUser,
const OUString& rPass ) :
294 aServiceName( rServ ),
312 mbHeaderLayout(false),
314 bSettingsChanged(false),
315 mbEnableGetPivotData(true)
321 aTableName( r.aTableName ),
322 aTableTag( r.aTableTag ),
323 aOutRange( r.aOutRange ),
324 maInteropGrabBag(r.maInteropGrabBag),
325 nHeaderRows( r.nHeaderRows ),
326 mbHeaderLayout( r.mbHeaderLayout ),
328 bSettingsChanged(false),
329 mbEnableGetPivotData(r.mbEnableGetPivotData)
505 if (nDataDimCount != 1)
512 return (rPos == aTabRange.
aStart);
540 if ( nHeaderRows == 0 )
549 pOutput->SetPosition( aStart );
558 class DisableGetPivotData
563 DisableGetPivotData(
ScDPObject& rObj,
bool bOld) : mrDPObj(rObj), mbOldState(bOld)
568 ~DisableGetPivotData()
574 class FindIntersectingTable
578 explicit FindIntersectingTable(
const ScRange& rRange) : maRange(rRange) {}
580 bool operator() (
const std::unique_ptr<ScDPObject>& rObj)
const
582 return maRange.
Intersects(rObj->GetOutRange());
586 class FindIntersectingTableByColumns
594 mnCol1(nCol1), mnCol2(nCol2), mnRow(nRow), mnTab(nTab) {}
596 bool operator() (
const std::unique_ptr<ScDPObject>& rObj)
const
598 const ScRange& rRange = rObj->GetOutRange();
620 class FindIntersectingTableByRows
628 mnCol(nCol), mnRow1(nRow1), mnRow2(nRow2), mnTab(nTab) {}
630 bool operator() (
const std::unique_ptr<ScDPObject>& rObj)
const
632 const ScRange& rRange = rObj->GetOutRange();
654 class AccumulateOutputRanges
659 explicit AccumulateOutputRanges(
SCTAB nTab) : mnTab(nTab) {}
660 AccumulateOutputRanges(
const AccumulateOutputRanges& r) : maRanges(r.maRanges), mnTab(r.mnTab) {}
662 void operator() (
const std::unique_ptr<ScDPObject>& rObj)
664 const ScRange& rRange = rObj->GetOutRange();
669 maRanges.
Join(rRange);
672 const ScRangeList& getRanges()
const {
return maRanges; }
681 shared_ptr<ScDPTableData>
pData;
691 pData = std::make_shared<ScDatabaseDPData>(
pDoc, *pCache);
699 OSL_FAIL(
"no source descriptor");
712 pData = std::make_shared<ScSheetDPData>(
pDoc, *
pSheetDesc, *pCache);
718 if (pData && pDimData)
720 auto pGroupData = std::make_shared<ScDPGroupTableData>(pData,
pDoc);
744 OSL_ENSURE( !
pServDesc,
"DPSource could not be created" );
765 uno::Reference<util::XRefreshable> xRef(
xSource, uno::UNO_QUERY );
772 catch(uno::Exception&)
805 mpTableData->GetCacheTable().getCache().RemoveReference(
this);
841 auto pGroupData = std::make_shared<ScDPGroupTableData>(pSource,
pDoc);
848 auto pGroupData = std::make_shared<ScDPGroupTableData>(
mpTableData,
pDoc);
850 mpTableData = pGroupData;
858 Reference< XComponent > xObjectComp(
xSource, UNO_QUERY );
859 if (xObjectComp.is())
863 xObjectComp->dispose();
877 rOverflow =
pOutput->HasError();
883 return pOutput->GetOutputRange();
917 return pOutput->GetOutputRange(nType);
925 return pOutput->GetOutputRange(nType);
946 while ( nInitial + 1 < nOutRows &&
lcl_HasButton(
pDoc, nFirstCol, nFirstRow + nInitial, nTab ) )
949 if ( nInitial + 1 < nOutRows &&
950 pDoc->
IsBlockEmpty( nTab, nFirstCol, nFirstRow + nInitial, nFirstCol, nFirstRow + nInitial ) &&
970 pSaveData->BuildAllDimensionMembers(pTableData);
992 pSaveData->SyncAllDimensionMembers(pData);
998 vector<ScDPLabelData::Member> aMembers;
1002 size_t n = aMembers.size();
1004 for (
size_t i = 0;
i < n; ++
i)
1012 Reference< sheet::XMembersAccess > xMembersNA;
1017 sal_Int32
nCount = xMembersIA->getCount();
1018 vector<ScDPLabelData::Member> aMembers;
1019 aMembers.reserve(nCount);
1021 for (sal_Int32
i = 0;
i < nCount; ++
i)
1023 Reference<container::XNamed> xMember(xMembersIA->getByIndex(
i), UNO_QUERY);
1027 aMem.
maName = xMember->getName();
1039 aMembers.push_back(aMem);
1041 rMembers.swap(aMembers);
1061 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
1070 const OUString& rRangeName =
pSheetDesc->GetRangeName();
1071 if (!rRangeName.isEmpty())
1086 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
1096 aParam.
nRow1 += nDiffY;
1097 aParam.
nRow2 += nDiffY;
1119 OSL_FAIL(
"RefsEqual: SheetDesc set at only one object");
1136 pOutput->GetPositionData(rPos, rPosData);
1140 const ScAddress& rPos, Sequence<sheet::DataPilotFieldFilter>& rFilters)
1144 vector<sheet::DataPilotFieldFilter> aFilters;
1145 if (!
pOutput->GetDataResultPositionData(aFilters, rPos))
1148 sal_Int32
n =
static_cast<sal_Int32
>(aFilters.size());
1149 rFilters.realloc(n);
1150 for (sal_Int32
i = 0;
i < n; ++
i)
1151 rFilters[
i] = aFilters[
i];
1160 Reference<sheet::XDrillDownDataSupplier> xDrillDownData(
xSource, UNO_QUERY);
1161 if (!xDrillDownData.is())
1164 Sequence<sheet::DataPilotFieldFilter> filters;
1168 rTableData = xDrillDownData->getDrillDownData(filters);
1178 for (
const OUString& rDimName : aDimNames)
1180 if (rDimName.equalsIgnoreAsciiCase(rName))
1189 if (aLayoutName.equalsIgnoreAsciiCase(rName))
1197 rIsDataLayout =
false;
1202 uno::Reference<container::XNameAccess> xDimsName =
xSource->getDimensions();
1205 if ( nDim < nDimCount )
1207 uno::Reference<uno::XInterface> xIntDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
1208 uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
1209 uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
1210 if ( xDimName.is() && xDimProp.is() )
1219 aName = xDimName->getName();
1221 catch(uno::Exception&)
1225 rIsDataLayout =
true;
1237 aRet =
pData->getDimensionName(nDim);
1238 rIsDataLayout =
pData->getIsDataLayoutDimension(nDim);
1246 bool bDuplicated =
false;
1249 uno::Reference<container::XNameAccess> xDimsName =
xSource->getDimensions();
1252 if ( nDim < nDimCount )
1254 uno::Reference<beans::XPropertySet> xDimProp(xDims->getByIndex(nDim), uno::UNO_QUERY);
1255 if ( xDimProp.is() )
1260 uno::Reference<uno::XInterface> xIntOrig;
1261 if ( (aOrigAny >>= xIntOrig) && xIntOrig.is() )
1264 catch(uno::Exception&)
1280 uno::Reference<container::XNameAccess> xDimsName =
xSource->getDimensions();
1281 if ( xDimsName.is() )
1282 nRet = xDimsName->getElementNames().getLength();
1284 catch(uno::Exception&)
1296 rData.Dimension = rData.Hierarchy = rData.Level = -1;
1299 DataPilotTablePositionData aPosData;
1300 pOutput->GetPositionData(rPos, aPosData);
1301 const sal_Int32 nPosType = aPosData.PositionType;
1303 aPosData.PositionData >>= rData;
1312 explicit FindByName(
const OUString& rName) : maName(rName) {}
1316 const std::optional<OUString> & pLayoutName = pDim->
GetLayoutName();
1331 class LessByDimOrder
1338 bool operator() (
const sheet::DataPilotFieldFilter& r1,
const sheet::DataPilotFieldFilter& r2)
const
1340 size_t nRank1 = mrDimOrder.size();
1341 size_t nRank2 = mrDimOrder.size();
1342 ScDPSaveData::DimOrderType::const_iterator it1 = mrDimOrder.find(r1.FieldName);
1343 if (it1 != mrDimOrder.end())
1344 nRank1 = it1->second;
1346 ScDPSaveData::DimOrderType::const_iterator it2 = mrDimOrder.find(r2.FieldName);
1347 if (it2 != mrDimOrder.end())
1348 nRank2 = it2->second;
1350 return nRank1 < nRank2;
1359 rtl::math::setNan(&fRet);
1365 std::vector<const ScDPSaveDimension*> aDataDims;
1366 pSaveData->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_DATA, aDataDims);
1367 if (aDataDims.empty())
1370 std::vector<const ScDPSaveDimension*>::iterator it = std::find_if(
1371 aDataDims.begin(), aDataDims.end(),
1374 if (it == aDataDims.end())
1377 size_t nDataIndex = std::distance(aDataDims.begin(), it);
1379 uno::Reference<sheet::XDataPilotResults> xDPResults(
xSource, uno::UNO_QUERY);
1380 if (!xDPResults.is())
1385 std::sort(rFilters.begin(), rFilters.end(), LessByDimOrder(
pSaveData->GetDimensionSortOrder()));
1387 size_t n = rFilters.size();
1388 uno::Sequence<sheet::DataPilotFieldFilter> aFilters(n);
1389 for (
size_t i = 0;
i < n; ++
i)
1390 aFilters[
i] = rFilters[
i];
1392 uno::Sequence<double> aRes = xDPResults->getFilteredResults(aFilters);
1393 if (static_cast<sal_Int32>(nDataIndex) >= aRes.getLength())
1396 return aRes[nDataIndex];
1403 return pOutput->IsFilterButton( rPos );
1410 return pOutput->GetHeaderDim( rPos, rOrient );
1418 return pOutput->GetHeaderDrag( rPos, bMouseLeft, bMouseTop, nDragDim, rPosRect, rOrient, rDimPos );
1425 pOutput->GetMemberResultNames(rNames, nDimension);
1448 bool dequote(
const OUString& rSource, sal_Int32 nStartPos, sal_Int32& rEndPos, OUString& rResult )
1454 if (rSource[nStartPos] == cQuote)
1457 sal_Int32
nPos = nStartPos + 1;
1458 const sal_Int32 nLen = rSource.getLength();
1460 while ( nPos < nLen )
1463 if ( cNext == cQuote )
1465 if (nPos+1 < nLen && rSource[nPos+1] == cQuote)
1468 aBuffer.append( cNext );
1474 rResult = aBuffer.makeStringAndClear();
1480 aBuffer.append( cNext );
1490 struct ScGetPivotDataFunctionEntry
1496 bool parseFunction(
const OUString& rList, sal_Int32 nStartPos, sal_Int32& rEndPos, sal_Int16& rFunc )
1498 static const ScGetPivotDataFunctionEntry aFunctions[] =
1501 {
"Sum", sheet::GeneralFunction2::SUM },
1503 {
"Average", sheet::GeneralFunction2::AVERAGE },
1504 {
"Max", sheet::GeneralFunction2::MAX },
1505 {
"Min", sheet::GeneralFunction2::MIN },
1506 {
"Product", sheet::GeneralFunction2::PRODUCT },
1507 {
"CountNums", sheet::GeneralFunction2::COUNTNUMS },
1508 {
"StDev", sheet::GeneralFunction2::STDEV },
1509 {
"StDevp", sheet::GeneralFunction2::STDEVP },
1510 {
"Var", sheet::GeneralFunction2::VAR },
1511 {
"VarP", sheet::GeneralFunction2::VARP },
1513 {
"Count Nums", sheet::GeneralFunction2::COUNTNUMS },
1514 {
"StdDev", sheet::GeneralFunction2::STDEV },
1515 {
"StdDevp", sheet::GeneralFunction2::STDEVP }
1518 const sal_Int32 nListLen = rList.getLength();
1519 while (nStartPos < nListLen && rList[nStartPos] ==
' ')
1522 bool bParsed =
false;
1523 bool bFound =
false;
1525 sal_Int32 nFuncEnd = 0;
1526 if (nStartPos < nListLen && rList[nStartPos] ==
'\'')
1527 bParsed = dequote( rList, nStartPos, nFuncEnd, aFuncStr );
1530 nFuncEnd = rList.indexOf(
']', nStartPos);
1533 aFuncStr = rList.copy(nStartPos, nFuncEnd - nStartPos);
1543 for ( sal_Int32 nFunc=0; nFunc<nFuncCount && !bFound; nFunc++ )
1545 if (aFuncStr.equalsIgnoreAsciiCaseAscii(aFunctions[nFunc].pName))
1547 rFunc = aFunctions[nFunc].eFunc;
1550 while (nFuncEnd < nListLen && rList[nFuncEnd] ==
' ')
1560 bool extractAtStart(
const OUString& rList, sal_Int32& rMatched,
bool bAllowBracket, sal_Int16* pFunc,
1561 OUString& rDequoted )
1563 sal_Int32 nMatchList = 0;
1565 bool bParsed =
false;
1566 if ( cFirst ==
'\'' || cFirst ==
'[' )
1571 sal_Int32 nQuoteEnd = 0;
1573 if ( cFirst ==
'\'' )
1574 bParsed = dequote( rList, 0, nQuoteEnd, aDequoted );
1575 else if ( cFirst ==
'[' )
1579 sal_Int32 nStartPos = 1;
1580 const sal_Int32 nListLen = rList.getLength();
1581 while (nStartPos < nListLen && rList[nStartPos] ==
' ')
1584 if (nStartPos < nListLen && rList[nStartPos] ==
'\'')
1586 if ( dequote( rList, nStartPos, nQuoteEnd, aDequoted ) )
1590 while (nQuoteEnd < nListLen && rList[nQuoteEnd] ==
' ')
1594 if (nQuoteEnd < nListLen && rList[nQuoteEnd] ==
';' && pFunc)
1596 sal_Int32 nFuncEnd = 0;
1597 if ( parseFunction( rList, nQuoteEnd + 1, nFuncEnd, *pFunc ) )
1598 nQuoteEnd = nFuncEnd;
1600 if (nQuoteEnd < nListLen && rList[nQuoteEnd] ==
']')
1611 sal_Int32 nClosePos = rList.indexOf(
']', nStartPos);
1614 sal_Int32 nNameEnd = nClosePos;
1615 sal_Int32 nSemiPos = rList.indexOf(
';', nStartPos);
1616 if (nSemiPos >= 0 && nSemiPos < nClosePos && pFunc)
1618 sal_Int32 nFuncEnd = 0;
1619 if (parseFunction(rList, nSemiPos+1, nFuncEnd, *pFunc))
1620 nNameEnd = nSemiPos;
1623 aDequoted = rList.copy(nStartPos, nNameEnd - nStartPos);
1626 nQuoteEnd = nClosePos + 1;
1634 nMatchList = nQuoteEnd;
1635 rDequoted = aDequoted;
1643 bool bValid =
false;
1644 if ( sal::static_int_cast<sal_Int32>(nMatchList) >= rList.getLength() )
1649 if ( cNext ==
' ' || ( bAllowBracket && cNext ==
'[' ) )
1655 rMatched = nMatchList;
1664 const OUString& rList,
const OUString& rSearch, sal_Int32& rMatched,
1665 bool bAllowBracket, sal_Int16* pFunc )
1667 sal_Int32 nMatchList = 0;
1668 sal_Int32 nMatchSearch = 0;
1670 if ( cFirst ==
'\'' || cFirst ==
'[' )
1673 bool bParsed = extractAtStart( rList, rMatched, bAllowBracket, pFunc, aDequoted);
1676 nMatchList = rMatched;
1677 nMatchSearch = rSearch.getLength();
1684 rList, 0, rList.getLength(), nMatchList, rSearch, 0, rSearch.getLength(), nMatchSearch);
1687 if (nMatchSearch == rSearch.getLength())
1691 bool bValid =
false;
1692 if ( sal::static_int_cast<sal_Int32>(nMatchList) >= rList.getLength() )
1697 if ( cNext ==
' ' || ( bAllowBracket && cNext ==
'[' ) )
1703 rMatched = nMatchList;
1714 OUString& rDataFieldName,
1715 std::vector<sheet::DataPilotFieldFilter>& rFilters,
1716 std::vector<sal_Int16>& rFilterFuncs, std::u16string_view rFilterList )
1722 std::vector<OUString> aDataNames;
1723 std::vector<OUString> aGivenNames;
1725 std::vector< uno::Sequence<OUString> > aFieldValueNames;
1726 std::vector< uno::Sequence<OUString> > aFieldValues;
1730 uno::Reference<container::XNameAccess> xDimsName =
xSource->getDimensions();
1732 sal_Int32
nDimCount = xIntDims->getCount();
1733 for ( sal_Int32 nDim = 0; nDim<nDimCount; nDim++ )
1735 uno::Reference<uno::XInterface> xIntDim(xIntDims->getByIndex(nDim), uno::UNO_QUERY);
1736 uno::Reference<container::XNamed> xDim( xIntDim, uno::UNO_QUERY );
1737 uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
1738 uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDim, uno::UNO_QUERY );
1743 sheet::DataPilotFieldOrientation_HIDDEN );
1746 if ( nOrient == sheet::DataPilotFieldOrientation_DATA )
1748 OUString aSourceName;
1749 OUString aGivenName;
1751 aDataNames.push_back( aSourceName );
1752 aGivenNames.push_back( aGivenName );
1754 else if ( nOrient != sheet::DataPilotFieldOrientation_HIDDEN )
1758 uno::Reference<container::XIndexAccess> xHiers =
new ScNameToIndexAccess( xDimSupp->getHierarchies() );
1761 if ( nHierarchy >= xHiers->getCount() )
1764 uno::Reference<sheet::XLevelsSupplier> xHierSupp(xHiers->getByIndex(nHierarchy),
1766 if ( xHierSupp.is() )
1768 uno::Reference<container::XIndexAccess> xLevels =
new ScNameToIndexAccess( xHierSupp->getLevels() );
1769 sal_Int32 nLevCount = xLevels->
getCount();
1770 for (sal_Int32 nLev=0; nLev<nLevCount; nLev++)
1772 uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLev),
1774 uno::Reference<container::XNamed> xLevNam( xLevel, uno::UNO_QUERY );
1775 uno::Reference<sheet::XMembersSupplier> xLevSupp( xLevel, uno::UNO_QUERY );
1776 if ( xLevNam.is() && xLevSupp.is() )
1778 uno::Reference<sheet::XMembersAccess> xMembers = xLevSupp->getMembers();
1780 OUString aFieldName( xLevNam->getName() );
1783 uno::Sequence<OUString> aMemberValueNames( xMembers->getElementNames() );
1784 uno::Sequence<OUString> aMemberValues( xMembers->getLocaleIndependentElementNames() );
1786 aFieldNames.push_back( aFieldName );
1787 aFieldValueNames.push_back( aMemberValueNames );
1788 aFieldValues.push_back( aMemberValues );
1798 SCSIZE nDataFields = aDataNames.size();
1799 SCSIZE nFieldCount = aFieldNames.size();
1800 OSL_ENSURE( aGivenNames.size() == nDataFields && aFieldValueNames.size() == nFieldCount &&
1801 aFieldValues.size() == nFieldCount,
"wrong count" );
1803 bool bError =
false;
1804 bool bHasData =
false;
1806 while (!aRemaining.isEmpty() && !bError)
1812 for (
SCSIZE nDataPos=0; nDataPos<nDataFields && !bUsed; nDataPos++ )
1815 sal_Int32 nMatched = 0;
1816 if (isAtStart(aRemaining, aDataNames[nDataPos], nMatched,
false,
nullptr))
1817 aFound = aDataNames[nDataPos];
1818 else if (isAtStart(aRemaining, aGivenNames[nDataPos], nMatched,
false,
nullptr))
1819 aFound = aGivenNames[nDataPos];
1821 if (!aFound.isEmpty())
1823 rDataFieldName = aFound;
1824 aRemaining = aRemaining.copy(nMatched);
1832 OUString aSpecField;
1833 bool bHasFieldName =
false;
1836 sal_Int32 nMatched = 0;
1837 for (
SCSIZE nField=0; nField<nFieldCount && !bHasFieldName; nField++ )
1839 if (isAtStart(aRemaining, aFieldNames[nField], nMatched,
true,
nullptr))
1841 aSpecField = aFieldNames[nField];
1842 aRemaining = aRemaining.copy(nMatched);
1846 if (aRemaining.startsWith(
"["))
1848 bHasFieldName =
true;
1864 bool bItemFound =
false;
1865 sal_Int32 nMatched = 0;
1866 OUString aFoundName;
1867 OUString aFoundValueName;
1868 OUString aFoundValue;
1872 OUString aQueryValueName;
1873 const bool bHasQuery = extractAtStart( aRemaining, nMatched,
false, &eFunc, aQueryValueName);
1875 OUString aQueryValue = aQueryValueName;
1883 sal_uInt32 nNumFormat = 0;
1885 if (pFormatter->
IsNumberFormat( aQueryValueName, nNumFormat, fValue))
1890 for (
SCSIZE nField=0; nField<nFieldCount; nField++ )
1894 if ( !bHasFieldName || aFieldNames[nField] == aSpecField )
1896 const uno::Sequence<OUString>& rItemNames = aFieldValueNames[nField];
1897 const uno::Sequence<OUString>& rItemValues = aFieldValues[nField];
1898 sal_Int32 nItemCount = rItemNames.getLength();
1899 assert(nItemCount == rItemValues.getLength());
1900 const OUString* pItemNamesArr = rItemNames.getConstArray();
1901 const OUString* pItemValuesArr = rItemValues.getConstArray();
1902 for ( sal_Int32 nItem=0; nItem<nItemCount; nItem++ )
1904 bool bThisItemFound;
1909 aQueryValueName, pItemNamesArr[nItem]);
1910 if (!bThisItemFound && pItemValuesArr[nItem] != pItemNamesArr[nItem])
1912 aQueryValueName, pItemValuesArr[nItem]);
1913 if (!bThisItemFound && aQueryValueName != aQueryValue)
1920 aQueryValue, pItemNamesArr[nItem]);
1921 if (!bThisItemFound && pItemValuesArr[nItem] != pItemNamesArr[nItem])
1923 aQueryValue, pItemValuesArr[nItem]);
1928 bThisItemFound = isAtStart( aRemaining, pItemNamesArr[nItem], nMatched,
false, &eFunc );
1929 if (!bThisItemFound && pItemValuesArr[nItem] != pItemNamesArr[nItem])
1930 bThisItemFound = isAtStart( aRemaining, pItemValuesArr[nItem], nMatched,
false, &eFunc );
1945 aFoundName = aFieldNames[nField];
1946 aFoundValueName = pItemNamesArr[nItem];
1947 aFoundValue = pItemValuesArr[nItem];
1957 if ( bItemFound && !bError )
1959 sheet::DataPilotFieldFilter aField;
1960 aField.FieldName = aFoundName;
1961 aField.MatchValueName = aFoundValueName;
1962 aField.MatchValue = aFoundValue;
1963 rFilters.push_back(aField);
1964 rFilterFuncs.push_back(eFoundFunc);
1965 aRemaining = aRemaining.copy(nMatched);
1976 if ( !bError && !bHasData && aDataNames.size() == 1 )
1979 rDataFieldName = aDataNames[0];
1983 return bHasData && !bError;
1992 uno::Reference<container::XNamed> xDim;
1993 uno::Reference<container::XNameAccess> xDimsName =
xSource->getDimensions();
1996 if ( rElemDesc.Dimension < nIntCount )
1998 xDim.set(xIntDims->getByIndex(rElemDesc.Dimension), uno::UNO_QUERY);
2000 OSL_ENSURE( xDim.is(),
"dimension not found" );
2001 if ( !xDim.is() )
return;
2002 OUString aDimName = xDim->getName();
2004 uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
2017 uno::Reference<container::XIndexAccess> xHiers;
2018 uno::Reference<sheet::XHierarchiesSupplier> xHierSupp( xDim, uno::UNO_QUERY );
2019 if ( xHierSupp.is() )
2021 uno::Reference<container::XNameAccess> xHiersName = xHierSupp->getHierarchies();
2023 nHierCount = xHiers->getCount();
2025 uno::Reference<uno::XInterface> xHier;
2026 if ( rElemDesc.Hierarchy < nHierCount )
2027 xHier.set(xHiers->getByIndex(rElemDesc.Hierarchy), uno::UNO_QUERY);
2028 OSL_ENSURE( xHier.is(),
"hierarchy not found" );
2029 if ( !xHier.is() )
return;
2032 uno::Reference<container::XIndexAccess> xLevels;
2033 uno::Reference<sheet::XLevelsSupplier> xLevSupp( xHier, uno::UNO_QUERY );
2034 if ( xLevSupp.is() )
2036 uno::Reference<container::XNameAccess> xLevsName = xLevSupp->getLevels();
2038 nLevCount = xLevels->getCount();
2040 uno::Reference<uno::XInterface> xLevel;
2041 if ( rElemDesc.Level < nLevCount )
2042 xLevel.set(xLevels->getByIndex(rElemDesc.Level), uno::UNO_QUERY);
2043 OSL_ENSURE( xLevel.is(),
"level not found" );
2044 if ( !xLevel.is() )
return;
2046 uno::Reference<sheet::XMembersAccess> xMembers;
2047 uno::Reference<sheet::XMembersSupplier> xMbrSupp( xLevel, uno::UNO_QUERY );
2048 if ( xMbrSupp.is() )
2049 xMembers = xMbrSupp->getMembers();
2051 bool bFound =
false;
2052 bool bShowDetails =
true;
2054 if ( xMembers.is() )
2056 if ( xMembers->hasByName(rElemDesc.MemberName) )
2058 uno::Reference<beans::XPropertySet> xMbrProp(xMembers->getByName(rElemDesc.MemberName),
2060 if ( xMbrProp.is() )
2070 OSL_ENSURE( bFound,
"member not found" );
2076 OSL_ENSURE( pModifyData,
"no data?" );
2079 const OUString
aName = rElemDesc.MemberName;
2081 GetMemberByName(aName)->SetShowDetails( !bShowDetails );
2092 uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDimProp, uno::UNO_QUERY );
2093 if ( xDimProp.is() && xDimSupp.is() )
2095 uno::Reference<container::XIndexAccess> xHiers =
new ScNameToIndexAccess( xDimSupp->getHierarchies() );
2098 if ( nHierarchy >= xHiers->getCount() )
2101 uno::Reference<sheet::XLevelsSupplier> xHierSupp(xHiers->getByIndex(nHierarchy),
2103 if ( xHierSupp.is() )
2105 uno::Reference<container::XIndexAccess> xLevels =
new ScNameToIndexAccess( xHierSupp->getLevels() );
2106 uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(0), uno::UNO_QUERY);
2107 uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY );
2108 if ( xLevProp.is() )
2115 catch(uno::Exception&)
2118 uno::Sequence<sal_Int16>
aSeq;
2119 if ( aSubAny >>= aSeq )
2122 for (
const sal_Int16 nElem : aSeq)
2130 OSL_FAIL(
"FirstSubTotal: NULL");
2141 FindByColumn(
SCCOL nCol,
PivotFunc nMask) : mnCol(nCol), mnMask(nMask) {}
2151 const uno::Reference<sheet::XDimensionsSupplier>& xSource,
2152 sheet::DataPilotFieldOrientation nOrient,
bool bAddData )
2156 bool bDataFound =
false;
2161 vector<tools::Long> aPos;
2163 uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
2166 for (
tools::Long nDim = 0; nDim < nDimCount; ++nDim)
2169 uno::Reference<beans::XPropertySet> xDimProp(xDims->getByIndex(nDim), uno::UNO_QUERY);
2174 sheet::DataPilotFieldOrientation_HIDDEN );
2176 if ( xDimProp.is() && nDimOrient == nOrient )
2182 if ( nOrient == sheet::DataPilotFieldOrientation_DATA )
2187 if ( eFunc == sheet::GeneralFunction2::AUTO )
2190 eFunc = sheet::GeneralFunction2::SUM;
2207 if (aOrigAny >>= nTmp)
2210 catch(uno::Exception&)
2215 if (nDupSource >= 0)
2223 nCompCol =
static_cast<SCCOL>(nDupSource);
2225 ScPivotFieldVector::iterator it = std::find_if(aFields.begin(), aFields.end(), FindByColumn(nCompCol, nMask));
2226 if (it != aFields.end())
2227 nDupCount = it->mnDupCount + 1;
2230 aFields.emplace_back();
2247 aPos.push_back(nPos);
2251 if (nOrient == sheet::DataPilotFieldOrientation_DATA)
2255 catch (uno::Exception&)
2263 size_t nOutCount = aFields.size();
2266 for (
size_t i = 0;
i < nOutCount - 1; ++
i)
2268 for (
size_t j = 0; j +
i < nOutCount - 1; ++j)
2270 if ( aPos[j+1] < aPos[j] )
2272 std::swap( aPos[j], aPos[j+1] );
2273 std::swap( aFields[j], aFields[j+1] );
2279 if (bAddData && !bDataFound)
2282 rFields.swap(aFields);
2307 uno::Reference<beans::XPropertySet> xProp(
xSource, uno::UNO_QUERY );
2324 catch(uno::Exception&)
2332 uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDimProp, uno::UNO_QUERY );
2333 if (!xDimProp.is() || !xDimSupp.is())
2336 uno::Reference<container::XIndexAccess> xHiers =
new ScNameToIndexAccess( xDimSupp->getHierarchies() );
2339 if ( nHierarchy >= xHiers->getCount() )
2343 uno::Reference<sheet::XLevelsSupplier> xHierSupp(xHiers->getByIndex(nHierarchy),
2345 if (!xHierSupp.is())
2348 uno::Reference<container::XIndexAccess> xLevels =
2351 uno::Reference<beans::XPropertySet> xLevProp(xLevels->getByIndex(0), uno::UNO_QUERY);
2370 catch(uno::Exception&)
2376 const uno::Reference<container::XIndexAccess>& xDims, sal_Int32 nDim,
ScDPLabelData& rLabelData)
2378 uno::Reference<uno::XInterface> xIntDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
2379 uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
2380 uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
2382 if (!xDimName.is() || !xDimProp.is())
2389 sal_Int32 nOrigPos = -1;
2390 OUString aFieldName;
2393 aFieldName = xDimName->getName();
2395 aOrigAny >>= nOrigPos;
2397 catch(uno::Exception&)
2413 rLabelData.
maName = aFieldName;
2441 uno::Reference<container::XNameAccess> xDimsName =
xSource->getDimensions();
2443 sal_Int32
nDimCount = xDims->getCount();
2444 if (nDimCount <= 0 || nDim >= nDimCount)
2458 uno::Reference<container::XNameAccess> xDimsName =
xSource->getDimensions();
2460 sal_Int32
nDimCount = xDims->getCount();
2464 for (sal_Int32 nDim = 0; nDim < nDimCount; ++nDim)
2468 rParam.
maLabelArray.push_back(std::unique_ptr<ScDPLabelData>(pNewLabel));
2475 uno::Reference<container::XNameAccess> xDimsName(
GetSource()->getDimensions() );
2479 uno::Reference<sheet::XHierarchiesSupplier> xHierSup(xIntDims->getByIndex( nDim ), uno::UNO_QUERY);
2482 xHiers.set( xHierSup->getHierarchies() );
2491 uno::Reference< container::XNameAccess > xHiersNA;
2494 rHiers = xHiersNA->getElementNames();
2500 sal_Int32 nHier = 0;
2501 uno::Reference<container::XNameAccess> xDimsName(
GetSource()->getDimensions() );
2503 uno::Reference<beans::XPropertySet> xDim(xIntDims->getByIndex( nDim ), uno::UNO_QUERY);
2514 bool ScDPObject::GetMembersNA( sal_Int32 nDim, sal_Int32 nHier, uno::Reference< sheet::XMembersAccess >& xMembers )
2517 uno::Reference<container::XNameAccess> xDimsName(
GetSource()->getDimensions() );
2519 uno::Reference<beans::XPropertySet> xDim(xIntDims->getByIndex( nDim ), uno::UNO_QUERY);
2522 uno::Reference<sheet::XHierarchiesSupplier> xHierSup(xDim, uno::UNO_QUERY);
2525 uno::Reference<container::XIndexAccess> xHiers(
new ScNameToIndexAccess(xHierSup->getHierarchies()));
2526 uno::Reference<sheet::XLevelsSupplier> xLevSupp( xHiers->getByIndex(nHier), uno::UNO_QUERY );
2527 if ( xLevSupp.is() )
2529 uno::Reference<container::XIndexAccess> xLevels(
new ScNameToIndexAccess( xLevSupp->getLevels()));
2532 sal_Int32 nLevCount = xLevels->getCount();
2535 uno::Reference<sheet::XMembersSupplier> xMembSupp( xLevels->getByIndex(0), uno::UNO_QUERY );
2536 if ( xMembSupp.is() )
2538 xMembers.set(xMembSupp->getMembers());
2553 OUString lcl_GetDimName(
const uno::Reference<sheet::XDimensionsSupplier>& xSource,
tools::Long nDim )
2558 uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
2561 if ( nDim < nDimCount )
2563 uno::Reference<container::XNamed> xDimName(xDims->getByIndex(nDim), uno::UNO_QUERY);
2568 aName = xDimName->getName();
2570 catch(uno::Exception&)
2579 bool hasFieldColumn(
const vector<ScPivotField>* pRefFields,
SCCOL nCol)
2584 return std::any_of(pRefFields->begin(), pRefFields->end(),
2587 return rField.nCol == nCol; });
2590 class FindByOriginalDim
2594 explicit FindByOriginalDim(
tools::Long nDim) : mnDim(nDim) {}
2605 const Reference<XDimensionsSupplier>& xSource,
2611 ScPivotFieldVector::const_iterator itr, itrBeg = rFields.begin(), itrEnd = rFields.end();
2612 for (itr = itrBeg; itr != itrEnd; ++itr)
2618 const sheet::DataPilotFieldReference& rFieldRef = rField.
maFieldRef;
2625 OUString aDocStr = lcl_GetDimName( xSource, nCol );
2626 if (!aDocStr.isEmpty())
2635 if ( nOrient == sheet::DataPilotFieldOrientation_DATA )
2642 if (hasFieldColumn(pRefColFields, nCol))
2645 if (bFirst && hasFieldColumn(pRefRowFields, nCol))
2648 if (bFirst && hasFieldColumn(pRefPageFields, nCol))
2655 bFirst = std::none_of(itrBeg, itr, FindByOriginalDim(nCol));
2673 std::vector<ScGeneralFunction> nSubTotalFuncs;
2674 nSubTotalFuncs.reserve(16);
2675 sal_uInt16 nMask = 1;
2678 if ( nFuncs & static_cast<PivotFunc>(nMask) )
2690 size_t nDimIndex = rField.
nCol;
2693 if (nDimIndex < rLabels.size())
2706 bool bAllowed =
true;
2709 case sheet::DataPilotFieldOrientation_PAGE:
2710 bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_PAGE_ORIENTATION ) == 0;
2712 case sheet::DataPilotFieldOrientation_COLUMN:
2713 bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_COLUMN_ORIENTATION ) == 0;
2715 case sheet::DataPilotFieldOrientation_ROW:
2716 bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_ROW_ORIENTATION ) == 0;
2718 case sheet::DataPilotFieldOrientation_DATA:
2719 bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_DATA_ORIENTATION ) == 0;
2731 bool bFound =
false;
2734 uno::Reference<container::XContentEnumerationAccess> xEnAc( xManager, uno::UNO_QUERY );
2737 uno::Reference<container::XEnumeration> xEnum = xEnAc->createContentEnumeration(
2739 if ( xEnum.is() && xEnum->hasMoreElements() )
2748 std::vector<OUString> aVec;
2753 uno::Reference<container::XContentEnumerationAccess> xEnAc( xManager, uno::UNO_QUERY );
2756 uno::Reference<container::XEnumeration> xEnum = xEnAc->createContentEnumeration(
2760 while ( xEnum->hasMoreElements() )
2762 uno::Any aAddInAny = xEnum->nextElement();
2765 uno::Reference<uno::XInterface> xIntFac;
2766 aAddInAny >>= xIntFac;
2769 uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY );
2772 OUString
sName = xInfo->getImplementationName();
2773 aVec.push_back( sName );
2787 uno::Reference<sheet::XDimensionsSupplier> xRet;
2790 uno::Reference<container::XContentEnumerationAccess> xEnAc(xManager, uno::UNO_QUERY);
2794 uno::Reference<container::XEnumeration> xEnum =
2799 while (xEnum->hasMoreElements() && !xRet.is())
2801 uno::Any aAddInAny = xEnum->nextElement();
2802 uno::Reference<uno::XInterface> xIntFac;
2803 aAddInAny >>= xIntFac;
2807 uno::Reference<lang::XServiceInfo> xInfo(xIntFac, uno::UNO_QUERY);
2808 if (!xInfo.is() || xInfo->getImplementationName() != aImplName)
2816 uno::Reference<uno::XInterface> xInterface;
2817 uno::Reference<uno::XComponentContext> xCtx(
2819 uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY );
2821 xInterface = xCFac->createInstanceWithContext(xCtx);
2823 if (!xInterface.is())
2825 uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY );
2827 xInterface = xFac->createInstance();
2830 uno::Reference<lang::XInitialization> xInit( xInterface, uno::UNO_QUERY );
2834 uno::Sequence<uno::Any>
aSeq(4);
2835 uno::Any* pArray = aSeq.getArray();
2840 xInit->initialize( aSeq );
2842 xRet.set( xInterface, uno::UNO_QUERY );
2844 catch(uno::Exception&)
2852 #if DUMP_PIVOT_TABLE
2878 struct FindInvalidRange
2880 bool operator() (
const ScRange& r)
const
2907 RangeIndexType::const_iterator it = std::find(maRanges.
begin(), maRanges.
end(), rRange);
2908 if (it == maRanges.
end())
2912 size_t nIndex = std::distance(maRanges.
begin(), it);
2913 CachesType::const_iterator
const itCache = m_Caches.find(nIndex);
2914 return itCache != m_Caches.end();
2919 RangeIndexType::iterator it = std::find(maRanges.
begin(), maRanges.
end(), rRange);
2920 if (it != maRanges.
end())
2923 size_t nIndex = std::distance(maRanges.
begin(), it);
2924 CachesType::iterator
const itCache = m_Caches.find(nIndex);
2925 if (itCache == m_Caches.end())
2927 OSL_FAIL(
"Cache pool and index pool out-of-sync !!!");
2933 (itCache->second)->ClearGroupFields();
2937 return itCache->second.get();
2942 pCache->InitFromDoc(
mrDoc, rRange);
2947 it = std::find_if(maRanges.
begin(), maRanges.
end(), FindInvalidRange());
2950 if (it == maRanges.
end())
2959 nIndex = std::distance(maRanges.
begin(), it);
2963 m_Caches.insert(std::make_pair(nIndex, std::move(pCache)));
2969 RangeIndexType::iterator it = std::find(maRanges.
begin(), maRanges.
end(), rRange);
2970 if (it == maRanges.
end())
2975 size_t nIndex = std::distance(maRanges.
begin(), it);
2976 CachesType::iterator
const itCache = m_Caches.find(nIndex);
2977 if (itCache == m_Caches.end())
2979 OSL_FAIL(
"Cache pool and index pool out-of-sync !!!");
2983 return itCache->second.get();
2988 RangeIndexType::const_iterator it = std::find(maRanges.
begin(), maRanges.
end(), rRange);
2989 if (it == maRanges.
end())
2994 size_t nIndex = std::distance(maRanges.
begin(), it);
2995 CachesType::const_iterator
const itCache = m_Caches.find(nIndex);
2996 if (itCache == m_Caches.end())
2998 OSL_FAIL(
"Cache pool and index pool out-of-sync !!!");
3002 return itCache->second.get();
3007 return m_Caches.size();
3013 if (maRanges.
empty())
3017 for (
ScRange& rKeyRange : maRanges)
3019 SCCOL nCol1 = rKeyRange.aStart.Col();
3020 SCROW nRow1 = rKeyRange.aStart.Row();
3021 SCTAB nTab1 = rKeyRange.aStart.Tab();
3022 SCCOL nCol2 = rKeyRange.aEnd.Col();
3023 SCROW nRow2 = rKeyRange.aEnd.Row();
3024 SCTAB nTab2 = rKeyRange.aEnd.Tab();
3030 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
3035 ScRange aNew(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
3043 RangeIndexType::iterator it = std::find(maRanges.
begin(), maRanges.
end(), rRange);
3044 if (it == maRanges.
end())
3051 size_t nIndex = std::distance(maRanges.
begin(), it);
3052 CachesType::iterator
const itCache = m_Caches.find(nIndex);
3053 if (itCache == m_Caches.end())
3055 OSL_FAIL(
"Cache pool and index pool out-of-sync !!!");
3069 setGroupItemsToCache(rCache, rRefs);
3074 CachesType::iterator it = std::find_if(m_Caches.begin(), m_Caches.end(),
3075 [&p](
const CachesType::value_type& rEntry) {
return rEntry.second.get() == p; });
3076 if (it != m_Caches.end())
3078 size_t idx = it->first;
3080 maRanges[idx].SetInvalid();
3095 return m_Caches.count(rName) != 0;
3101 CachesType::const_iterator
const itr = m_Caches.find(rName);
3102 if (itr != m_Caches.end())
3104 return itr->second.get();
3107 pCache->InitFromDoc(
mrDoc, rRange);
3112 m_Caches.insert(std::make_pair(rName, std::move(pCache)));
3118 CachesType::iterator
const itr = m_Caches.find(rName);
3119 return itr != m_Caches.end() ? itr->second.get() :
nullptr;
3124 return m_Caches.size();
3130 CachesType::iterator
const itr = m_Caches.find(rName);
3131 if (itr == m_Caches.end())
3145 setGroupItemsToCache(rCache, rRefs);
3150 CachesType::iterator it = std::find_if(m_Caches.begin(), m_Caches.end(),
3151 [&p](
const CachesType::value_type& rEntry) {
return rEntry.second.get() == p; });
3152 if (it != m_Caches.end())
3161 mnSdbType(nSdbType), maDBName(rDBName), maCommand(rCommand) {}
3165 return left < right;
3172 DBType aType(nSdbType, rDBName, rCommand);
3173 CachesType::const_iterator
const itr = m_Caches.find(aType);
3174 return itr != m_Caches.end();
3178 sal_Int32 nSdbType,
const OUString& rDBName,
const OUString& rCommand,
3181 DBType aType(nSdbType, rDBName, rCommand);
3182 CachesType::const_iterator
const itr = m_Caches.find(aType);
3183 if (itr != m_Caches.end())
3185 return itr->second.get();
3187 uno::Reference<sdbc::XRowSet> xRowSet = createRowSet(nSdbType, rDBName, rCommand);
3193 DBConnector aDB(*pCache, xRowSet, aFormat.
GetNullDate());
3197 if (!pCache->InitFromDataBase(aDB))
3207 ::comphelper::disposeComponent(xRowSet);
3209 m_Caches.insert(std::make_pair(aType, std::move(pCache)));
3214 sal_Int32 nSdbType,
const OUString& rDBName,
const OUString& rCommand)
3216 DBType aType(nSdbType, rDBName, rCommand);
3217 CachesType::iterator
const itr = m_Caches.find(aType);
3218 return itr != m_Caches.end() ? itr->second.get() :
nullptr;
3222 sal_Int32 nSdbType,
const OUString& rDBName,
const OUString& rCommand)
3224 uno::Reference<sdbc::XRowSet> xRowSet;
3231 uno::Reference<beans::XPropertySet> xRowProp(xRowSet, UNO_QUERY);
3232 OSL_ENSURE( xRowProp.is(),
"can't get RowSet" );
3235 xRowSet.set(
nullptr);
3245 uno::Reference<sdb::XCompletedExecution> xExecute( xRowSet, uno::UNO_QUERY );
3246 if ( xExecute.is() )
3248 uno::Reference<task::XInteractionHandler> xHandler(
3250 uno::UNO_QUERY_THROW);
3251 xExecute->executeWithCompletion( xHandler );
3258 catch (
const sdbc::SQLException& rError )
3262 VclMessageType::Info, VclButtonsType::Ok,
3266 catch ( uno::Exception& )
3271 xRowSet.set(
nullptr);
3276 sal_Int32 nSdbType,
const OUString& rDBName,
const OUString& rCommand,
3279 DBType aType(nSdbType, rDBName, rCommand);
3280 CachesType::iterator
const it = m_Caches.find(aType);
3281 if (it == m_Caches.end())
3290 uno::Reference<sdbc::XRowSet> xRowSet = createRowSet(nSdbType, rDBName, rCommand);
3298 DBConnector aDB(rCache, xRowSet, aFormat.
GetNullDate());
3315 setGroupItemsToCache(rCache, rRefs);
3320 CachesType::iterator it = std::find_if(m_Caches.begin(), m_Caches.end(),
3321 [&p](
const CachesType::value_type& rEntry) {
return rEntry.second.get() == p; });
3322 if (it != m_Caches.end())
3340 maSheetCaches(r.mrDoc),
3341 maNameCaches(r.mrDoc),
3360 explicit MatchByTable(
SCTAB nTab) : mnTab(nTab) {}
3362 bool operator() (
const std::unique_ptr<ScDPObject>& rObj)
const
3364 return rObj->GetOutRange().aStart.Tab() == mnTab;
3373 return STR_ERR_DATAPILOTSOURCE;
3380 return STR_ERR_DATAPILOTSOURCE;
3418 return STR_ERR_DATAPILOTSOURCE;
3524 for (
const std::unique_ptr<ScDPObject>& aTable :
maTables)
3528 if (&rRefObj == &rDPObj)
3537 if (pDesc ==
nullptr || pRefDesc ==
nullptr)
3570 if (pDesc ==
nullptr || pRefDesc ==
nullptr)
3596 rxTable->UpdateReference(eUpdateRefMode, r, nDx, nDy, nDz);
3605 for (
const auto& rxTable :
maTables)
3619 aAdded.push_back(std::unique_ptr<ScDPObject>(pNew));
3622 std::move(aAdded.begin(), aAdded.end(), std::back_inserter(maTables));
3628 [](
const TablesType::value_type&
a,
const TablesType::value_type& b) {
return a->RefsEqual(*b); });
3636 TablesType::iterator itr2 = r.
maTables.begin();
3637 for (
const auto& rxTable :
maTables)
3639 rxTable->WriteRefsTo(**itr2);
3649 size_t nDestSize = r.
maTables.size();
3650 OSL_ENSURE( nSrcSize >= nDestSize,
"WriteRefsTo: missing entries in document" );
3651 for (
size_t nSrcPos = 0; nSrcPos < nSrcSize; ++nSrcPos)
3654 const OUString& aName = rSrcObj.
GetName();
3655 bool bFound =
false;
3656 for (
size_t nDestPos = 0; nDestPos < nDestSize && !bFound; ++nDestPos)
3659 if (rDestObj.
GetName() == aName)
3672 OSL_ENSURE(
maTables.size() == r.
maTables.size(),
"WriteRefsTo: couldn't restore all entries" );
3695 if (
pObject->GetName() == rName)
3705 for (
size_t nAdd = 0; nAdd <= n; ++nAdd)
3707 OUString aNewName =
"DataPilot" + OUString::number(1 + nAdd);
3709 [&aNewName](
const TablesType::value_type& rxObj) {
return rxObj->GetName() == aNewName; }))
3722 auto funcRemoveCondition = [pDPObject] (std::unique_ptr<ScDPObject>
const & pCurrent)
3724 return pCurrent.get() == pDPObject;
3732 const ScRange& rOutRange = pDPObj->GetOutRange();
3737 maTables.push_back(std::move(pDPObj));
3743 for (
const std::unique_ptr<ScDPObject>& aTable :
maTables)
3745 if (aTable.get() == pDPObj)
3785 return std::for_each(
maTables.begin(),
maTables.end(), AccumulateOutputRanges(nTab)).getRanges();
3790 return std::any_of(
maTables.begin(),
maTables.end(), FindIntersectingTableByColumns(nCol1, nCol2, nRow, nTab));
3795 return std::any_of(
maTables.begin(),
maTables.end(), FindIntersectingTableByRows(nCol, nRow1, nRow2, nTab));
3800 return std::any_of(
maTables.begin(),
maTables.end(), FindIntersectingTable(rRange));
3803 #if DEBUG_PIVOT_TABLE
3809 void operator() (
const std::unique_ptr<ScDPObject>& rObj)
const
3811 cout <<
"-- '" << rObj->GetName() <<
"'" <<
endl;
3824 void ScDPCollection::DumpTables()
const
3849 for (
const auto& rxTable :
maTables)
3868 aRefs.
insert(const_cast<ScDPObject*>(&rObj));
3877 for (
const auto& rxTable :
maTables)
3896 aRefs.
insert(const_cast<ScDPObject*>(&rObj));
3903 sal_Int32 nSdbType, std::u16string_view rDBName, std::u16string_view rCommand,
3907 for (
const auto& rxTable :
maTables)
3922 aRefs.
insert(const_cast<ScDPObject*>(&rObj));
SheetCaches(ScDocument &rDoc)
void SetValue(double fVal)
bool operator()(const DBType &left, const DBType &right) const
const ScDPDimensionSaveData * GetExistingDimensionData() const
OString stripEnd(std::string_view rIn, char c)
SAL_DLLPRIVATE ScDPTableData * GetTableData()
#define SC_UNO_DP_FIELD_SUBTOTALNAME
bool IsDimNameInUse(std::u16string_view rName) const
virtual sal_Int32 SAL_CALL getCount() override
const std::optional< OUString > & GetLayoutName() const
void GetHeaderPositionData(const ScAddress &rPos, css::sheet::DataPilotTableHeaderData &rData)
static ScRefUpdateRes Update(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz, SCCOL &theCol1, SCROW &theRow1, SCTAB &theTab1, SCCOL &theCol2, SCROW &theRow2, SCTAB &theTab2)
void ReloadGroupTableData()
#define SC_UNO_DP_IGNOREEMPTY
static ScGeneralFunction FirstFunc(PivotFunc nBits)
ScPivotFieldVector maDataFields
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
void CopyToTab(SCTAB nOld, SCTAB nNew)
SC_DLLPUBLIC size_t GetCount() const
void SetOrientation(css::sheet::DataPilotFieldOrientation nNew)
std::vector< Member > maMembers
void FillOldParam(ScPivotParam &rParam) const
static OUString GetLocaleIndependentFormattedString(double fValue, SvNumberFormatter &rFormatter, sal_uInt32 nNumFormat)
#define SC_UNO_DP_REFVALUE
static sal_Int32 GetLongProperty(const css::uno::Reference< css::beans::XPropertySet > &xProp, const OUString &rName)
SC_DLLPUBLIC SheetCaches & GetSheetCaches()
bool HasGroupDimensions() const
void WriteSourceDataTo(ScDPObject &rDest) const
static SC_DLLPUBLIC::utl::TransliterationWrapper * GetpTransliteration()
static void ConvertOrientation(ScDPSaveData &rSaveData, const ScPivotFieldVector &rFields, css::sheet::DataPilotFieldOrientation nOrient, const css::uno::Reference< css::sheet::XDimensionsSupplier > &xSource, const ScDPLabelDataVector &rLabels, const ScPivotFieldVector *pRefColFields=nullptr, const ScPivotFieldVector *pRefRowFields=nullptr, const ScPivotFieldVector *pRefPageFields=nullptr)
bool mbEnableGetPivotData
std::unique_ptr< ContentProperties > pData
static weld::Window * GetActiveDialogParent()
DBType(sal_Int32 nSdbType, const OUString &rDBName, const OUString &rCommand)
bool RefsEqual(const ScDPCollection &r) const
#define SC_DBPROP_DATASOURCENAME
OString strip(std::string_view rIn, char c)
static void GetDataDimensionNames(OUString &rSourceName, OUString &rGivenName, const css::uno::Reference< css::uno::XInterface > &xDim)
tools::Long GetDimCount()
SC_DLLPUBLIC bool Intersects(const ScRange &rRange) const
SC_DLLPUBLIC bool GetReferenceGroups(const ScDPObject &rDPObj, const ScDPDimensionSaveData **pGroups) const
void GetDrillDownData(const ScAddress &rPos, css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &rTableData)
#define SC_UNO_DP_COLGRAND
dp field button with presence of hidden member
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
bool remove(const ScDPCache *p)
#define SC_UNO_DP_SORTING
void SetOutRange(const ScRange &rRange)
void FillLabelData(sal_Int32 nDim, ScDPLabelData &Labels)
const ContentProperties & rData
sal_Int32 mnUsedHier
Used hierarchy.
void SetAllowMove(bool bSet)
bool mbShowAll
true = Show all (also empty) results.
void updateReference(UpdateRefMode eMode, const ScRange &r, SCCOL nDx, SCROW nDy, SCTAB nDz)
static EnumT GetEnumProperty(const css::uno::Reference< css::beans::XPropertySet > &xProp, const OUString &rName, EnumT nDefault)
std::vector< std::unique_ptr< ScDPObject > > TablesType
#define SC_UNO_DP_REPEATEMPTY
void EnableGetPivotData(bool b)
#define SC_UNO_DP_POSITION
void swap(sorted_vector &other)
void SetImportDesc(const ScImportSourceDesc &rDesc)
Data caches for range name based source data.
static OUString GetStringProperty(const css::uno::Reference< css::beans::XPropertySet > &xProp, const OUString &rName, const OUString &rDefault)
This class represents the cached data part of the datapilot cache table implementation.
EmbeddedObjectRef * pObject
void InitFromDoc(ScDocument &rDoc, const ScRange &rRange)
ScDPObject * GetByName(std::u16string_view rName) const
SAL_DLLPRIVATE void ClearSource()
bool IsImportData() const
bool mbIsValue
true = Sum or count in data field.
#define SC_DBPROP_COMMANDTYPE
css::sheet::DataPilotFieldLayoutInfo maLayoutInfo
Layout info.
const char * CheckSourceRange() const
Check the sanity of the data source range.
ScDPServiceDesc(const OUString &rServ, const OUString &rSrc, const OUString &rNam, const OUString &rUser, const OUString &rPass)
#define SC_UNO_DP_ORIGINAL
ScDPCollection(ScDocument &rDocument)
OUString CreateNewName() const
Create a new name that's not yet used by any existing data pilot objects.
#define SC_UNO_DP_LAYOUTNAME
std::shared_ptr< ScDPTableData > mpTableData
css::uno::Reference< css::sheet::XDimensionsSupplier > xSource
static bool HasRegisteredSources()
void GetHierarchies(sal_Int32 nDim, css::uno::Sequence< OUString > &rHiers)
const ScRange & GetOutRange() const
Data caches for external database sources.
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 ...
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SC_DLLPUBLIC SCSIZE GetEntryCount() const
sal_Int32 mnFlags
Flags from the DataPilotSource dimension.
std::unique_ptr< ScDPServiceDesc > pServDesc
void push_back(const ScRange &rRange)
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
Defines connection type to external data source.
void AddReference(ScDPObject *pObj) const
bool SyncAllDimensionMembers()
Remove in the save data entries for members that don't exist anymore.
bool ReloadGroupsInCache(const ScDPObject *pDPObj, o3tl::sorted_vector< ScDPObject * > &rRefs)
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
ScGeneralFunction GetFunction() const
bool GetMembersNA(sal_Int32 nDim, css::uno::Reference< css::sheet::XMembersAccess > &xMembers)
virtual void ReloadCacheTable()=0
void SetStringInterned(rtl_uString *pS)
#define SC_DBPROP_COMMAND
void SetSheetDesc(const ScSheetSourceDesc &rDesc)
virtual void SetEmptyFlags(bool bIgnoreEmptyRows, bool bRepeatIfEmpty)=0
void Output(const ScAddress &rPos)
std::unordered_map< OUString, size_t > DimOrderType
bool IsDataDescriptionCell(const ScAddress &rPos)
Data description cell displays the description of a data dimension if and only if there is only one d...
void SetFunction(ScGeneralFunction nNew)
static SC_DLLPUBLIC OUString getSourceDimensionName(std::u16string_view rName)
void GetAllTables(const ScRange &rSrcRange, o3tl::sorted_vector< ScDPObject * > &rRefs) const
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
OUString maName
Original name of the dimension.
#define SC_UNO_DP_REPEATITEMLABELS
static css::uno::Reference< css::sheet::XDimensionsSupplier > CreateSource(const ScDPServiceDesc &rDesc)
void WriteRefsTo(ScDPObject &r) const
#define SAL_N_ELEMENTS(arr)
void SetName(const OUString &rNew)
void SetLayoutName(const OUString &rName)
ScDPLabelDataVector maLabelArray
bool IsFilterButton(const ScAddress &rPos)
static PivotFunc FunctionBit(sal_Int16 eFunc)
Interface for connecting to database source.
void SetHeaderLayout(bool bUseGrid)
#define DBG_UNHANDLED_EXCEPTION(...)
bool IntersectsTableByColumns(SCCOL nCol1, SCCOL nCol2, SCROW nRow, SCTAB nTab) const
bool RefsEqual(const ScDPObject &r) const
const ScDPCache * getCache(const OUString &rName, const ScRange &rRange, const ScDPDimensionSaveData *pDimData)
bool IntersectsTableByRows(SCCOL nCol, SCROW nRow1, SCROW nRow2, SCTAB nTab) const
#define TOOLS_WARN_EXCEPTION(area, stream)
ScPivotFieldVector maColFields
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
#define SC_UNO_DP_FUNCTION2
ScDPCache * getExistingCache(sal_Int32 nSdbType, const OUString &rDBName, const OUString &rCommand)
SC_DLLPUBLIC ScDPObject & operator[](size_t nIndex)
SC_DLLPUBLIC const std::vector< ScRange > & getAllRanges() const
std::vector< std::unique_ptr< ScDPLabelData > > ScDPLabelDataVector
tools::Long mnOriginalDim
>= 0 for duplicated field.
Stores and manages all caches from internal sheets.
std::vector< ScPivotField > ScPivotFieldVector
virtual OUString getDimensionName(sal_Int32 nColumn)=0
const ScDPCache * getCache(const ScRange &rRange, const ScDPDimensionSaveData *pDimData)
css::uno::Reference< css::sheet::XDimensionsSupplier > const & GetSource()
void SetSaveData(const ScDPSaveData &rData)
const OUString & GetName() const
::std::vector< ScRange >::const_iterator end() const
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
void SetTag(const OUString &rNew)
static bool GetBoolProperty(const css::uno::Reference< css::beans::XPropertySet > &xProp, const OUString &rName, bool bDefault=false)
std::unique_ptr< ScDPSaveData > pSaveData
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
bool GetHeaderDrag(const ScAddress &rPos, bool bMouseLeft, bool bMouseTop, tools::Long nDragDim, tools::Rectangle &rPosRect, css::sheet::DataPilotFieldOrientation &rOrient, tools::Long &rDimPos)
NameCaches(ScDocument &rDoc)
static sheet::DataPilotFieldOrientation lcl_GetDataGetOrientation(const uno::Reference< sheet::XDimensionsSupplier > &xSource)
bool hasCache(const ScRange &rRange) const
ScDPSaveData * GetSaveData() const
bool GetHierarchiesNA(sal_Int32 nDim, css::uno::Reference< css::container::XNameAccess > &xHiers)
SC_DLLPUBLIC ScDPObject * InsertNewTable(std::unique_ptr< ScDPObject > pDPObj)
const ScImportSourceDesc * GetImportSourceDesc() const
css::sheet::DataPilotFieldReference maFieldRef
static bool lcl_HasButton(const ScDocument *pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
bool ParseFilters(OUString &rDataFieldName, std::vector< css::sheet::DataPilotFieldFilter > &rFilters, std::vector< sal_Int16 > &rFilterFuncs, std::u16string_view rFilterList)
#define SC_UNO_DP_AUTOSHOW
bool IsBlockEmpty(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes=false) const
ScDPObject & operator=(const ScDPObject &r)
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
static SC_DLLPUBLIC LanguageType eLnge
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
SCCOL nCol
Cursor Position /.
ScDPSaveDimension * DuplicateDimension(std::u16string_view rName)
void SetReferenceValue(const css::sheet::DataPilotFieldReference *pNew)
Reference not affected, no change at all.
static PivotFunc lcl_FirstSubTotal(const uno::Reference< beans::XPropertySet > &xDimProp)
bool GetMembers(sal_Int32 nDim, sal_Int32 nHier,::std::vector< ScDPLabelData::Member > &rMembers)
bool hasCache(sal_Int32 nSdbType, const OUString &rDBName, const OUString &rCommand) const
bool GetDataFieldPositionData(const ScAddress &rPos, css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters)
bool hasCache(const OUString &rName) const
DBCaches(ScDocument &rDoc)
static sal_uInt8 getDuplicateIndex(const OUString &rName)
Get a duplicate index in case the dimension is a duplicate.
const char * ReloadCache(const ScDPObject *pDPObj, o3tl::sorted_vector< ScDPObject * > &rRefs)
const std::shared_ptr< ScDPTableData > & GetSourceTableData() const
bool remove(const ScDPCache *p)
#define SC_UNO_DP_ROWGRAND
void RemoveCache(const ScDPCache *pCache)
Only to be called from ScDPCache::RemoveReference().
bool HasRangeName() const
#define SC_UNO_DP_ORIENTATION
#define SC_UNO_DP_ORIGINAL_POS
SC_DLLPUBLIC size_t size() const
OUString GetDimName(tools::Long nDim, bool &rIsDataLayout, sal_Int32 *pFlags=nullptr)
SAL_DLLPRIVATE void FillLabelDataForDimension(const css::uno::Reference< css::container::XIndexAccess > &xDims, sal_Int32 nDim, ScDPLabelData &rLabelData)
OUString maLayoutName
Layout name (display name)
#define SC_UNO_DP_SHOWEMPTY
bool GetMemberNames(sal_Int32 nDim, css::uno::Sequence< OUString > &rNames)
static bool IsOrientationAllowed(css::sheet::DataPilotFieldOrientation nOrient, sal_Int32 nDimFlags)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
Base class that abstracts different data source types of a datapilot table.
bool InitFromDataBase(DBConnector &rDB)
ScDPObject(ScDocument *pD)
bool operator<(const ScDPCollection::DBType &left, const ScDPCollection::DBType &right)
Reference< XMultiServiceFactory > getProcessServiceFactory()
std::unique_ptr< char[]> aBuffer
void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange &r, SCCOL nDx, SCROW nDy, SCTAB nDz)
SC_DLLPUBLIC bool HasTable(const ScDPObject *pDPObj) const
void updateCache(const OUString &rName, const ScRange &rRange, o3tl::sorted_vector< ScDPObject * > &rRefs)
ScRangeList GetAllTableRanges(SCTAB nTab) const
#define SC_UNO_DP_USEDHIERARCHY
css::uno::Sequence< OUString > maHiers
Hierarchies.
void Join(const ScRange &, bool bIsInList=false)
OString stripStart(std::string_view rIn, char c)
SheetCaches maSheetCaches
void SetSubtotalName(const OUString &rName)
std::unordered_set< OUString > ScDPUniqueStringSet
SvStream & endl(SvStream &rStr)
void SetServiceData(const ScDPServiceDesc &rDesc)
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2, which causes some type-safety issues.
std::unique_ptr< ScImportSourceDesc > pImpDesc
const OUString & GetName() const
SCROW nRow
or start of destination area
#define SC_UNO_DP_ISVISIBLE
css::sheet::DataPilotFieldSortInfo maSortInfo
Sorting info.
SC_DLLPUBLIC bool RemoveFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
static void lcl_FillLabelData(ScDPLabelData &rData, const uno::Reference< beans::XPropertySet > &xDimProp)
const ScDPObjectSet & GetAllReferences() const
bool remove(const ScDPCache *p)
const ScSheetSourceDesc * GetSheetDesc() const
const OUString & GetRangeName() const
OUString GetFormattedString(std::u16string_view rDimName, const double fValue)
void RemoveSubtotalName()
bool operator==(const ScDPServiceDesc &rOther) const
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
ScPivotFieldVector maRowFields
sal_Int32 GetUsedHierarchy(sal_Int32 nDim)
Reference< XComponentContext > getProcessComponentContext()
Sequence< sal_Int8 > aSeq
static sal_Int16 GetShortProperty(const css::uno::Reference< css::beans::XPropertySet > &xProp, const OUString &rName, sal_Int16 nDefault)
void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange &r, SCCOL nDx, SCROW nDy, SCTAB nDz)
void GetMemberResultNames(ScDPUniqueStringSet &rNames, tools::Long nDimension)
void SetShowEmpty(bool bSet)
static SC_DLLPUBLIC OUString getDisplayedMeasureName(std::u16string_view rName, ScSubTotalFunc eFunc)
OUString GetFormattedString(sal_Int32 nDim, const ScDPItemData &rItem, bool bLocaleIndependent) const
bool IsDuplicated(tools::Long nDim)
std::map< OUString, css::uno::Any > maInteropGrabBag
void WriteRefsTo(ScDPCollection &r) const
void WriteToData(ScDPGroupTableData &rData) const
void disposeComponent(css::uno::Reference< TYPE > &_rxComp)
double GetPivotData(const OUString &rDataFieldName, std::vector< css::sheet::DataPilotFieldFilter > &rFilters)
std::unique_ptr< ScSheetSourceDesc > pSheetDesc
::std::vector< ScRange >::const_iterator begin() const
void WriteToCache(ScDPCache &rCache) const
#define SC_UNO_DP_SHOWDETAILS
ScPivotFieldVector maPageFields
void WriteTempDataTo(ScDPObject &rDest) const
SAL_DLLPRIVATE void CreateOutput()
void DeleteOnTab(SCTAB nTab)
#define SC_UNO_DP_ISDATALAYOUT
static css::uno::Reference< css::sdbc::XRowSet > createRowSet(sal_Int32 nSdbType, const OUString &rDBName, const OUString &rCommand)
const char *const aFieldNames[]
std::unique_ptr< ScDPOutput > pOutput
std::pair< const_iterator, bool > insert(Value &&x)
void BuildAllDimensionMembers()
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
NameCaches & GetNameCaches()
SAL_DLLPRIVATE void CreateObjects()
constexpr OUStringLiteral first
static void lcl_FillOldFields(ScPivotFieldVector &rFields, const uno::Reference< sheet::XDimensionsSupplier > &xSource, sheet::DataPilotFieldOrientation nOrient, bool bAddData)
ScRange GetNewOutputRange(bool &rOverflow)
static std::vector< OUString > GetRegisteredSources()
sal_Int32 GetCommandType() const
SC_DLLPUBLIC ScDPCache * getExistingCache(const ScRange &rRange)
#define SCDPSOURCE_SERVICE
#define SC_UNO_DP_SUBTOTAL2
#define SC_SERVICE_ROWSET
This class contains authoritative information on the internal reference used as the data source for d...
void SetSubTotals(std::vector< ScGeneralFunction > const &rFuncs)
void updateCache(sal_Int32 nSdbType, const OUString &rDBName, const OUString &rCommand, o3tl::sorted_vector< ScDPObject * > &rRefs)
ScRange GetOutputRangeByType(sal_Int32 nType)
tools::Long getOriginalDim() const
tools::Long mnOriginalDim
original dimension index (>= 0 for duplicated dimension)
const ScDPCache * getCache(sal_Int32 nSdbType, const OUString &rDBName, const OUString &rCommand, const ScDPDimensionSaveData *pDimData)
SC_DLLPUBLIC ScDPSaveDimension * GetDimensionByName(const OUString &rName)
Get a dimension object by its name.
SCCOL nCol
0-based dimension index (not source column index)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
ScDPCache * getExistingCache(const OUString &rName)
tools::Long GetHeaderDim(const ScAddress &rPos, css::sheet::DataPilotFieldOrientation &rOrient)
SC_DLLPUBLIC ScDPSaveDimension * GetDataLayoutDimension()
void ToggleDetails(const css::sheet::DataPilotTableHeaderData &rElemDesc, ScDPObject *pDestObj)
static SC_DLLPUBLIC ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc)
SCCOL mnCol
0-based field index (not the source column index)
css::sheet::DataPilotFieldAutoShowInfo maShowInfo
AutoShow info.
void GetPositionData(const ScAddress &rPos, css::sheet::DataPilotTablePositionData &rPosData)
void updateCache(const ScRange &rRange, o3tl::sorted_vector< ScDPObject * > &rRefs)
void FreeTable(const ScDPObject *pDPObj)
virtual sal_Int32 GetColumnCount()=0
use (new) typed collection instead of ScStrCollection or separate Str and ValueCollection ...