diff options
author | Michael Meeks <michael.meeks@novell.com> | 2011-09-12 11:26:35 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-09-12 12:47:12 +0200 |
commit | 731a562f54b9e39ca2b49160f4f463eb1f6b5dd7 (patch) | |
tree | cbadbba1aae2d12e235f7a7dfdb79285e074ebfb /cui | |
parent | 9f397368cce0b94f76d4f1d74150ccc75c498e8b (diff) |
start of embedding check-button & cui code cleanup
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/cuitabarea.hxx | 20 | ||||
-rw-r--r-- | cui/source/tabpages/tpcolor.cxx | 89 |
2 files changed, 85 insertions, 24 deletions
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index cafdc48bebff..a7ce897d3f06 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -641,9 +641,25 @@ public: virtual Window* GetParentLabeledBy( const Window* pLabeled ) const; }; +// Load save embed functionality +class SvxLoadSaveEmbed { + Window *pTopDlg; + CheckBox aBoxEmbed; + DECL_LINK( EmbedToggleHdl_Impl, void * ); +public: // FIXME: privatise these members ... + ImageButton aBtnLoad; + ImageButton aBtnSave; + SvxLoadSaveEmbed( Window *pParent, const ResId &aLoad, + const ResId &aSave, const ResId &aEmbed ); + XPropertyList *GetList(); + void HideLoadSaveEmbed(); + bool GetEmbed(); + void SetEmbed( bool bEmbed ); +}; + /************************************************************************/ -class SvxColorTabPage : public SfxTabPage +class SvxColorTabPage : public SfxTabPage, public SvxLoadSaveEmbed { using TabPage::ActivatePage; using TabPage::DeactivatePage; @@ -676,8 +692,6 @@ private: PushButton aBtnModify; PushButton aBtnWorkOn; PushButton aBtnDelete; - ImageButton aBtnLoad; - ImageButton aBtnSave; const SfxItemSet& rOutAttrs; diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 0a49fa99118c..89bc296c31b2 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -55,12 +55,6 @@ #define DLGWIN GetParentDialog( this ) -/************************************************************************* -|* -|* Dialog zum Aendern und Definieren der Farben -|* -\************************************************************************/ - static Window* GetParentDialog( Window* pWindow ) { while( pWindow ) @@ -74,6 +68,66 @@ static Window* GetParentDialog( Window* pWindow ) return pWindow; } +// Load save embed functionality +SvxLoadSaveEmbed::SvxLoadSaveEmbed( Window *pParent, const ResId &rLoad, + const ResId &rSave, const ResId &rEmbed ) + : pTopDlg( GetParentDialog( pParent ) ) + , aBoxEmbed( pParent, rEmbed ) + , aBtnLoad( pParent, rLoad ) + , aBtnSave( pParent, rSave ) +{ + aBoxEmbed.SetToggleHdl( LINK( this, SvxLoadSaveEmbed, EmbedToggleHdl_Impl ) ); + SetEmbed( GetEmbed() ); +} + +XPropertyList *SvxLoadSaveEmbed::GetList() +{ + SvxAreaTabDialog* pArea = dynamic_cast< SvxAreaTabDialog* >( pTopDlg ); + SvxLineTabDialog* pLine = dynamic_cast< SvxLineTabDialog* >( pTopDlg ); + + const XPropertyList *pList = NULL; + if( pArea ) + pList = pArea->GetNewColorTable(); + if( pLine ) + pList = pLine->GetNewColorTable(); + + if( !pList ) { + if( pArea ) + pList = pArea->GetColorTable(); + if( pLine ) + pList = pLine->GetColorTable(); + } + + return const_cast<XPropertyList *>(pList); +} + +void SvxLoadSaveEmbed::SetEmbed( bool bEmbed ) +{ + XPropertyList *pList = GetList(); + if( pList) + pList->SetEmbedInDocument( bEmbed ); + aBoxEmbed.Check( bEmbed ); +} + +bool SvxLoadSaveEmbed::GetEmbed() +{ + XPropertyList *pList = GetList(); + return pList ? pList->IsEmbedInDocument() : 0; +} + +IMPL_LINK( SvxLoadSaveEmbed, EmbedToggleHdl_Impl, void *, EMPTYARG ) +{ + SetEmbed( aBoxEmbed.IsChecked() ); + return 0; +} + +void SvxLoadSaveEmbed::HideLoadSaveEmbed() +{ + aBtnLoad.Hide(); + aBtnSave.Hide(); + aBoxEmbed.Hide(); +} + SvxColorTabPage::SvxColorTabPage ( Window* pParent, @@ -81,6 +135,8 @@ SvxColorTabPage::SvxColorTabPage ) : SfxTabPage ( pParent, CUI_RES( RID_SVXPAGE_COLOR ), rInAttrs ), + SvxLoadSaveEmbed ( this, CUI_RES( BTN_LOAD ), CUI_RES( BTN_SAVE ), + CUI_RES( BTN_EMBED ) ), aFlProp ( this, CUI_RES( FL_PROP ) ), aFtName ( this, CUI_RES( FT_NAME ) ), @@ -107,8 +163,6 @@ SvxColorTabPage::SvxColorTabPage aBtnModify ( this, CUI_RES( BTN_MODIFY ) ), aBtnWorkOn ( this, CUI_RES( BTN_WORK_ON ) ), aBtnDelete ( this, CUI_RES( BTN_DELETE ) ), - aBtnLoad ( this, CUI_RES( BTN_LOAD ) ), - aBtnSave ( this, CUI_RES( BTN_SAVE ) ), rOutAttrs ( rInAttrs ), pColorTab( NULL ), @@ -250,15 +304,7 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) } } else - { - // Buttons werden gehided, weil Paletten z.Z. nur - // ueber den AreaDlg funktionieren!!! - // ActivatePage() muss von anderen Dialogen explizit - // gerufen werden, da ActivatePage() nicht gerufen wird, - // wenn Seite als Erste im Dialog angezeigt wird - aBtnLoad.Hide(); - aBtnSave.Hide(); - } + HideLoadSaveEmbed(); } // ----------------------------------------------------------------------- @@ -761,19 +807,19 @@ IMPL_LINK( SvxColorTabPage, ClickLoadHdl_Impl, void *, EMPTYARG ) if( pColTab->Load() ) { // Pruefen, ob Tabelle geloescht werden darf: - const XColorList *pTempTable = 0; + const XColorList *pTempList = 0; SvxAreaTabDialog* pArea = dynamic_cast< SvxAreaTabDialog* >( DLGWIN ); SvxLineTabDialog* pLine = dynamic_cast< SvxLineTabDialog* >( DLGWIN ); if( pArea ) { - pTempTable = pArea->GetColorTable(); + pTempList = pArea->GetColorTable(); } else if( pLine ) { - pTempTable = pLine->GetColorTable(); + pTempList = pLine->GetColorTable(); } - if( pColorTab != pTempTable ) + if( pColorTab != pTempList ) { if( bDeleteColorTable ) delete pColorTab; @@ -825,6 +871,7 @@ IMPL_LINK( SvxColorTabPage, ClickLoadHdl_Impl, void *, EMPTYARG ) ChangeColorHdl_Impl( this ); SelectColorLBHdl_Impl( this ); + SetEmbed( true ); } else { |