diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-15 16:31:49 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-15 18:07:17 -0500 |
commit | 9210b95bcfd65ae558f445666d9b880e794d4c74 (patch) | |
tree | 5b2dcf170fd754ae457b7cf32d4e68dc563cbb5d /svtools | |
parent | 29206b09ca6bf2dfc5596b91fc80a0c1b62dcd6b (diff) |
Make GetParent() const-correct.
const method should return const pointer if it points to an object held
internally & prefer taking const pointer as a method argument if possible.
Change-Id: I4dc8c31d55aa0054ea6db521be9ad45fefef8d07
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/inc/svtools/treelist.hxx | 5 | ||||
-rw-r--r-- | svtools/inc/svtools/treelistbox.hxx | 3 | ||||
-rw-r--r-- | svtools/source/contnr/treelist.cxx | 14 | ||||
-rw-r--r-- | svtools/source/contnr/treelistbox.cxx | 5 |
4 files changed, 22 insertions, 5 deletions
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx index 467dda98a9e2..79fbc1b796e9 100644 --- a/svtools/inc/svtools/treelist.hxx +++ b/svtools/inc/svtools/treelist.hxx @@ -256,7 +256,10 @@ public: SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const; SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const; SvTreeListEntry* GetEntryAtAbsPos( sal_uLong nAbsPos ) const; - SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const; + + const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const; + SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ); + SvTreeListEntry* GetRootLevelParent( SvTreeListEntry* pEntry ) const; const SvTreeListEntries& GetChildList( SvTreeListEntry* pParent ) const; SvTreeListEntries& GetChildList( SvTreeListEntry* pParent ); diff --git a/svtools/inc/svtools/treelistbox.hxx b/svtools/inc/svtools/treelistbox.hxx index 8ec235de4408..a7e05d36fde5 100644 --- a/svtools/inc/svtools/treelistbox.hxx +++ b/svtools/inc/svtools/treelistbox.hxx @@ -399,7 +399,8 @@ public: void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const; using Window::GetParent; - SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const; + const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const; + SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const; SvTreeListEntry* GetRootLevelParent(SvTreeListEntry* pEntry ) const; using Window::GetChildCount; diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx index 675c01958291..ed278f1d2dfd 100644 --- a/svtools/source/contnr/treelist.cxx +++ b/svtools/source/contnr/treelist.cxx @@ -1855,11 +1855,19 @@ SvTreeListEntries& SvTreeList::GetChildList( SvTreeListEntry* pParent ) return pParent->maChildren; } -SvTreeListEntry* SvTreeList::GetParent( SvTreeListEntry* pEntry ) const +const SvTreeListEntry* SvTreeList::GetParent( const SvTreeListEntry* pEntry ) const +{ + const SvTreeListEntry* pParent = pEntry->pParent; + if (pParent == pRootItem) + pParent = NULL; + return pParent; +} + +SvTreeListEntry* SvTreeList::GetParent( SvTreeListEntry* pEntry ) { SvTreeListEntry* pParent = pEntry->pParent; - if ( pParent==pRootItem ) - pParent = 0; + if (pParent == pRootItem) + pParent = NULL; return pParent; } diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index 5cdff0c52401..167035b79416 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -938,6 +938,11 @@ void SvTreeListBox::FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_In } } +const SvTreeListEntry* SvTreeListBox::GetParent( const SvTreeListEntry* pEntry ) const +{ + return pModel->GetParent(pEntry); +} + SvTreeListEntry* SvTreeListBox::GetParent( SvTreeListEntry* pEntry ) const { return pModel->GetParent(pEntry); |