[Libreoffice-commits] .: svtools/inc svtools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Nov 15 15:07:35 PST 2012
svtools/inc/svtools/treelist.hxx | 5 ++++-
svtools/inc/svtools/treelistbox.hxx | 3 ++-
svtools/source/contnr/treelist.cxx | 14 +++++++++++---
svtools/source/contnr/treelistbox.cxx | 5 +++++
4 files changed, 22 insertions(+), 5 deletions(-)
New commits:
commit 9210b95bcfd65ae558f445666d9b880e794d4c74
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Nov 15 16:31:49 2012 -0500
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
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index 467dda9..79fbc1b 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 8ec235d..a7e05d3 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 675c019..ed278f1 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 5cdff0c..167035b 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);
More information about the Libreoffice-commits
mailing list