20#undef SC_DLLIMPLEMENTATION
27#include <document.hxx>
31#include <subtotals.hrc>
37#include <osl/diagnose.h>
42 :
SfxTabPage(pPage, pController,
"modules/scalc/ui/subtotalgrppage.ui",
"SubTotalGrpPage", &rArgSet)
44 , aStrColumn(
ScResId(SCSTR_COLUMN_LETTER))
47 , nWhichSubTotals(rArgSet.GetPool()->
GetWhich(SID_SUBTOTALS))
48 , rSubTotalData(rArgSet.
Get(nWhichSubTotals).GetSubTotalData())
50 , mxLbGroup(m_xBuilder->weld_combo_box(
"group_by"))
51 , mxLbColumns(m_xBuilder->weld_tree_view(
"columns"))
52 , mxLbFunctions(m_xBuilder->weld_tree_view(
"functions"))
53 , mxLbSelectAllColumns(m_xBuilder->weld_check_button(
"select_all_columns_button"))
67 mxLbGroup->set_buildable_name(
mxLbGroup->get_buildable_name() + OUString::number(rTabNumber));
80 assert(
pViewData &&
"CreateScSubTotalDlg aArgSet must contain a ScSubTotalItem with ViewData set");
82 assert(
pDoc &&
"Document not found :-(");
102 if ( rTreeView.
get_toggle(rEntry) == TRISTATE_TRUE )
114 sal_uInt16 nGroupIdx = 0;
116 OSL_ENSURE( (nGroupNo<=3) && (nGroupNo>0),
"Invalid group" );
118 if ( (nGroupNo > 3) || (nGroupNo == 0) )
121 nGroupIdx = nGroupNo-1;
142 sal_uInt16 nFirstChecked = 0;
143 for ( sal_uInt16
i=0;
i<nSubTotals;
i++ )
150 if (
i == 0 || nCheckPos < nFirstChecked)
151 nFirstChecked = nCheckPos;
158 mxLbGroup->set_active( (nGroupNo == 1) ? 1 : 0 );
174 sal_uInt16 nGroupIdx = 0;
176 OSL_ENSURE( (nGroupNo<=3) && (nGroupNo>0),
"Invalid group" );
180 "Non-initialized Lists" );
182 if ( (nGroupNo > 3) || (nGroupNo == 0)
189 nGroupIdx = nGroupNo-1;
196 theSubTotalData = pItem->GetSubTotalData();
199 std::unique_ptr<ScSubTotalFunc[]> pFunctions;
200 std::unique_ptr<SCCOL[]> pSubTotals;
201 const sal_Int32 nGroup =
mxLbGroup->get_active();
202 const sal_Int32 nEntryCount =
mxLbColumns->n_children();
203 const sal_Int32 nCheckCount = GetCheckedEntryCount(*
mxLbColumns);
209 theSubTotalData.
bGroupActive[nGroupIdx] = (nGroup != 0);
210 theSubTotalData.
nField[nGroupIdx] = (nGroup != 0)
212 :
static_cast<SCCOL>(0);
214 if ( nEntryCount>0 && nCheckCount>0 && nGroup!=0 )
216 sal_uInt16 nFunction = 0;
218 pSubTotals.reset(
new SCCOL [nCheckCount]);
221 for ( sal_Int32
i=0, nCheck=0;
i<nEntryCount;
i++ )
225 OSL_ENSURE( nCheck <= nCheckCount,
247 assert(
pViewData &&
pDoc &&
"CreateScSubTotalDlg aArgSet must contain a ScSubTotalItem with ViewData set");
265 if ( aFieldName.isEmpty() )
285 sal_uInt16 nFieldPos = 0;
317 OSL_FAIL(
"ScTpSubTotalGroup::LbPosToFunc" );
339 OSL_FAIL(
"ScTpSubTotalGroup::FuncToLbPos" );
350 if ( mxLbColumns->n_children() == GetCheckedEntryCount(*mxLbColumns) )
351 mxLbSelectAllColumns->set_active(
true );
353 mxLbSelectAllColumns->set_active(
false );
363 const sal_Int32 nColumn =
mxLbColumns->get_selected_index();
367 const sal_Int32 nFunction =
mxLbFunctions->get_selected_index();
368 sal_uInt16 nOldFunction =
mxLbColumns->get_id(nColumn).toUInt32();
376 mxLbColumns->set_id(nColumn, OUString::number(nFunction));
383 mxLbColumns->select(rRowCol.first);
384 SelectHdl(mxLbColumns.get());
386 if ( mxLbColumns->n_children() == GetCheckedEntryCount(*mxLbColumns) )
387 mxLbSelectAllColumns->set_active(
true );
389 mxLbSelectAllColumns->set_active(
false );
397 return std::make_unique<ScTpSubTotalGroup1>( pPage, pController, *rArgSet );
403 return std::make_unique<ScTpSubTotalGroup2>( pPage, pController, *rArgSet );
409 return std::make_unique<ScTpSubTotalGroup3>( pPage, pController, *rArgSet );
424#define RESET(i) (ScTpSubTotalGroup::DoReset( (i), *rArgSet ))
430#define FILLSET(i) (ScTpSubTotalGroup::DoFillItemSet( (i), *rArgSet ))
441 "modules/scalc/ui/subtotaloptionspage.ui",
"SubTotalOptionsPage",
443 pViewData ( nullptr ),
445 nWhichSubTotals ( rArgSet.GetPool()->
GetWhich( SID_SUBTOTALS ) ),
446 rSubTotalData ( rArgSet.
Get( nWhichSubTotals ).GetSubTotalData() )
447 , m_xBtnPagebreak(m_xBuilder->weld_check_button(
"pagebreak"))
448 , m_xBtnCase(m_xBuilder->weld_check_button(
"case"))
449 , m_xBtnSort(m_xBuilder->weld_check_button(
"sort"))
450 , m_xFlSort(m_xBuilder->weld_label(
"label2"))
451 , m_xBtnAscending(m_xBuilder->weld_radio_button(
"ascending"))
452 , m_xBtnDescending(m_xBuilder->weld_radio_button(
"descending"))
453 , m_xBtnFormats(m_xBuilder->weld_check_button(
"formats"))
454 , m_xBtnUserDef(m_xBuilder->weld_check_button(
"btnuserdef"))
455 , m_xLbUserDef(m_xBuilder->weld_combo_box(
"lbuserdef"))
471 assert(
pViewData &&
"CreateScSubTotalDlg aArgSet must contain a ScSubTotalItem with ViewData set");
473 assert(
pDoc &&
"Document not found!");
484 return std::make_unique<ScTpSubTotalOptions>(pPage, pController, *rArgSet);
519 theSubTotalData = pItem->GetSubTotalData();
557 if (&rBox == m_xBtnSort.get())
559 if ( m_xBtnSort->get_active() )
561 m_xFlSort->set_sensitive(
true);
562 m_xBtnFormats->set_sensitive(
true);
563 m_xBtnUserDef->set_sensitive(
true);
564 m_xBtnAscending->set_sensitive(
true);
565 m_xBtnDescending->set_sensitive(
true);
567 if ( m_xBtnUserDef->get_active() )
568 m_xLbUserDef->set_sensitive(
true);
572 m_xFlSort->set_sensitive(
false);
573 m_xBtnFormats->set_sensitive(
false);
574 m_xBtnUserDef->set_sensitive(
false);
575 m_xBtnAscending->set_sensitive(
false);
576 m_xBtnDescending->set_sensitive(
false);
577 m_xLbUserDef->set_sensitive(
false);
580 else if (&rBox == m_xBtnUserDef.get())
582 if ( m_xBtnUserDef->get_active() )
584 m_xLbUserDef->set_sensitive(
true);
585 m_xLbUserDef->grab_focus();
588 m_xLbUserDef->set_sensitive(
false);
594 if (&rBox != mxLbSelectAllColumns.get())
597 bool bChecked = mxLbSelectAllColumns->get_active();
void ScColToAlpha(OUStringBuffer &rBuf, SCCOL nCol)
append alpha representation of column to buffer
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
static SC_DLLPUBLIC OUString ReplaceOrAppend(const OUString &rString, std::u16string_view rPlaceholder, const OUString &rReplacement)
Replaces the first occurrence of rPlaceholder in rString with rReplacement, or if rPlaceholder is not...
static SC_DLLPUBLIC ScUserList * GetUserList()
ScViewData * GetViewData() const
virtual ~ScTpSubTotalGroup1() override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
ScTpSubTotalGroup1(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
virtual bool FillItemSet(SfxItemSet *rArgSet) override
virtual void Reset(const SfxItemSet *rArgSet) override
ScTpSubTotalGroup2(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
virtual ~ScTpSubTotalGroup2() override
virtual bool FillItemSet(SfxItemSet *rArgSet) override
virtual void Reset(const SfxItemSet *rArgSet) override
virtual void Reset(const SfxItemSet *rArgSet) override
virtual bool FillItemSet(SfxItemSet *rArgSet) override
virtual ~ScTpSubTotalGroup3() override
ScTpSubTotalGroup3(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
std::unique_ptr< weld::TreeView > mxLbFunctions
const OUString aStrColumn
sal_uInt16 GetFieldSelPos(SCCOL nField)
bool DoReset(sal_uInt16 nGroupNo, const SfxItemSet &rArgSet)
std::unique_ptr< weld::CheckButton > mxLbSelectAllColumns
static sal_uInt16 FuncToLbPos(ScSubTotalFunc eFunc)
bool DoFillItemSet(sal_uInt16 nGroupNo, SfxItemSet &rArgSet)
const ScSubTotalParam & rSubTotalData
std::vector< SCCOL > mnFieldArr
static ScSubTotalFunc LbPosToFunc(sal_uInt16 nPos)
std::unique_ptr< weld::TreeView > mxLbColumns
std::unique_ptr< weld::ComboBox > mxLbGroup
void SelectHdl(const weld::Widget *)
const TypedWhichId< ScSubTotalItem > nWhichSubTotals
ScTpSubTotalGroup(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet, const sal_uInt16 &nTabNumber)
virtual ~ScTpSubTotalGroup() override
std::unique_ptr< weld::CheckButton > m_xBtnSort
ScTpSubTotalOptions(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
std::unique_ptr< weld::CheckButton > m_xBtnUserDef
const ScSubTotalParam & rSubTotalData
const TypedWhichId< ScSubTotalItem > nWhichSubTotals
std::unique_ptr< weld::CheckButton > m_xBtnPagebreak
virtual void Reset(const SfxItemSet *rArgSet) override
std::unique_ptr< weld::CheckButton > m_xBtnCase
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
virtual bool FillItemSet(SfxItemSet *rArgSet) override
std::unique_ptr< weld::RadioButton > m_xBtnDescending
std::unique_ptr< weld::CheckButton > m_xBtnFormats
std::unique_ptr< weld::ComboBox > m_xLbUserDef
virtual ~ScTpSubTotalOptions() override
void FillUserSortListBox()
std::unique_ptr< weld::RadioButton > m_xBtnAscending
Collection of user-defined sort lists.
ScDocument & GetDocument() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const SfxItemSet & GetItemSet() const
const SfxItemSet * GetDialogExampleSet() const
std::pair< const TreeIter &, int > iter_col
virtual TriState get_toggle(int row, int col=-1) const=0
virtual void all_foreach(const std::function< bool(TreeIter &)> &func)=0
#define LINK(Instance, Class, Member)
#define SAL_N_ELEMENTS(arr)
RttiCompleteObjectLocator col
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
OUString ScResId(TranslateId aId)
bool bUserDef
sort user defined
bool bPagebreak
page break at change of group
bool bAscending
sort ascending
bool bGroupActive[MAXSUBTOTAL]
active groups
sal_uInt16 nUserIndex
index into list
SCCOL nField[MAXSUBTOTAL]
associated field
SCCOL nSubTotals[MAXSUBTOTAL]
number of SubTotals
std::unique_ptr< ScSubTotalFunc[]> pFunctions[MAXSUBTOTAL]
array of associated functions
std::unique_ptr< SCCOL[]> pSubTotals[MAXSUBTOTAL]
array of columns to be calculated
void SetSubTotals(sal_uInt16 nGroup, const SCCOL *ptrSubTotals, const ScSubTotalFunc *ptrFunctions, sal_uInt16 nCount)
bool bIncludePattern
sort formats
bool bReplace
replace existing results
SCCOL SC_MAXFIELDS(const ScSheetLimits &rLimits)
IMPL_LINK(ScTpSubTotalGroup, SelectTreeListBoxHdl, weld::TreeView &, rLb, void)