diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2015-03-15 13:29:53 +0100 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2015-03-17 00:10:01 +0100 |
commit | f7424ed710e54bb2437a28380b03ed7c26290edc (patch) | |
tree | ca44565d82433bf9c33fbeeeddce2bd5893c262c /sfx2 | |
parent | e3167924fd28c8b854f23139dbf49f53e6282ef7 (diff) |
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
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/styledlg.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 19 |
2 files changed, 11 insertions, 13 deletions
diff --git a/sfx2/source/dialog/styledlg.cxx b/sfx2/source/dialog/styledlg.cxx index 99e9408e37fb..dc0d5f00d774 100644 --- a/sfx2/source/dialog/styledlg.cxx +++ b/sfx2/source/dialog/styledlg.cxx @@ -81,12 +81,11 @@ SfxStyleDialog::~SfxStyleDialog() { pExampleSet = 0; pStyle = 0; - delete GetInputSetImpl(); } -const SfxItemSet* SfxStyleDialog::GetRefreshedSet() +void SfxStyleDialog::RefreshInputSet() /* [Description] @@ -95,7 +94,7 @@ const SfxItemSet* SfxStyleDialog::GetRefreshedSet() */ { - return GetInputSetImpl(); + SfxTabDialog::RefreshInputSet(); } diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 2d5f88d60bf0..cdb6a1baeac7 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -318,7 +318,7 @@ SfxTabDialog::SfxTabDialog ) : TabDialog(pParent, rID, rUIXMLDescription) , pFrame(pViewFrame) - , pSet(pItemSet) + , pSet(pItemSet ? new SfxItemSet(*pItemSet) : 0) , pOutSet(0) , pRanges(0) , nAppPageId(USHRT_MAX) @@ -347,7 +347,7 @@ SfxTabDialog::SfxTabDialog ) : TabDialog(pParent, rID, rUIXMLDescription) , pFrame(0) - , pSet(pItemSet) + , pSet(pItemSet ? new SfxItemSet(*pItemSet) : 0) , pOutSet(0) , pRanges(0) , nAppPageId(USHRT_MAX) @@ -397,6 +397,7 @@ SfxTabDialog::~SfxTabDialog() } delete pImpl; + delete pSet; delete pOutSet; delete pExampleSet; delete [] pRanges; @@ -735,7 +736,7 @@ SfxItemSet* SfxTabDialog::GetInputSetImpl() */ { - return (SfxItemSet*)pSet; + return pSet; } @@ -856,7 +857,7 @@ SfxItemSet* SfxTabDialog::CreateInputItemSet( sal_uInt16 ) -const SfxItemSet* SfxTabDialog::GetRefreshedSet() +void SfxTabDialog::RefreshInputSet() /* [Description] @@ -866,8 +867,7 @@ const SfxItemSet* SfxTabDialog::GetRefreshedSet() */ { - SAL_INFO ( "sfx.dialog", "GetRefreshedSet not implemented" ); - return 0; + SAL_INFO ( "sfx.dialog", "RefreshInputSet not implemented" ); } @@ -1240,8 +1240,7 @@ IMPL_LINK( SfxTabDialog, DeactivatePageHdl, TabControl *, pTabCtrl ) if ( nRet & SfxTabPage::REFRESH_SET ) { - pSet = GetRefreshedSet(); - DBG_ASSERT( pSet, "GetRefreshedSet() returns NULL" ); + RefreshInputSet(); // Flag all Pages as to be initialized as new for ( SfxTabDlgData_Impl::const_iterator it = pImpl->aData.begin(); it != pImpl->aData.end(); ++it ) @@ -1353,8 +1352,8 @@ void SfxTabDialog::SetInputSet( const SfxItemSet* pInSet ) { bool bSet = ( pSet != NULL ); - - pSet = pInSet; + delete pSet; + pSet = pInSet ? new SfxItemSet(*pInSet) : 0; if ( !bSet && !pExampleSet && !pOutSet ) { |