1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
12 #include <PivotLayoutTreeList.hxx>
13 #include <PivotLayoutDialog.hxx>
14 #include <reffact.hxx>
16 #include <rangeutl.hxx>
17 #include <uiitems.hxx>
19 #include <dbdocfun.hxx>
21 #include <dpshttab.hxx>
28 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
29 #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
31 using namespace css::uno
;
32 using namespace css::sheet
;
34 ScItemValue::ScItemValue(OUString aName
, SCCOL nColumn
, PivotFunc nFunctionMask
) :
35 maName(std::move(aName
)),
36 maFunctionData(nColumn
, nFunctionMask
),
37 mpOriginalItemValue(this)
40 ScItemValue::ScItemValue(const ScItemValue
* pInputItemValue
) :
41 maName(pInputItemValue
->maName
),
42 maFunctionData(pInputItemValue
->maFunctionData
),
43 mpOriginalItemValue(this)
46 ScItemValue::~ScItemValue()
52 ScRange
lclGetRangeForNamedRange(OUString
const & aName
, const ScDocument
& rDocument
)
54 ScRange
aInvalidRange(ScAddress::INITIALIZE_INVALID
);
55 ScRangeName
* pRangeName
= rDocument
.GetRangeName();
56 if (pRangeName
== nullptr)
59 const ScRangeData
* pData
= pRangeName
->findByUpperName(aName
.toAsciiUpperCase());
64 if (pData
->IsReference(aRange
))
72 ScPivotLayoutDialog::ScPivotLayoutDialog(
73 SfxBindings
* pSfxBindings
, SfxChildWindow
* pChildWindow
, weld::Window
* pParent
,
74 ScViewData
* pViewData
, const ScDPObject
* pPivotTableObject
, bool bNewPivotTable
)
75 : ScAnyRefDlgController(pSfxBindings
, pChildWindow
, pParent
, u
"modules/scalc/ui/pivottablelayoutdialog.ui"_ustr
, u
"PivotTableLayout"_ustr
)
76 , maPivotTableObject(*pPivotTableObject
)
77 , mpPreviouslyFocusedListBox(nullptr)
78 , mpViewData(pViewData
)
79 , mrDocument(pViewData
->GetDocument())
80 , mbNewPivotTable(bNewPivotTable
)
81 , maAddressDetails(mrDocument
.GetAddressConvention(), 0, 0)
82 , mbDialogLostFocus(false)
83 , mpActiveEdit(nullptr)
84 , mxListBoxField(new ScPivotLayoutTreeListLabel(m_xBuilder
->weld_tree_view(u
"listbox-fields"_ustr
)))
85 , mxListBoxPage(new ScPivotLayoutTreeList(m_xBuilder
->weld_tree_view(u
"listbox-page"_ustr
)))
86 , mxListBoxColumn(new ScPivotLayoutTreeList(m_xBuilder
->weld_tree_view(u
"listbox-column"_ustr
)))
87 , mxListBoxRow(new ScPivotLayoutTreeList(m_xBuilder
->weld_tree_view(u
"listbox-row"_ustr
)))
88 , mxListBoxData(new ScPivotLayoutTreeListData(m_xBuilder
->weld_tree_view(u
"listbox-data"_ustr
)))
89 , mxCheckIgnoreEmptyRows(m_xBuilder
->weld_check_button(u
"check-ignore-empty-rows"_ustr
))
90 , mxCheckTotalColumns(m_xBuilder
->weld_check_button(u
"check-total-columns"_ustr
))
91 , mxCheckAddFilter(m_xBuilder
->weld_check_button(u
"check-add-filter"_ustr
))
92 , mxCheckIdentifyCategories(m_xBuilder
->weld_check_button(u
"check-identify-categories"_ustr
))
93 , mxCheckTotalRows(m_xBuilder
->weld_check_button(u
"check-total-rows"_ustr
))
94 , mxCheckDrillToDetail(m_xBuilder
->weld_check_button(u
"check-drill-to-details"_ustr
))
95 , mxCheckExpandCollapse(m_xBuilder
->weld_check_button(u
"check-show-expand-collapse"_ustr
))
96 , mxSourceRadioNamedRange(m_xBuilder
->weld_radio_button(u
"source-radio-named-range"_ustr
))
97 , mxSourceRadioSelection(m_xBuilder
->weld_radio_button(u
"source-radio-selection"_ustr
))
98 , mxSourceListBox(m_xBuilder
->weld_combo_box(u
"source-list"_ustr
))
99 , mxSourceEdit(new formula::RefEdit(m_xBuilder
->weld_entry(u
"source-edit"_ustr
)))
100 , mxSourceButton(new formula::RefButton(m_xBuilder
->weld_button(u
"source-button"_ustr
)))
101 , mxDestinationRadioNewSheet(m_xBuilder
->weld_radio_button(u
"destination-radio-new-sheet"_ustr
))
102 , mxDestinationRadioNamedRange(m_xBuilder
->weld_radio_button(u
"destination-radio-named-range"_ustr
))
103 , mxDestinationRadioSelection(m_xBuilder
->weld_radio_button(u
"destination-radio-selection"_ustr
))
104 , mxDestinationListBox(m_xBuilder
->weld_combo_box(u
"destination-list"_ustr
))
105 , mxDestinationEdit(new formula::RefEdit(m_xBuilder
->weld_entry(u
"destination-edit"_ustr
)))
106 , mxDestinationButton(new formula::RefButton(m_xBuilder
->weld_button(u
"destination-button"_ustr
)))
107 , mxBtnOK(m_xBuilder
->weld_button(u
"ok"_ustr
))
108 , mxBtnCancel(m_xBuilder
->weld_button(u
"cancel"_ustr
))
109 , mxSourceFrame(m_xBuilder
->weld_frame(u
"frame2"_ustr
))
110 , mxSourceLabel(mxSourceFrame
->weld_label_widget())
111 , mxDestFrame(m_xBuilder
->weld_frame(u
"frame1"_ustr
))
112 , mxDestLabel(mxDestFrame
->weld_label_widget())
113 , mxOptions(m_xBuilder
->weld_expander(u
"options"_ustr
))
114 , mxMore(m_xBuilder
->weld_expander(u
"more"_ustr
))
117 Link
<weld::Toggleable
&,void> aLink2
= LINK(this, ScPivotLayoutDialog
, ToggleSource
);
118 mxSourceRadioNamedRange
->connect_toggled(aLink2
);
119 mxSourceRadioSelection
->connect_toggled(aLink2
);
121 mxSourceEdit
->SetReferences(this, mxSourceLabel
.get());
122 mxSourceButton
->SetReferences(this, mxSourceEdit
.get());
124 Link
<formula::RefEdit
&,void> aEditLink
= LINK(this, ScPivotLayoutDialog
, GetEditFocusHandler
);
125 mxDestinationEdit
->SetGetFocusHdl(aEditLink
);
126 mxSourceEdit
->SetGetFocusHdl(aEditLink
);
128 aEditLink
= LINK(this, ScPivotLayoutDialog
, LoseEditFocusHandler
);
129 mxDestinationEdit
->SetLoseFocusHdl(aEditLink
);
130 mxSourceEdit
->SetLoseFocusHdl(aEditLink
);
132 mxSourceEdit
->SetModifyHdl(LINK(this, ScPivotLayoutDialog
, SourceEditModified
));
133 mxSourceListBox
->connect_changed(LINK(this, ScPivotLayoutDialog
, SourceListSelected
));
136 aLink2
= LINK(this, ScPivotLayoutDialog
, ToggleDestination
);
137 mxDestinationRadioNewSheet
->connect_toggled(aLink2
);
138 mxDestinationRadioNamedRange
->connect_toggled(aLink2
);
139 mxDestinationRadioSelection
->connect_toggled(aLink2
);
141 mxDestinationEdit
->SetReferences(this, mxDestLabel
.get());
142 mxDestinationButton
->SetReferences(this, mxDestinationEdit
.get());
144 Link
<formula::RefButton
&,void> aButtonLink
= LINK(this, ScPivotLayoutDialog
, GetButtonFocusHandler
);
145 mxSourceButton
->SetGetFocusHdl(aButtonLink
);
146 mxDestinationButton
->SetGetFocusHdl(aButtonLink
);
148 aButtonLink
= LINK(this, ScPivotLayoutDialog
, LoseButtonFocusHandler
);
149 mxSourceButton
->SetLoseFocusHdl(aButtonLink
);
150 mxDestinationButton
->SetLoseFocusHdl(aButtonLink
);
153 mxBtnCancel
->connect_clicked(LINK(this, ScPivotLayoutDialog
, CancelClicked
));
154 mxBtnOK
->connect_clicked(LINK(this, ScPivotLayoutDialog
, OKClicked
));
157 maPivotTableObject
.FillOldParam(maPivotParameters
);
158 maPivotTableObject
.FillLabelData(maPivotParameters
);
160 mxListBoxField
->Setup (this);
161 mxListBoxPage
->Setup (this, ScPivotLayoutTreeList::PAGE_LIST
);
162 mxListBoxColumn
->Setup(this, ScPivotLayoutTreeList::COLUMN_LIST
);
163 mxListBoxRow
->Setup (this, ScPivotLayoutTreeList::ROW_LIST
);
164 mxListBoxData
->Setup (this);
166 FillValuesToListBoxes();
168 // Initialize Options
169 const ScDPSaveData
* pSaveData
= maPivotTableObject
.GetSaveData();
170 if (pSaveData
== nullptr)
172 mxCheckAddFilter
->set_active(false);
173 mxCheckDrillToDetail
->set_active(false);
174 mxCheckExpandCollapse
->set_active(false);
178 mxCheckAddFilter
->set_active(pSaveData
->GetFilterButton());
179 mxCheckDrillToDetail
->set_active(pSaveData
->GetDrillDown());
180 mxCheckExpandCollapse
->set_active(pSaveData
->GetExpandCollapse());
183 mxCheckIgnoreEmptyRows
->set_active(maPivotParameters
.bIgnoreEmptyRows
);
184 mxCheckIdentifyCategories
->set_active(maPivotParameters
.bDetectCategories
);
185 mxCheckTotalColumns
->set_active(maPivotParameters
.bMakeTotalCol
);
186 mxCheckTotalRows
->set_active(maPivotParameters
.bMakeTotalRow
);
192 ScPivotLayoutDialog::~ScPivotLayoutDialog()
196 void ScPivotLayoutDialog::SetupSource()
198 mxSourceListBox
->clear();
200 ScRange aSourceRange
;
201 OUString sSourceNamedRangeName
;
203 if (maPivotTableObject
.GetSheetDesc())
205 const ScSheetSourceDesc
* pSheetSourceDesc
= maPivotTableObject
.GetSheetDesc();
206 aSourceRange
= pSheetSourceDesc
->GetSourceRange();
208 if(!aSourceRange
.IsValid())
210 // Source is probably a DB Range
211 mxSourceRadioNamedRange
->set_sensitive(false);
212 mxSourceRadioSelection
->set_sensitive(false);
218 OUString aSourceRangeName
= aSourceRange
.Format(mrDocument
, ScRefFlags::RANGE_ABS_3D
, maAddressDetails
);
219 mxSourceEdit
->SetText(aSourceRangeName
);
224 mxSourceRadioNamedRange
->set_sensitive(false);
225 mxSourceRadioSelection
->set_sensitive(false);
230 // Setup Named Ranges
231 bool bIsNamedRange
= false;
233 ScAreaNameIterator
aIterator(mrDocument
);
237 while (aIterator
.Next(aEachName
, aEachRange
))
239 if (!aIterator
.WasDBName())
241 mxSourceListBox
->append_text(aEachName
);
242 if (aEachRange
== aSourceRange
)
244 sSourceNamedRangeName
= aEachName
;
245 bIsNamedRange
= true;
250 bool bSourceBoxHasEntries
= mxSourceListBox
->get_count() > 0;
254 mxSourceListBox
->set_active_text(sSourceNamedRangeName
);
255 mxSourceRadioNamedRange
->set_active(true);
259 // If entries - select first entry
260 mxSourceListBox
->set_active(bSourceBoxHasEntries
? 0 : -1);
261 mxSourceRadioSelection
->set_active(true);
264 // If no entries disable the radio button.
265 if (!bSourceBoxHasEntries
)
266 mxSourceRadioNamedRange
->set_sensitive(false);
271 void ScPivotLayoutDialog::SetupDestination()
273 mxDestinationListBox
->clear();
275 // Fill up named ranges
276 ScAreaNameIterator
aIterator(mrDocument
);
280 while (aIterator
.Next(aName
, aRange
))
282 if (!aIterator
.WasDBName())
284 mxDestinationListBox
->append_text(aName
);
288 // If entries - select first entry, otherwise disable the radio button.
289 if (mxDestinationListBox
->get_count() > 0)
290 mxDestinationListBox
->set_active(0);
292 mxDestinationRadioNamedRange
->set_sensitive(false);
297 mxDestinationRadioNewSheet
->set_active(true);
301 if (maPivotParameters
.nTab
!= MAXTAB
+ 1)
303 ScAddress
aAddress(maPivotParameters
.nCol
, maPivotParameters
.nRow
, maPivotParameters
.nTab
);
304 OUString aAddressString
= aAddress
.Format(ScRefFlags::ADDR_ABS_3D
, &mrDocument
, maAddressDetails
);
305 mxDestinationEdit
->SetText(aAddressString
);
306 mxDestinationRadioSelection
->set_active(true);
313 void ScPivotLayoutDialog::FillValuesToListBoxes()
315 mxListBoxField
->FillLabelFields(maPivotParameters
.maLabelArray
);
316 mxListBoxData
->FillDataField(maPivotParameters
.maDataFields
);
317 mxListBoxColumn
->FillFields(maPivotParameters
.maColFields
);
318 mxListBoxRow
->FillFields(maPivotParameters
.maRowFields
);
319 mxListBoxPage
->FillFields(maPivotParameters
.maPageFields
);
322 void ScPivotLayoutDialog::SetActive()
324 if (mbDialogLostFocus
)
326 mbDialogLostFocus
= false;
327 if(mpActiveEdit
!= nullptr)
329 mpActiveEdit
->GrabFocus();
330 if (mpActiveEdit
== mxSourceEdit
.get())
336 m_xDialog
->grab_focus();
342 void ScPivotLayoutDialog::SetReference(const ScRange
& rReferenceRange
, ScDocument
& rDocument
)
344 if (!mbDialogLostFocus
)
347 if (mpActiveEdit
== nullptr)
350 if (rReferenceRange
.aStart
!= rReferenceRange
.aEnd
)
351 RefInputStart(mpActiveEdit
);
353 OUString aReferenceString
= rReferenceRange
.Format(rDocument
, ScRefFlags::RANGE_ABS_3D
, maAddressDetails
);
355 if (mpActiveEdit
== mxSourceEdit
.get())
357 mxSourceEdit
->SetRefString(aReferenceString
);
359 else if (mpActiveEdit
== mxDestinationEdit
.get())
361 mxDestinationEdit
->SetRefString(aReferenceString
);
365 bool ScPivotLayoutDialog::IsRefInputMode() const
367 return mbDialogLostFocus
;
370 void ScPivotLayoutDialog::ItemInserted(const ScItemValue
* pItemValue
, ScPivotLayoutTreeList::SvPivotTreeListType eType
)
372 if (pItemValue
== nullptr)
377 case ScPivotLayoutTreeList::ROW_LIST
:
378 case ScPivotLayoutTreeList::COLUMN_LIST
:
379 case ScPivotLayoutTreeList::PAGE_LIST
:
381 mxListBoxRow
->RemoveEntryForItem(pItemValue
);
382 mxListBoxColumn
->RemoveEntryForItem(pItemValue
);
383 mxListBoxPage
->RemoveEntryForItem(pItemValue
);
386 case ScPivotLayoutTreeList::LABEL_LIST
:
388 mxListBoxRow
->RemoveEntryForItem(pItemValue
);
389 mxListBoxColumn
->RemoveEntryForItem(pItemValue
);
390 mxListBoxPage
->RemoveEntryForItem(pItemValue
);
391 mxListBoxData
->RemoveEntryForItem(pItemValue
);
399 void ScPivotLayoutDialog::UpdateSourceRange()
401 if (!maPivotTableObject
.GetSheetDesc())
404 ScSheetSourceDesc aSourceSheet
= *maPivotTableObject
.GetSheetDesc();
406 if (mxSourceRadioNamedRange
->get_active())
408 OUString aEntryString
= mxSourceListBox
->get_active_text();
409 ScRange aSourceRange
= lclGetRangeForNamedRange(aEntryString
, mrDocument
);
410 if (!aSourceRange
.IsValid() || aSourceSheet
.GetSourceRange() == aSourceRange
)
412 aSourceSheet
.SetRangeName(aEntryString
);
414 else if (mxSourceRadioSelection
->get_active())
416 OUString aSourceString
= mxSourceEdit
->GetText();
417 ScRange aSourceRange
;
418 ScRefFlags nResult
= aSourceRange
.Parse(aSourceString
, mrDocument
, maAddressDetails
);
420 bool bIsValid
= (nResult
& ScRefFlags::VALID
) == ScRefFlags::VALID
; // aSourceString is valid
422 mxSourceEdit
->SetRefValid(true);
429 ConvertDoubleRef(mrDocument
, aSourceString
, 1, aStart
, aEnd
, maAddressDetails
);
430 aSourceRange
.aStart
= aStart
.GetAddress();
431 aSourceRange
.aEnd
= aEnd
.GetAddress();
435 aSourceRange
= lclGetRangeForNamedRange(aSourceString
, mrDocument
);
438 if (!aSourceRange
.IsValid())
440 mxSourceEdit
->SetRefValid(false);
444 if (aSourceSheet
.GetSourceRange() == aSourceRange
)
447 aSourceSheet
.SetSourceRange(aSourceRange
);
448 if (aSourceSheet
.CheckSourceRange())
450 mxSourceEdit
->SetRefValid(false);
459 maPivotTableObject
.SetSheetDesc(aSourceSheet
);
460 maPivotTableObject
.FillOldParam(maPivotParameters
);
461 maPivotTableObject
.FillLabelData(maPivotParameters
);
463 FillValuesToListBoxes();
466 void ScPivotLayoutDialog::ApplyChanges()
468 ScDPSaveData aSaveData
;
469 ApplySaveData(aSaveData
);
470 ApplyLabelData(aSaveData
);
472 ScDPObject
*pOldDPObj
= mrDocument
.GetDPAtCursor( maPivotParameters
.nCol
, maPivotParameters
.nRow
, maPivotParameters
.nTab
);
473 ScRange aDestinationRange
;
474 bool bToNewSheet
= false;
476 if (!GetDestination(aDestinationRange
, bToNewSheet
))
479 SetDispatcherLock(false);
482 sal_uInt16 nWhichPivot
= ScModule::get()->GetPool().GetWhichIDFromSlotID(SID_PIVOT_TABLE
);
483 ScPivotItem
aPivotItem(nWhichPivot
, &aSaveData
, &aDestinationRange
, bToNewSheet
);
484 mpViewData
->GetViewShell()->SetDialogDPObject(std::make_unique
<ScDPObject
>(maPivotTableObject
));
487 SfxDispatcher
* pDispatcher
= GetBindings().GetDispatcher();
488 SfxCallMode
const nCallMode
= SfxCallMode::SLOT
| SfxCallMode::RECORD
;
489 const SfxPoolItemHolder
aResult(pDispatcher
->ExecuteList(SID_PIVOT_TABLE
,
490 nCallMode
, { &aPivotItem
}));
494 // existing pivot table might have moved to a new range or a new sheet
495 if ( pOldDPObj
!= nullptr )
497 const ScRange
& rOldRange
= pOldDPObj
->GetOutRange();
499 ScDPObject
*pDPObj
= nullptr;
500 // FIXME: if the new range overlaps with the old one, the table actually doesn't move
501 // and shouldn't therefore be deleted
502 if ( ( ( rOldRange
!= aDestinationRange
) && !rOldRange
.Contains( aDestinationRange
) )
505 pDPObj
= mrDocument
.GetDPAtCursor( maPivotParameters
.nCol
, maPivotParameters
.nRow
, maPivotParameters
.nTab
);
509 ScDBDocFunc
aFunc( *(mpViewData
->GetDocShell() ));
510 aFunc
.RemovePivotTable( *pDPObj
, true, false);
511 mpViewData
->GetView()->CursorPosChanged();
517 SetDispatcherLock(true);
520 void ScPivotLayoutDialog::ApplySaveData(ScDPSaveData
& rSaveData
)
522 rSaveData
.SetIgnoreEmptyRows(mxCheckIgnoreEmptyRows
->get_active());
523 rSaveData
.SetRepeatIfEmpty(mxCheckIdentifyCategories
->get_active());
524 rSaveData
.SetColumnGrand(mxCheckTotalColumns
->get_active());
525 rSaveData
.SetRowGrand(mxCheckTotalRows
->get_active());
526 rSaveData
.SetFilterButton(mxCheckAddFilter
->get_active());
527 rSaveData
.SetDrillDown(mxCheckDrillToDetail
->get_active());
528 rSaveData
.SetExpandCollapse(mxCheckExpandCollapse
->get_active());
530 Reference
<XDimensionsSupplier
> xSource
= maPivotTableObject
.GetSource();
532 ScPivotFieldVector aPageFieldVector
;
533 mxListBoxPage
->PushEntriesToPivotFieldVector(aPageFieldVector
);
534 ScDPObject::ConvertOrientation(rSaveData
, aPageFieldVector
, DataPilotFieldOrientation_PAGE
,
535 xSource
, maPivotParameters
.maLabelArray
);
537 ScPivotFieldVector aColFieldVector
;
538 mxListBoxColumn
->PushEntriesToPivotFieldVector(aColFieldVector
);
539 ScDPObject::ConvertOrientation(rSaveData
, aColFieldVector
, DataPilotFieldOrientation_COLUMN
,
540 xSource
, maPivotParameters
.maLabelArray
);
542 ScPivotFieldVector aRowFieldVector
;
543 mxListBoxRow
->PushEntriesToPivotFieldVector(aRowFieldVector
);
544 ScDPObject::ConvertOrientation(rSaveData
, aRowFieldVector
, DataPilotFieldOrientation_ROW
,
545 xSource
, maPivotParameters
.maLabelArray
);
547 ScPivotFieldVector aDataFieldVector
;
548 mxListBoxData
->PushEntriesToPivotFieldVector(aDataFieldVector
);
549 ScDPObject::ConvertOrientation(rSaveData
, aDataFieldVector
, DataPilotFieldOrientation_DATA
,
550 xSource
, maPivotParameters
.maLabelArray
,
551 &aColFieldVector
, &aRowFieldVector
, &aPageFieldVector
);
554 void ScPivotLayoutDialog::ApplyLabelData(const ScDPSaveData
& rSaveData
)
556 ScDPLabelDataVector
& rLabelDataVector
= GetLabelDataVector();
558 for (std::unique_ptr
<ScDPLabelData
> const & pLabelData
: rLabelDataVector
)
560 OUString aUnoName
= ScDPUtil::createDuplicateDimensionName(pLabelData
->maName
, pLabelData
->mnDupCount
);
561 ScDPSaveDimension
* pSaveDimensions
= rSaveData
.GetExistingDimensionByName(aUnoName
);
563 if (pSaveDimensions
== nullptr)
566 pSaveDimensions
->SetUsedHierarchy(pLabelData
->mnUsedHier
);
567 pSaveDimensions
->SetShowEmpty(pLabelData
->mbShowAll
);
568 pSaveDimensions
->SetRepeatItemLabels(pLabelData
->mbRepeatItemLabels
);
569 pSaveDimensions
->SetSortInfo(&pLabelData
->maSortInfo
);
570 pSaveDimensions
->SetLayoutInfo(&pLabelData
->maLayoutInfo
);
571 pSaveDimensions
->SetAutoShowInfo(&pLabelData
->maShowInfo
);
573 bool bManualSort
= (pLabelData
->maSortInfo
.Mode
== DataPilotFieldSortMode::MANUAL
);
575 for (ScDPLabelData::Member
const & rLabelMember
: pLabelData
->maMembers
)
577 ScDPSaveMember
* pMember
= pSaveDimensions
->GetMemberByName(rLabelMember
.maName
);
579 if (bManualSort
|| !rLabelMember
.mbVisible
|| !rLabelMember
.mbShowDetails
)
581 pMember
->SetIsVisible(rLabelMember
.mbVisible
);
582 pMember
->SetShowDetails(rLabelMember
.mbShowDetails
);
588 bool ScPivotLayoutDialog::GetDestination(ScRange
& aDestinationRange
, bool& bToNewSheet
)
592 if (mxDestinationRadioNamedRange
->get_active())
594 OUString aName
= mxDestinationListBox
->get_active_text();
595 aDestinationRange
= lclGetRangeForNamedRange(aName
, mrDocument
);
596 if (!aDestinationRange
.IsValid())
599 else if (mxDestinationRadioSelection
->get_active())
602 aAddress
.Parse(mxDestinationEdit
->GetText(), mrDocument
, maAddressDetails
);
603 aDestinationRange
= ScRange(aAddress
);
608 aDestinationRange
= ScRange(maPivotParameters
.nCol
, maPivotParameters
.nRow
, maPivotParameters
.nTab
);
613 ScItemValue
* ScPivotLayoutDialog::GetItem(SCCOL nColumn
)
615 return mxListBoxField
->GetItem(nColumn
);
618 bool ScPivotLayoutDialog::IsDataElement(SCCOL nColumn
)
620 return mxListBoxField
->IsDataElement(nColumn
);
623 ScDPLabelData
& ScPivotLayoutDialog::GetLabelData(SCCOL nColumn
)
625 return *maPivotParameters
.maLabelArray
[nColumn
];
628 void ScPivotLayoutDialog::PushDataFieldNames(std::vector
<ScDPName
>& rDataFieldNames
)
630 mxListBoxData
->PushDataFieldNames(rDataFieldNames
);
633 void ScPivotLayoutDialog::Close()
635 DoClose(ScPivotLayoutWrapper::GetChildWindowId());
636 SfxDialogController::Close();
639 IMPL_LINK_NOARG( ScPivotLayoutDialog
, OKClicked
, weld::Button
&, void )
641 /* tdf#137726 hide so it's not a candidate to be parent of any error
642 messages that may appear because this dialog is going to disappear on
643 response(RET_OK) and the error dialog is not run in its own event loop
648 m_xDialog
->response(RET_OK
);
651 IMPL_LINK_NOARG( ScPivotLayoutDialog
, CancelClicked
, weld::Button
&, void )
653 m_xDialog
->response(RET_CANCEL
);
656 IMPL_LINK(ScPivotLayoutDialog
, GetEditFocusHandler
, formula::RefEdit
&, rCtrl
, void)
658 mpActiveEdit
= &rCtrl
;
659 mpActiveEdit
->SelectAll();
662 IMPL_LINK(ScPivotLayoutDialog
, GetButtonFocusHandler
, formula::RefButton
&, rCtrl
, void)
664 mpActiveEdit
= nullptr;
666 if (&rCtrl
== mxSourceButton
.get())
667 mpActiveEdit
= mxSourceEdit
.get();
668 else if (&rCtrl
== mxDestinationButton
.get())
669 mpActiveEdit
= mxDestinationEdit
.get();
672 mpActiveEdit
->SelectAll();
675 IMPL_LINK_NOARG(ScPivotLayoutDialog
, LoseEditFocusHandler
, formula::RefEdit
&, void)
677 mbDialogLostFocus
= !m_xDialog
->has_toplevel_focus();
680 IMPL_LINK_NOARG(ScPivotLayoutDialog
, LoseButtonFocusHandler
, formula::RefButton
&, void)
682 mbDialogLostFocus
= !m_xDialog
->has_toplevel_focus();
685 IMPL_LINK_NOARG(ScPivotLayoutDialog
, SourceListSelected
, weld::ComboBox
&, void)
690 IMPL_LINK_NOARG(ScPivotLayoutDialog
, SourceEditModified
, formula::RefEdit
&, void)
695 IMPL_LINK_NOARG(ScPivotLayoutDialog
, ToggleSource
, weld::Toggleable
&, void)
700 void ScPivotLayoutDialog::ToggleSource()
702 bool bNamedRange
= mxSourceRadioNamedRange
->get_active();
703 bool bSelection
= mxSourceRadioSelection
->get_active();
704 mxSourceListBox
->set_sensitive(bNamedRange
);
705 mxSourceButton
->GetWidget()->set_sensitive(bSelection
);
706 mxSourceEdit
->GetWidget()->set_sensitive(bSelection
);
710 IMPL_LINK_NOARG(ScPivotLayoutDialog
, ToggleDestination
, weld::Toggleable
&, void)
715 void ScPivotLayoutDialog::ToggleDestination()
717 bool bNamedRange
= mxDestinationRadioNamedRange
->get_active();
718 bool bSelection
= mxDestinationRadioSelection
->get_active();
719 mxDestinationListBox
->set_sensitive(bNamedRange
);
720 mxDestinationButton
->GetWidget()->set_sensitive(bSelection
);
721 mxDestinationEdit
->GetWidget()->set_sensitive(bSelection
);
724 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */