20#undef SC_DLLIMPLEMENTATION
24#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
25#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
26#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
27#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
28#include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
30#include <osl/diagnose.h>
35#include <pvfundlg.hrc>
43using ::com::sun::star::uno::Sequence;
56bool lclFillListBox(
weld::ComboBox& rLBox,
const Sequence< OUString >& rStrings)
59 for (
const OUString& str : rStrings)
72bool lclFillListBox(
weld::ComboBox& rLBox,
const vector<ScDPLabelData::Member>& rMembers,
int nEmptyPos)
75 vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
76 for (; itr != itrEnd; ++itr)
78 OUString
aName = itr->getDisplayName();
90bool lclFillListBox(
weld::TreeView& rLBox,
const vector<ScDPLabelData::Member>& rMembers)
93 for (
const auto& rMember : rMembers)
98 OUString
aName = rMember.getDisplayName();
127const sal_uInt16 SC_BASEITEM_PREV_POS = 0;
128const sal_uInt16 SC_BASEITEM_NEXT_POS = 1;
129const sal_uInt16 SC_BASEITEM_USER_POS = 2;
131const sal_uInt16 SC_SORTNAME_POS = 0;
132const sal_uInt16 SC_SORTDATA_POS = 1;
152 if (
bool(nFuncMask & spnFunctions[ nEntry ]))
163 std::vector<int> aRows =
m_xControl->get_selected_rows();
164 for (
int nSel : aRows)
165 nFuncMask |= spnFunctions[nSel];
171 OSL_ENSURE( !
m_xControl->n_children(),
"ScDPMultiFuncListBox::FillFunctionNames - do not add texts to resource" );
182 int FromDataPilotFieldReferenceType(
int eMode)
188 case DataPilotFieldReferenceType::ITEM_DIFFERENCE:
190 case DataPilotFieldReferenceType::ITEM_PERCENTAGE:
192 case DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
194 case DataPilotFieldReferenceType::RUNNING_TOTAL:
196 case DataPilotFieldReferenceType::ROW_PERCENTAGE:
198 case DataPilotFieldReferenceType::COLUMN_PERCENTAGE:
200 case DataPilotFieldReferenceType::TOTAL_PERCENTAGE:
202 case DataPilotFieldReferenceType::INDEX:
208 int ToDataPilotFieldReferenceType(
int nPos)
215 return DataPilotFieldReferenceType::ITEM_DIFFERENCE;
217 return DataPilotFieldReferenceType::ITEM_PERCENTAGE;
219 return DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
221 return DataPilotFieldReferenceType::RUNNING_TOTAL;
223 return DataPilotFieldReferenceType::ROW_PERCENTAGE;
225 return DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
227 return DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
229 return DataPilotFieldReferenceType::INDEX;
239 : GenericDialogController(pParent,
"modules/scalc/ui/datafielddialog.ui",
"DataFieldDialog")
241 , mxFtName(m_xBuilder->weld_label(
"name"))
242 , mxLbType(m_xBuilder->weld_combo_box(
"type"))
243 , mxFtBaseField(m_xBuilder->weld_label(
"basefieldft"))
244 , mxLbBaseField(m_xBuilder->weld_combo_box(
"basefield"))
245 , mxFtBaseItem(m_xBuilder->weld_label(
"baseitemft"))
246 , mxLbBaseItem(m_xBuilder->weld_combo_box(
"baseitem"))
247 , mxBtnOk(m_xBuilder->weld_button(
"ok"))
248 , mxBtnCancel(m_xBuilder->weld_button(
"cancel"))
249 , mrLabelVec(rLabelVec)
254 Init(rLabelData, rFuncData);
268 DataPilotFieldReference aRef;
270 aRef.ReferenceType = ToDataPilotFieldReferenceType(
mxLbType->get_active());
274 switch( nBaseItemPos )
276 case SC_BASEITEM_PREV_POS:
277 aRef.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
279 case SC_BASEITEM_NEXT_POS:
280 aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
284 aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
285 if( !
mbEmptyItem || (nBaseItemPos > SC_BASEITEM_USER_POS) )
300 mxLbFunc->SetSelection( nFuncMask );
311 OUString aSelectedEntry;
316 if (rxLabel->maName == rFuncData.
maFieldRef.ReferenceField)
317 aSelectedEntry = rxLabel->getDisplayName();
321 mxLbType->set_active(FromDataPilotFieldReferenceType(rFuncData.
maFieldRef.ReferenceType));
331 switch( rFuncData.
maFieldRef.ReferenceItemType )
333 case DataPilotFieldReferenceItemType::PREVIOUS:
336 case DataPilotFieldReferenceItemType::NEXT:
348 sal_Int32 nStartPos =
mbEmptyItem ? (SC_BASEITEM_USER_POS + 1) : SC_BASEITEM_USER_POS;
351 nPos = (
mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
372 sal_Int32
nPos = nStartPos;
374 while (nPos < mxLbBaseItem->get_count())
386 return bFound ?
nPos : -1;
391 if (&rLBox == mxLbType.get())
393 bool bEnableField, bEnableItem;
394 switch (ToDataPilotFieldReferenceType(mxLbType->get_active()))
396 case DataPilotFieldReferenceType::ITEM_DIFFERENCE:
397 case DataPilotFieldReferenceType::ITEM_PERCENTAGE:
398 case DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
399 bEnableField = bEnableItem =
true;
402 case DataPilotFieldReferenceType::RUNNING_TOTAL:
408 bEnableField = bEnableItem =
false;
411 bEnableField &= (mxLbBaseField->get_count() > 0);
412 mxFtBaseField->set_sensitive( bEnableField );
413 mxLbBaseField->set_sensitive( bEnableField );
415 bEnableItem &= bEnableField;
416 mxFtBaseItem->set_sensitive( bEnableItem );
417 mxLbBaseItem->set_sensitive( bEnableItem );
419 else if (&rLBox == mxLbBaseField.get())
422 while (mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS)
423 mxLbBaseItem->remove(SC_BASEITEM_USER_POS);
427 size_t nBasePos = mxLbBaseField->get_active();
428 if (nBasePos < mrLabelVec.size())
430 const vector<ScDPLabelData::Member>& rMembers = mrLabelVec[nBasePos]->maMembers;
431 mbEmptyItem = lclFillListBox(*mxLbBaseItem, rMembers, SC_BASEITEM_USER_POS);
434 for (
const auto& rMember : rMembers)
435 aMap.emplace(rMember.getDisplayName(), rMember.maName);
436 maBaseItemNameMap.swap(
aMap);
440 sal_uInt16 nItemPos = (mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
441 mxLbBaseItem->set_active( nItemPos );
447 if (&rButton == mxBtnOk.get())
461 const ScDPNameVec& rDataFields,
bool bEnableLayout)
462 : GenericDialogController(pParent,
"modules/scalc/ui/pivotfielddialog.ui",
"PivotFieldDialog")
464 , mrDataFields(rDataFields)
465 , maLabelData(rLabelData)
466 , mbEnableLayout(bEnableLayout)
467 , mxRbNone(m_xBuilder->weld_radio_button(
"none"))
468 , mxRbAuto(m_xBuilder->weld_radio_button(
"auto"))
469 , mxRbUser(m_xBuilder->weld_radio_button(
"user"))
471 , mxFtName(m_xBuilder->weld_label(
"name"))
472 , mxCbShowAll(m_xBuilder->weld_check_button(
"showall"))
473 , mxBtnOk(m_xBuilder->weld_button(
"ok"))
474 , mxBtnCancel(m_xBuilder->weld_button(
"cancel"))
475 , mxBtnOptions(m_xBuilder->weld_button(
"options"))
477 mxLbFunc->set_selection_mode(SelectionMode::Multiple);
479 Init(rLabelData, rFuncData);
503 nFuncMask =
mxLbFunc->GetSelection();
541 RadioClickHdl(*pRBtn);
558 if (&rButton == mxBtnOk.get())
566 if (!rBtn.get_active())
568 mxLbFunc->set_sensitive(mxRbUser->get_active());
579 if (&rBtn == mxBtnOptions.get())
581 mxOptionsDlg = std::make_shared<ScDPSubtotalOptDlg>(
m_xDialog.get(), mrDPObj, maLabelData, mrDataFields, mbEnableLayout);
585 mxOptionsDlg->FillLabelData(maLabelData);
586 mxOptionsDlg =
nullptr;
593 int FromDataPilotFieldLayoutMode(
int eMode)
597 case DataPilotFieldLayoutMode::TABULAR_LAYOUT:
599 case DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP:
601 case DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM:
603 case DataPilotFieldLayoutMode::COMPACT_LAYOUT:
609 int ToDataPilotFieldLayoutMode(
int nPos)
614 return DataPilotFieldLayoutMode::TABULAR_LAYOUT;
616 return DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
618 return DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
620 return DataPilotFieldLayoutMode::COMPACT_LAYOUT;
622 return DataPilotFieldLayoutMode::TABULAR_LAYOUT;
625 int FromDataPilotFieldShowItemsMode(
int eMode)
629 case DataPilotFieldShowItemsMode::FROM_TOP:
631 case DataPilotFieldShowItemsMode::FROM_BOTTOM:
637 int ToDataPilotFieldShowItemsMode(
int nPos)
642 return DataPilotFieldShowItemsMode::FROM_TOP;
644 return DataPilotFieldShowItemsMode::FROM_BOTTOM;
646 return DataPilotFieldShowItemsMode::FROM_TOP;
653 : GenericDialogController(pParent,
"modules/scalc/ui/datafieldoptionsdialog.ui",
654 "DataFieldOptionsDialog")
655 , m_xLbSortBy(m_xBuilder->weld_combo_box(
"sortby"))
656 , m_xRbSortAsc(m_xBuilder->weld_radio_button(
"ascending"))
657 , m_xRbSortDesc(m_xBuilder->weld_radio_button(
"descending"))
658 , m_xRbSortMan(m_xBuilder->weld_radio_button(
"manual"))
659 , m_xLayoutFrame(m_xBuilder->weld_widget(
"layoutframe"))
660 , m_xLbLayout(m_xBuilder->weld_combo_box(
"layout"))
661 , m_xCbLayoutEmpty(m_xBuilder->weld_check_button(
"emptyline"))
662 , m_xCbRepeatItemLabels(m_xBuilder->weld_check_button(
"repeatitemlabels"))
663 , m_xCbShow(m_xBuilder->weld_check_button(
"show"))
664 , m_xNfShow(m_xBuilder->weld_spin_button(
"items"))
665 , m_xFtShow(m_xBuilder->weld_label(
"showft"))
666 , m_xFtShowFrom(m_xBuilder->weld_label(
"showfromft"))
667 , m_xLbShowFrom(m_xBuilder->weld_combo_box(
"from"))
668 , m_xFtShowUsing(m_xBuilder->weld_label(
"usingft"))
669 , m_xLbShowUsing(m_xBuilder->weld_combo_box(
"using"))
670 , m_xHideFrame(m_xBuilder->weld_widget(
"hideframe"))
671 , m_xLbHide(m_xBuilder->weld_tree_view(
"hideitems"))
672 , m_xFtHierarchy(m_xBuilder->weld_label(
"hierarchyft"))
673 , m_xLbHierarchy(m_xBuilder->weld_combo_box(
"hierarchy"))
674 , m_xBtnOk(m_xBuilder->weld_button(
"ok"))
675 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
677 , maLabelData(rLabelData)
683 Init(rDataFields, bEnableLayout);
695 rLabelData.
maSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
696 else if (
m_xLbSortBy->get_active() == SC_SORTNAME_POS)
697 rLabelData.
maSortInfo.Mode = DataPilotFieldSortMode::NAME;
699 rLabelData.
maSortInfo.Mode = DataPilotFieldSortMode::DATA;
702 if (!aFieldName.
maName.isEmpty())
718 if (!aFieldName.
maName.isEmpty())
722 rLabelData.
maShowInfo.ItemCount = sal::static_int_cast<sal_Int32>(
m_xNfShow->get_value() );
751 for(
const auto& rDataField : rDataFields )
760 sal_Int32 nSortPos = SC_SORTNAME_POS;
761 if( nSortMode == DataPilotFieldSortMode::DATA )
766 nSortPos = SC_SORTNAME_POS;
767 nSortMode = DataPilotFieldSortMode::MANUAL;
781 case DataPilotFieldSortMode::MANUAL:
788 RadioClickHdl(*pRBtn);
842 for (
size_t i = 0;
i <
n; ++
i)
844 bool bEnable =
m_xLbHide->n_children() > 0;
855 const weld::ComboBox& rLBox, std::u16string_view rEntry, sal_Int32 nStartPos )
const
857 sal_Int32
nPos = nStartPos;
864 if (aUnoName == rEntry)
871 return bFound ?
nPos : -1;
876 if (&rButton == m_xBtnOk.get())
884 if (!rBtn.get_active())
887 m_xLbSortBy->set_sensitive(m_xRbSortMan->get_active());
892 if (&rCBox == m_xCbShow.get())
894 bool bEnable = m_xCbShow->get_active();
895 m_xNfShow->set_sensitive( bEnable );
896 m_xFtShow->set_sensitive( bEnable );
897 m_xFtShowFrom->set_sensitive( bEnable );
898 m_xLbShowFrom->set_sensitive( bEnable );
900 bool bEnableUsing = bEnable && (m_xLbShowUsing->get_count() > 0);
901 m_xFtShowUsing->set_sensitive(bEnableUsing);
902 m_xLbShowUsing->set_sensitive(bEnableUsing);
908 mrDPObj.GetMembers(maLabelData.mnCol, m_xLbHierarchy->get_active(), maLabelData.maMembers);
913 : GenericDialogController(pParent,
"modules/scalc/ui/showdetaildialog.ui",
"ShowDetail")
915 , mxLbDims(m_xBuilder->weld_tree_view(
"dimsTreeview"))
922 sal_Int32 nDimFlags = 0;
931 const std::optional<OUString> & pLayoutName = pDimension->
GetLayoutName();
933 aName = *pLayoutName;
952 return mxLbDims->n_children() ? GenericDialogController::run() :
static_cast<short>(
RET_CANCEL);
959 OUString aSelectedName =
mxLbDims->get_selected_text();
960 DimNameIndexMap::const_iterator itr =
maNameIndexMap.find(aSelectedName);
963 return aSelectedName;
966 bool bIsDataLayout =
false;
Reference< XExecutableDialog > m_xDialog
NameMapType maBaseItemNameMap
std::unique_ptr< weld::Button > mxBtnOk
PivotFunc GetFuncMask() const
std::unique_ptr< weld::Button > mxBtnCancel
bool mbEmptyItem
Data of all labels.
std::unique_ptr< weld::ComboBox > mxLbBaseField
sal_Int32 FindBaseItemPos(std::u16string_view rEntry, sal_Int32 nStartPos) const
Searches for a listbox entry, starts search at specified position.
std::unique_ptr< ScDPFunctionListBox > mxLbFunc
const OUString & GetBaseFieldName(const OUString &rLayoutName) const
ScDPFunctionDlg(weld::Widget *pParent, const ScDPLabelDataVector &rLabelVec, const ScDPLabelData &rLabelData, const ScPivotFuncData &rFuncData)
css::sheet::DataPilotFieldReference GetFieldRef() const
const ScDPLabelDataVector & mrLabelVec
std::unique_ptr< weld::Label > mxFtName
NameMapType maBaseFieldNameMap
const OUString & GetBaseItemName(const OUString &rLayoutName) const
void Init(const ScDPLabelData &rLabelData, const ScPivotFuncData &rFuncData)
std::unique_ptr< weld::ComboBox > mxLbType
std::unique_ptr< weld::ComboBox > mxLbBaseItem
virtual ~ScDPFunctionDlg() override
std::unique_ptr< weld::TreeView > m_xControl
void SetSelection(PivotFunc nFuncMask)
ScDPFunctionListBox(std::unique_ptr< weld::TreeView > xControl)
PivotFunc GetSelection() const
static bool IsOrientationAllowed(css::sheet::DataPilotFieldOrientation nOrient, sal_Int32 nDimFlags)
bool IsDuplicated(tools::Long nDim)
ScDPSaveData * GetSaveData() const
OUString GetDimName(tools::Long nDim, bool &rIsDataLayout, sal_Int32 *pFlags=nullptr)
tools::Long GetDimCount()
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDimensionByName(std::u16string_view rName) const
css::sheet::DataPilotFieldOrientation GetOrientation() const
const std::optional< OUString > & GetLayoutName() const
ScDPShowDetailDlg(weld::Window *pParent, ScDPObject &rDPObj, css::sheet::DataPilotFieldOrientation nOrient)
virtual ~ScDPShowDetailDlg() override
std::unique_ptr< weld::TreeView > mxLbDims
DimNameIndexMap maNameIndexMap
virtual short run() override
OUString GetDimensionName() const
std::unique_ptr< weld::Label > mxFtName
void FillLabelData(ScDPLabelData &rLabelData) const
std::unique_ptr< weld::RadioButton > mxRbAuto
PivotFunc GetFuncMask() const
std::shared_ptr< ScDPSubtotalOptDlg > mxOptionsDlg
ScDPSubtotalDlg(weld::Widget *pParent, ScDPObject &rDPObj, const ScDPLabelData &rLabelData, const ScPivotFuncData &rFuncData, const ScDPNameVec &rDataFields, bool bEnableLayout)
std::unique_ptr< weld::RadioButton > mxRbUser
std::unique_ptr< weld::RadioButton > mxRbNone
true = Enable Layout mode controls.
std::unique_ptr< weld::Button > mxBtnOptions
std::unique_ptr< weld::CheckButton > mxCbShowAll
std::unique_ptr< weld::Button > mxBtnOk
ScDPLabelData maLabelData
The list of all data field names.
std::unique_ptr< weld::Button > mxBtnCancel
void Init(const ScDPLabelData &rLabelData, const ScPivotFuncData &rFuncData)
virtual ~ScDPSubtotalDlg() override
std::unique_ptr< ScDPFunctionListBox > mxLbFunc
std::unique_ptr< weld::ComboBox > m_xLbShowUsing
std::unique_ptr< weld::Button > m_xBtnCancel
std::unique_ptr< weld::ComboBox > m_xLbShowFrom
ScDPName GetFieldName(const OUString &rLayoutName) const
NameMapType maDataFieldNameMap
void Init(const ScDPNameVec &rDataFields, bool bEnableLayout)
std::unique_ptr< weld::ComboBox > m_xLbLayout
std::unique_ptr< weld::SpinButton > m_xNfShow
std::unique_ptr< weld::RadioButton > m_xRbSortAsc
ScDPLabelData maLabelData
The DataPilot object (for member names).
ScDPSubtotalOptDlg(weld::Window *pParent, ScDPObject &rDPObj, const ScDPLabelData &rLabelData, const ScDPNameVec &rDataFields, bool bEnableLayout)
std::unique_ptr< weld::ComboBox > m_xLbSortBy
std::unique_ptr< weld::CheckButton > m_xCbRepeatItemLabels
std::unique_ptr< weld::ComboBox > m_xLbHierarchy
std::unique_ptr< weld::Label > m_xFtHierarchy
void FillLabelData(ScDPLabelData &rLabelData) const
sal_Int32 FindListBoxEntry(const weld::ComboBox &rLBox, std::u16string_view rEntry, sal_Int32 nStartPos) const
Searches for a listbox entry, starts search at specified position.
virtual ~ScDPSubtotalOptDlg() override
std::unique_ptr< weld::RadioButton > m_xRbSortMan
std::unique_ptr< weld::Button > m_xBtnOk
std::unique_ptr< weld::Widget > m_xLayoutFrame
std::unique_ptr< weld::TreeView > m_xLbHide
std::unique_ptr< weld::CheckButton > m_xCbShow
std::unique_ptr< weld::CheckButton > m_xCbLayoutEmpty
std::unique_ptr< weld::RadioButton > m_xRbSortDesc
std::unique_ptr< weld::Widget > m_xHideFrame
static SC_DLLPUBLIC OUString createDuplicateDimensionName(const OUString &rOriginal, size_t nDupCount)
virtual OUString get_text(int pos) const=0
void append_text(const OUString &rStr)
void insert_text(int pos, const OUString &rStr)
virtual int get_count() const=0
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
virtual void set_active(bool active)=0
virtual void set_text(int row, const OUString &rText, int col=-1)=0
virtual void set_toggle(int row, TriState eState, int col=-1)=0
virtual int n_children() const=0
void append(TreeIter *pRet=nullptr)
#define LINK(Instance, Class, Member)
#define SAL_N_ELEMENTS(arr)
HashMap_OWString_Interface aMap
std::vector< ScDPName > ScDPNameVec
std::vector< std::unique_ptr< ScDPLabelData > > ScDPLabelDataVector
IMPL_LINK_NOARG(ScDPFunctionDlg, DblClickHdl, weld::TreeView &, bool)
IMPL_LINK(ScDPFunctionDlg, SelectHdl, weld::ComboBox &, rLBox, void)
OUString ScResId(TranslateId aId)
sal_Int32 mnUsedHier
Used hierarchy.
css::sheet::DataPilotFieldAutoShowInfo maShowInfo
AutoShow info.
css::sheet::DataPilotFieldLayoutInfo maLayoutInfo
Layout info.
bool mbShowAll
true = Show all (also empty) results.
css::uno::Sequence< OUString > maHiers
Hierarchies.
css::sheet::DataPilotFieldSortInfo maSortInfo
Sorting info.
PivotFunc mnFuncMask
Page/Column/Row subtotal function.
std::vector< Member > maMembers
SC_DLLPUBLIC OUString const & getDisplayName() const
OUString maName
Original name of the dimension.
css::sheet::DataPilotFieldReference maFieldRef