Kaydet (Commit) f7424ed7 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

SfxTabDialog: avoid changing const input parameter

* SfxTabDialog constructor has a const pointer parameter
pointing  to the input set and also the corresponding member
is a const pointer which indicated that set is not changed by
the dialog, but this is not true, const is casted away and
the input set is changed.
* So use a copy of the input set instead, pointed by
a non-const member, so we can spare some const cast and
misunderstandings.
* GetRefreshedSet not behaves as a getter method, but changes
the input set instead, so redeclare it accordingly.

Change-Id: Ic63f9ae68c50e65d4498b20f597547c1c075b94e
üst e3167924
...@@ -547,8 +547,7 @@ bool IconChoiceDialog::DeActivatePageImpl () ...@@ -547,8 +547,7 @@ bool IconChoiceDialog::DeActivatePageImpl ()
if ( nRet & IconChoicePage::REFRESH_SET ) if ( nRet & IconChoicePage::REFRESH_SET )
{ {
pSet = GetRefreshedSet(); RefreshInputSet();
DBG_ASSERT( pSet, "GetRefreshedSet() liefert NULL" );
// flag all pages to be newly initialized // flag all pages to be newly initialized
for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i ) for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i )
{ {
...@@ -723,10 +722,9 @@ void IconChoiceDialog::Start_Impl() ...@@ -723,10 +722,9 @@ void IconChoiceDialog::Start_Impl()
ActivatePageImpl(); ActivatePageImpl();
} }
const SfxItemSet* IconChoiceDialog::GetRefreshedSet() void IconChoiceDialog::RefreshInputSet()
{ {
SAL_WARN( "cui.dialogs", "GetRefreshedSet not implemented" ); SAL_WARN( "cui.dialogs", "RefreshInputSet not implemented" );
return 0;
} }
/********************************************************************** /**********************************************************************
......
...@@ -170,7 +170,7 @@ protected : ...@@ -170,7 +170,7 @@ protected :
inline SfxItemSet* GetInputSetImpl() { return (SfxItemSet*)pSet; } inline SfxItemSet* GetInputSetImpl() { return (SfxItemSet*)pSet; }
inline IconChoicePage* GetTabPage( sal_uInt16 nPageId ) inline IconChoicePage* GetTabPage( sal_uInt16 nPageId )
{ return ( GetPageData (nPageId)->pPage?GetPageData (nPageId)->pPage:NULL); } { return ( GetPageData (nPageId)->pPage?GetPageData (nPageId)->pPage:NULL); }
const SfxItemSet* GetRefreshedSet(); void RefreshInputSet();
void ActivatePageImpl (); void ActivatePageImpl ();
bool DeActivatePageImpl (); bool DeActivatePageImpl ();
......
...@@ -34,7 +34,7 @@ private: ...@@ -34,7 +34,7 @@ private:
DECL_DLLPRIVATE_LINK( CancelHdl, Button * ); DECL_DLLPRIVATE_LINK( CancelHdl, Button * );
sal_uInt16 m_nOrganizerId; sal_uInt16 m_nOrganizerId;
protected: protected:
virtual const SfxItemSet* GetRefreshedSet() SAL_OVERRIDE; virtual void RefreshInputSet() SAL_OVERRIDE;
public: public:
SfxStyleDialog(vcl::Window* pParent, const OUString& rID, SfxStyleDialog(vcl::Window* pParent, const OUString& rID,
......
...@@ -81,7 +81,7 @@ friend class SfxTabDialogController; ...@@ -81,7 +81,7 @@ friend class SfxTabDialogController;
bool m_bOwnsResetBtn; bool m_bOwnsResetBtn;
bool m_bOwnsBaseFmtBtn; bool m_bOwnsBaseFmtBtn;
const SfxItemSet* pSet; SfxItemSet* pSet;
SfxItemSet* pOutSet; SfxItemSet* pOutSet;
TabDlg_Impl* pImpl; TabDlg_Impl* pImpl;
sal_uInt16* pRanges; sal_uInt16* pRanges;
...@@ -103,7 +103,7 @@ protected: ...@@ -103,7 +103,7 @@ protected:
// Is deleted in Sfx! // Is deleted in Sfx!
virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId ); virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId );
// Is not deleted in Sfx! // Is not deleted in Sfx!
virtual const SfxItemSet* GetRefreshedSet(); virtual void RefreshInputSet();
virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ); virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
VclButtonBox* m_pActionArea; VclButtonBox* m_pActionArea;
......
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
protected: protected:
virtual void PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) SAL_OVERRIDE; virtual void PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) SAL_OVERRIDE;
virtual const SfxItemSet* GetRefreshedSet() SAL_OVERRIDE; virtual void RefreshInputSet() SAL_OVERRIDE;
private: private:
sal_uInt16 nDlgRsc; sal_uInt16 nDlgRsc;
......
...@@ -173,12 +173,11 @@ void ScStyleDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) ...@@ -173,12 +173,11 @@ void ScStyleDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage )
} }
} }
const SfxItemSet* ScStyleDlg::GetRefreshedSet() void ScStyleDlg::RefreshInputSet()
{ {
SfxItemSet* pItemSet = GetInputSetImpl(); SfxItemSet* pItemSet = GetInputSetImpl();
pItemSet->ClearItem(); pItemSet->ClearItem();
pItemSet->SetParent( GetStyleSheet().GetItemSet().GetParent() ); pItemSet->SetParent( GetStyleSheet().GetItemSet().GetParent() );
return pItemSet;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -172,7 +172,7 @@ void SdTabTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) ...@@ -172,7 +172,7 @@ void SdTabTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
} }
} }
const SfxItemSet* SdTabTemplateDlg::GetRefreshedSet() void SdTabTemplateDlg::RefreshInputSet()
{ {
SfxItemSet* pRet = GetInputSetImpl(); SfxItemSet* pRet = GetInputSetImpl();
...@@ -183,8 +183,6 @@ const SfxItemSet* SdTabTemplateDlg::GetRefreshedSet() ...@@ -183,8 +183,6 @@ const SfxItemSet* SdTabTemplateDlg::GetRefreshedSet()
} }
else else
pRet = new SfxItemSet( GetStyleSheet().GetItemSet() ); pRet = new SfxItemSet( GetStyleSheet().GetItemSet() );
return pRet;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -66,7 +66,7 @@ private: ...@@ -66,7 +66,7 @@ private:
sal_uInt16 m_nAsianTypoId; sal_uInt16 m_nAsianTypoId;
virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) SAL_OVERRIDE; virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) SAL_OVERRIDE;
virtual const SfxItemSet* GetRefreshedSet() SAL_OVERRIDE; virtual void RefreshInputSet() SAL_OVERRIDE;
public: public:
SdTabTemplateDlg(vcl::Window* pParent, SdTabTemplateDlg(vcl::Window* pParent,
......
...@@ -81,12 +81,11 @@ SfxStyleDialog::~SfxStyleDialog() ...@@ -81,12 +81,11 @@ SfxStyleDialog::~SfxStyleDialog()
{ {
pExampleSet = 0; pExampleSet = 0;
pStyle = 0; pStyle = 0;
delete GetInputSetImpl();
} }
const SfxItemSet* SfxStyleDialog::GetRefreshedSet() void SfxStyleDialog::RefreshInputSet()
/* [Description] /* [Description]
...@@ -95,7 +94,7 @@ const SfxItemSet* SfxStyleDialog::GetRefreshedSet() ...@@ -95,7 +94,7 @@ const SfxItemSet* SfxStyleDialog::GetRefreshedSet()
*/ */
{ {
return GetInputSetImpl(); SfxTabDialog::RefreshInputSet();
} }
......
...@@ -318,7 +318,7 @@ SfxTabDialog::SfxTabDialog ...@@ -318,7 +318,7 @@ SfxTabDialog::SfxTabDialog
) )
: TabDialog(pParent, rID, rUIXMLDescription) : TabDialog(pParent, rID, rUIXMLDescription)
, pFrame(pViewFrame) , pFrame(pViewFrame)
, pSet(pItemSet) , pSet(pItemSet ? new SfxItemSet(*pItemSet) : 0)
, pOutSet(0) , pOutSet(0)
, pRanges(0) , pRanges(0)
, nAppPageId(USHRT_MAX) , nAppPageId(USHRT_MAX)
...@@ -347,7 +347,7 @@ SfxTabDialog::SfxTabDialog ...@@ -347,7 +347,7 @@ SfxTabDialog::SfxTabDialog
) )
: TabDialog(pParent, rID, rUIXMLDescription) : TabDialog(pParent, rID, rUIXMLDescription)
, pFrame(0) , pFrame(0)
, pSet(pItemSet) , pSet(pItemSet ? new SfxItemSet(*pItemSet) : 0)
, pOutSet(0) , pOutSet(0)
, pRanges(0) , pRanges(0)
, nAppPageId(USHRT_MAX) , nAppPageId(USHRT_MAX)
...@@ -397,6 +397,7 @@ SfxTabDialog::~SfxTabDialog() ...@@ -397,6 +397,7 @@ SfxTabDialog::~SfxTabDialog()
} }
delete pImpl; delete pImpl;
delete pSet;
delete pOutSet; delete pOutSet;
delete pExampleSet; delete pExampleSet;
delete [] pRanges; delete [] pRanges;
...@@ -735,7 +736,7 @@ SfxItemSet* SfxTabDialog::GetInputSetImpl() ...@@ -735,7 +736,7 @@ SfxItemSet* SfxTabDialog::GetInputSetImpl()
*/ */
{ {
return (SfxItemSet*)pSet; return pSet;
} }
...@@ -856,7 +857,7 @@ SfxItemSet* SfxTabDialog::CreateInputItemSet( sal_uInt16 ) ...@@ -856,7 +857,7 @@ SfxItemSet* SfxTabDialog::CreateInputItemSet( sal_uInt16 )
const SfxItemSet* SfxTabDialog::GetRefreshedSet() void SfxTabDialog::RefreshInputSet()
/* [Description] /* [Description]
...@@ -866,8 +867,7 @@ const SfxItemSet* SfxTabDialog::GetRefreshedSet() ...@@ -866,8 +867,7 @@ const SfxItemSet* SfxTabDialog::GetRefreshedSet()
*/ */
{ {
SAL_INFO ( "sfx.dialog", "GetRefreshedSet not implemented" ); SAL_INFO ( "sfx.dialog", "RefreshInputSet not implemented" );
return 0;
} }
...@@ -1240,8 +1240,7 @@ IMPL_LINK( SfxTabDialog, DeactivatePageHdl, TabControl *, pTabCtrl ) ...@@ -1240,8 +1240,7 @@ IMPL_LINK( SfxTabDialog, DeactivatePageHdl, TabControl *, pTabCtrl )
if ( nRet & SfxTabPage::REFRESH_SET ) if ( nRet & SfxTabPage::REFRESH_SET )
{ {
pSet = GetRefreshedSet(); RefreshInputSet();
DBG_ASSERT( pSet, "GetRefreshedSet() returns NULL" );
// Flag all Pages as to be initialized as new // Flag all Pages as to be initialized as new
for ( SfxTabDlgData_Impl::const_iterator it = pImpl->aData.begin(); it != pImpl->aData.end(); ++it ) for ( SfxTabDlgData_Impl::const_iterator it = pImpl->aData.begin(); it != pImpl->aData.end(); ++it )
...@@ -1353,8 +1352,8 @@ void SfxTabDialog::SetInputSet( const SfxItemSet* pInSet ) ...@@ -1353,8 +1352,8 @@ void SfxTabDialog::SetInputSet( const SfxItemSet* pInSet )
{ {
bool bSet = ( pSet != NULL ); bool bSet = ( pSet != NULL );
delete pSet;
pSet = pInSet; pSet = pInSet ? new SfxItemSet(*pInSet) : 0;
if ( !bSet && !pExampleSet && !pOutSet ) if ( !bSet && !pExampleSet && !pOutSet )
{ {
......
...@@ -363,12 +363,11 @@ short SwTemplateDlg::Ok() ...@@ -363,12 +363,11 @@ short SwTemplateDlg::Ok()
return nRet; return nRet;
} }
const SfxItemSet* SwTemplateDlg::GetRefreshedSet() void SwTemplateDlg::RefreshInputSet()
{ {
SfxItemSet* pInSet = GetInputSetImpl(); SfxItemSet* pInSet = GetInputSetImpl();
pInSet->ClearItem(); pInSet->ClearItem();
pInSet->SetParent( &GetStyleSheet().GetItemSet() ); pInSet->SetParent( &GetStyleSheet().GetItemSet() );
return pInSet;
} }
void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
SwWrtShell* pActShell = 0, SwWrtShell* pActShell = 0,
bool bNew = false ); bool bNew = false );
const SfxItemSet* GetRefreshedSet() SAL_OVERRIDE; virtual void RefreshInputSet() SAL_OVERRIDE;
virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) SAL_OVERRIDE; virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) SAL_OVERRIDE;
virtual short Ok() SAL_OVERRIDE; virtual short Ok() SAL_OVERRIDE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment