diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-04-30 10:25:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:19 +0100 |
commit | 0d7cbdbeac23b6a04b4b7b6e8fd39f2a99da0f41 (patch) | |
tree | c74fa047782a141306fcead918a486933fdfc7e1 | |
parent | 8f256819b14044afce7e8cf44fbecbe1cb8cb4cf (diff) |
just return a vector rather than pass one in by ref to be cleared
-rw-r--r-- | accessibility/source/standard/vclxaccessibleradiobutton.cxx | 5 | ||||
-rw-r--r-- | vcl/inc/vcl/button.hxx | 10 | ||||
-rw-r--r-- | vcl/source/control/button.cxx | 20 |
3 files changed, 17 insertions, 18 deletions
diff --git a/accessibility/source/standard/vclxaccessibleradiobutton.cxx b/accessibility/source/standard/vclxaccessibleradiobutton.cxx index 467bf5bd7d01..c821700a0a65 100644 --- a/accessibility/source/standard/vclxaccessibleradiobutton.cxx +++ b/accessibility/source/standard/vclxaccessibleradiobutton.cxx @@ -102,9 +102,8 @@ void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelati RadioButton* pRadioButton = dynamic_cast< RadioButton* >( GetWindow() ); if ( pRadioButton ) { - ::std::vector< RadioButton* > aGroup; - pRadioButton->GetRadioButtonGroup( aGroup, true ); - if ( !aGroup.empty() ) + ::std::vector< RadioButton* > aGroup(pRadioButton->GetRadioButtonGroup(true)); + if (!aGroup.empty()) { sal_Int32 i = 0; Sequence< Reference< XInterface > > aSequence( static_cast< sal_Int32 >( aGroup.size() ) ); diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx index d47abe219c5c..f7d05f41b0d4 100644 --- a/vcl/inc/vcl/button.hxx +++ b/vcl/inc/vcl/button.hxx @@ -393,14 +393,14 @@ public: or giving up the SolarMutex may mean events get executed that lead to the pointers getting invalid. - @param io_rGroup - gets cleared on entering the function. on return contains the <code>RadioButton</code>s - in the same group as this <code>RadioButton</code>. - @param bIncludeThis defines whether <code>this</code> is contained in the returned list + + @return + on return contains the <code>RadioButton</code>s + in the same group as this <code>RadioButton</code>. */ - void GetRadioButtonGroup( std::vector<RadioButton*>& io_rGroup, bool bIncludeThis ) const; + std::vector<RadioButton*> GetRadioButtonGroup(bool bIncludeThis = true) const; virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue); void group(RadioButton &rOther); diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 93b4065a3e5e..e49debd5e831 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -2316,25 +2316,24 @@ void RadioButton::group(RadioButton &rOther) // .----------------------------------------------------------------------- -void RadioButton::GetRadioButtonGroup( std::vector< RadioButton* >& io_rGroup, bool bIncludeThis ) const +std::vector< RadioButton* > RadioButton::GetRadioButtonGroup(bool bIncludeThis) const { - // empty the list - io_rGroup.clear(); + std::vector< RadioButton* > aGroup; if (m_xGroup) { for (std::set<RadioButton*>::iterator aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI) { RadioButton *pRadioButton = *aI; - if (pRadioButton == this) + if (!bIncludeThis && pRadioButton == this) continue; - io_rGroup.push_back(pRadioButton); + aGroup.push_back(pRadioButton); } - return; + return aGroup; } //old-school - SAL_WARN("vcl", "No group set on radiobutton"); + SAL_WARN("vcl", "No new-style group set on radiobutton, using old-style digging around"); // go back to first in group; Window* pFirst = const_cast<RadioButton*>(this); @@ -2352,10 +2351,12 @@ void RadioButton::GetRadioButtonGroup( std::vector< RadioButton* >& io_rGroup, b if( pFirst->GetType() == WINDOW_RADIOBUTTON ) { if( pFirst != this || bIncludeThis ) - io_rGroup.push_back( static_cast<RadioButton*>(pFirst) ); + aGroup.push_back( static_cast<RadioButton*>(pFirst) ); } pFirst = pFirst->GetWindow( WINDOW_NEXT ); } while( pFirst && ( ( pFirst->GetStyle() & WB_GROUP ) == 0 ) ); + + return aGroup; } // ----------------------------------------------------------------------- @@ -2364,8 +2365,7 @@ void RadioButton::ImplUncheckAllOther() { mpWindowImpl->mnStyle |= WB_TABSTOP; - std::vector<RadioButton*> aGroup; - GetRadioButtonGroup(aGroup, false); + std::vector<RadioButton*> aGroup(GetRadioButtonGroup(false)); // iterate over radio button group and checked buttons for (std::vector<RadioButton*>::iterator aI = aGroup.begin(), aEnd = aGroup.end(); aI != aEnd; ++aI) { |