sc: loplugin:badstatics: remove pActiveEdWnd global variable
Just use a Link, or rather std::function to set a member in the tab page. Unfortunately loplugin:vclwidgets complains about the new member. Change-Id: Ie2f9cb73c38292d02057d43b12694c6609fa0db8
This commit is contained in:
@@ -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",
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user