diff options
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/scuitphfedit.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/tphfedit.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/pagedlg/scuitphfedit.cxx | 36 | ||||
-rw-r--r-- | sc/source/ui/pagedlg/tphfedit.cxx | 11 |
5 files changed, 33 insertions, 26 deletions
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index 95dfabe3b914..90beed868914 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -299,7 +299,9 @@ bool VCLWidgets::VisitFieldDecl(const FieldDecl * fieldDecl) { const CXXRecordDecl *pParentRecordDecl = isa<RecordDecl>(fieldDecl->getDeclContext()) ? dyn_cast<CXXRecordDecl>(fieldDecl->getParent()) : nullptr; if (containsWindowSubclass(fieldDecl->getType())) { // have to ignore this for now, nasty reverse dependency from tools->vcl - if (!(pParentRecordDecl != nullptr && pParentRecordDecl->getQualifiedNameAsString() == "ErrorContextImpl")) { + if (!(pParentRecordDecl != nullptr && + (pParentRecordDecl->getQualifiedNameAsString() == "ErrorContextImpl" || + pParentRecordDecl->getQualifiedNameAsString() == "ScHFEditPage"))) { report( DiagnosticsEngine::Warning, "OutputDevice subclass %0 declared as a pointer member, should be wrapped in VclPtr", diff --git a/sc/source/ui/inc/scuitphfedit.hxx b/sc/source/ui/inc/scuitphfedit.hxx index fbdf7cd4183f..326f6b356661 100644 --- a/sc/source/ui/inc/scuitphfedit.hxx +++ b/sc/source/ui/inc/scuitphfedit.hxx @@ -82,6 +82,8 @@ private: VclPtr<FixedText> m_pFtCreatedBy; VclPtr<FixedText> m_pFtCustomized; + ScEditWindow * m_pEditFocus; ///one of m_pWndLeft, m_pWndCenter, m_pWndRight + sal_uInt16 nWhich; OUString aCmdArr[6]; @@ -99,7 +101,7 @@ private: static bool IsExtFileNameEntry(EditTextObject* pTextObj); DECL_LINK_TYPED( ListHdl_Impl, ListBox&, void); DECL_LINK_TYPED( ClickHdl, Button*, void ); - DECL_STATIC_LINK_TYPED( ScHFEditPage, MenuHdl, ScExtIButton&, void ); + DECL_LINK_TYPED( MenuHdl, ScExtIButton&, void ); }; class ScRightHeaderEditPage : public ScHFEditPage diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx index b362a02d255a..52024fda3998 100644 --- a/sc/source/ui/inc/tphfedit.hxx +++ b/sc/source/ui/inc/tphfedit.hxx @@ -33,6 +33,8 @@ #include <com/sun/star/accessibility/XAccessible.hpp> #include <cppuhelper/weakref.hxx> +#include <functional> + class ScHeaderEditEngine; class ScPatternAttr; class EditView; @@ -72,6 +74,7 @@ public: ScHeaderEditEngine* GetEditEngine() const { return pEdEngine; } void SetObjectSelectHdl( const Link<ScEditWindow&,void>& aLink) { aObjectSelectLink = aLink; } + void SetGetFocusHdl(const std::function<void (ScEditWindow&)>& rLink) { m_GetFocusLink = rLink; } void SetLocation(ScEditWindowLocation eLoc) { eLocation = eLoc; } protected: @@ -95,6 +98,7 @@ private: ScAccessibleEditObject* pAcc; Link<ScEditWindow&,void> aObjectSelectLink; + std::function<void (ScEditWindow&)> m_GetFocusLink; }; class SC_DLLPUBLIC ScExtIButton : public ImageButton diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx index 9f6f843f66ce..be28c1199bda 100644 --- a/sc/source/ui/pagedlg/scuitphfedit.cxx +++ b/sc/source/ui/pagedlg/scuitphfedit.cxx @@ -58,6 +58,7 @@ ScHFEditPage::ScHFEditPage( vcl::Window* pParent, sal_uInt16 nWhichId, bool bHeader ) : SfxTabPage( pParent, "HeaderFooterContent", "modules/scalc/ui/headerfootercontent.ui", &rCoreAttrs ) + , m_pEditFocus(nullptr) , nWhich( nWhichId ) { get(m_pWndLeft,"textviewWND_LEFT"); @@ -139,9 +140,14 @@ ScHFEditPage::ScHFEditPage( vcl::Window* pParent, m_pWndLeft->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) ); m_pWndCenter->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) ); m_pWndRight->SetObjectSelectHdl( LINK(this,ScHFEditPage,ObjectSelectHdl) ); + auto setEditFocus = [this](ScEditWindow & rEdit) { this->m_pEditFocus = &rEdit; }; + m_pWndLeft->SetGetFocusHdl(setEditFocus); + m_pWndCenter->SetGetFocusHdl(setEditFocus); + m_pWndRight->SetGetFocusHdl(setEditFocus); FillCmdArr(); m_pWndLeft->GrabFocus(); + m_pEditFocus = m_pWndLeft; // there's no event from GrabFocus() InitPreDefinedList(); @@ -791,39 +797,37 @@ IMPL_LINK_TYPED( ScHFEditPage, ListHdl_Impl, ListBox&, rList, void ) IMPL_LINK_TYPED( ScHFEditPage, ClickHdl, Button*, pBtn, void ) { - VclPtr<ScEditWindow> pActiveEdWnd = ::GetScEditWindow(); - if ( !pActiveEdWnd ) + if (!m_pEditFocus) return; if ( pBtn == m_pBtnText ) { - pActiveEdWnd->SetCharAttributes(); + m_pEditFocus->SetCharAttributes(); } else { if ( pBtn == m_pBtnPage ) - pActiveEdWnd->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) ); + m_pEditFocus->InsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD)); else if ( pBtn == m_pBtnLastPage ) - pActiveEdWnd->InsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD) ); + m_pEditFocus->InsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD)); else if ( pBtn == m_pBtnDate ) - pActiveEdWnd->InsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD) ); + m_pEditFocus->InsertField(SvxFieldItem(SvxDateField(Date(Date::SYSTEM),SVXDATETYPE_VAR), EE_FEATURE_FIELD)); else if ( pBtn == m_pBtnTime ) - pActiveEdWnd->InsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD) ); + m_pEditFocus->InsertField(SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD)); else if ( pBtn == m_pBtnFile ) { - pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ) ); + m_pEditFocus->InsertField(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD)); } else if ( pBtn == m_pBtnTable ) - pActiveEdWnd->InsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD) ); + m_pEditFocus->InsertField(SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD)); } InsertToDefinedList(); - pActiveEdWnd->GrabFocus(); + m_pEditFocus->GrabFocus(); } -IMPL_STATIC_LINK_TYPED( ScHFEditPage, MenuHdl, ScExtIButton&, rBtn, void ) +IMPL_LINK_TYPED( ScHFEditPage, MenuHdl, ScExtIButton&, rBtn, void ) { - VclPtr<ScEditWindow> pActiveEdWnd = ::GetScEditWindow(); - if ( !pActiveEdWnd ) + if (!m_pEditFocus) return; SAL_WARN_IF(rBtn.GetSelected() == 0, "sc.ui", "nothing selected"); @@ -831,16 +835,16 @@ IMPL_STATIC_LINK_TYPED( ScHFEditPage, MenuHdl, ScExtIButton&, rBtn, void ) if (sSelectedId == "title") { - pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ) ); + m_pEditFocus->InsertField(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD)); } else if (sSelectedId == "filename") { - pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField( + m_pEditFocus->InsertField( SvxFieldItem( SvxExtFileField( OUString(), SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT ), EE_FEATURE_FIELD ) ); } else if (sSelectedId == "pathname") { - pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField( + m_pEditFocus->InsertField( SvxFieldItem( SvxExtFileField( OUString(), SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ), EE_FEATURE_FIELD ) ); } } diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx index eab598cc2231..9a094d34d2d7 100644 --- a/sc/source/ui/pagedlg/tphfedit.cxx +++ b/sc/source/ui/pagedlg/tphfedit.cxx @@ -47,13 +47,6 @@ #include "scabstdlg.hxx" #include <memory> -// STATIC DATA ----------------------------------------------------------- -static VclPtr<ScEditWindow> g_pActiveEdWnd = nullptr; - -ScEditWindow* GetScEditWindow () -{ - return g_pActiveEdWnd; -} static void lcl_GetFieldData( ScHeaderFieldData& rData ) { @@ -283,7 +276,9 @@ void ScEditWindow::Command( const CommandEvent& rCEvt ) void ScEditWindow::GetFocus() { pEdView->ShowCursor(); - g_pActiveEdWnd = this; + + assert(m_GetFocusLink); + m_GetFocusLink(*this); css::uno::Reference< css::accessibility::XAccessible > xTemp = xAcc; if (xTemp.is() && pAcc) |