diff options
23 files changed, 943 insertions, 116 deletions
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx index b426440fdf33..4f99e12e5b71 100644 --- a/include/sfx2/tabdlg.hxx +++ b/include/sfx2/tabdlg.hxx @@ -225,6 +225,72 @@ public: virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override; }; +class SFX2_DLLPUBLIC SfxTabDialogController : public weld::GenericDialogController +{ +protected: + std::unique_ptr<weld::Notebook> m_xTabCtrl; +private: + std::unique_ptr<weld::Button> m_xOKBtn; + std::unique_ptr<weld::Button> m_xApplyBtn; + std::unique_ptr<weld::Button> m_xCancelBtn; + std::unique_ptr<weld::Button> m_xResetBtn; + + SfxItemSet* m_pSet; + std::unique_ptr<SfxItemSet> m_pOutSet; + std::unique_ptr< TabDlg_Impl > m_pImpl; + sal_uInt16* m_pRanges; + bool m_bStandardPushed; + + DECL_DLLPRIVATE_LINK(ActivatePageHdl, const OString&, void); + DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool); + DECL_DLLPRIVATE_LINK(OkHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(ResetHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(CancelHdl, weld::Button&, void); + SAL_DLLPRIVATE void Init_Impl(bool bFmtFlag); + +protected: + virtual short Ok(); + virtual void RefreshInputSet(); + virtual void PageCreated(const OString &rName, SfxTabPage &rPage); + + SfxItemSet* m_pExampleSet; + SfxItemSet* GetInputSetImpl(); + + /** prepare to leave the current page. Calls the DeactivatePage method of the current page, (if necessary), + handles the item sets to copy. + @return sal_True if it is allowed to leave the current page, sal_False otherwise + */ + bool PrepareLeaveCurrentPage(); + + /** save the position of the TabDialog and which tab page is the currently active one + */ + void SavePosAndId(); + +public: + SfxTabDialogController(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID, + const SfxItemSet * = nullptr, bool bEditFmt = false); + virtual ~SfxTabDialogController() override; + + void AddTabPage( const OString& rName, // Name of the label for the page in the notebook .ui + CreateTabPage pCreateFunc, // != 0 + GetTabPageRanges pRangesFunc); // can be 0 + void RemoveTabPage( const OString& rName ); // Name of the label for the page in the notebook .ui + + void SetCurPageId(const OString& rName); + + // may provide local slots converted by Map + const sal_uInt16* GetInputRanges( const SfxItemPool& ); + void SetInputSet( const SfxItemSet* pInSet ); + const SfxItemSet* GetOutputItemSet() const { return m_pOutSet.get(); } + + short execute(); + + const SfxItemSet* GetExampleSet() const { return m_pExampleSet; } + SfxItemSet* GetExampleSet() { return m_pExampleSet; } + + SAL_DLLPRIVATE void Start_Impl(); +}; + namespace sfx { class ItemConnectionBase; } enum class DeactivateRC { @@ -242,6 +308,7 @@ namespace o3tl { class SFX2_DLLPUBLIC SfxTabPage: public TabPage { friend class SfxTabDialog; +friend class SfxTabDialogController; private: const SfxItemSet* pSet; @@ -264,9 +331,13 @@ protected: { return static_cast<const T*>(GetOldItem(rSet, sal_uInt16(nSlot), bDeep)); } + SfxTabDialog* GetTabDialog() const; void SetTabDialog(SfxTabDialog* pDialog); + SfxTabDialogController* GetDialogController() const; + void SetDialogController(SfxTabDialogController* pDialog); + void AddItemConnection( sfx::ItemConnectionBase* pConnection ); public: diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index d21c6aa96a9b..d15d593ecc7f 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -131,6 +131,8 @@ public: virtual OString get_current_page_ident() const = 0; virtual void set_current_page(int nPage) = 0; virtual void set_current_page(const OString& rIdent) = 0; + virtual void remove_page(const OString& rIdent) = 0; + virtual OUString get_tab_label_text(const OString& rIdent) const = 0; virtual int get_n_pages() const = 0; virtual weld::Container* get_page(const OString& rIdent) const = 0; @@ -753,14 +755,12 @@ public: class VCL_DLLPUBLIC DialogController { -private: +public: virtual Dialog* getDialog() = 0; const Dialog* getConstDialog() const { return const_cast<DialogController*>(this)->getDialog(); } - -public: short run() { return getDialog()->run(); } static bool runAsync(const std::shared_ptr<DialogController>& rController, const std::function<void(sal_Int32)>&); @@ -774,9 +774,6 @@ public: class VCL_DLLPUBLIC GenericDialogController : public DialogController { -private: - virtual Dialog* getDialog() override; - protected: std::unique_ptr<weld::Builder> m_xBuilder; std::shared_ptr<weld::Dialog> m_xDialog; @@ -784,14 +781,12 @@ protected: public: GenericDialogController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId); + virtual Dialog* getDialog() override; virtual ~GenericDialogController() COVERITY_NOEXCEPT_FALSE override; }; class VCL_DLLPUBLIC MessageDialogController : public DialogController { -private: - virtual Dialog* getDialog() override; - protected: std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::MessageDialog> m_xDialog; @@ -802,6 +797,7 @@ protected: public: MessageDialogController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId, const OString& rRelocateId = OString()); + virtual Dialog* getDialog() override; virtual ~MessageDialogController() override; void set_primary_text(const OUString& rText) { m_xDialog->set_primary_text(rText); } OUString get_primary_text() const { return m_xDialog->get_primary_text(); } diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index dfca78c96d7f..a39efbd00cba 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -53,24 +53,27 @@ struct TabPageImpl bool mbStandard; sfx::ItemConnectionArray maItemConn; VclPtr<SfxTabDialog> mxDialog; + SfxTabDialogController* mpDialogController; css::uno::Reference< css::frame::XFrame > mxFrame; - TabPageImpl() : mbStandard( false ) {} + TabPageImpl() : mbStandard( false ), mpDialogController(nullptr) {} }; struct Data_Impl { - sal_uInt16 nId; // The ID + sal_uInt16 nId; // The ID + OString sId; // The ID CreateTabPage fnCreatePage; // Pointer to Factory GetTabPageRanges fnGetRanges; // Pointer to Ranges-Function VclPtr<SfxTabPage> pTabPage; // The TabPage itself bool bRefresh; // Flag: Page must be re-initialized // Constructor - Data_Impl( sal_uInt16 Id, CreateTabPage fnPage, + Data_Impl( sal_uInt16 Id, const OString& rId, CreateTabPage fnPage, GetTabPageRanges fnRanges ) : nId ( Id ), + sId ( rId ), fnCreatePage( fnPage ), fnGetRanges ( fnRanges ), pTabPage ( nullptr ), @@ -144,6 +147,24 @@ static Data_Impl* Find( const SfxTabDlgData_Impl& rArr, sal_uInt16 nId, sal_uInt return nullptr; } +static Data_Impl* Find( const SfxTabDlgData_Impl& rArr, const OString& rId, sal_uInt16* pPos = nullptr) +{ + const sal_uInt16 nCount = rArr.size(); + + for ( sal_uInt16 i = 0; i < nCount; ++i ) + { + Data_Impl* pObj = rArr[i]; + + if ( pObj->sId == rId ) + { + if ( pPos ) + *pPos = i; + return pObj; + } + } + return nullptr; +} + void SfxTabPage::SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame) { if (pImpl) @@ -318,6 +339,16 @@ SfxTabDialog* SfxTabPage::GetTabDialog() const return pImpl->mxDialog; } +void SfxTabPage::SetDialogController(SfxTabDialogController* pDialog) +{ + pImpl->mpDialogController = pDialog; +} + +SfxTabDialogController* SfxTabPage::GetDialogController() const +{ + return pImpl->mpDialogController; +} + OString SfxTabPage::GetConfigId() const { if (m_xContainer) @@ -624,8 +655,7 @@ sal_uInt16 SfxTabDialog::AddTabPage ) { sal_uInt16 nId = m_pTabCtrl->GetPageId(rName); - m_pImpl->aData.push_back( - new Data_Impl( nId, pCreateFunc, pRangesFunc ) ); + m_pImpl->aData.push_back(new Data_Impl(nId, rName, pCreateFunc, pRangesFunc)); return nId; } @@ -645,7 +675,7 @@ sal_uInt16 SfxTabDialog::AddTabPage assert(pCreateFunc); GetTabPageRanges pRangesFunc = pFact->GetTabPageRangesFunc(nPageCreateId); sal_uInt16 nPageId = m_pTabCtrl->GetPageId(rName); - m_pImpl->aData.push_back(new Data_Impl(nPageId, pCreateFunc, pRangesFunc)); + m_pImpl->aData.push_back(new Data_Impl(nPageId, rName, pCreateFunc, pRangesFunc)); return nPageId; } @@ -669,7 +699,7 @@ void SfxTabDialog::AddTabPage DBG_ASSERT( TAB_PAGE_NOTFOUND == m_pTabCtrl->GetPagePos( nId ), "Double Page-Ids in the Tabpage" ); m_pTabCtrl->InsertPage( nId, rRiderText, nPos ); - m_pImpl->aData.push_back( new Data_Impl( nId, pCreateFunc, pRangesFunc ) ); + m_pImpl->aData.push_back( new Data_Impl(nId, "", pCreateFunc, pRangesFunc ) ); } void SfxTabDialog::RemoveTabPage( sal_uInt16 nId ) @@ -1422,4 +1452,583 @@ bool SfxTabDialog::selectPageByUIXMLDescription(const OString& rUIXMLDescription return false; } +SfxTabDialogController::SfxTabDialogController +( + weld::Window* pParent, // Parent Window + const OUString& rUIXMLDescription, const OString& rID, // Dialog .ui path, Dialog Name + const SfxItemSet* pItemSet, // Itemset with the data; + // can be NULL, when Pages are onDemand + bool bEditFmt // when yes -> additional Button for standard +) + : GenericDialogController(pParent, rUIXMLDescription, rID) + , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol")) + , m_xOKBtn(m_xBuilder->weld_button("ok")) + , m_xApplyBtn(m_xBuilder->weld_button("apply")) + , m_xCancelBtn(m_xBuilder->weld_button("cancel")) + , m_xResetBtn(m_xBuilder->weld_button("reset")) + , m_pSet(pItemSet ? new SfxItemSet(*pItemSet) : nullptr) + , m_pOutSet(nullptr) + , m_pRanges(nullptr) + , m_bStandardPushed(false) + , m_pExampleSet(nullptr) +{ + Init_Impl(bEditFmt); +} + +void SfxTabDialogController::Init_Impl(bool /*bFmtFlag*/) +{ + m_pImpl.reset(new TabDlg_Impl(m_xTabCtrl->get_n_pages())); + m_pImpl->bHideResetBtn = !m_xResetBtn->get_visible(); + m_xOKBtn->connect_clicked(LINK(this, SfxTabDialogController, OkHdl)); + m_xCancelBtn->connect_clicked(LINK(this, SfxTabDialogController, CancelHdl)); + m_xResetBtn->connect_clicked(LINK(this, SfxTabDialogController, ResetHdl)); + m_xResetBtn->set_label(SfxResId(STR_RESET)); + m_xTabCtrl->connect_enter_page(LINK(this, SfxTabDialogController, ActivatePageHdl)); + m_xTabCtrl->connect_leave_page(LINK(this, SfxTabDialogController, DeactivatePageHdl)); + m_xResetBtn->set_help_id(HID_TABDLG_RESET_BTN); + + if (m_pSet) + { + m_pExampleSet = new SfxItemSet(*m_pSet); + m_pOutSet.reset(new SfxItemSet(*m_pSet->GetPool(), m_pSet->GetRanges())); + } +} + +IMPL_LINK_NOARG(SfxTabDialogController, OkHdl, weld::Button&, void) + +/* [Description] + + Handler of the Ok-Buttons + This calls the current page <SfxTabPage::DeactivatePage(SfxItemSet *)>. + Returns <DeactivateRC::LeavePage>, <SfxTabDialog::Ok()> is called + and the Dialog is ended. +*/ + +{ + if (PrepareLeaveCurrentPage()) + m_xDialog->response(Ok()); +} + +IMPL_LINK_NOARG(SfxTabDialogController, CancelHdl, weld::Button&, void) +{ + m_xDialog->response(RET_USER_CANCEL); +} + +IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void) + +/* [Description] + + Handler behind the reset button. + The Current Page is new initialized with their initial data, all the + settings that the user has made on this page are repealed. +*/ + +{ + const OString sId = m_xTabCtrl->get_current_page_ident(); + Data_Impl* pDataObject = Find( m_pImpl->aData, sId ); + DBG_ASSERT( pDataObject, "Id not known" ); + + pDataObject->pTabPage->Reset( m_pSet ); + // Also reset relevant items of ExampleSet and OutSet to initial state + if (pDataObject->fnGetRanges) + { + if (!m_pExampleSet) + m_pExampleSet = new SfxItemSet(*m_pSet); + + const SfxItemPool* pPool = m_pSet->GetPool(); + const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); + + while (*pTmpRanges) + { + const sal_uInt16* pU = pTmpRanges + 1; + + // Correct Range with multiple values + sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU; + DBG_ASSERT(nTmp <= nTmpEnd, "Range is sorted the wrong way"); + + if (nTmp > nTmpEnd) + { + // If really sorted wrongly, then set new + std::swap(nTmp, nTmpEnd); + } + + while (nTmp && nTmp <= nTmpEnd) + { + // Iterate over the Range and set the Items + sal_uInt16 nWh = pPool->GetWhich(nTmp); + const SfxPoolItem* pItem; + if (SfxItemState::SET == m_pSet->GetItemState(nWh, false, &pItem)) + { + m_pExampleSet->Put(*pItem); + m_pOutSet->Put(*pItem); + } + else + { + m_pExampleSet->ClearItem(nWh); + m_pOutSet->ClearItem(nWh); + } + nTmp++; + } + // Go to the next pair + pTmpRanges += 2; + } + } +} + +IMPL_LINK(SfxTabDialogController, ActivatePageHdl, const OString&, rPage, void) + +/* [Description] + + Handler that is called by StarView for switching to a different page. + If possible the <SfxTabPage::Reset(const SfxItemSet &)> or + <SfxTabPage::ActivatePage(const SfxItemSet &)> is called on the new page +*/ + +{ + assert(!m_pImpl->aData.empty() && "no Pages registered"); + Data_Impl* pDataObject = Find(m_pImpl->aData, rPage); + if (!pDataObject) + { + SAL_WARN("sfx.dialog", "Tab Page ID not known, this is pretty serious and needs investigation"); + return; + } + + VclPtr<SfxTabPage> pTabPage = pDataObject->pTabPage; + + if (pDataObject->bRefresh) + pTabPage->Reset(m_pSet); + pDataObject->bRefresh = false; + + if (m_pExampleSet) + pTabPage->ActivatePage(*m_pExampleSet); + + if (pTabPage->IsReadOnly() || m_pImpl->bHideResetBtn) + m_xResetBtn->hide(); + else + m_xResetBtn->show(); +} + +IMPL_LINK(SfxTabDialogController, DeactivatePageHdl, const OString&, rPage, bool) + +/* [Description] + + Handler that is called by StarView before leaving a page. + + [Cross-reference] + + <SfxTabPage::DeactivatePage(SfxItemSet *)> +*/ + +{ + assert(!m_pImpl->aData.empty() && "no Pages registered"); + Data_Impl* pDataObject = Find(m_pImpl->aData, rPage); + if (!pDataObject) + { + SAL_WARN("sfx.dialog", "Tab Page ID not known, this is pretty serious and needs investigation"); + return false; + } + + VclPtr<SfxTabPage> pPage = pDataObject->pTabPage; + DBG_ASSERT( pPage, "no active Page" ); + if (!pPage) + return false; + + DeactivateRC nRet = DeactivateRC::LeavePage; + + if (!m_pExampleSet && pPage->HasExchangeSupport() && m_pSet) + m_pExampleSet = new SfxItemSet(*m_pSet->GetPool(), m_pSet->GetRanges()); + + if (m_pSet) + { + SfxItemSet aTmp( *m_pSet->GetPool(), m_pSet->GetRanges() ); + + if (pPage->HasExchangeSupport()) + nRet = pPage->DeactivatePage(&aTmp); + else + nRet = pPage->DeactivatePage(nullptr); + if ( ( DeactivateRC::LeavePage & nRet ) == DeactivateRC::LeavePage && + aTmp.Count() && m_pExampleSet) + { + m_pExampleSet->Put( aTmp ); + m_pOutSet->Put( aTmp ); + } + } + else + { + if ( pPage->HasExchangeSupport() ) //!!! + { + if ( !m_pExampleSet ) + { + SfxItemPool* pPool = pPage->GetItemSet().GetPool(); + m_pExampleSet = + new SfxItemSet( *pPool, GetInputRanges( *pPool ) ); + } + nRet = pPage->DeactivatePage( m_pExampleSet ); + } + else + nRet = pPage->DeactivatePage( nullptr ); + } + + if ( nRet & DeactivateRC::RefreshSet ) + { + RefreshInputSet(); + // Flag all Pages as to be initialized as new + + for (auto const& elem : m_pImpl->aData) + { + elem->bRefresh = ( elem->pTabPage.get() != pPage ); // Do not refresh own Page anymore + } + } + return static_cast<bool>(nRet & DeactivateRC::LeavePage); +} + +bool SfxTabDialogController::PrepareLeaveCurrentPage() +{ + const OString sId = m_xTabCtrl->get_current_page_ident(); + Data_Impl* pDataObject = Find(m_pImpl->aData, sId); + DBG_ASSERT( pDataObject, "Id not known" ); + VclPtr<SfxTabPage> pPage = pDataObject ? pDataObject->pTabPage : nullptr; + + bool bEnd = !pPage; + + if ( pPage ) + { + DeactivateRC nRet = DeactivateRC::LeavePage; + if ( m_pSet ) + { + SfxItemSet aTmp( *m_pSet->GetPool(), m_pSet->GetRanges() ); + + if ( pPage->HasExchangeSupport() ) + nRet = pPage->DeactivatePage( &aTmp ); + else + nRet = pPage->DeactivatePage( nullptr ); + + if ( ( DeactivateRC::LeavePage & nRet ) == DeactivateRC::LeavePage + && aTmp.Count() ) + { + m_pExampleSet->Put( aTmp ); + m_pOutSet->Put( aTmp ); + } + } + else + nRet = pPage->DeactivatePage( nullptr ); + bEnd = nRet != DeactivateRC::KeepPage; + } + + return bEnd; +} + +const sal_uInt16* SfxTabDialogController::GetInputRanges(const SfxItemPool& rPool) + +/* [Description] + + Makes the set over the range of all pages of the dialogue. Pages have the + static method for querying their range in AddTabPage, ie deliver their + sets onDemand. + + [Return value] + + Pointer to a null-terminated array of sal_uInt16. This array belongs to the + dialog and is deleted when the dialogue is destroy. + + [Cross-reference] + + <SfxTabDialog::AddTabPage(sal_uInt16, CreateTabPage, GetTabPageRanges, bool)> + <SfxTabDialog::AddTabPage(sal_uInt16, const String &, CreateTabPage, GetTabPageRanges, bool, sal_uInt16)> + <SfxTabDialog::AddTabPage(sal_uInt16, const Bitmap &, CreateTabPage, GetTabPageRanges, bool, sal_uInt16)> +*/ + +{ + if ( m_pSet ) + { + SAL_WARN( "sfx.dialog", "Set already exists!" ); + return m_pSet->GetRanges(); + } + + if ( m_pRanges ) + return m_pRanges; + std::vector<sal_uInt16> aUS; + + for (auto const& elem : m_pImpl->aData) + { + + if ( elem->fnGetRanges ) + { + const sal_uInt16* pTmpRanges = (elem->fnGetRanges)(); + const sal_uInt16* pIter = pTmpRanges; + + sal_uInt16 nLen; + for( nLen = 0; *pIter; ++nLen, ++pIter ) + ; + aUS.insert( aUS.end(), pTmpRanges, pTmpRanges + nLen ); + } + } + + //! Remove duplicated Ids? + { + for (auto & elem : aUS) + elem = rPool.GetWhich(elem); + } + + // sort + if ( aUS.size() > 1 ) + { + std::sort( aUS.begin(), aUS.end() ); + } + + m_pRanges = new sal_uInt16[aUS.size() + 1]; + std::copy( aUS.begin(), aUS.end(), m_pRanges ); + m_pRanges[aUS.size()] = 0; + return m_pRanges; +} + +SfxTabDialogController::~SfxTabDialogController() +{ + SavePosAndId(); + + for (auto & elem : m_pImpl->aData) + { + if ( elem->pTabPage ) + { + // save settings of all pages (user data) + elem->pTabPage->FillUserData(); + OUString aPageData( elem->pTabPage->GetUserData() ); + if ( !aPageData.isEmpty() ) + { + // save settings of all pages (user data) + OUString sConfigId = OStringToOUString(elem->pTabPage->GetConfigId(), + RTL_TEXTENCODING_UTF8); + SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); + aPageOpt.SetUserItem( USERITEM_NAME, makeAny( aPageData ) ); + } + + elem->pTabPage.disposeAndClear(); + } + delete elem; + elem = nullptr; + } +} + +short SfxTabDialogController::Ok() + +/* [Description] + + Ok handler for the Dialogue. + + Dialog's current location and current page are saved for the next time + the dialog is shown. + + The OutputSet is created and for each page this or the special OutputSet + is set by calling the method <SfxTabPage::FillItemSet(SfxItemSet &)>, to + insert the entered data by the user into the set. + + [Return value] + + RET_OK: if at least one page has returned from FillItemSet, + otherwise RET_CANCEL. +*/ +{ + SavePosAndId(); //See fdo#38828 "Apply" resetting window position + + if ( !m_pOutSet ) + { + if ( m_pExampleSet ) + m_pOutSet.reset(new SfxItemSet( *m_pExampleSet )); + else if ( m_pSet ) + m_pOutSet = m_pSet->Clone( false ); // without Items + } + bool bModified = false; + + for (auto const& elem : m_pImpl->aData) + { + SfxTabPage* pTabPage = elem->pTabPage; + + if ( pTabPage ) + { + if ( m_pSet && !pTabPage->HasExchangeSupport() ) + { + SfxItemSet aTmp( *m_pSet->GetPool(), m_pSet->GetRanges() ); + + if ( pTabPage->FillItemSet( &aTmp ) ) + { + bModified = true; + if (m_pExampleSet) + m_pExampleSet->Put( aTmp ); + m_pOutSet->Put( aTmp ); + } + } + } + } + + if ( m_pOutSet && m_pOutSet->Count() > 0 ) + bModified = true; + + if (m_bStandardPushed) + bModified = true; + return bModified ? RET_OK : RET_CANCEL; +} + +void SfxTabDialogController::RefreshInputSet() + +/* [Description] + + Default implementation of the virtual Method. + This is called, when <SfxTabPage::DeactivatePage(SfxItemSet *)> + returns <DeactivateRC::RefreshSet>. +*/ + +{ + SAL_INFO ( "sfx.dialog", "RefreshInputSet not implemented" ); +} + +void SfxTabDialogController::PageCreated + +/* [Description] + + Default implementation of the virtual method. This is called immediately + after creating a page. Here the dialogue can call the TabPage Method + directly. +*/ + +( + const OString&, // Id of the created page + SfxTabPage& // Reference to the created page +) +{ +} + +void SfxTabDialogController::SavePosAndId() +{ + // save settings (screen position and current page) + SvtViewOptions aDlgOpt(EViewType::TabDialog, OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8)); + aDlgOpt.SetPageID(m_xTabCtrl->get_current_page_ident()); +} + +/* + Adds a page to the dialog. The Name must correspond to a entry in the + TabControl in the dialog .ui +*/ +void SfxTabDialogController::AddTabPage +( + const OString &rName, // Page ID + CreateTabPage pCreateFunc, // Pointer to the Factory Method + GetTabPageRanges pRangesFunc // Pointer to the Method for querying + // Ranges onDemand +) +{ + m_pImpl->aData.push_back(new Data_Impl(m_pImpl->aData.size(), rName, pCreateFunc, pRangesFunc)); + Data_Impl* pDataObject = m_pImpl->aData.back(); + + assert(pDataObject->pTabPage == nullptr && "create TabPage more than once"); + weld::Container* pPage = m_xTabCtrl->get_page(rName); + pDataObject->pTabPage = (pDataObject->fnCreatePage)(pPage, m_pSet); + pDataObject->pTabPage->SetDialogController(this); + + OUString sConfigId = OStringToOUString(pDataObject->pTabPage->GetConfigId(), RTL_TEXTENCODING_UTF8); + SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); + OUString sUserData; + Any aUserItem = aPageOpt.GetUserItem(USERITEM_NAME); + OUString aTemp; + if ( aUserItem >>= aTemp ) + sUserData = aTemp; + pDataObject->pTabPage->SetUserData(sUserData); + + PageCreated(rName, *pDataObject->pTabPage); + pDataObject->pTabPage->Reset(m_pSet); +} + +void SfxTabDialogController::RemoveTabPage(const OString& rId) + +/* [Description] + + Delete the TabPage with ID nId +*/ + +{ + sal_uInt16 nPos = 0; + m_xTabCtrl->remove_page(rId); + Data_Impl* pDataObject = Find( m_pImpl->aData, rId, &nPos ); + + if ( pDataObject ) + { + if ( pDataObject->pTabPage ) + { + pDataObject->pTabPage->FillUserData(); + OUString aPageData( pDataObject->pTabPage->GetUserData() ); + if ( !aPageData.isEmpty() ) + { + // save settings of this page (user data) + OUString sConfigId = OStringToOUString(pDataObject->pTabPage->GetConfigId(), + RTL_TEXTENCODING_UTF8); + SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); + aPageOpt.SetUserItem( USERITEM_NAME, makeAny( aPageData ) ); + } + + pDataObject->pTabPage.disposeAndClear(); + } + + delete pDataObject; + m_pImpl->aData.erase( m_pImpl->aData.begin() + nPos ); + } + else + { + SAL_INFO( "sfx.dialog", "TabPage-Id not known" ); + } +} + +void SfxTabDialogController::Start_Impl() +{ + assert(m_pImpl->aData.size() == static_cast<size_t>(m_xTabCtrl->get_n_pages()) + && "not all pages registered"); + + // load old settings, when exists + SvtViewOptions aDlgOpt(EViewType::TabDialog, OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8)); + if (aDlgOpt.Exists()) + m_xTabCtrl->set_current_page(aDlgOpt.GetPageID()); + + ActivatePageHdl(m_xTabCtrl->get_current_page_ident()); +} + +void SfxTabDialogController::SetCurPageId(const OString& rIdent) +{ + m_xTabCtrl->set_current_page(rIdent); +} + +short SfxTabDialogController::execute() +{ + Start_Impl(); + return m_xDialog->run(); +} + +void SfxTabDialogController::SetInputSet( const SfxItemSet* pInSet ) + +/* [Description] + + With this method the Input-Set can subsequently be set initially or re-set. +*/ + +{ + bool bSet = ( m_pSet != nullptr ); + delete m_pSet; + m_pSet = pInSet ? new SfxItemSet(*pInSet) : nullptr; + + if (!bSet && !m_pExampleSet && !m_pOutSet && m_pSet) + { + m_pExampleSet = new SfxItemSet( *m_pSet ); + m_pOutSet.reset(new SfxItemSet( *m_pSet->GetPool(), m_pSet->GetRanges() )); + } +} + +SfxItemSet* SfxTabDialogController::GetInputSetImpl() + +/* [Description] + + Derived classes may create new storage for the InputSet. This has to be + released in the Destructor. To do this, this method must be called. +*/ + +{ + return m_pSet; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 63411ef6b03c..552c3b730b27 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -275,8 +275,8 @@ class AbstractSwLabDlg : public SfxAbstractTabDialog protected: virtual ~AbstractSwLabDlg() override = default; public: - virtual const OUString& GetBusinessCardStr() const = 0; - virtual Printer *GetPrt() =0; + virtual const OUString& GetBusinessCardStr() const = 0; + virtual Printer *GetPrt() =0; }; class AbstractSwSelGlossaryDlg : public VclAbstractDialog @@ -390,7 +390,7 @@ public: SwField* pField, bool bPrevButton, bool bNextButton) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) = 0; - virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(const SfxItemSet& rSet, + virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, SwDBManager* pDBManager, bool bLabel) = 0; virtual SwLabDlgMethod GetSwLabDlgStaticMethod () =0; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 842fe09aff9e..3df60e9b35e0 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -139,7 +139,11 @@ short AbstractDropDownFieldDialog_Impl::Execute() return m_xDlg->execute(); } -IMPL_ABSTDLG_BASE(AbstractSwLabDlg_Impl); +short AbstractSwLabDlg_Impl::Execute() +{ + return m_xDlg->execute(); +} + IMPL_ABSTDLG_BASE(AbstractSwSelGlossaryDlg_Impl); short AbstractSwAutoFormatDlg_Impl::Execute() { @@ -291,37 +295,37 @@ bool AbstractDropDownFieldDialog_Impl::NextButtonPressed() const void AbstractSwLabDlg_Impl::SetCurPageId( const OString &rName ) { - pDlg->SetCurPageId( rName ); + m_xDlg->SetCurPageId( rName ); } const SfxItemSet* AbstractSwLabDlg_Impl::GetOutputItemSet() const { - return pDlg->GetOutputItemSet(); + return m_xDlg->GetOutputItemSet(); } const sal_uInt16* AbstractSwLabDlg_Impl::GetInputRanges(const SfxItemPool& pItem ) { - return pDlg->GetInputRanges( pItem ); + return m_xDlg->GetInputRanges( pItem ); } void AbstractSwLabDlg_Impl::SetInputSet( const SfxItemSet* pInSet ) { - pDlg->SetInputSet( pInSet ); + m_xDlg->SetInputSet( pInSet ); } void AbstractSwLabDlg_Impl::SetText( const OUString& rStr ) { - pDlg->SetText( rStr ); + m_xDlg->set_title(rStr); } const OUString& AbstractSwLabDlg_Impl::GetBusinessCardStr() const { - return pDlg->GetBusinessCardStr(); + return m_xDlg->GetBusinessCardStr(); } Printer * AbstractSwLabDlg_Impl::GetPrt() { - return pDlg->GetPrt(); + return m_xDlg->GetPrt(); } void AbstractSwSelGlossaryDlg_Impl::InsertGlos(const OUString &rRegion, const OUString &rGlosName) @@ -762,11 +766,10 @@ VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg ( vcl: return VclPtr<AbstractTabDialog_Impl>::Create( pDlg ); } -VclPtr<AbstractSwLabDlg> SwAbstractDialogFactory_Impl::CreateSwLabDlg(const SfxItemSet& rSet, +VclPtr<AbstractSwLabDlg> SwAbstractDialogFactory_Impl::CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, SwDBManager* pDBManager, bool bLabel) { - VclPtr<SwLabDlg> pDlg = VclPtr<SwLabDlg>::Create(nullptr, rSet, pDBManager, bLabel); - return VclPtr<AbstractSwLabDlg_Impl>::Create(pDlg); + return VclPtr<AbstractSwLabDlg_Impl>::Create(new SwLabDlg(pParent, rSet, pDBManager, bLabel)); } SwLabDlgMethod SwAbstractDialogFactory_Impl::GetSwLabDlgStaticMethod () diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 635d99ccb0cd..1be0a93ab046 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -275,7 +275,14 @@ public: class AbstractSwLabDlg_Impl : public AbstractSwLabDlg { - DECL_ABSTDLG_BASE(AbstractSwLabDlg_Impl,SwLabDlg) +protected: + std::unique_ptr<SwLabDlg> m_xDlg; +public: + explicit AbstractSwLabDlg_Impl(SwLabDlg* p) + : m_xDlg(p) + { + } + virtual short Execute() override; virtual void SetCurPageId( const OString &rName ) override; virtual const SfxItemSet* GetOutputItemSet() const override; virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override; @@ -544,7 +551,7 @@ public: virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Window* pParent, SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) override; virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) override; - virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(const SfxItemSet& rSet, + virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, SwDBManager* pDBManager, bool bLabel) override; virtual SwLabDlgMethod GetSwLabDlgStaticMethod () override; diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx index edca19a60979..c8768e85b995 100644 --- a/sw/source/ui/envelp/label1.cxx +++ b/sw/source/ui/envelp/label1.cxx @@ -75,11 +75,11 @@ void SwLabDlg::ReplaceGroup_( const OUString &rMake ) aLstGroup = rMake; } -void SwLabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) +void SwLabDlg::PageCreated(const OString &rId, SfxTabPage &rPage) { - if (nId == m_nLabelId) + if (rId == "labels") { - if(m_bLabel) + if (m_bLabel) { static_cast<SwLabPage*>(&rPage)->SetDBManager(pDBManager); static_cast<SwLabPage*>(&rPage)->InitDatabaseBox(); @@ -87,43 +87,21 @@ void SwLabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) else static_cast<SwLabPage*>(&rPage)->SetToBusinessCard(); } - else if (nId == m_nOptionsId) + else if (rId == "options") pPrtPage = static_cast<SwLabPrtPage*>(&rPage); } -SwLabDlg::SwLabDlg(vcl::Window* pParent, const SfxItemSet& rSet, +SwLabDlg::SwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, SwDBManager* pDBManager_, bool bLabel) - : SfxTabDialog(pParent, "LabelDialog", - "modules/swriter/ui/labeldialog.ui", &rSet) + : SfxTabDialogController(pParent, "modules/swriter/ui/labeldialog.ui", "LabelDialog", &rSet) , pDBManager(pDBManager_) , pPrtPage(nullptr) , aTypeIds(50, 10) , m_pRecs(new SwLabRecs) , m_bLabel(bLabel) - , m_nOptionsId(0) - , m_nLabelId(0) { - WaitObject aWait( pParent ); + weld::WaitObject aWait(pParent); - AddTabPage("format", SwLabFormatPage::Create, nullptr); - m_nOptionsId = AddTabPage("options", SwLabPrtPage::Create, nullptr); - m_sBusinessCardDlg = SwResId(STR_BUSINESS_CARDS); - - if (m_bLabel) - { - RemoveTabPage("business"); - RemoveTabPage("private"); - RemoveTabPage("medium"); - m_nLabelId = AddTabPage("labels", SwLabPage::Create, nullptr); - } - else - { - RemoveTabPage("labels"); - m_nLabelId = AddTabPage("medium", SwLabPage::Create, nullptr); - AddTabPage("business", SwBusinessDataPage::Create, nullptr ); - AddTabPage("private", SwPrivateDataPage::Create, nullptr); - SetText(m_sBusinessCardDlg); - } // Read user label from writer.cfg SwLabItem aItem(static_cast<const SwLabItem&>(rSet.Get( FN_LABEL ))); std::unique_ptr<SwLabRec> pRec(new SwLabRec); @@ -159,18 +137,33 @@ SwLabDlg::SwLabDlg(vcl::Window* pParent, const SfxItemSet& rSet, if (m_pExampleSet) m_pExampleSet->Put(aItem); -} -SwLabDlg::~SwLabDlg() -{ - disposeOnce(); + AddTabPage("format", SwLabFormatPage::Create, nullptr); + AddTabPage("options", SwLabPrtPage::Create, nullptr); + m_sBusinessCardDlg = SwResId(STR_BUSINESS_CARDS); + + if (m_bLabel) + { + RemoveTabPage("business"); + RemoveTabPage("private"); + RemoveTabPage("medium"); + AddTabPage("labels", SwLabPage::Create, nullptr); + } + else + { + RemoveTabPage("labels"); + AddTabPage("medium", SwLabPage::Create, nullptr); + AddTabPage("business", SwBusinessDataPage::Create, nullptr ); + AddTabPage("private", SwPrivateDataPage::Create, nullptr); + m_xDialog->set_title(m_sBusinessCardDlg); + } + + pParent->set_busy_cursor(false); } -void SwLabDlg::dispose() +SwLabDlg::~SwLabDlg() { delete m_pRecs; - pPrtPage.clear(); - SfxTabDialog::dispose(); } void SwLabDlg::GetLabItem(SwLabItem &rItem) @@ -267,6 +260,9 @@ SwLabPage::SwLabPage(TabPageParent pParent, const SfxItemSet& rSet) m_xInsertBT->set_sensitive(false); m_xContButton->connect_toggled(LINK(this, SwLabPage, PageHdl)); m_xSheetButton->connect_toggled(LINK(this, SwLabPage, PageHdl)); + auto nMaxWidth = m_xMakeBox->get_approximate_digit_width() * 32; + m_xMakeBox->set_size_request(nMaxWidth, -1); + m_xTypeBox->set_size_request(nMaxWidth, -1); m_xMakeBox->connect_changed(LINK(this, SwLabPage, MakeHdl)); m_xTypeBox->connect_changed(LINK(this, SwLabPage, TypeHdl)); @@ -302,7 +298,7 @@ IMPL_LINK( SwLabPage, DatabaseHdl, weld::ComboBoxText&, rListBox, void ) { sActDBName = m_xDatabaseLB->get_active_text(); - WaitObject aObj( GetParentSwLabDlg() ); + weld::WaitObject aObj(GetParentSwLabDlg()->getDialog()); if (&rListBox == m_xDatabaseLB.get()) GetDBManager()->GetTableNames(*m_xTableLB, sActDBName); @@ -337,7 +333,7 @@ IMPL_LINK_NOARG(SwLabPage, PageHdl, weld::ToggleButton&, void) IMPL_LINK_NOARG(SwLabPage, MakeHdl, weld::ComboBoxText&, void) { - WaitObject aWait( GetParentSwLabDlg() ); + weld::WaitObject aWait(GetParentSwLabDlg()->getDialog()); m_xTypeBox->clear(); m_xHiddenSortTypeBox->clear(); @@ -595,7 +591,7 @@ DeactivateRC SwPrivateDataPage::DeactivatePage(SfxItemSet* _pSet) bool SwPrivateDataPage::FillItemSet(SfxItemSet* rSet) { - SwLabItem aItem = static_cast<const SwLabItem&>( GetTabDialog()->GetExampleSet()->Get(FN_LABEL) ); + SwLabItem aItem = static_cast<const SwLabItem&>(GetDialogController()->GetExampleSet()->Get(FN_LABEL)); aItem.m_aPrivFirstName = m_xFirstNameED->get_text(); aItem.m_aPrivName = m_xNameED->get_text(); aItem.m_aPrivShortCut = m_xShortCutED->get_text(); @@ -685,7 +681,7 @@ DeactivateRC SwBusinessDataPage::DeactivatePage(SfxItemSet* _pSet) bool SwBusinessDataPage::FillItemSet(SfxItemSet* rSet) { - SwLabItem aItem = static_cast<const SwLabItem&>( GetTabDialog()->GetExampleSet()->Get(FN_LABEL) ); + SwLabItem aItem = static_cast<const SwLabItem&>(GetDialogController()->GetExampleSet()->Get(FN_LABEL)); aItem.m_aCompCompany = m_xCompanyED->get_text(); aItem.m_aCompCompanyExt= m_xCompanyExtED->get_text(); diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx index 8c4d038aed5f..b016700362f0 100644 --- a/sw/source/ui/envelp/labfmt.cxx +++ b/sw/source/ui/envelp/labfmt.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <svtools/unitconv.hxx> #include <tools/poly.hxx> #include <vcl/weld.hxx> #include <vcl/settings.hxx> @@ -153,6 +154,7 @@ IMPL_LINK(SwLabPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) rRenderContext.SetFont(aFont); rRenderContext.SetBackground(Wallpaper(rWinColor)); + rRenderContext.Erase(); rRenderContext.SetLineColor(rWinColor); rRenderContext.SetFillColor(m_aGrayColor); @@ -301,14 +303,14 @@ SwLabFormatPage::SwLabFormatPage(TabPageParent pParent, const SfxItemSet& rSet) // Metrics FieldUnit aMetric = ::GetDfltMetric(false); - SetMetric(*m_xHDistField, aMetric); - SetMetric(*m_xVDistField , aMetric); - SetMetric(*m_xWidthField , aMetric); - SetMetric(*m_xHeightField, aMetric); - SetMetric(*m_xLeftField , aMetric); - SetMetric(*m_xUpperField , aMetric); - SetMetric(*m_xPWidthField , aMetric); - SetMetric(*m_xPHeightField, aMetric); + ::SetFieldUnit(*m_xHDistField, aMetric); + ::SetFieldUnit(*m_xVDistField , aMetric); + ::SetFieldUnit(*m_xWidthField , aMetric); + ::SetFieldUnit(*m_xHeightField, aMetric); + ::SetFieldUnit(*m_xLeftField , aMetric); + ::SetFieldUnit(*m_xUpperField , aMetric); + ::SetFieldUnit(*m_xPWidthField , aMetric); + ::SetFieldUnit(*m_xPHeightField, aMetric); // Install handlers Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwLabFormatPage, MetricModifyHdl); @@ -509,7 +511,7 @@ IMPL_LINK_NOARG(SwLabFormatPage, SaveHdl, weld::Button&, void) } SwSaveLabelDlg::SwSaveLabelDlg(SwLabDlg* pParent, SwLabRec& rRec) - : GenericDialogController(pParent->GetFrameWeld(), "modules/swriter/ui/savelabeldialog.ui", "SaveLabelDialog") + : GenericDialogController(pParent->getDialog(), "modules/swriter/ui/savelabeldialog.ui", "SaveLabelDialog") , bSuccess(false) , m_pLabDialog(pParent) , rLabRec(rRec) diff --git a/sw/source/ui/envelp/labfmt.hxx b/sw/source/ui/envelp/labfmt.hxx index 81e79351ce16..1be3737a1e0b 100644 --- a/sw/source/ui/envelp/labfmt.hxx +++ b/sw/source/ui/envelp/labfmt.hxx @@ -108,13 +108,13 @@ public: virtual bool FillItemSet(SfxItemSet* rSet) override; virtual void Reset(const SfxItemSet* rSet) override; - SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());} + SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());} }; class SwSaveLabelDlg : public weld::GenericDialogController { bool bSuccess; - VclPtr<SwLabDlg> m_pLabDialog; + SwLabDlg* m_pLabDialog; SwLabRec& rLabRec; std::unique_ptr<weld::ComboBoxText> m_xMakeCB; diff --git a/sw/source/ui/envelp/labprt.hxx b/sw/source/ui/envelp/labprt.hxx index d4dc36d0dfab..aecc2d7b8b64 100644 --- a/sw/source/ui/envelp/labprt.hxx +++ b/sw/source/ui/envelp/labprt.hxx @@ -44,7 +44,7 @@ class SwLabPrtPage : public SfxTabPage DECL_LINK( CountHdl, weld::Button&, void ); - SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());} + SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());} using TabPage::ActivatePage; using TabPage::DeactivatePage; diff --git a/sw/source/ui/envelp/swuilabimp.hxx b/sw/source/ui/envelp/swuilabimp.hxx index a2057557461e..8fe65957ee95 100644 --- a/sw/source/ui/envelp/swuilabimp.hxx +++ b/sw/source/ui/envelp/swuilabimp.hxx @@ -69,7 +69,7 @@ public: virtual bool FillItemSet(SfxItemSet* rSet) override; virtual void Reset(const SfxItemSet* rSet) override; - SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());} + SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());} void SetToBusinessCard(); diff --git a/sw/source/uibase/app/applab.cxx b/sw/source/uibase/app/applab.cxx index 6dfdd0168cf4..4379f6e7ea8b 100644 --- a/sw/source/uibase/app/applab.cxx +++ b/sw/source/uibase/app/applab.cxx @@ -169,7 +169,7 @@ void SwModule::InsertLab(SfxRequest& rReq, bool bLabel) SwAbstractDialogFactory* pDialogFactory = SwAbstractDialogFactory::Create(); OSL_ENSURE(pDialogFactory, "SwAbstractDialogFactory fail!"); - ScopedVclPtr<AbstractSwLabDlg> pDlg(pDialogFactory->CreateSwLabDlg(aSet, + ScopedVclPtr<AbstractSwLabDlg> pDlg(pDialogFactory->CreateSwLabDlg(rReq.GetFrameWeld(), aSet, #if HAVE_FEATURE_DBCONNECTIVITY pDBManager.get(), #else diff --git a/sw/source/uibase/inc/label.hxx b/sw/source/uibase/inc/label.hxx index cc2e77a1e9ec..fdb099cc24e6 100644 --- a/sw/source/uibase/inc/label.hxx +++ b/sw/source/uibase/inc/label.hxx @@ -29,7 +29,7 @@ class SwLabPrtPage; class SwDBManager; class Printer; -class SwLabDlg : public SfxTabDialog +class SwLabDlg : public SfxTabDialogController { SwLabelConfig aLabelsCfg; SwDBManager* pDBManager; @@ -42,17 +42,14 @@ class SwLabDlg : public SfxTabDialog OUString aLstGroup; OUString m_sBusinessCardDlg; bool m_bLabel; - sal_uInt16 m_nOptionsId; - sal_uInt16 m_nLabelId; void ReplaceGroup_( const OUString &rMake ); - virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) override; + virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; public: - SwLabDlg( vcl::Window* pParent, const SfxItemSet& rSet, - SwDBManager* pDBManager, bool bLabel); + SwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, + SwDBManager* pDBManager, bool bLabel); virtual ~SwLabDlg() override; - virtual void dispose() override; SwLabRec* GetRecord(const OUString &rRecName, bool bCont); void GetLabItem(SwLabItem &rItem); @@ -67,7 +64,12 @@ public: const std::vector<OUString> &Makes() const { return aMakes; } Printer *GetPrt(); - inline void ReplaceGroup( const OUString &rMake ); + void ReplaceGroup( const OUString &rMake ) + { + if ( rMake != aLstGroup ) + ReplaceGroup_( rMake ); + } + void UpdateGroup( const OUString &rMake ) {ReplaceGroup_( rMake );} static void UpdateFieldInformation(css::uno::Reference< css::frame::XModel> const & xModel, const SwLabItem& rItem); @@ -77,12 +79,6 @@ public: }; -inline void SwLabDlg::ReplaceGroup( const OUString &rMake ) -{ - if ( rMake != aLstGroup ) - ReplaceGroup_( rMake ); -} - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/uitool.hxx b/sw/source/uibase/inc/uitool.hxx index 51d3c9faa0f7..54f2268a7cfe 100644 --- a/sw/source/uibase/inc/uitool.hxx +++ b/sw/source/uibase/inc/uitool.hxx @@ -40,7 +40,6 @@ class SfxViewFrame; // switch a metric SW_DLLPUBLIC void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit); -SW_DLLPUBLIC void SetMetric(weld::MetricSpinButton& rCtrl, FieldUnit eUnit); // fill BoxInfo attribute SW_DLLPUBLIC void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh); diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index a29449286634..2bac72c751fc 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -96,14 +96,6 @@ void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit) rCtrl.SetMax(nMax, FUNIT_TWIP); } -void SetMetric(weld::MetricSpinButton& rCtrl, FieldUnit eUnit) -{ - int nMin, nMax; - rCtrl.get_range(nMin, nMax, FUNIT_TWIP); - rCtrl.set_unit(eUnit); - rCtrl.set_range(nMin, nMax, FUNIT_TWIP); -} - // Set boxinfo attribute void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh) diff --git a/sw/uiconfig/swriter/ui/businessdatapage.ui b/sw/uiconfig/swriter/ui/businessdatapage.ui index 2c2a6ad046c1..7b44940a69bf 100644 --- a/sw/uiconfig/swriter/ui/businessdatapage.ui +++ b/sw/uiconfig/swriter/ui/businessdatapage.ui @@ -1,10 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> <object class="GtkFrame" id="BusinessDataPage"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="border_width">6</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> diff --git a/sw/uiconfig/swriter/ui/cardmediumpage.ui b/sw/uiconfig/swriter/ui/cardmediumpage.ui index 6b916a804a0d..a530df0a83c1 100644 --- a/sw/uiconfig/swriter/ui/cardmediumpage.ui +++ b/sw/uiconfig/swriter/ui/cardmediumpage.ui @@ -2,7 +2,6 @@ <!-- Generated with glade 3.20.4 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="lower">1</property> <property name="upper">100</property> @@ -256,6 +255,7 @@ <property name="tooltip_text" translatable="yes" context="cardmediumpage|insert|tooltip_text">Insert</property> <property name="valign">center</property> <property name="image">image1</property> + <property name="always_show_image">True</property> </object> <packing> <property name="left_attach">1</property> @@ -394,7 +394,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="max_width_chars">32</property> + <property name="popup_fixed_width">False</property> </object> <packing> <property name="left_attach">1</property> @@ -406,7 +406,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="max_width_chars">32</property> + <property name="popup_fixed_width">False</property> </object> <packing> <property name="left_attach">1</property> diff --git a/sw/uiconfig/swriter/ui/labeldialog.ui b/sw/uiconfig/swriter/ui/labeldialog.ui index eb75eeb8ea79..4fbdff34a64c 100644 --- a/sw/uiconfig/swriter/ui/labeldialog.ui +++ b/sw/uiconfig/swriter/ui/labeldialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.20.4 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="LabelDialog"> @@ -7,6 +7,9 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="labeldialog|LabelDialog">Labels</property> <property name="resizable">False</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -97,6 +100,30 @@ <child> <placeholder/> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> </child> <child type="tab"> @@ -116,6 +143,30 @@ <child> <placeholder/> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="position">1</property> @@ -162,6 +213,30 @@ <child> <placeholder/> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="position">3</property> @@ -185,6 +260,30 @@ <child> <placeholder/> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="position">4</property> @@ -208,6 +307,30 @@ <child> <placeholder/> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="position">5</property> @@ -239,5 +362,8 @@ <action-widget response="-11">help</action-widget> <action-widget response="0">reset</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> diff --git a/sw/uiconfig/swriter/ui/labelformatpage.ui b/sw/uiconfig/swriter/ui/labelformatpage.ui index e3a9608dff30..59ce399f703c 100644 --- a/sw/uiconfig/swriter/ui/labelformatpage.ui +++ b/sw/uiconfig/swriter/ui/labelformatpage.ui @@ -2,7 +2,6 @@ <!-- Generated with glade 3.20.4 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="lower">1</property> <property name="upper">100</property> @@ -19,6 +18,8 @@ <object class="GtkBox" id="LabelFormatPage"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="border_width">6</property> <property name="spacing">12</property> <child> diff --git a/sw/uiconfig/swriter/ui/labeloptionspage.ui b/sw/uiconfig/swriter/ui/labeloptionspage.ui index c9e4d27fbb24..78acc7c82bad 100644 --- a/sw/uiconfig/swriter/ui/labeloptionspage.ui +++ b/sw/uiconfig/swriter/ui/labeloptionspage.ui @@ -18,6 +18,8 @@ <object class="GtkBox" id="LabelOptionsPage"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="border_width">6</property> <property name="orientation">vertical</property> <property name="spacing">12</property> @@ -25,6 +27,7 @@ <object class="GtkFrame" id="frame1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> diff --git a/sw/uiconfig/swriter/ui/privateuserpage.ui b/sw/uiconfig/swriter/ui/privateuserpage.ui index 7e4e551f4df7..20e26c4d56f1 100644 --- a/sw/uiconfig/swriter/ui/privateuserpage.ui +++ b/sw/uiconfig/swriter/ui/privateuserpage.ui @@ -1,10 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> <object class="GtkFrame" id="PrivateUserPage"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="border_width">6</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 6ec83d72d0d8..c2f4312aa371 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -810,11 +810,21 @@ public: m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(rIdent)); } + virtual void remove_page(const OString& rIdent) override + { + m_xNotebook->RemovePage(m_xNotebook->GetPageId(rIdent)); + } + virtual int get_n_pages() const override { return m_xNotebook->GetPageCount(); } + virtual OUString get_tab_label_text(const OString& rIdent) const override + { + return m_xNotebook->GetPageText(m_xNotebook->GetPageId(rIdent)); + } + virtual ~SalInstanceNotebook() override { m_xNotebook->SetActivatePageHdl(Link<TabControl*,void>()); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index a204143cf5f1..134dd540f973 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2453,6 +2453,18 @@ public: return gtk_notebook_get_n_pages(m_pNotebook); } + virtual OUString get_tab_label_text(const OString& rIdent) const override + { + gint nPage = get_page_number(rIdent); + const gchar* pStr = gtk_notebook_get_tab_label_text(m_pNotebook, gtk_notebook_get_nth_page(m_pNotebook, nPage)); + return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); + } + + virtual void remove_page(const OString& rIdent) override + { + gtk_notebook_remove_page(m_pNotebook, get_page_number(rIdent)); + } + virtual ~GtkInstanceNotebook() override { g_signal_handler_disconnect(m_pNotebook, m_nSignalId); |