summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2015-03-15 13:29:53 +0100
committerZolnai Tamás <zolnaitamas2000@gmail.com>2015-03-17 00:10:01 +0100
commitf7424ed710e54bb2437a28380b03ed7c26290edc (patch)
treeca44565d82433bf9c33fbeeeddce2bd5893c262c
parente3167924fd28c8b854f23139dbf49f53e6282ef7 (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
-rw-r--r--cui/source/dialogs/iconcdlg.cxx8
-rw-r--r--cui/source/inc/iconcdlg.hxx2
-rw-r--r--include/sfx2/styledlg.hxx2
-rw-r--r--include/sfx2/tabdlg.hxx4
-rw-r--r--sc/source/ui/inc/styledlg.hxx2
-rw-r--r--sc/source/ui/styleui/styledlg.cxx3
-rw-r--r--sd/source/ui/dlg/tabtempl.cxx4
-rw-r--r--sd/source/ui/inc/tabtempl.hxx2
-rw-r--r--sfx2/source/dialog/styledlg.cxx5
-rw-r--r--sfx2/source/dialog/tabdlg.cxx19
-rw-r--r--sw/source/ui/fmtui/tmpdlg.cxx3
-rw-r--r--sw/source/uibase/inc/tmpdlg.hxx2
12 files changed, 24 insertions, 32 deletions
diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx
index 45e8dcb06531..982ed6c1ca2a 100644
--- a/cui/source/dialogs/iconcdlg.cxx
+++ b/cui/source/dialogs/iconcdlg.cxx
@@ -547,8 +547,7 @@ bool IconChoiceDialog::DeActivatePageImpl ()
if ( nRet & IconChoicePage::REFRESH_SET )
{
- pSet = GetRefreshedSet();
- DBG_ASSERT( pSet, "GetRefreshedSet() liefert NULL" );
+ RefreshInputSet();
// flag all pages to be newly initialized
for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i )
{
@@ -723,10 +722,9 @@ void IconChoiceDialog::Start_Impl()
ActivatePageImpl();
}
-const SfxItemSet* IconChoiceDialog::GetRefreshedSet()
+void IconChoiceDialog::RefreshInputSet()
{
- SAL_WARN( "cui.dialogs", "GetRefreshedSet not implemented" );
- return 0;
+ SAL_WARN( "cui.dialogs", "RefreshInputSet not implemented" );
}
/**********************************************************************
diff --git a/cui/source/inc/iconcdlg.hxx b/cui/source/inc/iconcdlg.hxx
index 29317d3ecaf2..0c89da130c03 100644
--- a/cui/source/inc/iconcdlg.hxx
+++ b/cui/source/inc/iconcdlg.hxx
@@ -170,7 +170,7 @@ protected :
inline SfxItemSet* GetInputSetImpl() { return (SfxItemSet*)pSet; }
inline IconChoicePage* GetTabPage( sal_uInt16 nPageId )
{ return ( GetPageData (nPageId)->pPage?GetPageData (nPageId)->pPage:NULL); }
- const SfxItemSet* GetRefreshedSet();
+ void RefreshInputSet();
void ActivatePageImpl ();
bool DeActivatePageImpl ();
diff --git a/include/sfx2/styledlg.hxx b/include/sfx2/styledlg.hxx
index f3b0448a4c93..9e9bef903aeb 100644
--- a/include/sfx2/styledlg.hxx
+++ b/include/sfx2/styledlg.hxx
@@ -34,7 +34,7 @@ private:
DECL_DLLPRIVATE_LINK( CancelHdl, Button * );
sal_uInt16 m_nOrganizerId;
protected:
- virtual const SfxItemSet* GetRefreshedSet() SAL_OVERRIDE;
+ virtual void RefreshInputSet() SAL_OVERRIDE;
public:
SfxStyleDialog(vcl::Window* pParent, const OUString& rID,
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 252d728a79b5..2465321b3acd 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -81,7 +81,7 @@ friend class SfxTabDialogController;
bool m_bOwnsResetBtn;
bool m_bOwnsBaseFmtBtn;
- const SfxItemSet* pSet;
+ SfxItemSet* pSet;
SfxItemSet* pOutSet;
TabDlg_Impl* pImpl;
sal_uInt16* pRanges;
@@ -103,7 +103,7 @@ protected:
// Is deleted in Sfx!
virtual SfxItemSet* CreateInputItemSet( sal_uInt16 nId );
// Is not deleted in Sfx!
- virtual const SfxItemSet* GetRefreshedSet();
+ virtual void RefreshInputSet();
virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
VclButtonBox* m_pActionArea;
diff --git a/sc/source/ui/inc/styledlg.hxx b/sc/source/ui/inc/styledlg.hxx
index 04a70a1f7633..b91572c35772 100644
--- a/sc/source/ui/inc/styledlg.hxx
+++ b/sc/source/ui/inc/styledlg.hxx
@@ -33,7 +33,7 @@ public:
protected:
virtual void PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) SAL_OVERRIDE;
- virtual const SfxItemSet* GetRefreshedSet() SAL_OVERRIDE;
+ virtual void RefreshInputSet() SAL_OVERRIDE;
private:
sal_uInt16 nDlgRsc;
diff --git a/sc/source/ui/styleui/styledlg.cxx b/sc/source/ui/styleui/styledlg.cxx
index 1c1dc170b61d..fc72ca45d783 100644
--- a/sc/source/ui/styleui/styledlg.cxx
+++ b/sc/source/ui/styleui/styledlg.cxx
@@ -173,12 +173,11 @@ void ScStyleDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage )
}
}
-const SfxItemSet* ScStyleDlg::GetRefreshedSet()
+void ScStyleDlg::RefreshInputSet()
{
SfxItemSet* pItemSet = GetInputSetImpl();
pItemSet->ClearItem();
pItemSet->SetParent( GetStyleSheet().GetItemSet().GetParent() );
- return pItemSet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/dlg/tabtempl.cxx b/sd/source/ui/dlg/tabtempl.cxx
index 2c875ef0a784..a213c380cd10 100644
--- a/sd/source/ui/dlg/tabtempl.cxx
+++ b/sd/source/ui/dlg/tabtempl.cxx
@@ -172,7 +172,7 @@ void SdTabTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
}
}
-const SfxItemSet* SdTabTemplateDlg::GetRefreshedSet()
+void SdTabTemplateDlg::RefreshInputSet()
{
SfxItemSet* pRet = GetInputSetImpl();
@@ -183,8 +183,6 @@ const SfxItemSet* SdTabTemplateDlg::GetRefreshedSet()
}
else
pRet = new SfxItemSet( GetStyleSheet().GetItemSet() );
-
- return pRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/tabtempl.hxx b/sd/source/ui/inc/tabtempl.hxx
index ed57b580b0b1..636ae6bcbe75 100644
--- a/sd/source/ui/inc/tabtempl.hxx
+++ b/sd/source/ui/inc/tabtempl.hxx
@@ -66,7 +66,7 @@ private:
sal_uInt16 m_nAsianTypoId;
virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) SAL_OVERRIDE;
- virtual const SfxItemSet* GetRefreshedSet() SAL_OVERRIDE;
+ virtual void RefreshInputSet() SAL_OVERRIDE;
public:
SdTabTemplateDlg(vcl::Window* pParent,
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 )
{
diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx
index 4ac9c0f8fb19..0fef7a5499cb 100644
--- a/sw/source/ui/fmtui/tmpdlg.cxx
+++ b/sw/source/ui/fmtui/tmpdlg.cxx
@@ -363,12 +363,11 @@ short SwTemplateDlg::Ok()
return nRet;
}
-const SfxItemSet* SwTemplateDlg::GetRefreshedSet()
+void SwTemplateDlg::RefreshInputSet()
{
SfxItemSet* pInSet = GetInputSetImpl();
pInSet->ClearItem();
pInSet->SetParent( &GetStyleSheet().GetItemSet() );
- return pInSet;
}
void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
diff --git a/sw/source/uibase/inc/tmpdlg.hxx b/sw/source/uibase/inc/tmpdlg.hxx
index 75cab4201d6a..c92bde4fd143 100644
--- a/sw/source/uibase/inc/tmpdlg.hxx
+++ b/sw/source/uibase/inc/tmpdlg.hxx
@@ -78,7 +78,7 @@ public:
SwWrtShell* pActShell = 0,
bool bNew = false );
- const SfxItemSet* GetRefreshedSet() SAL_OVERRIDE;
+ virtual void RefreshInputSet() SAL_OVERRIDE;
virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) SAL_OVERRIDE;
virtual short Ok() SAL_OVERRIDE;