44#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
45#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
47#include <unordered_map>
52using namespace css::sheet;
53using css::sheet::DataPilotFieldOrientation;
62 return DataPilotFieldOrientation_HIDDEN;
64 DataPilotFieldOrientation nOrient = DataPilotFieldOrientation_HIDDEN;
71 if ( nField >= 0 && nOrient == DataPilotFieldOrientation_PAGE )
73 bool bIsDataLayout =
false;
74 OUString aFieldName = pDPObj->
GetDimName( nField, bIsDataLayout );
75 if ( !aFieldName.isEmpty() && !bIsDataLayout )
76 return DataPilotFieldOrientation_PAGE;
80 nOrient = DataPilotFieldOrientation_HIDDEN;
84 if (nField >= 0 && (nOrient == DataPilotFieldOrientation_COLUMN || nOrient == DataPilotFieldOrientation_ROW) )
86 bool bIsDataLayout =
false;
87 OUString aFieldName = pDPObj->
GetDimName(nField, bIsDataLayout);
88 if (!aFieldName.isEmpty() && !bIsDataLayout)
92 return DataPilotFieldOrientation_HIDDEN;
116 if ( bLayoutRTL && !bLOKActive )
117 aDiffPix.
setX( -aDiffPix.
X() );
123 Size aScrSize(nSizeX-1, nSizeY-1);
127 mpFilterButton->setBoundingBox(aScrPos, aScrSize, bLayoutRTL && !bLOKActive);
128 mpFilterButton->setPopupLeft(bLayoutRTL && bLOKActive ?
false : bLayoutRTL);
160 DataPilotFieldOrientation nOrient = DataPilotFieldOrientation_HIDDEN;
163 if (!bButton &&
bPopup && aDimPos.
Col() > 0)
202 OSL_ENSURE(pDesc,
"no sheet source for filter button");
217 if ( pDlg->Execute() ==
RET_OK )
223 const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
236 OSL_FAIL(
"Nothing here");
258 Size aScrSize(nSizeX - 1, nSizeY - 1);
260 sal_uInt16 nIndent = 0;
262 nIndent = pIndentItem->GetValue();
275 sheet::DataPilotTableHeaderData
aData;
299 if ( aPixel.
X() < 0 )
301 if ( aPixel.
Y() < 0 )
304 if ( aPixel.
X() >= aSize.
Width() )
306 if ( aPixel.
Y() >= aSize.
Height() )
308 if ( nDx != 0 || nDy != 0 )
330 DataPilotFieldOrientation nOrient;
333 aPosRect, nOrient, nDimPos );
337 sal_Int32 nDimFlags = 0;
345 ePointer = PointerStyle::NotAllowed;
346 else if ( bHasRange )
349 case DataPilotFieldOrientation_COLUMN: ePointer = PointerStyle::PivotCol;
break;
350 case DataPilotFieldOrientation_ROW: ePointer = PointerStyle::PivotRow;
break;
351 case DataPilotFieldOrientation_PAGE:
352 case DataPilotFieldOrientation_DATA: ePointer = PointerStyle::PivotField;
break;
360 nOrient = DataPilotFieldOrientation_HIDDEN;
362 if ( bIsDataLayout && ( nOrient != DataPilotFieldOrientation_COLUMN &&
363 nOrient != DataPilotFieldOrientation_ROW ) )
407 Size aScrSize(nSizeX-1, nSizeY-1);
437 Size aScrSize(nSizeX - 1, nSizeY - 1);
450 DataPilotFieldOrientation nOrient;
469struct DPMultiFieldPopupData :
public DPFieldPopupData
471 std::vector<tools::Long> maFieldIndices;
472 std::vector<OUString> maFieldNames;
481 virtual bool execute()
override
483 mpGridWindow->UpdateDPFromFieldPopupMenu();
496 virtual bool execute()
override
498 mpGridWindow->UpdateDPPopupMenuForFieldChange();
508 enum SortType { ASCENDING, DESCENDING,
CUSTOM };
512 : mpDPObject(pDPObject)
513 , mnDimIndex(nDimIndex)
515 , mnUserListIndex(nUserListIndex)
516 , mpViewShell(pViewShell)
519 virtual bool execute()
override
524 mpViewShell->DataPilotSort(mpDPObject, mnDimIndex,
true);
527 mpViewShell->DataPilotSort(mpDPObject, mnDimIndex,
false);
530 mpViewShell->DataPilotSort(mpDPObject, mnDimIndex,
true, &mnUserListIndex);
542 sal_uInt16 mnUserListIndex;
551 DataPilotFieldOrientation nOrient;
558 DPFieldPopupData& rDPData,
bool& bDimOrientNotPage)
563 rDPData.mnDim = nDimIndex;
567 OUString aDimName = pDPObj->
GetDimName(rDPData.mnDim, bIsDataLayout);
575 bDimOrientNotPage = pDim->
GetOrientation() != DataPilotFieldOrientation_PAGE;
579 rDPData.mpDPObj = pDPObj;
585 ScDPObject* pDPObj, DataPilotFieldOrientation nOrient)
592 std::unique_ptr<DPMultiFieldPopupData> pDPData(
new DPMultiFieldPopupData);
593 pDPObj->
GetFieldIdsNames(nOrient, pDPData->maFieldIndices, pDPData->maFieldNames);
595 if (pDPData->maFieldIndices.empty())
598 tools::Long nDimIndex = pDPData->maFieldIndices[0];
600 bool bDimOrientNotPage =
true;
627 for (
size_t i = 0;
i <
n; ++
i)
647 const tools::Long nDimIndex =
static_cast<DPFieldPopupData*
>(pDPData.get())->mnDim;
651 mpDPFieldPopup->setFieldChangedAction(
new DPFieldChangedAction(
this));
656 if (bDimOrientNotPage)
658 vector<OUString> aUserSortNames;
662 size_t n = pUserList->
size();
663 aUserSortNames.reserve(
n);
664 for (
size_t i = 0;
i <
n; ++
i)
667 aUserSortNames.push_back(rData.
GetString());
675 new PopupSortAction(pDPObj, nDimIndex, PopupSortAction::ASCENDING, 0, pViewShell));
678 new PopupSortAction(pDPObj, nDimIndex, PopupSortAction::DESCENDING, 0, pViewShell));
683 size_t n = aUserSortNames.size();
684 for (
size_t i = 0;
i <
n; ++
i)
687 new PopupSortAction(pDPObj, nDimIndex, PopupSortAction::CUSTOM, sal_uInt16(
i), pViewShell));
710 std::unique_ptr<DPFieldPopupData> pDPData(
new DPFieldPopupData);
711 bool bDimOrientNotPage =
true;
723 false, -1, pNotifier));
741 DPMultiFieldPopupData* pDPData =
static_cast<DPMultiFieldPopupData*
>(
mpDPFieldPopup->getExtendedData());
745 if (pDPData->maFieldIndices.empty())
753 if (nDimIndex == pDPData->mnDim)
756 bool bDimOrientNotPage =
true;
769 typedef std::unordered_map<OUString, OUString> MemNameMapType;
774 DPFieldPopupData* pDPData =
static_cast<DPFieldPopupData*
>(
mpDPFieldPopup->getExtendedData());
782 OUString aDimName = pDPObj->
GetDimName(pDPData->mnDim, bIsDataLayout);
789 MemNameMapType aMemNameMap;
790 for (
const auto& rMember : rLabelData.
maMembers)
791 aMemNameMap.emplace(rMember.maLayoutName, rMember.maName);
797 std::unordered_map<OUString, bool> aResult;
798 for (
const auto& rItem : aRawResult)
800 MemNameMapType::const_iterator itrNameMap = aMemNameMap.find(rItem.aName);
801 if (itrNameMap == aMemNameMap.end())
804 OUString
aName = rItem.aName;
809 aResult.emplace(
aName, rItem.bValid);
814 aResult.emplace(itrNameMap->second, rItem.bValid);
827T lcl_getValidValue(T value, T defvalue)
829 return (value <0) ? defvalue :
value;
855 if (nXRight > rDoc.
MaxCol())
858 if (nYBottom > rDoc.
MaxRow())
934 if ( nMouseX <= aTL.
X() + 4 )
939 else if ( nMouseX >= aBR.
X() - 6 )
944 if ( nMouseY <= aTL.
Y() + 2 )
949 else if ( nMouseY >= aBR.
Y() - 4 )
955 if ( bHori || bVert )
957 sal_uInt16
nCount = sal::static_int_cast<sal_uInt16>( pPageData->
GetCount() );
962 bool bLHit = ( bHori && nHitX == aRange.
aStart.
Col() );
963 bool bRHit = ( bHori && nHitX == aRange.
aEnd.
Col() + 1 );
964 bool bTHit = ( bVert && nHitY == aRange.
aStart.
Row() );
965 bool bBHit = ( bVert && nHitY == aRange.
aEnd.
Row() + 1 );
966 bool bInsideH = ( nPosX >= aRange.
aStart.
Col() && nPosX <= aRange.
aEnd.
Col() );
967 bool bInsideV = ( nPosY >= aRange.
aStart.
Row() && nPosY <= aRange.
aEnd.
Row() );
987 else if ( bTHit && bInsideH )
989 else if ( bBHit && bInsideH )
996 if ( bVert && bInsideH && !nFound )
1000 for (
size_t nRowPos=0; nRowPos+1<nRowCount; nRowPos++)
1001 if ( pRowEnd[nRowPos]+1 == nHitY )
1007 nPrev = pRowEnd[nRowPos-1]+1;
1012 if ( bHori && bInsideV && !nFound )
1016 for (
size_t nColPos=0; nColPos+1<nColCount; nColPos++)
1017 if ( pColEnd[nColPos]+1 == nHitX )
1023 nPrev = pColEnd[nColPos-1]+1;
1048 bool bTimer =
false;
1052 if ( aPos.
X() < 0 ) nDx = -1;
1053 if ( aPos.
Y() < 0 ) nDy = -1;
1055 if ( aPos.
X() >= aSize.
Width() )
1057 if ( aPos.
Y() >= aSize.
Height() )
1059 if ( nDx != 0 || nDy != 0 )
1103 if ( !bLeft ) ++nPosX;
1104 if ( !bTop ) ++nPosY;
1108 bool bToEnd =
false;
1172 if ( !bUp && !bHide )
1198 OUString aUndo =
ScResId( STR_UNDO_DRAG_BREAK );
1210 if ( !bHide && !bToEnd )
1237 if ( !bHide && !bToEnd )
1239 ScAddress aNewAddr( nPosX, nNew, nTab );
1274 OUString aNewRanges;
1288 if (!aTemp.isEmpty())
1290 if ( !aNewRanges.isEmpty() )
1292 aNewRanges += aTemp;
const Point & GetPosPixel() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
constexpr tools::Long X() const
virtual VclPtr< AbstractScPivotFilterDlg > CreateScPivotFilterDlg(weld::Window *pParent, const SfxItemSet &rArgSet, sal_uInt16 nSourceTab)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
void IncCol(SCCOL nDelta=1)
bool UpdatePivotTable(ScDPObject &rDPObj, bool bRecord, bool bApi)
bool DataPilotUpdate(ScDPObject *pOldObj, const ScDPObject *pNewObj, bool bRecord, bool bApi, bool bAllowMove=false)
void GetHeaderPositionData(const ScAddress &rPos, css::sheet::DataPilotTableHeaderData &rData)
void SetSaveData(const ScDPSaveData &rData)
static bool IsOrientationAllowed(css::sheet::DataPilotFieldOrientation nOrient, sal_Int32 nDimFlags)
css::uno::Reference< css::sheet::XDimensionsSupplier > const & GetSource()
bool GetHeaderDrag(const ScAddress &rPos, bool bMouseLeft, bool bMouseTop, tools::Long nDragDim, tools::Rectangle &rPosRect, css::sheet::DataPilotFieldOrientation &rOrient, tools::Long &rDimPos)
tools::Long GetHeaderDim(const ScAddress &rPos, css::sheet::DataPilotFieldOrientation &rOrient)
void BuildAllDimensionMembers()
bool IsFilterButton(const ScAddress &rPos)
void SetSheetDesc(const ScSheetSourceDesc &rDesc)
const ScSheetSourceDesc * GetSheetDesc() const
void ToggleDetails(const css::sheet::DataPilotTableHeaderData &rElemDesc, ScDPObject *pDestObj)
ScDPSaveData * GetSaveData() const
OUString GetDimName(tools::Long nDim, bool &rIsDataLayout, sal_Int32 *pFlags=nullptr)
void GetFieldIdsNames(css::sheet::DataPilotFieldOrientation nOrient, std::vector< tools::Long > &rIndices, std::vector< OUString > &rNames)
void FillLabelData(sal_Int32 nDim, ScDPLabelData &Labels)
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDimensionByName(std::u16string_view rName) const
bool GetDrillDown() const
void SetPosition(ScDPSaveDimension *pDim, tools::Long nNew)
SC_DLLPUBLIC ScDPSaveDimension * GetDataLayoutDimension()
SC_DLLPUBLIC ScDPSaveDimension * GetDimensionByName(const OUString &rName)
Get a dimension object by its name.
void UpdateMemberVisibility(const std::unordered_map< OUString, bool > &rData)
void SetOrientation(css::sheet::DataPilotFieldOrientation nNew)
css::sheet::DataPilotFieldOrientation GetOrientation() const
bool AdjustPrintZoom(const ScRange &rRange)
void SetDocumentModified()
const ScDocument & GetDocument() const
virtual SfxUndoManager * GetUndoManager() override
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC const ScRange * GetPrintRange(SCTAB nTab, sal_uInt16 nPos)
SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
bool IsUndoEnabled() const
SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount(SCTAB nTab)
bool IsPrintEntireSheet(SCTAB nTab) const
Returns true, if the specified sheet is always printed.
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
static SC_DLLPUBLIC ScUserList * GetUserList()
void DPMouseButtonUp(const MouseEvent &rMEvt)
bool DoPageFieldSelection(SCCOL nCol, SCROW nRow)
void UpdateDPPopupMenuForFieldChange()
css::sheet::DataPilotFieldOrientation GetDPFieldOrientation(SCCOL nCol, SCROW nRow) const
void DPPopulateFieldMembers(const ScDPLabelData &rLabelData)
void DPLaunchFieldPopupMenu(const Point &rScrPos, const Size &rScrSize, const ScAddress &rPos, ScDPObject *pDPObj)
std::unique_ptr< ScDPFieldButton > mpFilterButton
void DPSetupFieldPopup(std::unique_ptr< ScCheckListMenuControl::ExtendedData > pDPData, bool bDimOrientNotPage, ScDPObject *pDPObj, bool bMultiField=false)
void DPConfigFieldPopup()
bool DPTestFieldPopupArrow(const MouseEvent &rMEvt, const ScAddress &rPos, const ScAddress &rDimPos, ScDPObject *pDPObj)
Check if the mouse click is on a field popup button.
bool DPTestMultiFieldPopupArrow(const MouseEvent &rMEvt, const ScAddress &rPos, ScDPObject *pDPObj)
void DoPushPivotToggle(SCCOL nCol, SCROW nRow, const MouseEvent &rMEvt)
void UpdateDragRect(bool bShowRange, const tools::Rectangle &rPosRect)
void UpdateDPFromFieldPopupMenu()
void UpdateDragRectOverlay()
void DoPushPivotButton(SCCOL nCol, SCROW nRow, const MouseEvent &rMEvt, bool bButton, bool bPopup, bool bMultiField)
void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
void DPLaunchMultiFieldPopupMenu(const Point &rScrPos, const Size &rScrSize, ScDPObject *pDPObj, css::sheet::DataPilotFieldOrientation nOrient)
void PagebreakMove(const MouseEvent &rMEvt, bool bUp)
void DPMouseMove(const MouseEvent &rMEvt)
std::unique_ptr< ScCheckListMenuControl > mpDPFieldPopup
void LaunchPageFieldMenu(SCCOL nCol, SCROW nRow)
bool IsAutoFilterActive(SCCOL nCol, SCROW nRow, SCTAB nTab)
sal_uInt16 HitPageBreak(const Point &rMouse, ScRange *pSource, SCCOLROW *pBreak, SCCOLROW *pPrev)
sal_uInt16 nPagebreakMouse
void DPTestMouse(const MouseEvent &rMEvt, bool bMove)
bool DoAutoFilterButton(SCCOL nCol, SCROW nRow, const MouseEvent &rMEvt)
bool UpdateVisibleRange()
VisibleRange maVisibleRange
ScPrintRangeData & GetData(size_t i)
const SCCOL * GetPageEndX() const
const SCROW * GetPageEndY() const
const ScRange & GetPrintRange() const
const ScQueryParam & GetQueryData() const
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
This class contains authoritative information on the internal reference used as the data source for d...
const ScQueryParam & GetQueryParam() const
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
void SetQueryParam(const ScQueryParam &rParam)
void UpdatePageBreakData(bool bForcePaint=false)
SCROW GetLOKStartHeaderRow() const
SCROW GetLOKEndHeaderRow() const
void ErrorMessage(TranslateId pGlobStrId)
SCCOL GetLOKStartHeaderCol() const
void ScrollX(tools::Long nDeltaX, ScHSplitPos eWhich, bool bUpdBars=true)
void SetTimer(ScGridWindow *pWin, const MouseEvent &rMEvt)
void ActivatePart(ScSplitPos eWhich)
void ScrollY(tools::Long nDeltaY, ScVSplitPos eWhich, bool bUpdBars=true)
SCCOL GetLOKEndHeaderCol() const
ScPageBreakData * GetPageBreakData()
Stores individual user-defined sort list.
const OUString & GetString() const
Collection of user-defined sort lists.
bool GetMergeSizePixel(SCCOL nX, SCROW nY, tools::Long &rSizeXPix, tools::Long &rSizeYPix) const
void GetMouseQuadrant(const Point &rClickPos, ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY, bool &rLeft, bool &rTop)
const Fraction & GetZoomY() const
ScDocument & GetDocument() const
SCROW GetPosY(ScVSplitPos eWhich, SCTAB nForTab=-1) const
ScSplitMode GetHSplitMode() const
ScDocShell * GetDocShell() const
void GetPosFromPixel(tools::Long nClickX, tools::Long nClickY, ScSplitPos eWhich, SCCOL &rPosX, SCROW &rPosY, bool bTestMerge=true, bool bRepair=false, SCTAB nForTab=-1)
ScTabViewShell * GetViewShell() const
static tools::Long ToPixel(sal_uInt16 nTwips, double nFactor)
ScDBFunc * GetView() const
SCROW VisibleCellsY(ScVSplitPos eWhichY) const
ScSplitPos GetActivePart() const
Point GetScrPos(SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bAllowNeg=false, SCTAB nForTab=-1) const
SCCOL VisibleCellsX(ScHSplitPos eWhichX) const
ScSplitMode GetVSplitMode() const
SCCOL GetPosX(ScHSplitPos eWhich, SCTAB nForTab=-1) const
SC_DLLPUBLIC void DeletePageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
void SetPrintRanges(bool bEntireSheet, const OUString *pPrint, const OUString *pRepCol, const OUString *pRepRow, bool bAddPrint)
SC_DLLPUBLIC void InsertPageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SfxItemPool & GetPool() const
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
weld::Window * GetFrameWeld() const
ViewShellId GetViewShellId() const override
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual void SetPointer(PointerStyle) override
Point OutputToScreenPixel(const Point &rPos) const
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
bool IsMouseCaptured() const
const AllSettings & GetSettings() const
const MapMode & GetMapMode() const
::OutputDevice const * GetOutDev() const
Size GetOutputSizePixel() const
weld::Window * GetFrameWeld() const
bool lcl_FillDPFieldPopupData(tools::Long nDimIndex, ScDPObject *pDPObj, DPFieldPopupData &rDPData, bool &bDimOrientNotPage)
constexpr OUStringLiteral aData
uint8_t maLabels[mnMaxStaticSize]
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< ScIndentItem > ATTR_INDENT(131)
SC_DLLPUBLIC OUString const & getDisplayName() const
std::vector< Member > maMembers
bool set(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
ScHSplitPos WhichH(ScSplitPos ePos)
ScVSplitPos WhichV(ScSplitPos ePos)