summaryrefslogtreecommitdiff
path: root/svtools/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-10-15 18:30:16 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-10-19 11:45:36 +0200
commitd47508e036fd30f410798f37d25039bb25528f60 (patch)
tree132fb1a59c3f18b54bdce7f225152266d871b560 /svtools/source
parentdad00b3cab73575f027406ee0118c74d7fe8645b (diff)
Move SvListEntry and SvLBoxEntry into own files.
They will be merged later. Change-Id: I8529f9ee442fce10dc63e44d7cb26bdb2f3b8eb7
Diffstat (limited to 'svtools/source')
-rw-r--r--svtools/source/contnr/treelist.cxx62
-rw-r--r--svtools/source/contnr/treelistbox.cxx97
-rw-r--r--svtools/source/contnr/treelistentry.cxx196
3 files changed, 196 insertions, 159 deletions
diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx
index 0f930f552ed3..17f56c50a2a9 100644
--- a/svtools/source/contnr/treelist.cxx
+++ b/svtools/source/contnr/treelist.cxx
@@ -28,9 +28,6 @@
#include <svtools/treelist.hxx>
-DBG_NAME(SvListEntry);
-
-
SvTreeEntryList::SvTreeEntryList() {}
void SvTreeEntryList::push_back( SvListEntry* pItem )
@@ -158,65 +155,6 @@ SvTreeEntryList::SvTreeEntryList(const SvTreeEntryList& rList)
maEntryList.push_back(const_cast<SvListEntry*>(rList[i]));
}
-SvListEntry::SvListEntry()
-{
- DBG_CTOR(SvListEntry,0);
- pChildren = 0;
- pParent = 0;
- nListPos = 0;
- nAbsPos = 0;
-}
-
-SvListEntry::SvListEntry( const SvListEntry& rEntry )
-{
- DBG_CTOR(SvListEntry,0);
- pChildren = 0;
- pParent = 0;
- nListPos &= 0x80000000;
- nListPos |= ( rEntry.nListPos & 0x7fffffff);
- nAbsPos = rEntry.nAbsPos;
-}
-
-SvListEntry::~SvListEntry()
-{
- DBG_DTOR(SvListEntry,0);
- if ( pChildren )
- {
- pChildren->DestroyAll();
- delete pChildren;
- }
-#ifdef DBG_UTIL
- pChildren = 0;
- pParent = 0;
-#endif
-}
-
-void SvListEntry::Clone( SvListEntry* pSource)
-{
- DBG_CHKTHIS(SvListEntry,0);
- nListPos &= 0x80000000;
- nListPos |= ( pSource->nListPos & 0x7fffffff);
- nAbsPos = pSource->nAbsPos;
-}
-
-void SvListEntry::SetListPositions()
-{
- if( pChildren )
- {
- SvTreeEntryList::iterator it = pChildren->begin(), itEnd = pChildren->end();
- sal_uLong nCur = 0;
- for (; it != itEnd; ++it)
- {
- SvListEntry* pEntry = *it;
- pEntry->nListPos &= 0x80000000;
- pEntry->nListPos |= nCur;
- ++nCur;
- }
- }
- nListPos &= (~0x80000000);
-}
-
-
DBG_NAME(SvViewData);
SvViewData::SvViewData()
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 724f6517617e..a16efd6e9e4b 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -385,103 +385,6 @@ SvViewDataItem::~SvViewDataItem()
DBG_DTOR(SvViewDataItem,0);
}
-
-
-// ***************************************************************
-// class SvLBoxEntry
-// ***************************************************************
-
-DBG_NAME(SvLBoxEntry);
-
-SvLBoxEntry::SvLBoxEntry() : aItems()
-{
- DBG_CTOR(SvLBoxEntry,0);
- nEntryFlags = 0;
- pUserData = 0;
-}
-
-SvLBoxEntry::~SvLBoxEntry()
-{
- DBG_DTOR(SvLBoxEntry,0);
- DeleteItems_Impl();
-}
-
-void SvLBoxEntry::DeleteItems_Impl()
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- sal_uInt16 nCount = aItems.size();
- while( nCount )
- {
- nCount--;
- SvLBoxItem* pItem = aItems[ nCount ];
- delete pItem;
- }
- aItems.clear();
-}
-
-
-void SvLBoxEntry::AddItem( SvLBoxItem* pItem )
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- aItems.push_back( pItem );
-}
-
-void SvLBoxEntry::Clone( SvListEntry* pSource )
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- SvListEntry::Clone( pSource );
- SvLBoxItem* pNewItem;
- DeleteItems_Impl();
- sal_uInt16 nCount = ((SvLBoxEntry*)pSource)->ItemCount();
- sal_uInt16 nCurPos = 0;
- while( nCurPos < nCount )
- {
- SvLBoxItem* pItem = ((SvLBoxEntry*)pSource)->GetItem( nCurPos );
- pNewItem = pItem->Create();
- pNewItem->Clone( pItem );
- AddItem( pNewItem );
- nCurPos++;
- }
- pUserData = ((SvLBoxEntry*)pSource)->GetUserData();
- nEntryFlags = ((SvLBoxEntry*)pSource)->nEntryFlags;
-}
-
-void SvLBoxEntry::EnableChildrenOnDemand( sal_Bool bEnable )
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- if ( bEnable )
- nEntryFlags |= SV_ENTRYFLAG_CHILDREN_ON_DEMAND;
- else
- nEntryFlags &= (~SV_ENTRYFLAG_CHILDREN_ON_DEMAND);
-}
-
-void SvLBoxEntry::ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos )
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- DBG_ASSERT(pNewItem,"ReplaceItem:No Item");
- SvLBoxItem* pOld = GetItem( nPos );
- if ( pOld )
- {
- aItems[ nPos ] = pNewItem;
- delete pOld;
- }
-}
-
-SvLBoxItem* SvLBoxEntry::GetFirstItem( sal_uInt16 nId )
-{
- sal_uInt16 nCount = aItems.size();
- sal_uInt16 nCur = 0;
- SvLBoxItem* pItem;
- while( nCur < nCount )
- {
- pItem = GetItem( nCur );
- if( pItem->IsA() == nId )
- return pItem;
- nCur++;
- }
- return 0;
-}
-
SvLBoxEntry* SvLBoxTreeList::First() const
{
return (SvLBoxEntry*)SvTreeList::First();
diff --git a/svtools/source/contnr/treelistentry.cxx b/svtools/source/contnr/treelistentry.cxx
new file mode 100644
index 000000000000..cacc12d1980e
--- /dev/null
+++ b/svtools/source/contnr/treelistentry.cxx
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "svtools/treelistentry.hxx"
+#include "svtools/treelist.hxx"
+#include "svtools/treelistbox.hxx"
+
+#include "tools/debug.hxx"
+
+DBG_NAME(SvListEntry);
+
+SvListEntry::SvListEntry()
+{
+ DBG_CTOR(SvListEntry,0);
+ pChildren = 0;
+ pParent = 0;
+ nListPos = 0;
+ nAbsPos = 0;
+}
+
+SvListEntry::SvListEntry( const SvListEntry& rEntry )
+{
+ DBG_CTOR(SvListEntry,0);
+ pChildren = 0;
+ pParent = 0;
+ nListPos &= 0x80000000;
+ nListPos |= ( rEntry.nListPos & 0x7fffffff);
+ nAbsPos = rEntry.nAbsPos;
+}
+
+SvListEntry::~SvListEntry()
+{
+ DBG_DTOR(SvListEntry,0);
+ if ( pChildren )
+ {
+ pChildren->DestroyAll();
+ delete pChildren;
+ }
+#ifdef DBG_UTIL
+ pChildren = 0;
+ pParent = 0;
+#endif
+}
+
+void SvListEntry::Clone( SvListEntry* pSource)
+{
+ DBG_CHKTHIS(SvListEntry,0);
+ nListPos &= 0x80000000;
+ nListPos |= ( pSource->nListPos & 0x7fffffff);
+ nAbsPos = pSource->nAbsPos;
+}
+
+void SvListEntry::SetListPositions()
+{
+ if( pChildren )
+ {
+ SvTreeEntryList::iterator it = pChildren->begin(), itEnd = pChildren->end();
+ sal_uLong nCur = 0;
+ for (; it != itEnd; ++it)
+ {
+ SvListEntry* pEntry = *it;
+ pEntry->nListPos &= 0x80000000;
+ pEntry->nListPos |= nCur;
+ ++nCur;
+ }
+ }
+ nListPos &= (~0x80000000);
+}
+
+// ***************************************************************
+// class SvLBoxEntry
+// ***************************************************************
+
+DBG_NAME(SvLBoxEntry);
+
+SvLBoxEntry::SvLBoxEntry() : aItems()
+{
+ DBG_CTOR(SvLBoxEntry,0);
+ nEntryFlags = 0;
+ pUserData = 0;
+}
+
+SvLBoxEntry::~SvLBoxEntry()
+{
+ DBG_DTOR(SvLBoxEntry,0);
+ DeleteItems_Impl();
+}
+
+void SvLBoxEntry::DeleteItems_Impl()
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ sal_uInt16 nCount = aItems.size();
+ while( nCount )
+ {
+ nCount--;
+ SvLBoxItem* pItem = aItems[ nCount ];
+ delete pItem;
+ }
+ aItems.clear();
+}
+
+
+void SvLBoxEntry::AddItem( SvLBoxItem* pItem )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ aItems.push_back( pItem );
+}
+
+void SvLBoxEntry::Clone( SvListEntry* pSource )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ SvListEntry::Clone( pSource );
+ SvLBoxItem* pNewItem;
+ DeleteItems_Impl();
+ sal_uInt16 nCount = ((SvLBoxEntry*)pSource)->ItemCount();
+ sal_uInt16 nCurPos = 0;
+ while( nCurPos < nCount )
+ {
+ SvLBoxItem* pItem = ((SvLBoxEntry*)pSource)->GetItem( nCurPos );
+ pNewItem = pItem->Create();
+ pNewItem->Clone( pItem );
+ AddItem( pNewItem );
+ nCurPos++;
+ }
+ pUserData = ((SvLBoxEntry*)pSource)->GetUserData();
+ nEntryFlags = ((SvLBoxEntry*)pSource)->nEntryFlags;
+}
+
+void SvLBoxEntry::EnableChildrenOnDemand( sal_Bool bEnable )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ if ( bEnable )
+ nEntryFlags |= SV_ENTRYFLAG_CHILDREN_ON_DEMAND;
+ else
+ nEntryFlags &= (~SV_ENTRYFLAG_CHILDREN_ON_DEMAND);
+}
+
+void SvLBoxEntry::ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ DBG_ASSERT(pNewItem,"ReplaceItem:No Item");
+ SvLBoxItem* pOld = GetItem( nPos );
+ if ( pOld )
+ {
+ aItems[ nPos ] = pNewItem;
+ delete pOld;
+ }
+}
+
+SvLBoxItem* SvLBoxEntry::GetFirstItem( sal_uInt16 nId )
+{
+ sal_uInt16 nCount = aItems.size();
+ sal_uInt16 nCur = 0;
+ SvLBoxItem* pItem;
+ while( nCur < nCount )
+ {
+ pItem = GetItem( nCur );
+ if( pItem->IsA() == nId )
+ return pItem;
+ nCur++;
+ }
+ return 0;
+}
+
+sal_uInt16 SvLBoxEntry::GetPos( SvLBoxItem* pItem ) const
+{
+ std::vector<SvLBoxItem*>::const_iterator it = std::find( aItems.begin(), aItems.end(), pItem );
+ return it == aItems.end() ? USHRT_MAX : it - aItems.begin();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */