fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / dbgui / PivotLayoutDialog.cxx
blobe6e2b9890039083f615133186baf539537d3af9b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
15 #include <svtools/treelistentry.hxx>
17 #include "rangeutl.hxx"
18 #include "uiitems.hxx"
19 #include "dputil.hxx"
21 #include <vector>
23 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
24 #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
26 using namespace css::uno;
27 using namespace css::sheet;
29 ScItemValue::ScItemValue(OUString const & aName, SCCOL nColumn, sal_uInt16 nFunctionMask) :
30 maName(aName),
31 maFunctionData(nColumn, nFunctionMask),
32 mpOriginalItemValue(this)
35 ScItemValue::ScItemValue(ScItemValue* pInputItemValue) :
36 maName(pInputItemValue->maName),
37 maFunctionData(pInputItemValue->maFunctionData),
38 mpOriginalItemValue(this)
41 ScItemValue::~ScItemValue()
44 namespace
47 ScRange lclGetRangeForNamedRange(OUString const & aName, ScDocument* pDocument)
49 ScRange aInvalidRange(ScAddress::INITIALIZE_INVALID);
50 ScRangeName* pRangeName = pDocument->GetRangeName();
51 if (pRangeName == NULL)
52 return aInvalidRange;
54 const ScRangeData* pData = pRangeName->findByUpperName(aName.toAsciiUpperCase());
55 if (pData == NULL)
56 return aInvalidRange;
58 ScRange aRange;
59 if (pData->IsReference(aRange))
60 return aRange;
62 return aInvalidRange;
67 ScPivotLayoutDialog::ScPivotLayoutDialog(
68 SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, vcl::Window* pParent,
69 ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bNewPivotTable) :
70 ScAnyRefDlg (pSfxBindings, pChildWindow, pParent, "PivotTableLayout", "modules/scalc/ui/pivottablelayoutdialog.ui"),
71 maPivotTableObject (*pPivotTableObject),
72 mpPreviouslyFocusedListBox(NULL),
73 mpCurrentlyFocusedListBox(NULL),
74 mpViewData (pViewData),
75 mpDocument (pViewData->GetDocument()),
76 mbNewPivotTable (bNewPivotTable),
77 mpActiveEdit (NULL),
78 maAddressDetails (mpDocument->GetAddressConvention(), 0, 0),
79 mbDialogLostFocus (false)
81 Link<> aLink;
83 get(mpListBoxField, "listbox-fields");
84 get(mpListBoxPage, "listbox-page");
85 get(mpListBoxColumn, "listbox-column");
86 get(mpListBoxRow, "listbox-row");
87 get(mpListBoxData, "listbox-data");
89 get(mpCheckIgnoreEmptyRows, "check-ignore-empty-rows");
90 get(mpCheckTotalColumns, "check-total-columns");
91 get(mpCheckAddFilter, "check-add-filter");
92 get(mpCheckIdentifyCategories, "check-identify-categories");
93 get(mpCheckTotalRows, "check-total-rows");
94 get(mpCheckDrillToDetail, "check-drill-to-details");
96 get(mpBtnOK, "ok");
97 get(mpBtnCancel, "cancel");
99 get(mpSourceRadioNamedRange, "source-radio-named-range");
100 get(mpSourceRadioSelection, "source-radio-selection");
101 get(mpSourceListBox, "source-list");
102 get(mpSourceEdit, "source-edit");
103 get(mpSourceButton, "source-button");
105 get(mpDestinationRadioNewSheet, "destination-radio-new-sheet");
106 get(mpDestinationRadioNamedRange, "destination-radio-named-range");
107 get(mpDestinationRadioSelection, "destination-radio-selection");
108 get(mpDestinationListBox, "destination-list");
109 get(mpDestinationEdit, "destination-edit");
110 get(mpDestinationButton, "destination-button");
112 // Source UI
113 aLink = LINK(this, ScPivotLayoutDialog, ToggleSource);
114 mpSourceRadioNamedRange->SetToggleHdl(aLink);
115 mpSourceRadioSelection->SetToggleHdl(aLink);
117 mpSourceEdit->SetReferences(this, mpSourceRadioSelection);
118 mpSourceButton->SetReferences(this, mpSourceEdit);
120 aLink = LINK(this, ScPivotLayoutDialog, GetFocusHandler);
121 mpSourceEdit->SetGetFocusHdl(aLink);
122 mpSourceButton->SetGetFocusHdl(aLink);
124 aLink = LINK(this, ScPivotLayoutDialog, LoseFocusHandler);
125 mpSourceEdit->SetLoseFocusHdl(aLink);
126 mpSourceButton->SetLoseFocusHdl(aLink);
128 mpSourceEdit->SetModifyHdl(LINK(this, ScPivotLayoutDialog, SourceEditModified));
129 mpSourceListBox->SetSelectHdl(LINK(this, ScPivotLayoutDialog, SourceEditModified));
131 // Destination UI
132 aLink = LINK(this, ScPivotLayoutDialog, ToggleDestination);
133 mpDestinationRadioNewSheet->SetToggleHdl(aLink);
134 mpDestinationRadioNamedRange->SetToggleHdl(aLink);
135 mpDestinationRadioSelection->SetToggleHdl(aLink);
137 mpDestinationEdit->SetReferences(this, mpDestinationRadioNewSheet);
138 mpDestinationButton->SetReferences(this, mpDestinationEdit);
140 aLink = LINK(this, ScPivotLayoutDialog, GetFocusHandler);
141 mpDestinationEdit->SetGetFocusHdl(aLink);
142 mpDestinationButton->SetGetFocusHdl(aLink);
144 aLink = LINK(this, ScPivotLayoutDialog, LoseFocusHandler);
145 mpDestinationEdit->SetLoseFocusHdl(aLink);
146 mpDestinationButton->SetLoseFocusHdl(aLink);
148 // Buttons
149 mpBtnCancel->SetClickHdl(LINK(this, ScPivotLayoutDialog, CancelClicked));
150 mpBtnOK->SetClickHdl(LINK(this, ScPivotLayoutDialog, OKClicked));
152 // Initialize Data
153 maPivotTableObject.FillOldParam(maPivotParameters);
154 maPivotTableObject.FillLabelData(maPivotParameters);
156 mpListBoxField->Setup (this);
157 mpListBoxPage->Setup (this, ScPivotLayoutTreeList::PAGE_LIST);
158 mpListBoxColumn->Setup(this, ScPivotLayoutTreeList::COLUMN_LIST);
159 mpListBoxRow->Setup (this, ScPivotLayoutTreeList::ROW_LIST);
160 mpListBoxData->Setup (this);
162 FillValuesToListBoxes();
164 // Initialize Options
165 const ScDPSaveData* pSaveData = maPivotTableObject.GetSaveData();
166 if (pSaveData == NULL)
168 mpCheckAddFilter->Check(false);
169 mpCheckDrillToDetail->Check(false);
171 else
173 mpCheckAddFilter->Check(pSaveData->GetFilterButton());
174 mpCheckDrillToDetail->Check(pSaveData->GetDrillDown());
177 mpCheckIgnoreEmptyRows->Check(maPivotParameters.bIgnoreEmptyRows);
178 mpCheckIdentifyCategories->Check(maPivotParameters.bDetectCategories);
179 mpCheckTotalColumns->Check(maPivotParameters.bMakeTotalCol);
180 mpCheckTotalRows->Check(maPivotParameters.bMakeTotalRow);
182 SetupSource();
183 SetupDestination();
186 ScPivotLayoutDialog::~ScPivotLayoutDialog()
188 disposeOnce();
191 void ScPivotLayoutDialog::dispose()
193 mpPreviouslyFocusedListBox.clear();
194 mpCurrentlyFocusedListBox.clear();
195 mpListBoxField.clear();
196 mpListBoxPage.clear();
197 mpListBoxColumn.clear();
198 mpListBoxRow.clear();
199 mpListBoxData.clear();
200 mpCheckIgnoreEmptyRows.clear();
201 mpCheckTotalColumns.clear();
202 mpCheckAddFilter.clear();
203 mpCheckIdentifyCategories.clear();
204 mpCheckTotalRows.clear();
205 mpCheckDrillToDetail.clear();
206 mpSourceRadioNamedRange.clear();
207 mpSourceRadioSelection.clear();
208 mpSourceListBox.clear();
209 mpSourceEdit.clear();
210 mpSourceButton.clear();
211 mpDestinationRadioNewSheet.clear();
212 mpDestinationRadioNamedRange.clear();
213 mpDestinationRadioSelection.clear();
214 mpDestinationListBox.clear();
215 mpDestinationEdit.clear();
216 mpDestinationButton.clear();
217 mpBtnOK.clear();
218 mpBtnCancel.clear();
219 mpActiveEdit.clear();
220 ScAnyRefDlg::dispose();
223 void ScPivotLayoutDialog::SetupSource()
225 mpSourceListBox->Clear();
227 ScRange aSourceRange;
228 OUString sSourceNamedRangeName;
230 if (maPivotTableObject.GetSheetDesc())
232 const ScSheetSourceDesc* pSheetSourceDesc = maPivotTableObject.GetSheetDesc();
233 aSourceRange = pSheetSourceDesc->GetSourceRange();
235 if(!aSourceRange.IsValid())
237 // Source is probably a DB Range
238 mpSourceRadioNamedRange->Disable();
239 mpSourceRadioSelection->Disable();
240 ToggleSource(NULL);
241 return;
243 else
245 OUString aSourceRangeName = aSourceRange.Format(SCR_ABS_3D, mpDocument, maAddressDetails);
246 mpSourceEdit->SetText(aSourceRangeName);
249 else
251 mpSourceRadioNamedRange->Disable();
252 mpSourceRadioSelection->Disable();
253 ToggleSource(NULL);
254 return;
257 // Setup Named Ranges
258 bool bIsNamedRange = false;
260 ScAreaNameIterator aIterator(mpDocument);
261 OUString aEachName;
262 ScRange aEachRange;
264 while (aIterator.Next(aEachName, aEachRange))
266 if (!aIterator.WasDBName())
268 mpSourceListBox->InsertEntry(aEachName);
269 if (aEachRange == aSourceRange)
271 sSourceNamedRangeName = aEachName;
272 bIsNamedRange = true;
277 if (bIsNamedRange)
279 mpSourceListBox->SelectEntry(sSourceNamedRangeName, true);
280 mpSourceRadioNamedRange->Check(true);
282 else
284 mpSourceListBox->SelectEntryPos(0, true);
285 mpSourceRadioSelection->Check(true);
288 // If entries - select first entry, otherwise disable the radio button.
289 if (mpSourceListBox->GetEntryCount() <= 0)
290 mpSourceRadioNamedRange->Disable();
292 ToggleSource(NULL);
295 void ScPivotLayoutDialog::SetupDestination()
297 mpDestinationListBox->Clear();
299 // Fill up named ranges
300 ScAreaNameIterator aIterator(mpDocument);
301 OUString aName;
302 ScRange aRange;
304 while (aIterator.Next(aName, aRange))
306 if (!aIterator.WasDBName())
308 mpDestinationListBox->InsertEntry(aName);
312 // If entries - select first entry, otherwise disable the radio button.
313 if (mpDestinationListBox->GetEntryCount() > 0)
314 mpDestinationListBox->SelectEntryPos(0, true);
315 else
316 mpDestinationRadioNamedRange->Disable();
319 if (mbNewPivotTable)
321 mpDestinationRadioNewSheet->Check(true);
323 else
325 if (maPivotParameters.nTab != MAXTAB + 1)
327 ScAddress aAddress(maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
328 OUString aAddressString = aAddress.Format(SCA_VALID | SCA_TAB_3D | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE, mpDocument, maAddressDetails);
329 mpDestinationEdit->SetText(aAddressString);
330 mpDestinationRadioSelection->Check(true);
334 ToggleDestination(NULL);
337 void ScPivotLayoutDialog::FillValuesToListBoxes()
339 mpListBoxField->FillLabelFields(maPivotParameters.maLabelArray);
340 mpListBoxData->FillDataField(maPivotParameters.maDataFields);
341 mpListBoxColumn->FillFields(maPivotParameters.maColFields);
342 mpListBoxRow->FillFields(maPivotParameters.maRowFields);
343 mpListBoxPage->FillFields(maPivotParameters.maPageFields);
346 void ScPivotLayoutDialog::SetActive()
348 if (mbDialogLostFocus)
350 mbDialogLostFocus = false;
351 if(mpActiveEdit != nullptr)
353 mpActiveEdit->GrabFocus();
354 if (mpActiveEdit == mpSourceEdit)
355 UpdateSourceRange();
358 else
360 GrabFocus();
363 RefInputDone();
366 void ScPivotLayoutDialog::SetReference(const ScRange& rReferenceRange, ScDocument* pDocument)
368 if (!mbDialogLostFocus)
369 return;
371 if (mpActiveEdit == nullptr)
372 return;
374 if (rReferenceRange.aStart != rReferenceRange.aEnd)
375 RefInputStart(mpActiveEdit);
377 OUString aReferenceString = rReferenceRange.Format(SCR_ABS_3D, pDocument, maAddressDetails);
379 if (mpActiveEdit == mpSourceEdit)
381 mpSourceEdit->SetRefString(aReferenceString);
383 else if (mpActiveEdit == mpDestinationEdit)
385 mpDestinationEdit->SetRefString(aReferenceString);
389 bool ScPivotLayoutDialog::IsRefInputMode() const
391 return mbDialogLostFocus;
394 void ScPivotLayoutDialog::ItemInserted(ScItemValue* pItemValue, ScPivotLayoutTreeList::SvPivotTreeListType eType)
396 if (pItemValue == NULL)
397 return;
399 switch (eType)
401 case ScPivotLayoutTreeList::ROW_LIST:
402 case ScPivotLayoutTreeList::COLUMN_LIST:
403 case ScPivotLayoutTreeList::PAGE_LIST:
405 mpListBoxRow->RemoveEntryForItem(pItemValue);
406 mpListBoxColumn->RemoveEntryForItem(pItemValue);
407 mpListBoxPage->RemoveEntryForItem(pItemValue);
409 case ScPivotLayoutTreeList::LABEL_LIST:
411 mpListBoxRow->RemoveEntryForItem(pItemValue);
412 mpListBoxColumn->RemoveEntryForItem(pItemValue);
413 mpListBoxPage->RemoveEntryForItem(pItemValue);
414 mpListBoxData->RemoveEntryForItem(pItemValue);
416 break;
417 default:
418 break;
422 void ScPivotLayoutDialog::UpdateSourceRange()
424 if (!maPivotTableObject.GetSheetDesc())
425 return;
427 ScSheetSourceDesc aSourceSheet = *maPivotTableObject.GetSheetDesc();
429 if (mpSourceRadioNamedRange->IsChecked())
431 OUString aEntryString = mpSourceListBox->GetSelectEntry();
432 ScRange aSourceRange = lclGetRangeForNamedRange(aEntryString, mpDocument);
433 if (!aSourceRange.IsValid() || aSourceSheet.GetSourceRange() == aSourceRange)
434 return;
435 aSourceSheet.SetRangeName(aEntryString);
437 else if (mpSourceRadioSelection->IsChecked())
439 OUString aSourceString = mpSourceEdit->GetText();
440 ScRange aSourceRange;
441 sal_uInt16 nResult = aSourceRange.Parse(aSourceString, mpDocument, maAddressDetails);
443 bool bIsValid = (nResult & SCA_VALID) == SCA_VALID; // aSourceString is valid
445 mpSourceEdit->SetRefValid(true);
447 if (bIsValid)
449 ScRefAddress aStart;
450 ScRefAddress aEnd;
452 ConvertDoubleRef(mpDocument, aSourceString, 1, aStart, aEnd, maAddressDetails);
453 aSourceRange.aStart = aStart.GetAddress();
454 aSourceRange.aEnd = aEnd.GetAddress();
456 else
458 aSourceRange = lclGetRangeForNamedRange(aSourceString, mpDocument);
461 if (!aSourceRange.IsValid())
463 mpSourceEdit->SetRefValid(false);
464 return;
467 if (aSourceSheet.GetSourceRange() == aSourceRange)
468 return;
470 aSourceSheet.SetSourceRange(aSourceRange);
471 if (aSourceSheet.CheckSourceRange() != 0)
473 mpSourceEdit->SetRefValid(false);
474 return;
477 else
479 return;
482 maPivotTableObject.SetSheetDesc(aSourceSheet);
483 maPivotTableObject.FillOldParam(maPivotParameters);
484 maPivotTableObject.FillLabelData(maPivotParameters);
486 FillValuesToListBoxes();
489 bool ScPivotLayoutDialog::ApplyChanges()
491 ScDPSaveData aSaveData;
492 ApplySaveData(aSaveData);
493 ApplyLabelData(aSaveData);
495 ScRange aDestinationRange;
496 bool bToNewSheet = false;
498 if (!GetDestination(aDestinationRange, bToNewSheet))
499 return false;
501 SetDispatcherLock(false);
502 SwitchToDocument();
504 sal_uInt16 nWhichPivot = SC_MOD()->GetPool().GetWhich(SID_PIVOT_TABLE);
505 ScPivotItem aPivotItem(nWhichPivot, &aSaveData, &aDestinationRange, bToNewSheet);
506 mpViewData->GetViewShell()->SetDialogDPObject(&maPivotTableObject);
508 SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
509 SfxCallMode nCallMode = SfxCallMode::SLOT | SfxCallMode::RECORD;
510 const SfxPoolItem* pResult = pDispatcher->Execute(SID_PIVOT_TABLE, nCallMode, &aPivotItem, NULL, 0);
512 if (pResult != NULL)
514 const SfxBoolItem* pItem = reinterpret_cast<const SfxBoolItem*>(pResult);
515 if (pItem)
517 return pItem->GetValue();
521 SetDispatcherLock(true);
522 return true;
525 void ScPivotLayoutDialog::ApplySaveData(ScDPSaveData& rSaveData)
527 rSaveData.SetIgnoreEmptyRows(mpCheckIgnoreEmptyRows->IsChecked());
528 rSaveData.SetRepeatIfEmpty(mpCheckIdentifyCategories->IsChecked());
529 rSaveData.SetColumnGrand(mpCheckTotalColumns->IsChecked());
530 rSaveData.SetRowGrand(mpCheckTotalRows->IsChecked());
531 rSaveData.SetFilterButton(mpCheckAddFilter->IsChecked());
532 rSaveData.SetDrillDown(mpCheckDrillToDetail->IsChecked());
534 Reference<XDimensionsSupplier> xSource = maPivotTableObject.GetSource();
536 ScPivotFieldVector aPageFieldVector;
537 mpListBoxPage->PushEntriesToPivotFieldVector(aPageFieldVector);
538 ScDPObject::ConvertOrientation(rSaveData, aPageFieldVector, DataPilotFieldOrientation_PAGE,
539 xSource, maPivotParameters.maLabelArray);
541 ScPivotFieldVector aColFieldVector;
542 mpListBoxColumn->PushEntriesToPivotFieldVector(aColFieldVector);
543 ScDPObject::ConvertOrientation(rSaveData, aColFieldVector, DataPilotFieldOrientation_COLUMN,
544 xSource, maPivotParameters.maLabelArray);
546 ScPivotFieldVector aRowFieldVector;
547 mpListBoxRow->PushEntriesToPivotFieldVector(aRowFieldVector);
548 ScDPObject::ConvertOrientation(rSaveData, aRowFieldVector, DataPilotFieldOrientation_ROW,
549 xSource, maPivotParameters.maLabelArray);
551 ScPivotFieldVector aDataFieldVector;
552 mpListBoxData->PushEntriesToPivotFieldVector(aDataFieldVector);
553 ScDPObject::ConvertOrientation(rSaveData, aDataFieldVector, DataPilotFieldOrientation_DATA,
554 xSource, maPivotParameters.maLabelArray,
555 &aColFieldVector, &aRowFieldVector, &aPageFieldVector);
558 void ScPivotLayoutDialog::ApplyLabelData(ScDPSaveData& rSaveData)
560 ScDPLabelDataVector::const_iterator it;
561 ScDPLabelDataVector& rLabelDataVector = GetLabelDataVector();
563 for (it = rLabelDataVector.begin(); it != rLabelDataVector.end(); ++it)
565 const ScDPLabelData& pLabelData = *it;
567 OUString aUnoName = ScDPUtil::createDuplicateDimensionName(pLabelData.maName, pLabelData.mnDupCount);
568 ScDPSaveDimension* pSaveDimensions = rSaveData.GetExistingDimensionByName(aUnoName);
570 if (pSaveDimensions == NULL)
571 continue;
573 pSaveDimensions->SetUsedHierarchy(pLabelData.mnUsedHier);
574 pSaveDimensions->SetShowEmpty(pLabelData.mbShowAll);
575 pSaveDimensions->SetRepeatItemLabels(pLabelData.mbRepeatItemLabels);
576 pSaveDimensions->SetSortInfo(&pLabelData.maSortInfo);
577 pSaveDimensions->SetLayoutInfo(&pLabelData.maLayoutInfo);
578 pSaveDimensions->SetAutoShowInfo(&pLabelData.maShowInfo);
580 bool bManualSort = (pLabelData.maSortInfo.Mode == DataPilotFieldSortMode::MANUAL);
582 std::vector<ScDPLabelData::Member>::const_iterator itMember;
583 for (itMember = pLabelData.maMembers.begin(); itMember != pLabelData.maMembers.end(); ++itMember)
585 const ScDPLabelData::Member& rLabelMember = *itMember;
586 ScDPSaveMember* pMember = pSaveDimensions->GetMemberByName(rLabelMember.maName);
588 if (bManualSort || !rLabelMember.mbVisible || !rLabelMember.mbShowDetails)
590 pMember->SetIsVisible(rLabelMember.mbVisible);
591 pMember->SetShowDetails(rLabelMember.mbShowDetails);
597 bool ScPivotLayoutDialog::GetDestination(ScRange& aDestinationRange, bool& bToNewSheet)
599 bToNewSheet = false;
601 if (mpDestinationRadioNamedRange->IsChecked())
603 OUString aName = mpDestinationListBox->GetSelectEntry();
604 aDestinationRange = lclGetRangeForNamedRange(aName, mpDocument);
605 if (!aDestinationRange.IsValid())
606 return false;
608 else if (mpDestinationRadioSelection->IsChecked())
610 ScAddress aAddress;
611 aAddress.Parse(mpDestinationEdit->GetText(), mpDocument, maAddressDetails);
612 aDestinationRange = ScRange(aAddress);
614 else
616 bToNewSheet = true;
617 aDestinationRange = ScRange(maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
619 return true;
622 ScItemValue* ScPivotLayoutDialog::GetItem(SCCOL nColumn)
624 return mpListBoxField->GetItem(nColumn);
627 bool ScPivotLayoutDialog::IsDataElement(SCCOL nColumn)
629 return mpListBoxField->IsDataElement(nColumn);
632 ScDPLabelData* ScPivotLayoutDialog::GetLabelData(SCCOL nColumn)
634 return &maPivotParameters.maLabelArray[nColumn];
637 void ScPivotLayoutDialog::PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames)
639 return mpListBoxData->PushDataFieldNames(rDataFieldNames);
642 bool ScPivotLayoutDialog::Close()
644 return DoClose( ScPivotLayoutWrapper::GetChildWindowId() );
647 IMPL_LINK( ScPivotLayoutDialog, OKClicked, PushButton*, /*pButton*/ )
649 ApplyChanges();
650 Close();
651 return 0;
654 IMPL_LINK( ScPivotLayoutDialog, CancelClicked, PushButton*, /*pButton*/ )
656 Close();
657 return 0;
660 IMPL_LINK(ScPivotLayoutDialog, GetFocusHandler, Control*, pCtrl)
662 mpActiveEdit = NULL;
664 if (pCtrl == (Control*) mpSourceEdit ||
665 pCtrl == (Control*) mpSourceButton)
667 mpActiveEdit = mpSourceEdit;
669 else if (pCtrl == (Control*) mpDestinationEdit ||
670 pCtrl == (Control*) mpDestinationButton)
672 mpActiveEdit = mpDestinationEdit;
675 if (mpActiveEdit)
676 mpActiveEdit->SetSelection(Selection(0, SELECTION_MAX));
678 return 0;
681 IMPL_LINK_NOARG(ScPivotLayoutDialog, LoseFocusHandler)
683 mbDialogLostFocus = !IsActive();
684 return 0;
687 IMPL_LINK_NOARG(ScPivotLayoutDialog, SourceEditModified)
689 UpdateSourceRange();
690 return 0;
693 IMPL_LINK_NOARG(ScPivotLayoutDialog, ToggleSource)
695 bool bNamedRange = mpSourceRadioNamedRange->IsChecked();
696 bool bSelection = mpSourceRadioSelection->IsChecked();
697 mpSourceListBox->Enable(bNamedRange);
698 mpSourceButton->Enable(bSelection);
699 mpSourceEdit->Enable(bSelection);
700 UpdateSourceRange();
701 return 0;
704 IMPL_LINK_NOARG(ScPivotLayoutDialog, ToggleDestination)
706 bool bNamedRange = mpDestinationRadioNamedRange->IsChecked();
707 bool bSelection = mpDestinationRadioSelection->IsChecked();
708 mpDestinationListBox->Enable(bNamedRange);
709 mpDestinationButton->Enable(bSelection);
710 mpDestinationEdit->Enable(bSelection);
711 return 0;
714 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */