loplugin:mergeclasses SfxMacroTabPage

Change-Id: I74790c665fbd191914291365ce711fea9f1cf320
Reviewed-on: https://gerrit.libreoffice.org/26147
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin
2016-06-10 09:37:39 +02:00
committed by Noel Grandin
parent 8970f569f1
commit febeefc6c7
3 changed files with 56 additions and 68 deletions

View File

@@ -134,7 +134,6 @@ merge SdrPowerPointImport with ImplSdPPTImport
merge SdrSnapView with SdrMarkView merge SdrSnapView with SdrMarkView
merge SdwTextBoxRecord with SdwTextArt merge SdwTextBoxRecord with SdwTextArt
merge ServerFontLayoutEngine with HbLayoutEngine merge ServerFontLayoutEngine with HbLayoutEngine
merge SfxMacroTabPage_ with SfxMacroTabPage
merge SfxModelSubComponent with sfx2::DocumentUndoManager merge SfxModelSubComponent with sfx2::DocumentUndoManager
merge SfxMultiFixRecordWriter with SfxMultiVarRecordWriter merge SfxMultiFixRecordWriter with SfxMultiVarRecordWriter
merge SfxSingleRecordReader with SfxMultiRecordReader merge SfxSingleRecordReader with SfxMultiRecordReader

View File

@@ -32,7 +32,7 @@ class SvTabListBox;
class SvTreeListBox; class SvTreeListBox;
class SfxMacroTabPage_Impl; class SfxMacroTabPage_Impl;
class SfxMacroTabPage_ : public SfxTabPage class SfxMacroTabPage : public SfxTabPage
{ {
SvxMacroTableDtor aTbl; SvxMacroTableDtor aTbl;
DECL_DLLPRIVATE_LINK_TYPED( SelectEvent_Impl, SvTreeListBox*, void ); DECL_DLLPRIVATE_LINK_TYPED( SelectEvent_Impl, SvTreeListBox*, void );
@@ -45,9 +45,7 @@ class SfxMacroTabPage_ : public SfxTabPage
DECL_DLLPRIVATE_LINK_TYPED( TimeOut_Impl, Idle*, void ); DECL_DLLPRIVATE_LINK_TYPED( TimeOut_Impl, Idle*, void );
protected: protected:
SfxMacroTabPage_Impl* mpImpl; SfxMacroTabPage_Impl* mpImpl;
SfxMacroTabPage_( vcl::Window* pParent, const SfxItemSet& rItemSet );
void InitAndSetHandler(); void InitAndSetHandler();
void FillEvents(); void FillEvents();
@@ -55,8 +53,13 @@ protected:
void EnableButtons(); void EnableButtons();
public: public:
SfxMacroTabPage(
vcl::Window* pParent,
const css::uno::Reference< css::frame::XFrame >& rxDocumentFrame,
const SfxItemSet& rSet
);
virtual ~SfxMacroTabPage_(); virtual ~SfxMacroTabPage();
virtual void dispose() override; virtual void dispose() override;
void AddEvent( const OUString & rEventName, sal_uInt16 nEventId ); void AddEvent( const OUString & rEventName, sal_uInt16 nEventId );
@@ -72,16 +75,6 @@ public:
virtual void Reset( const SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override;
bool IsReadOnly() const override; bool IsReadOnly() const override;
};
class SfxMacroTabPage : public SfxMacroTabPage_
{
public:
SfxMacroTabPage(
vcl::Window* pParent,
const css::uno::Reference< css::frame::XFrame >& rxDocumentFrame,
const SfxItemSet& rSet
);
// --------- inherit from the base ------------- // --------- inherit from the base -------------
static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* rAttrSet ); static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* rAttrSet );

View File

@@ -117,7 +117,7 @@ OUString ConvertToUIName_Impl( SvxMacro *pMacro )
return aName; return aName;
} }
void SfxMacroTabPage_::EnableButtons() void SfxMacroTabPage::EnableButtons()
{ {
// don't do anything as long as the eventbox is empty // don't do anything as long as the eventbox is empty
const SvTreeListEntry* pE = mpImpl->pEventLB->GetListBox().FirstSelected(); const SvTreeListEntry* pE = mpImpl->pEventLB->GetListBox().FirstSelected();
@@ -136,24 +136,41 @@ void SfxMacroTabPage_::EnableButtons()
mpImpl->pAssignPB->Enable( false ); mpImpl->pAssignPB->Enable( false );
} }
SfxMacroTabPage_::SfxMacroTabPage_(vcl::Window* pParent, const SfxItemSet& rAttrSet) SfxMacroTabPage::SfxMacroTabPage(vcl::Window* pParent, const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rAttrSet )
: SfxTabPage(pParent, "EventAssignPage", "cui/ui/eventassignpage.ui", &rAttrSet) : SfxTabPage(pParent, "EventAssignPage", "cui/ui/eventassignpage.ui", &rAttrSet)
{ {
mpImpl = new SfxMacroTabPage_Impl; mpImpl = new SfxMacroTabPage_Impl;
mpImpl->sStrEvent = get<FixedText>("eventft")->GetText();
mpImpl->sAssignedMacro = get<FixedText>("assignft")->GetText();
get(mpImpl->pEventLB , "assignments");
get(mpImpl->pAssignPB, "assign");
get(mpImpl->pDeletePB, "delete");
get(mpImpl->pGroupFrame, "groupframe");
get(mpImpl->pGroupLB, "libraries");
get(mpImpl->pMacroFrame, "macroframe");
mpImpl->maStaticMacroLBLabel = mpImpl->pMacroFrame->get_label();
get(mpImpl->pMacroLB, "macros");
SetFrame( rxDocumentFrame );
InitAndSetHandler();
ScriptChanged();
} }
SfxMacroTabPage_::~SfxMacroTabPage_()
SfxMacroTabPage::~SfxMacroTabPage()
{ {
disposeOnce(); disposeOnce();
} }
void SfxMacroTabPage_::dispose() void SfxMacroTabPage::dispose()
{ {
DELETEZ( mpImpl ); DELETEZ( mpImpl );
SfxTabPage::dispose(); SfxTabPage::dispose();
} }
void SfxMacroTabPage_::AddEvent( const OUString & rEventName, sal_uInt16 nEventId ) void SfxMacroTabPage::AddEvent( const OUString & rEventName, sal_uInt16 nEventId )
{ {
OUString sTmp( rEventName ); OUString sTmp( rEventName );
sTmp += "\t"; sTmp += "\t";
@@ -170,7 +187,7 @@ void SfxMacroTabPage_::AddEvent( const OUString & rEventName, sal_uInt16 nEventI
pE->SetUserData( reinterpret_cast< void* >( sal::static_int_cast< sal_IntPtr >( nEventId )) ); pE->SetUserData( reinterpret_cast< void* >( sal::static_int_cast< sal_IntPtr >( nEventId )) );
} }
void SfxMacroTabPage_::ScriptChanged() void SfxMacroTabPage::ScriptChanged()
{ {
// get new areas and their functions // get new areas and their functions
mpImpl->pGroupFrame->Show(); mpImpl->pGroupFrame->Show();
@@ -179,7 +196,7 @@ void SfxMacroTabPage_::ScriptChanged()
EnableButtons(); EnableButtons();
} }
bool SfxMacroTabPage_::FillItemSet( SfxItemSet* rSet ) bool SfxMacroTabPage::FillItemSet( SfxItemSet* rSet )
{ {
SvxMacroItem aItem( GetWhich( aPageRg[0] ) ); SvxMacroItem aItem( GetWhich( aPageRg[0] ) );
((SvxMacroTableDtor&)aItem.GetMacroTable()) = aTbl; ((SvxMacroTableDtor&)aItem.GetMacroTable()) = aTbl;
@@ -194,17 +211,17 @@ bool SfxMacroTabPage_::FillItemSet( SfxItemSet* rSet )
return false; return false;
} }
void SfxMacroTabPage_::LaunchFillGroup() void SfxMacroTabPage::LaunchFillGroup()
{ {
if (!mpImpl->maFillGroupIdle.GetIdleHdl().IsSet()) if (!mpImpl->maFillGroupIdle.GetIdleHdl().IsSet())
{ {
mpImpl->maFillGroupIdle.SetIdleHdl( LINK( this, SfxMacroTabPage_, TimeOut_Impl ) ); mpImpl->maFillGroupIdle.SetIdleHdl( LINK( this, SfxMacroTabPage, TimeOut_Impl ) );
mpImpl->maFillGroupIdle.SetPriority( SchedulerPriority::HIGHEST ); mpImpl->maFillGroupIdle.SetPriority( SchedulerPriority::HIGHEST );
mpImpl->maFillGroupIdle.Start(); mpImpl->maFillGroupIdle.Start();
} }
} }
void SfxMacroTabPage_::ActivatePage( const SfxItemSet& ) void SfxMacroTabPage::ActivatePage( const SfxItemSet& )
{ {
// fdo#57553 lazily init script providers, because it is annoying if done // fdo#57553 lazily init script providers, because it is annoying if done
// on dialog open (SfxTabDialog::Start_Impl activates all tab pages once!) // on dialog open (SfxTabDialog::Start_Impl activates all tab pages once!)
@@ -216,7 +233,7 @@ void SfxMacroTabPage_::ActivatePage( const SfxItemSet& )
LaunchFillGroup(); LaunchFillGroup();
} }
void SfxMacroTabPage_::PageCreated(const SfxAllItemSet& aSet) void SfxMacroTabPage::PageCreated(const SfxAllItemSet& aSet)
{ {
const SfxPoolItem* pEventsItem; const SfxPoolItem* pEventsItem;
if( !mpImpl->bGotEvents && SfxItemState::SET == aSet.GetItemState( SID_EVENTCONFIG, true, &pEventsItem ) ) if( !mpImpl->bGotEvents && SfxItemState::SET == aSet.GetItemState( SID_EVENTCONFIG, true, &pEventsItem ) )
@@ -231,7 +248,7 @@ void SfxMacroTabPage_::PageCreated(const SfxAllItemSet& aSet)
} }
} }
void SfxMacroTabPage_::Reset( const SfxItemSet* rSet ) void SfxMacroTabPage::Reset( const SfxItemSet* rSet )
{ {
const SfxPoolItem* pItem; const SfxPoolItem* pItem;
if( SfxItemState::SET == rSet->GetItemState( GetWhich( aPageRg[0] ), true, &pItem )) if( SfxItemState::SET == rSet->GetItemState( GetWhich( aPageRg[0] ), true, &pItem ))
@@ -257,12 +274,12 @@ void SfxMacroTabPage_::Reset( const SfxItemSet* rSet )
rListBox.SetCurEntry( pE ); rListBox.SetCurEntry( pE );
} }
bool SfxMacroTabPage_::IsReadOnly() const bool SfxMacroTabPage::IsReadOnly() const
{ {
return mpImpl->bReadOnly; return mpImpl->bReadOnly;
} }
IMPL_LINK_NOARG_TYPED( SfxMacroTabPage_, SelectEvent_Impl, SvTreeListBox*, void) IMPL_LINK_NOARG_TYPED( SfxMacroTabPage, SelectEvent_Impl, SvTreeListBox*, void)
{ {
SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
SvTreeListEntry* pE = rListBox.FirstSelected(); SvTreeListEntry* pE = rListBox.FirstSelected();
@@ -278,7 +295,7 @@ IMPL_LINK_NOARG_TYPED( SfxMacroTabPage_, SelectEvent_Impl, SvTreeListBox*, void)
EnableButtons(); EnableButtons();
} }
IMPL_LINK_NOARG_TYPED( SfxMacroTabPage_, SelectGroup_Impl, SvTreeListBox*, void) IMPL_LINK_NOARG_TYPED( SfxMacroTabPage, SelectGroup_Impl, SvTreeListBox*, void)
{ {
mpImpl->pGroupLB->GroupSelected(); mpImpl->pGroupLB->GroupSelected();
const OUString sScriptURI = mpImpl->pMacroLB->GetSelectedScriptURI(); const OUString sScriptURI = mpImpl->pMacroLB->GetSelectedScriptURI();
@@ -290,22 +307,22 @@ IMPL_LINK_NOARG_TYPED( SfxMacroTabPage_, SelectGroup_Impl, SvTreeListBox*, void)
EnableButtons(); EnableButtons();
} }
IMPL_LINK_NOARG_TYPED( SfxMacroTabPage_, SelectMacro_Impl, SvTreeListBox*, void) IMPL_LINK_NOARG_TYPED( SfxMacroTabPage, SelectMacro_Impl, SvTreeListBox*, void)
{ {
EnableButtons(); EnableButtons();
} }
IMPL_LINK_TYPED( SfxMacroTabPage_, AssignDeleteClickHdl_Impl, Button*, pBtn, void ) IMPL_LINK_TYPED( SfxMacroTabPage, AssignDeleteClickHdl_Impl, Button*, pBtn, void )
{ {
AssignDeleteHdl(pBtn); AssignDeleteHdl(pBtn);
} }
IMPL_LINK_TYPED( SfxMacroTabPage_, AssignDeleteHdl_Impl, SvTreeListBox*, pBtn, bool ) IMPL_LINK_TYPED( SfxMacroTabPage, AssignDeleteHdl_Impl, SvTreeListBox*, pBtn, bool )
{ {
return AssignDeleteHdl(pBtn); return AssignDeleteHdl(pBtn);
} }
bool SfxMacroTabPage_::AssignDeleteHdl(Control* pBtn) bool SfxMacroTabPage::AssignDeleteHdl(Control* pBtn)
{ {
SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
SvTreeListEntry* pE = rListBox.FirstSelected(); SvTreeListEntry* pE = rListBox.FirstSelected();
@@ -334,7 +351,7 @@ bool SfxMacroTabPage_::AssignDeleteHdl(Control* pBtn)
} }
else else
{ {
OSL_ENSURE( false, "SfxMacroTabPage_::AssignDeleteHdl_Impl: this branch is *not* dead? (out of interest: tell fs, please!)" ); OSL_ENSURE( false, "SfxMacroTabPage::AssignDeleteHdl_Impl: this branch is *not* dead? (out of interest: tell fs, please!)" );
aTbl.Insert( aTbl.Insert(
nEvent, SvxMacro( sScriptURI, OUString( SVX_MACRO_LANGUAGE_STARBASIC ) ) ); nEvent, SvxMacro( sScriptURI, OUString( SVX_MACRO_LANGUAGE_STARBASIC ) ) );
} }
@@ -351,7 +368,7 @@ bool SfxMacroTabPage_::AssignDeleteHdl(Control* pBtn)
return false; return false;
} }
IMPL_LINK_TYPED( SfxMacroTabPage_, TimeOut_Impl, Idle*,, void ) IMPL_LINK_TYPED( SfxMacroTabPage, TimeOut_Impl, Idle*,, void )
{ {
// FillMacroList() can take a long time -> show wait cursor and disable input // FillMacroList() can take a long time -> show wait cursor and disable input
SfxTabDialog* pTabDlg = GetTabDialog(); SfxTabDialog* pTabDlg = GetTabDialog();
@@ -369,19 +386,19 @@ IMPL_LINK_TYPED( SfxMacroTabPage_, TimeOut_Impl, Idle*,, void )
} }
} }
void SfxMacroTabPage_::InitAndSetHandler() void SfxMacroTabPage::InitAndSetHandler()
{ {
SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
HeaderBar& rHeaderBar = mpImpl->pEventLB->GetHeaderBar(); HeaderBar& rHeaderBar = mpImpl->pEventLB->GetHeaderBar();
Link<SvTreeListBox*,bool> aLnk(LINK(this, SfxMacroTabPage_, AssignDeleteHdl_Impl )); Link<SvTreeListBox*,bool> aLnk(LINK(this, SfxMacroTabPage, AssignDeleteHdl_Impl ));
mpImpl->pMacroLB->SetDoubleClickHdl( aLnk ); mpImpl->pMacroLB->SetDoubleClickHdl( aLnk );
mpImpl->pDeletePB->SetClickHdl( LINK(this, SfxMacroTabPage_, AssignDeleteClickHdl_Impl ) ); mpImpl->pDeletePB->SetClickHdl( LINK(this, SfxMacroTabPage, AssignDeleteClickHdl_Impl ) );
mpImpl->pAssignPB->SetClickHdl( LINK(this, SfxMacroTabPage_, AssignDeleteClickHdl_Impl ) ); mpImpl->pAssignPB->SetClickHdl( LINK(this, SfxMacroTabPage, AssignDeleteClickHdl_Impl ) );
rListBox.SetDoubleClickHdl( aLnk ); rListBox.SetDoubleClickHdl( aLnk );
rListBox.SetSelectHdl( LINK( this, SfxMacroTabPage_, SelectEvent_Impl )); rListBox.SetSelectHdl( LINK( this, SfxMacroTabPage, SelectEvent_Impl ));
mpImpl->pGroupLB->SetSelectHdl( LINK( this, SfxMacroTabPage_, SelectGroup_Impl )); mpImpl->pGroupLB->SetSelectHdl( LINK( this, SfxMacroTabPage, SelectGroup_Impl ));
mpImpl->pMacroLB->SetSelectHdl( LINK( this, SfxMacroTabPage_, SelectMacro_Impl )); mpImpl->pMacroLB->SetSelectHdl( LINK( this, SfxMacroTabPage, SelectMacro_Impl ));
rListBox.SetSelectionMode( SelectionMode::Single ); rListBox.SetSelectionMode( SelectionMode::Single );
rListBox.SetTabs( &nTabs[0] ); rListBox.SetTabs( &nTabs[0] );
@@ -402,7 +419,7 @@ void SfxMacroTabPage_::InitAndSetHandler()
} }
void SfxMacroTabPage_::FillMacroList() void SfxMacroTabPage::FillMacroList()
{ {
mpImpl->pGroupLB->Init( mpImpl->pGroupLB->Init(
css::uno::Reference< css::uno::Reference<
@@ -411,7 +428,7 @@ void SfxMacroTabPage_::FillMacroList()
OUString(), false); OUString(), false);
} }
void SfxMacroTabPage_::FillEvents() void SfxMacroTabPage::FillEvents()
{ {
SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox(); SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
@@ -424,7 +441,7 @@ void SfxMacroTabPage_::FillEvents()
if( pE ) if( pE )
{ {
SvLBoxString& rLItem = static_cast<SvLBoxString&>( pE->GetItem( LB_MACROS_ITEMPOS ) ); SvLBoxString& rLItem = static_cast<SvLBoxString&>( pE->GetItem( LB_MACROS_ITEMPOS ) );
DBG_ASSERT( SV_ITEM_ID_LBOXSTRING == rLItem.GetType(), "SfxMacroTabPage_::FillEvents(): no LBoxString" ); DBG_ASSERT( SV_ITEM_ID_LBOXSTRING == rLItem.GetType(), "SfxMacroTabPage::FillEvents(): no LBoxString" );
OUString sOld( rLItem.GetText() ); OUString sOld( rLItem.GetText() );
OUString sNew; OUString sNew;
@@ -441,27 +458,6 @@ void SfxMacroTabPage_::FillEvents()
} }
} }
SfxMacroTabPage::SfxMacroTabPage(vcl::Window* pParent, const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rSet )
: SfxMacroTabPage_( pParent, rSet )
{
mpImpl->sStrEvent = get<FixedText>("eventft")->GetText();
mpImpl->sAssignedMacro = get<FixedText>("assignft")->GetText();
get(mpImpl->pEventLB , "assignments");
get(mpImpl->pAssignPB, "assign");
get(mpImpl->pDeletePB, "delete");
get(mpImpl->pGroupFrame, "groupframe");
get(mpImpl->pGroupLB, "libraries");
get(mpImpl->pMacroFrame, "macroframe");
mpImpl->maStaticMacroLBLabel = mpImpl->pMacroFrame->get_label();
get(mpImpl->pMacroLB, "macros");
SetFrame( rxDocumentFrame );
InitAndSetHandler();
ScriptChanged();
}
namespace namespace
{ {
VclPtr<SfxMacroTabPage> CreateSfxMacroTabPage( vcl::Window* pParent, const SfxItemSet& rAttrSet ) VclPtr<SfxMacroTabPage> CreateSfxMacroTabPage( vcl::Window* pParent, const SfxItemSet& rAttrSet )