diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-12-18 15:16:04 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-31 10:31:01 +0200 |
commit | 389491aedd659a3c4b24b9902b6cb54075874d3e (patch) | |
tree | 1c54ab5215e81e5cf6beedad5e0acdfe0542169d /sw/source/ui/index | |
parent | 6bd751f9f577f25b058fb8a5479c0de7552c3ffc (diff) |
weld SwMultiTOXTabDialog
Change-Id: Ic1ae4cfe43bdf31d511e9ac0f65a821c53ab59eb
Reviewed-on: https://gerrit.libreoffice.org/65432
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/ui/index')
-rw-r--r-- | sw/source/ui/index/cntex.cxx | 9 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 175 |
2 files changed, 82 insertions, 102 deletions
diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index d569144abec0..e70fd8d4f179 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -94,11 +94,11 @@ static void lcl_SetBOOLProp( } } -IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, SwOneExampleFrame&, void) +IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, OneExampleFrame&, void) { try { - uno::Reference< frame::XModel > & xModel = m_pExampleFrame->GetModel(); + uno::Reference< frame::XModel > & xModel = m_xExampleFrame->GetModel(); uno::Reference< lang::XUnoTunnel > xDocTunnel(xModel, uno::UNO_QUERY); SwXTextDocument* pDoc = reinterpret_cast<SwXTextDocument*>(xDocTunnel->getSomething(SwXTextDocument::getUnoTunnelId())); @@ -138,7 +138,7 @@ IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, SwOneExampleFrame&, void void SwMultiTOXTabDialog::CreateOrUpdateExample( TOXTypes nTOXIndex, sal_uInt16 nPage, sal_uInt16 nCurrentLevel) { - if(!m_pExampleFrame || !m_pExampleFrame->IsInitialized()) + if(!m_xExampleFrame || !m_xExampleFrame->IsInitialized()) return; try @@ -157,7 +157,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( OSL_ENSURE(m_vTypeData[nTOXIndex].m_pxIndexSections && m_vTypeData[nTOXIndex].m_pxIndexSections->xContainerSection.is(), "Section not created"); - uno::Reference< frame::XModel > & xModel = m_pExampleFrame->GetModel(); + uno::Reference< frame::XModel > & xModel = m_xExampleFrame->GetModel(); bool bInitialCreate = true; if(!m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex.is()) { @@ -401,6 +401,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( { OSL_FAIL("::CreateExample() - exception caught"); } + m_xExampleFrame->Invalidate(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 915133cc54b5..8f2a9a14fb55 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -208,12 +208,10 @@ sal_uInt16 CurTOXType::GetFlatIndex() const ? TOX_AUTHORITIES + nIndex : eType ); } -SwMultiTOXTabDialog::SwMultiTOXTabDialog(vcl::Window* pParent, const SfxItemSet& rSet, - SwWrtShell &rShell, - SwTOXBase* pCurTOX, - sal_uInt16 nToxType, bool bGlobal) - : SfxTabDialog(pParent, "TocDialog", - "modules/swriter/ui/tocdialog.ui", &rSet) +SwMultiTOXTabDialog::SwMultiTOXTabDialog(weld::Window* pParent, const SfxItemSet& rSet, + SwWrtShell &rShell, SwTOXBase* pCurTOX, + sal_uInt16 nToxType, bool bGlobal) + : SfxTabDialogController(pParent, "modules/swriter/ui/tocdialog.ui", "TocDialog", &rSet) , m_pMgr( new SwTOXMgr( &rShell ) ) , m_rWrtShell(rShell) , m_pParamTOXBase(pCurTOX) @@ -222,14 +220,8 @@ SwMultiTOXTabDialog::SwMultiTOXTabDialog(vcl::Window* pParent, const SfxItemSet& , m_bEditTOX(false) , m_bExampleCreated(false) , m_bGlobalFlag(bGlobal) + , m_xShowExampleCB(m_xBuilder->weld_check_button("showexample")) { - get(m_pShowExampleCB, "showexample"); - get(m_pExampleContainerWIN, "example"); - Size aWinSize(LogicToPixel(Size(150, 188), MapMode(MapUnit::MapAppFont))); - m_pExampleContainerWIN->set_width_request(aWinSize.Width()); - m_pExampleContainerWIN->set_height_request(aWinSize.Height()); - m_pExampleContainerWIN->SetSizePixel(aWinSize); - m_eCurrentTOXType.eType = TOX_CONTENT; m_eCurrentTOXType.nIndex = 0; @@ -286,64 +278,42 @@ SwMultiTOXTabDialog::SwMultiTOXTabDialog(vcl::Window* pParent, const SfxItemSet& } } SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); - m_nSelectId = AddTabPage("index", SwTOXSelectTabPage::Create); - AddTabPage("styles", SwTOXStylesTabPage::Create); - m_nColumnId = AddTabPage("columns", SwColumnPage::Create); - m_nBackGroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG )); - m_nEntriesId = AddTabPage("entries", SwTOXEntryTabPage::Create); - if(!pCurTOX) - SetCurPageId(m_nSelectId); - - m_pShowExampleCB->SetClickHdl(LINK(this, SwMultiTOXTabDialog, ShowPreviewHdl)); - - m_pShowExampleCB->Check( SW_MOD()->GetModuleConfig()->IsShowIndexPreview()); + AddTabPage("index", SwTOXSelectTabPage::Create, nullptr); + AddTabPage("styles", SwTOXStylesTabPage::Create, nullptr); + AddTabPage("columns", SwColumnPage::Create, nullptr); + AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr); + AddTabPage("entries", SwTOXEntryTabPage::Create, nullptr); + if (!pCurTOX) + SetCurPageId("index"); - SetViewAlign( WindowAlign::Left ); - // SetViewWindow does not work if the dialog is visible! + m_xShowExampleCB->connect_toggled(LINK(this, SwMultiTOXTabDialog, ShowPreviewHdl)); + m_xShowExampleCB->set_active(SW_MOD()->GetModuleConfig()->IsShowIndexPreview()); - if(!m_pShowExampleCB->IsChecked()) - SetViewWindow(m_pExampleContainerWIN); - - ShowPreviewHdl(nullptr); + ShowPreviewHdl(*m_xShowExampleCB); } SwMultiTOXTabDialog::~SwMultiTOXTabDialog() { - disposeOnce(); -} - -void SwMultiTOXTabDialog::dispose() -{ - SW_MOD()->GetModuleConfig()->SetShowIndexPreview(m_pShowExampleCB->IsChecked()); - - // fdo#38515 Avoid setting focus on deleted controls in the destructors - EnableInput( false ); - - m_vTypeData.clear(); - m_pMgr.reset(); - m_pExampleFrame.reset(); - m_pExampleContainerWIN.clear(); - m_pShowExampleCB.clear(); - SfxTabDialog::dispose(); + SW_MOD()->GetModuleConfig()->SetShowIndexPreview(m_xShowExampleCB->get_active()); } -void SwMultiTOXTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) +void SwMultiTOXTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) { - if (nId == m_nBackGroundId) + if (rId == "background") { SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR))); rPage.PageCreated(aSet); } - else if(nId == m_nColumnId) + else if (rId == "columns") { const SwFormatFrameSize& rSize = GetInputSetImpl()->Get(RES_FRM_SIZE); static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth()); } - else if (nId == m_nEntriesId) + else if (rId == "entries") static_cast<SwTOXEntryTabPage&>(rPage).SetWrtShell(m_rWrtShell); - else if (nId == m_nSelectId) + else if (rId == "index") { static_cast<SwTOXSelectTabPage&>(rPage).SetWrtShell(m_rWrtShell); if(USHRT_MAX != m_nInitialTOXType) @@ -353,7 +323,7 @@ void SwMultiTOXTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) short SwMultiTOXTabDialog::Ok() { - short nRet = SfxTabDialog::Ok(); + short nRet = SfxTabDialogController::Ok(); SwTOXDescription& rDesc = GetTOXDescription(m_eCurrentTOXType); SwTOXBase aNewDef(*m_rWrtShell.GetDefaultTOXBase( m_eCurrentTOXType.eType, true )); @@ -451,11 +421,11 @@ std::unique_ptr<SwTOXDescription> SwMultiTOXTabDialog::CreateTOXDescFromTOXBase( return pDesc; } -IMPL_LINK_NOARG( SwMultiTOXTabDialog, ShowPreviewHdl, Button*, void ) +IMPL_LINK_NOARG(SwMultiTOXTabDialog, ShowPreviewHdl, weld::ToggleButton&, void) { - if(m_pShowExampleCB->IsChecked()) + if (m_xShowExampleCB->get_active()) { - if(!m_pExampleFrame && !m_bExampleCreated) + if(!m_xExampleFrame && !m_bExampleCreated) { m_bExampleCreated = true; OUString sTemplate("internal/idxexample.odt"); @@ -468,32 +438,31 @@ IMPL_LINK_NOARG( SwMultiTOXTabDialog, ShowPreviewHdl, Button*, void ) OUString sInfo(SwResId(STR_FILE_NOT_FOUND)); sInfo = sInfo.replaceFirst( "%1", sTemplate ); sInfo = sInfo.replaceFirst( "%2", aOpt.GetTemplatePath() ); - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Info, VclButtonsType::Ok, sInfo)); xInfoBox->run(); } else { - Link<SwOneExampleFrame&,void> aLink(LINK(this, SwMultiTOXTabDialog, CreateExample_Hdl)); - m_pExampleFrame.reset(new SwOneExampleFrame( - *m_pExampleContainerWIN, EX_SHOW_ONLINE_LAYOUT, &aLink, &sTemplate)); - - if(!m_pExampleFrame->IsServiceAvailable()) - { - SwOneExampleFrame::CreateErrorMessage(); - } + Link<OneExampleFrame&,void> aLink(LINK(this, SwMultiTOXTabDialog, CreateExample_Hdl)); + m_xExampleFrame.reset(new OneExampleFrame(EX_SHOW_ONLINE_LAYOUT, &aLink, &sTemplate)); + m_xExampleFrameWin.reset(new weld::CustomWeld(*m_xBuilder, "example", *m_xExampleFrame)); } - m_pShowExampleCB->Show(m_pExampleFrame && m_pExampleFrame->IsServiceAvailable()); + m_xShowExampleCB->set_visible(m_xExampleFrame != nullptr); } } - bool bSetViewWindow = m_pShowExampleCB->IsChecked() - && m_pExampleFrame && m_pExampleFrame->IsServiceAvailable(); - m_pExampleContainerWIN->Show( bSetViewWindow ); - SetViewWindow( bSetViewWindow ? m_pExampleContainerWIN.get() : nullptr ); + if (m_xExampleFrame) + { + const bool bSetViewWindow = m_xShowExampleCB->get_active(); + if (bSetViewWindow) + m_xExampleFrame->Show(); + else + m_xExampleFrame->Hide(); + } - setOptimalLayoutSize(); + m_xDialog->resize_to_request(); } bool SwMultiTOXTabDialog::IsNoNum(SwWrtShell& rSh, const OUString& rName) @@ -783,10 +752,10 @@ SwTOXSelectTabPage::SwTOXSelectTabPage(TabPageParent pParent, const SfxItemSet& false ); //Default mode is arranged to be the tallest mode - //of alphabetical index, lock that height in now + //of alphabetical index, lock that size in now LanguageHdl(nullptr); //fill sort algorithm list - Size aPrefSize(get_preferred_size()); - set_height_request(aPrefSize.Height()); + Size aPrefSize(m_xContainer->get_preferred_size()); + m_xContainer->set_size_request(aPrefSize.Width(), aPrefSize.Height()); sAddStyleContent = m_xAddStylesCB->get_label(); @@ -826,7 +795,7 @@ SwTOXSelectTabPage::SwTOXSelectTabPage(TabPageParent pParent, const SfxItemSet& m_xLevelNF->connect_value_changed(LINK(this, SwTOXSelectTabPage, ModifySpinHdl)); m_xSortAlgorithmLB->connect_changed(LINK(this, SwTOXSelectTabPage, ModifyListBoxHdl)); - aLk = LINK(this, SwTOXSelectTabPage, RadioButtonHdl); + aLk = LINK(this, SwTOXSelectTabPage, RadioButtonHdl); m_xFromCaptionsRB->connect_toggled(aLk); m_xFromObjectNamesRB->connect_toggled(aLk); RadioButtonHdl(*m_xFromCaptionsRB); @@ -932,7 +901,7 @@ static CurTOXType lcl_UserData2TOXTypes(sal_uInt16 nData) void SwTOXSelectTabPage::ApplyTOXDescription() { - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType(); SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType); m_xReadOnlyCB->set_active(rDesc.IsReadonly()); @@ -1048,7 +1017,7 @@ void SwTOXSelectTabPage::ApplyTOXDescription() void SwTOXSelectTabPage::FillTOXDescription() { - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); CurTOXType aCurType = pTOXDlg->GetCurrentTOXType(); SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType); rDesc.SetTitle(m_xTitleED->get_text()); @@ -1159,7 +1128,7 @@ void SwTOXSelectTabPage::FillTOXDescription() void SwTOXSelectTabPage::Reset( const SfxItemSet* ) { - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); SwWrtShell& rSh = pTOXDlg->GetWrtShell(); const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType(); sal_uInt32 nData = lcl_TOXTypesToUserData(aCurType); @@ -1216,7 +1185,7 @@ VclPtr<SfxTabPage> SwTOXSelectTabPage::Create(TabPageParent pParent, const SfxIt IMPL_LINK(SwTOXSelectTabPage, TOXTypeHdl, weld::ComboBox&, rBox, void) { - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); const sal_uInt16 nType = rBox.get_active_id().toUInt32(); CurTOXType eCurType = lcl_UserData2TOXTypes(nType); pTOXDlg->SetCurrentTOXType(eCurType); @@ -1284,7 +1253,7 @@ void SwTOXSelectTabPage::ModifyHdl() if(!m_bWaitingInitialSettings) { FillTOXDescription(); - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); pTOXDlg->CreateOrUpdateExample(pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_SELECT); } } @@ -1306,7 +1275,7 @@ IMPL_LINK_NOARG(SwTOXSelectTabPage, ModifySpinHdl, weld::SpinButton&, void) IMPL_LINK(SwTOXSelectTabPage, CheckBoxHdl, weld::ToggleButton&, rButton, void) { - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType(); if(TOX_CONTENT == aCurType.eType) { @@ -1377,7 +1346,7 @@ void SwTOXSelectTabPage::LanguageHdl(const weld::ComboBox* pBox) IMPL_LINK_NOARG(SwTOXSelectTabPage, AddStylesHdl, weld::Button&, void) { - SwAddStylesDlg_Impl aDlg(GetDialogFrameWeld(), static_cast<SwMultiTOXTabDialog*>(GetTabDialog())->GetWrtShell(), + SwAddStylesDlg_Impl aDlg(GetDialogFrameWeld(), static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell(), aStyleArr); aDlg.run(); ModifyHdl(); @@ -1408,8 +1377,7 @@ IMPL_LINK(SwTOXSelectTabPage, MenuExecuteHdl, const OString&, rIdent, void) return; } - VclPtrInstance<SwAutoMarkDlg_Impl> pAutoMarkDlg( - GetTabDialog(), sAutoMarkURL, bNew); + VclPtrInstance<SwAutoMarkDlg_Impl> pAutoMarkDlg(nullptr, sAutoMarkURL, bNew); if( RET_OK != pAutoMarkDlg->Execute() && bNew ) sAutoMarkURL = sSaveAutoMarkURL; @@ -1447,7 +1415,7 @@ public: , aFormToken(rToken) , bNextControl(false) , m_pParent(pTokenWin) - , m_xEntry(m_xBuilder->weld_entry("entry")) + , m_xEntry(m_xBuilder->weld_entry("entry", true)) { m_xEntry->connect_changed(LINK(this, SwTOXEdit, ModifyHdl)); m_xEntry->connect_key_press(LINK(this, SwTOXEdit, KeyInputHdl)); @@ -1603,7 +1571,7 @@ public: , aFormToken(rToken) , bNextControl(false) , m_pParent(pTokenWin) - , m_xButton(m_xBuilder->weld_toggle_button("button")) + , m_xButton(m_xBuilder->weld_toggle_button("button", true)) { m_xButton->connect_key_press(LINK(this, SwTOXButton, KeyInputHdl)); m_xButton->connect_focus_in(LINK(this, SwTOXButton, FocusInHdl)); @@ -1938,6 +1906,10 @@ SwTOXEntryTabPage::SwTOXEntryTabPage(TabPageParent pParent, const SfxItemSet& rA m_xFirstKeyLB->set_active(0); m_xSecondKeyLB->set_active(0); m_xThirdKeyLB->set_active(0); + + //lock size + Size aPrefSize(m_xContainer->get_preferred_size()); + m_xContainer->set_size_request(aPrefSize.Width(), aPrefSize.Height()); } SwTOXEntryTabPage::~SwTOXEntryTabPage() @@ -1966,7 +1938,7 @@ void SwTOXEntryTabPage::OnModify(bool bAllLevels) { UpdateDescriptor(); - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); if (pTOXDlg) { sal_uInt16 nCurLevel = m_xLevelLB->get_selected_index() + 1; @@ -1985,7 +1957,7 @@ bool SwTOXEntryTabPage::FillItemSet( SfxItemSet* ) void SwTOXEntryTabPage::Reset( const SfxItemSet* ) { - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType(); m_pCurrentForm = pTOXDlg->GetForm(aCurType); if(TOX_INDEX == aCurType.eType) @@ -2008,7 +1980,7 @@ void SwTOXEntryTabPage::Reset( const SfxItemSet* ) void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& /*rSet*/) { - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType(); m_pCurrentForm = pTOXDlg->GetForm(aCurType); @@ -2114,7 +2086,7 @@ void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& /*rSet*/) void SwTOXEntryTabPage::UpdateDescriptor() { WriteBackLevel(); - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aLastTOXType); if(TOX_INDEX == aLastTOXType.eType) { @@ -2162,7 +2134,7 @@ IMPL_LINK_NOARG(SwTOXEntryTabPage, EditStyleHdl, weld::Button&, void) { SfxStringItem aStyle(SID_STYLE_EDIT, m_xCharStyleLB->get_active_text()); SfxUInt16Item aFamily(SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Char)); - static_cast<SwMultiTOXTabDialog*>(GetTabDialog())->GetWrtShell(). + static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell(). GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_STYLE_EDIT, SfxCallMode::SYNCHRON, { &aStyle, &aFamily }); @@ -2628,8 +2600,9 @@ SwTokenWindow::SwTokenWindow(std::unique_ptr<weld::Container> xParent) , m_sCharStyle(SwResId(STR_CHARSTYLE)) , m_pActiveCtrl(nullptr) , m_pParent(nullptr) - , m_xBuilder(Application::CreateBuilder(xParent.get(), "modules/swriter/ui/tokenwidget.ui")) - , m_xContainer(std::move(xParent)) + , m_xParentWidget(std::move(xParent)) + , m_xBuilder(Application::CreateBuilder(m_xParentWidget.get(), "modules/swriter/ui/tokenwidget.ui")) + , m_xContainer(m_xBuilder->weld_container("TokenWidget")) , m_xLeftScrollWin(m_xBuilder->weld_button("left")) , m_xCtrlParentWin(m_xBuilder->weld_container("ctrl")) , m_xScrollWin(m_xBuilder->weld_scrolled_window("scrollwin")) @@ -2637,6 +2610,7 @@ SwTokenWindow::SwTokenWindow(std::unique_ptr<weld::Container> xParent) { m_xScrollWin->connect_hadjustment_changed(LINK(this, SwTokenWindow, ScrollHdl)); m_xCtrlParentWin->set_size_request(-1, Edit::GetMinimumEditSize().Height()); + m_xCtrlParentWin->connect_size_allocate(LINK(this, SwTokenWindow, AdjustPositionsHdl)); for (sal_uInt32 i = 0; i < TOKEN_END; ++i) { @@ -3062,11 +3036,15 @@ void SwTokenWindow::RemoveControl(const SwTOXButton* pDel, bool bInternalCall) m_aModifyHdl.Call(nullptr); } +IMPL_LINK_NOARG(SwTokenWindow, AdjustPositionsHdl, const Size&, void) +{ + AdjustScrolling(); +} + void SwTokenWindow::AdjustPositions() { for (size_t i = 0; i < m_aControlList.size(); ++i) m_aControlList[i]->set_grid_left_attach(i); - AdjustScrolling(); } @@ -3089,6 +3067,7 @@ void SwTokenWindow::AdjustScrolling() auto nLeft = m_xScrollWin->hadjustment_get_value(); auto nSpace = m_xScrollWin->hadjustment_get_page_size(); auto nWidth = m_xScrollWin->hadjustment_get_upper(); + bool bEnable = nWidth > nSpace; //the active control must be visible @@ -3480,7 +3459,7 @@ void SwTOXStylesTabPage::ActivatePage( const SfxItemSet& ) m_xLevelLB->thaw(); // initialise templates - SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetTabDialog())->GetWrtShell(); + SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell(); const sal_uInt16 nSz = rSh.GetTextFormatCollCount(); m_xParaLayLB->freeze(); @@ -3522,7 +3501,7 @@ IMPL_LINK_NOARG(SwTOXStylesTabPage, EditStyleHdl, weld::Button&, void) { SfxStringItem aStyle(SID_STYLE_EDIT, m_xParaLayLB->get_selected_text()); SfxUInt16Item aFamily(SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Para)); - SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetTabDialog())->GetWrtShell(); + SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell(); rSh.GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_STYLE_EDIT, SfxCallMode::SYNCHRON, { &aStyle, &aFamily }); @@ -3567,7 +3546,7 @@ IMPL_LINK_NOARG(SwTOXStylesTabPage, StdHdl, weld::Button&, void) IMPL_LINK_NOARG(SwTOXStylesTabPage, DoubleClickHdl, weld::TreeView&, void) { const OUString aTmpName(m_xParaLayLB->get_selected_text()); - SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetTabDialog())->GetWrtShell(); + SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell(); if(m_xParaLayLB->get_selected_index() != -1 && (m_xLevelLB->get_selected_index() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName))) @@ -3579,7 +3558,7 @@ IMPL_LINK_NOARG(SwTOXStylesTabPage, EnableSelectHdl, weld::TreeView&, void) { m_xStdBT->set_sensitive(m_xLevelLB->get_selected_index() != -1); - SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetTabDialog())->GetWrtShell(); + SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell(); const OUString aTmpName(m_xParaLayLB->get_selected_text()); m_xAssignBT->set_sensitive(m_xParaLayLB->get_selected_index() != -1 && m_xLevelLB->get_selected_index() != -1 && @@ -3589,7 +3568,7 @@ IMPL_LINK_NOARG(SwTOXStylesTabPage, EnableSelectHdl, weld::TreeView&, void) void SwTOXStylesTabPage::Modify() { - SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog()); + SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); if (pTOXDlg) { GetForm() = *m_pCurrentForm; |