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>
36 #include <globstr.hrc>
43 using ::com::sun::star::uno::Sequence;
59 for (
const OUString& str : rStrings)
72 bool 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();
90 bool lclFillListBox(
weld::TreeView& rLBox,
const vector<ScDPLabelData::Member>& rMembers)
93 for (
const auto& rMember : rMembers)
98 OUString aName = rMember.getDisplayName();
127 const sal_uInt16 SC_BASEITEM_PREV_POS = 0;
128 const sal_uInt16 SC_BASEITEM_NEXT_POS = 1;
129 const sal_uInt16 SC_BASEITEM_USER_POS = 2;
131 const sal_uInt16 SC_SORTNAME_POS = 0;
132 const 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 , mxExpander(m_xBuilder->weld_expander(
"expander"))
250 , mrLabelVec(rLabelVec)
255 Init(rLabelData, rFuncData);
269 DataPilotFieldReference aRef;
271 aRef.ReferenceType = ToDataPilotFieldReferenceType(
mxLbType->get_active());
275 switch( nBaseItemPos )
277 case SC_BASEITEM_PREV_POS:
278 aRef.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
280 case SC_BASEITEM_NEXT_POS:
281 aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
285 aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
286 if( !
mbEmptyItem || (nBaseItemPos > SC_BASEITEM_USER_POS) )
301 mxLbFunc->SetSelection( nFuncMask );
312 OUString aSelectedEntry;
317 if (rxLabel->maName == rFuncData.
maFieldRef.ReferenceField)
318 aSelectedEntry = rxLabel->getDisplayName();
322 mxLbType->set_active(FromDataPilotFieldReferenceType(rFuncData.
maFieldRef.ReferenceType));
332 switch( rFuncData.
maFieldRef.ReferenceItemType )
334 case DataPilotFieldReferenceItemType::PREVIOUS:
337 case DataPilotFieldReferenceItemType::NEXT:
349 sal_Int32 nStartPos =
mbEmptyItem ? (SC_BASEITEM_USER_POS + 1) : SC_BASEITEM_USER_POS;
352 nPos = (
mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
373 sal_Int32
nPos = nStartPos;
375 while (nPos < mxLbBaseItem->get_count())
387 return bFound ? nPos : -1;
392 if (&rLBox == mxLbType.get())
394 bool bEnableField, bEnableItem;
395 switch (ToDataPilotFieldReferenceType(mxLbType->get_active()))
397 case DataPilotFieldReferenceType::ITEM_DIFFERENCE:
398 case DataPilotFieldReferenceType::ITEM_PERCENTAGE:
399 case DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
400 bEnableField = bEnableItem =
true;
403 case DataPilotFieldReferenceType::RUNNING_TOTAL:
409 bEnableField = bEnableItem =
false;
412 bEnableField &= (mxLbBaseField->get_count() > 0);
413 mxFtBaseField->set_sensitive( bEnableField );
414 mxLbBaseField->set_sensitive( bEnableField );
416 bEnableItem &= bEnableField;
417 mxFtBaseItem->set_sensitive( bEnableItem );
418 mxLbBaseItem->set_sensitive( bEnableItem );
420 else if (&rLBox == mxLbBaseField.get())
423 while (mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS)
424 mxLbBaseItem->remove(SC_BASEITEM_USER_POS);
428 size_t nBasePos = mxLbBaseField->get_active();
429 if (nBasePos < mrLabelVec.size())
431 const vector<ScDPLabelData::Member>& rMembers = mrLabelVec[nBasePos]->maMembers;
432 mbEmptyItem = lclFillListBox(*mxLbBaseItem, rMembers, SC_BASEITEM_USER_POS);
435 for (
const auto& rMember : rMembers)
436 aMap.emplace(rMember.getDisplayName(), rMember.maName);
437 maBaseItemNameMap.swap(aMap);
441 sal_uInt16 nItemPos = (mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
442 mxLbBaseItem->set_active( nItemPos );
448 if (&rButton == mxBtnOk.get())
462 const ScDPNameVec& rDataFields,
bool bEnableLayout)
463 : GenericDialogController(pParent,
"modules/scalc/ui/pivotfielddialog.ui",
"PivotFieldDialog")
465 , mrDataFields(rDataFields)
466 , maLabelData(rLabelData)
467 , mbEnableLayout(bEnableLayout)
468 , mxRbNone(m_xBuilder->weld_radio_button(
"none"))
469 , mxRbAuto(m_xBuilder->weld_radio_button(
"auto"))
470 , mxRbUser(m_xBuilder->weld_radio_button(
"user"))
472 , mxFtName(m_xBuilder->weld_label(
"name"))
473 , mxCbShowAll(m_xBuilder->weld_check_button(
"showall"))
474 , mxBtnOk(m_xBuilder->weld_button(
"ok"))
475 , mxBtnCancel(m_xBuilder->weld_button(
"cancel"))
476 , mxBtnOptions(m_xBuilder->weld_button(
"options"))
478 mxLbFunc->set_selection_mode(SelectionMode::Multiple);
480 Init(rLabelData, rFuncData);
494 nFuncMask =
mxLbFunc->GetSelection();
532 RadioClickHdl(*pRBtn);
547 if (&rButton == mxBtnOk.get())
555 mxLbFunc->set_sensitive(&rBtn == mxRbUser.get());
566 if (&rBtn == mxBtnOptions.get())
576 int FromDataPilotFieldLayoutMode(
int eMode)
580 case DataPilotFieldLayoutMode::TABULAR_LAYOUT:
582 case DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP:
584 case DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM:
590 int ToDataPilotFieldLayoutMode(
int nPos)
595 return DataPilotFieldLayoutMode::TABULAR_LAYOUT;
597 return DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
599 return DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
601 return DataPilotFieldLayoutMode::TABULAR_LAYOUT;
604 int FromDataPilotFieldShowItemsMode(
int eMode)
608 case DataPilotFieldShowItemsMode::FROM_TOP:
610 case DataPilotFieldShowItemsMode::FROM_BOTTOM:
616 int ToDataPilotFieldShowItemsMode(
int nPos)
621 return DataPilotFieldShowItemsMode::FROM_TOP;
623 return DataPilotFieldShowItemsMode::FROM_BOTTOM;
625 return DataPilotFieldShowItemsMode::FROM_TOP;
632 : GenericDialogController(pParent,
"modules/scalc/ui/datafieldoptionsdialog.ui",
633 "DataFieldOptionsDialog")
634 , m_xLbSortBy(m_xBuilder->weld_combo_box(
"sortby"))
635 , m_xRbSortAsc(m_xBuilder->weld_radio_button(
"ascending"))
636 , m_xRbSortDesc(m_xBuilder->weld_radio_button(
"descending"))
637 , m_xRbSortMan(m_xBuilder->weld_radio_button(
"manual"))
638 , m_xLayoutFrame(m_xBuilder->weld_widget(
"layoutframe"))
639 , m_xLbLayout(m_xBuilder->weld_combo_box(
"layout"))
640 , m_xCbLayoutEmpty(m_xBuilder->weld_check_button(
"emptyline"))
641 , m_xCbRepeatItemLabels(m_xBuilder->weld_check_button(
"repeatitemlabels"))
642 , m_xCbShow(m_xBuilder->weld_check_button(
"show"))
643 , m_xNfShow(m_xBuilder->weld_spin_button(
"items"))
644 , m_xFtShow(m_xBuilder->weld_label(
"showft"))
645 , m_xFtShowFrom(m_xBuilder->weld_label(
"showfromft"))
646 , m_xLbShowFrom(m_xBuilder->weld_combo_box(
"from"))
647 , m_xFtShowUsing(m_xBuilder->weld_label(
"usingft"))
648 , m_xLbShowUsing(m_xBuilder->weld_combo_box(
"using"))
649 , m_xHideFrame(m_xBuilder->weld_widget(
"hideframe"))
650 , m_xLbHide(m_xBuilder->weld_tree_view(
"hideitems"))
651 , m_xFtHierarchy(m_xBuilder->weld_label(
"hierarchyft"))
652 , m_xLbHierarchy(m_xBuilder->weld_combo_box(
"hierarchy"))
653 , m_xBtnOk(m_xBuilder->weld_button(
"ok"))
654 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
656 , maLabelData(rLabelData)
662 Init(rDataFields, bEnableLayout);
674 rLabelData.
maSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
676 rLabelData.
maSortInfo.Mode = DataPilotFieldSortMode::NAME;
678 rLabelData.
maSortInfo.Mode = DataPilotFieldSortMode::DATA;
681 if (!aFieldName.maName.isEmpty())
697 if (!aFieldName.maName.isEmpty())
701 rLabelData.
maShowInfo.ItemCount = sal::static_int_cast<sal_Int32>(
m_xNfShow->get_value() );
710 for (
int nPos = 0; nPos < nVisCount; ++nPos)
730 for(
const auto& rDataField : rDataFields )
739 sal_Int32 nSortPos = SC_SORTNAME_POS;
740 if( nSortMode == DataPilotFieldSortMode::DATA )
745 nSortPos = SC_SORTNAME_POS;
746 nSortMode = DataPilotFieldSortMode::MANUAL;
760 case DataPilotFieldSortMode::MANUAL:
767 RadioClickHdl(*pRBtn);
785 nCount = SC_SHOW_DEFAULT;
821 for (
size_t i = 0;
i < n; ++
i)
823 bool bEnable =
m_xLbHide->n_children() > 0;
834 const weld::ComboBox& rLBox, std::u16string_view rEntry, sal_Int32 nStartPos )
const
836 sal_Int32 nPos = nStartPos;
843 if (aUnoName == rEntry)
850 return bFound ? nPos : -1;
855 if (&rButton == m_xBtnOk.get())
863 m_xLbSortBy->set_sensitive(&rBtn != m_xRbSortMan.get());
868 if (&rCBox == m_xCbShow.get())
870 bool bEnable = m_xCbShow->get_active();
871 m_xNfShow->set_sensitive( bEnable );
872 m_xFtShow->set_sensitive( bEnable );
873 m_xFtShowFrom->set_sensitive( bEnable );
874 m_xLbShowFrom->set_sensitive( bEnable );
876 bool bEnableUsing = bEnable && (m_xLbShowUsing->get_count() > 0);
877 m_xFtShowUsing->set_sensitive(bEnableUsing);
878 m_xLbShowUsing->set_sensitive(bEnableUsing);
884 mrDPObj.GetMembers(maLabelData.mnCol, m_xLbHierarchy->get_active(), maLabelData.maMembers);
889 : GenericDialogController(pParent,
"modules/scalc/ui/showdetaildialog.ui",
"ShowDetail")
891 , mxLbDims(m_xBuilder->weld_tree_view(
"dimsTreeview"))
898 sal_Int32 nDimFlags = 0;
899 OUString aName = rDPObj.
GetDimName( nDim, bIsDataLayout, &nDimFlags );
907 const std::optional<OUString> & pLayoutName = pDimension->
GetLayoutName();
909 aName = *pLayoutName;
928 return mxLbDims->n_children() ? GenericDialogController::run() :
static_cast<short>(
RET_CANCEL);
935 OUString aSelectedName =
mxLbDims->get_selected_text();
936 DimNameIndexMap::const_iterator itr =
maNameIndexMap.find(aSelectedName);
939 return aSelectedName;
942 bool bIsDataLayout =
false;
virtual void set_text(int row, const OUString &rText, int col=-1)=0
std::unique_ptr< weld::ComboBox > m_xLbShowUsing
#define LINK(Instance, Class, Member)
static SC_DLLPUBLIC OUString createDuplicateDimensionName(const OUString &rOriginal, size_t nDupCount)
void FillLabelData(ScDPLabelData &rLabelData) const
std::unique_ptr< weld::Button > mxBtnCancel
const std::optional< OUString > & GetLayoutName() const
OUString maName
Original name of the dimension.
std::vector< Member > maMembers
void Init(const ScDPLabelData &rLabelData, const ScPivotFuncData &rFuncData)
std::unique_ptr< ScDPFunctionListBox > mxLbFunc
std::unique_ptr< weld::RadioButton > m_xRbSortAsc
sal_Int32 FindBaseItemPos(std::u16string_view rEntry, sal_Int32 nStartPos) const
Searches for a listbox entry, starts search at specified position.
std::unique_ptr< weld::ComboBox > mxLbBaseField
void insert_text(int pos, const OUString &rStr)
css::sheet::DataPilotFieldOrientation GetOrientation() const
virtual ~ScDPSubtotalOptDlg() override
tools::Long GetDimCount()
const ScDPLabelDataVector & mrLabelVec
virtual OUString get_text(int pos) const =0
std::unique_ptr< weld::Button > mxBtnOk
ScDPSubtotalOptDlg(weld::Window *pParent, ScDPObject &rDPObj, const ScDPLabelData &rLabelData, const ScDPNameVec &rDataFields, bool bEnableLayout)
sal_Int32 mnUsedHier
Used hierarchy.
bool mbShowAll
true = Show all (also empty) results.
virtual ~ScDPShowDetailDlg() override
std::unique_ptr< weld::Button > mxBtnCancel
std::unique_ptr< weld::ComboBox > mxLbBaseItem
void Init(const ScDPNameVec &rDataFields, bool bEnableLayout)
ScDPName GetFieldName(const OUString &rLayoutName) const
virtual int get_count() const =0
css::sheet::DataPilotFieldLayoutInfo maLayoutInfo
Layout info.
std::unique_ptr< weld::ComboBox > m_xLbShowFrom
HashMap_OWString_Interface aMap
std::unique_ptr< weld::Button > mxBtnOk
ScDPSubtotalDlg(weld::Widget *pParent, ScDPObject &rDPObj, const ScDPLabelData &rLabelData, const ScPivotFuncData &rFuncData, const ScDPNameVec &rDataFields, bool bEnableLayout)
void Init(const ScDPLabelData &rLabelData, const ScPivotFuncData &rFuncData)
ScDPLabelData maLabelData
The list of all data field names.
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
std::unique_ptr< weld::RadioButton > mxRbUser
std::unique_ptr< ScDPFunctionListBox > mxLbFunc
virtual int n_children() const =0
std::unique_ptr< weld::Label > m_xFtHierarchy
css::sheet::DataPilotFieldReference maFieldRef
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.
PivotFunc mnFuncMask
Page/Column/Row subtotal function.
std::unique_ptr< weld::ComboBox > m_xLbLayout
#define SAL_N_ELEMENTS(arr)
std::vector< ScDPName > ScDPNameVec
NameMapType maBaseFieldNameMap
std::unique_ptr< weld::ComboBox > m_xLbHierarchy
std::unique_ptr< weld::ComboBox > m_xLbSortBy
virtual ~ScDPFunctionDlg() override
virtual short run() override
std::unique_ptr< weld::RadioButton > mxRbAuto
ScDPShowDetailDlg(weld::Window *pParent, ScDPObject &rDPObj, css::sheet::DataPilotFieldOrientation nOrient)
std::unique_ptr< weld::Label > mxFtName
std::vector< std::unique_ptr< ScDPLabelData > > ScDPLabelDataVector
std::unique_ptr< weld::Button > mxBtnOptions
std::unique_ptr< weld::RadioButton > mxRbNone
true = Enable Layout mode controls.
virtual void set_toggle(int row, TriState eState, int col=-1)=0
std::unique_ptr< weld::Button > m_xBtnCancel
std::unique_ptr< weld::Button > m_xBtnOk
std::unique_ptr< weld::TreeView > m_xControl
OUString ScResId(const char *pId)
OUString GetDimensionName() const
DimNameIndexMap maNameIndexMap
ScDPSaveData * GetSaveData() const
SC_DLLPUBLIC OUString const & getDisplayName() const
std::unique_ptr< weld::CheckButton > mxCbShowAll
void SetSelection(PivotFunc nFuncMask)
virtual ~ScDPSubtotalDlg() override
IMPL_LINK_NOARG(ScDPFunctionDlg, DblClickHdl, weld::TreeView &, bool)
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDimensionByName(std::u16string_view rName) const
const OUString & GetBaseItemName(const OUString &rLayoutName) const
const OUString & GetBaseFieldName(const OUString &rLayoutName) const
ScDPFunctionListBox(std::unique_ptr< weld::TreeView > xControl)
std::unique_ptr< weld::CheckButton > m_xCbShow
std::unique_ptr< weld::SpinButton > m_xNfShow
void FillLabelData(ScDPLabelData &rLabelData) const
std::unique_ptr< weld::ComboBox > mxLbType
OUString GetDimName(tools::Long nDim, bool &rIsDataLayout, sal_Int32 *pFlags=nullptr)
std::unique_ptr< weld::TreeView > m_xLbHide
std::unique_ptr< weld::CheckButton > m_xCbRepeatItemLabels
static bool IsOrientationAllowed(css::sheet::DataPilotFieldOrientation nOrient, sal_Int32 nDimFlags)
std::unique_ptr< weld::Label > mxFtName
NameMapType maDataFieldNameMap
css::sheet::DataPilotFieldReference GetFieldRef() const
css::uno::Sequence< OUString > maHiers
Hierarchies.
NameMapType maBaseItemNameMap
css::sheet::DataPilotFieldSortInfo maSortInfo
Sorting info.
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< weld::Widget > m_xLayoutFrame
std::unique_ptr< weld::TreeView > mxLbDims
bool IsDuplicated(tools::Long nDim)
void append(TreeIter *pRet=nullptr)
std::unique_ptr< weld::RadioButton > m_xRbSortMan
ScDPFunctionDlg(weld::Widget *pParent, const ScDPLabelDataVector &rLabelVec, const ScDPLabelData &rLabelData, const ScPivotFuncData &rFuncData)
IMPL_LINK(ScDPFunctionDlg, SelectHdl, weld::ComboBox &, rLBox, void)
void append_text(const OUString &rStr)
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
PivotFunc GetSelection() const
std::unique_ptr< weld::Widget > m_xHideFrame
PivotFunc GetFuncMask() const
std::unique_ptr< weld::RadioButton > m_xRbSortDesc
std::unique_ptr< weld::CheckButton > m_xCbLayoutEmpty
css::sheet::DataPilotFieldAutoShowInfo maShowInfo
AutoShow info.
PivotFunc GetFuncMask() const
bool mbEmptyItem
Data of all labels.
ScDPLabelData maLabelData
The DataPilot object (for member names).