[Libreoffice-commits] .: toolkit/inc toolkit/source
Joseph Powers
jpowers at kemper.freedesktop.org
Thu Feb 10 20:31:59 PST 2011
toolkit/inc/toolkit/controls/stdtabcontrollermodel.hxx | 18 +-
toolkit/source/controls/stdtabcontrollermodel.cxx | 108 ++++++++++-------
2 files changed, 78 insertions(+), 48 deletions(-)
New commits:
commit 79cd4bb9e39e0c8e80feb3503fd29b1dbb079841
Author: Joseph Powers <jpowers27 at cox.net>
Date: Thu Feb 10 20:26:00 2011 -0800
Remove DECLARE_LIST( UnoControlModelEntryListBase, UnoControlModelEntry* )
diff --git a/toolkit/inc/toolkit/controls/stdtabcontrollermodel.hxx b/toolkit/inc/toolkit/controls/stdtabcontrollermodel.hxx
index 17ea392..f486142 100644
--- a/toolkit/inc/toolkit/controls/stdtabcontrollermodel.hxx
+++ b/toolkit/inc/toolkit/controls/stdtabcontrollermodel.hxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* 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
@@ -43,14 +43,16 @@
#include <tools/list.hxx>
#include <tools/gen.hxx>
+#include <vector>
struct UnoControlModelEntry;
-DECLARE_LIST( UnoControlModelEntryListBase, UnoControlModelEntry* )
+typedef ::std::vector< UnoControlModelEntry* > UnoControlModelEntryListBase;
-class UnoControlModelEntryList : public UnoControlModelEntryListBase
+class UnoControlModelEntryList
{
private:
+ UnoControlModelEntryListBase maList;
::rtl::OUString maGroupName;
public:
@@ -61,7 +63,11 @@ public:
void SetName( const ::rtl::OUString& rName ) { maGroupName = rName; }
void Reset();
- void DestroyEntry( sal_uInt32 nEntry );
+ void DestroyEntry( size_t nEntry );
+ size_t size() const;
+ UnoControlModelEntry* operator[]( size_t i ) const;
+ void push_back( UnoControlModelEntry* item );
+ void insert( size_t i, UnoControlModelEntry* item );
};
struct UnoControlModelEntry
@@ -85,9 +91,9 @@ DECLARE_LIST( ComponentEntryList, ComponentEntry* )
#define CONTROLPOS_NOTFOUND 0xFFFFFFFF
-class StdTabControllerModel : public ::com::sun::star::awt::XTabControllerModel,
+class StdTabControllerModel : public ::com::sun::star::awt::XTabControllerModel,
public ::com::sun::star::lang::XServiceInfo,
- public ::com::sun::star::io::XPersistObject,
+ public ::com::sun::star::io::XPersistObject,
public ::com::sun::star::lang::XTypeProvider,
public ::cppu::OWeakAggObject
{
diff --git a/toolkit/source/controls/stdtabcontrollermodel.cxx b/toolkit/source/controls/stdtabcontrollermodel.cxx
index efa718f..132e303 100644
--- a/toolkit/source/controls/stdtabcontrollermodel.cxx
+++ b/toolkit/source/controls/stdtabcontrollermodel.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* 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
@@ -56,23 +56,47 @@ UnoControlModelEntryList::~UnoControlModelEntryList()
void UnoControlModelEntryList::Reset()
{
- for ( sal_uInt32 n = Count(); n; )
+ for ( size_t n = maList.size(); n; )
DestroyEntry( --n );
}
-void UnoControlModelEntryList::DestroyEntry( sal_uInt32 nEntry )
+void UnoControlModelEntryList::DestroyEntry( size_t nEntry )
{
- UnoControlModelEntry* pEntry = GetObject( nEntry );
+ UnoControlModelEntryListBase::iterator it = maList.begin();
+ ::std::advance( it, nEntry );
- if ( pEntry->bGroup )
- delete pEntry->pGroup;
+ if ( (*it)->bGroup )
+ delete (*it)->pGroup;
else
- delete pEntry->pxControl;
+ delete (*it)->pxControl;
+
+ delete *it;
+ maList.erase( it );
+}
- Remove( nEntry );
- delete pEntry;
+size_t UnoControlModelEntryList::size() const {
+ return maList.size();
}
+UnoControlModelEntry* UnoControlModelEntryList::operator[]( size_t i ) const {
+ return ( i < maList.size() ) ? maList[ i ] : NULL;
+}
+
+void UnoControlModelEntryList::push_back( UnoControlModelEntry* item ) {
+ maList.push_back( item );
+}
+
+void UnoControlModelEntryList::insert( size_t i, UnoControlModelEntry* item ) {
+ if ( i < maList.size() ) {
+ UnoControlModelEntryListBase::iterator it = maList.begin();
+ ::std::advance( it, i );
+ maList.insert( it, item );
+ } else {
+ maList.push_back( item );
+ }
+}
+
+
// ----------------------------------------------------
// class StdTabControllerModel
// ----------------------------------------------------
@@ -88,10 +112,10 @@ StdTabControllerModel::~StdTabControllerModel()
sal_uInt32 StdTabControllerModel::ImplGetControlCount( const UnoControlModelEntryList& rList ) const
{
sal_uInt32 nCount = 0;
- sal_uInt32 nEntries = rList.Count();
- for ( sal_uInt32 n = 0; n < nEntries; n++ )
+ size_t nEntries = rList.size();
+ for ( size_t n = 0; n < nEntries; n++ )
{
- UnoControlModelEntry* pEntry = rList.GetObject( n );
+ UnoControlModelEntry* pEntry = rList[ n ];
if ( pEntry->bGroup )
nCount += ImplGetControlCount( *pEntry->pGroup );
else
@@ -102,10 +126,10 @@ sal_uInt32 StdTabControllerModel::ImplGetControlCount( const UnoControlModelEntr
void StdTabControllerModel::ImplGetControlModels( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > ** ppRefs, const UnoControlModelEntryList& rList ) const
{
- sal_uInt32 nEntries = rList.Count();
- for ( sal_uInt32 n = 0; n < nEntries; n++ )
+ size_t nEntries = rList.size();
+ for ( size_t n = 0; n < nEntries; n++ )
{
- UnoControlModelEntry* pEntry = rList.GetObject( n );
+ UnoControlModelEntry* pEntry = rList[ n ];
if ( pEntry->bGroup )
ImplGetControlModels( ppRefs, *pEntry->pGroup );
else
@@ -126,15 +150,15 @@ void StdTabControllerModel::ImplSetControlModels( UnoControlModelEntryList& rLis
pNewEntry->bGroup = sal_False;
pNewEntry->pxControl = new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > ;
*pNewEntry->pxControl = pRefs[n];
- rList.Insert( pNewEntry, LIST_APPEND );
+ rList.push_back( pNewEntry );
}
}
sal_uInt32 StdTabControllerModel::ImplGetControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xCtrl, const UnoControlModelEntryList& rList ) const
{
- for ( sal_uInt32 n = rList.Count(); n; )
+ for ( size_t n = rList.size(); n; )
{
- UnoControlModelEntry* pEntry = rList.GetObject( --n );
+ UnoControlModelEntry* pEntry = rList[ --n ];
if ( !pEntry->bGroup && ( *pEntry->pxControl == xCtrl ) )
return n;
}
@@ -219,21 +243,21 @@ IMPL_XTYPEPROVIDER_END
sal_Bool StdTabControllerModel::getGroupControl( ) throw(::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
return mbGroupControl;
}
void StdTabControllerModel::setGroupControl( sal_Bool GroupControl ) throw(::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
mbGroupControl = GroupControl;
}
void StdTabControllerModel::setControlModels( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) throw(::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
maControls.Reset();
ImplSetControlModels( maControls, Controls );
}
@@ -241,7 +265,7 @@ void StdTabControllerModel::setControlModels( const ::com::sun::star::uno::Seque
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > StdTabControllerModel::getControlModels( ) throw(::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aSeq( ImplGetControlCount( maControls ) );
::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > * pRefs = aSeq.getArray();
ImplGetControlModels( &pRefs, maControls );
@@ -251,7 +275,7 @@ void StdTabControllerModel::setControlModels( const ::com::sun::star::uno::Seque
void StdTabControllerModel::setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, const ::rtl::OUString& GroupName ) throw(::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
// Die Controls stehen eventuel flach in der Liste und werden jetzt gruppiert.
// Verschachtelte Gruppen sind erstmal nicht moeglich...
// Das erste Element der Gruppe welches auch schon in der flachen Liste
@@ -264,10 +288,10 @@ void StdTabControllerModel::setGroup( const ::com::sun::star::uno::Sequence< ::c
ImplSetControlModels( *pNewEntry->pGroup, Group );
sal_Bool bInserted = sal_False;
- sal_uInt32 nElements = pNewEntry->pGroup->Count();
- for ( sal_uInt32 n = 0; n < nElements; n++ )
+ size_t nElements = pNewEntry->pGroup->size();
+ for ( size_t n = 0; n < nElements; n++ )
{
- UnoControlModelEntry* pEntry = pNewEntry->pGroup->GetObject( n );
+ UnoControlModelEntry* pEntry = (*pNewEntry->pGroup)[ n ];
if ( !pEntry->bGroup )
{
sal_uInt32 nPos = ImplGetControlPos( *pEntry->pxControl, maControls );
@@ -278,29 +302,29 @@ void StdTabControllerModel::setGroup( const ::com::sun::star::uno::Sequence< ::c
maControls.DestroyEntry( nPos );
if ( !bInserted )
{
- maControls.Insert( pNewEntry, nPos );
+ maControls.insert( nPos, pNewEntry );
bInserted = sal_True;
}
}
}
}
if ( !bInserted )
- maControls.Insert( pNewEntry, LIST_APPEND );
+ maControls.push_back( pNewEntry );
}
sal_Int32 StdTabControllerModel::getGroupCount( ) throw(::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
// erstmal nur eine Ebene...
// Das Model und die Impl-Methoden arbeiten zwar rekursiv, aber das wird
// erstmal nich nach aussen gegeben.
sal_Int32 nGroups = 0;
- sal_uInt32 nEntries = maControls.Count();
- for ( sal_uInt32 n = 0; n < nEntries; n++ )
+ size_t nEntries = maControls.size();
+ for ( size_t n = 0; n < nEntries; n++ )
{
- UnoControlModelEntry* pEntry = maControls.GetObject( n );
+ UnoControlModelEntry* pEntry = maControls[ n ];
if ( pEntry->bGroup )
nGroups++;
}
@@ -310,13 +334,13 @@ sal_Int32 StdTabControllerModel::getGroupCount( ) throw(::com::sun::star::uno::
void StdTabControllerModel::getGroup( sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& rGroup, ::rtl::OUString& rName ) throw(::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aSeq;
sal_uInt32 nG = 0;
- sal_uInt32 nEntries = maControls.Count();
- for ( sal_uInt32 n = 0; n < nEntries; n++ )
+ size_t nEntries = maControls.size();
+ for ( size_t n = 0; n < nEntries; n++ )
{
- UnoControlModelEntry* pEntry = maControls.GetObject( n );
+ UnoControlModelEntry* pEntry = maControls[ n ];
if ( pEntry->bGroup )
{
if ( nG == (sal_uInt32)nGroup )
@@ -337,12 +361,12 @@ void StdTabControllerModel::getGroup( sal_Int32 nGroup, ::com::sun::star::uno::S
void StdTabControllerModel::getGroupByName( const ::rtl::OUString& rName, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& rGroup ) throw(::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
sal_uInt32 nGroup = 0;
- sal_uInt32 nEntries = maControls.Count();
- for ( sal_uInt32 n = 0; n < nEntries; n++ )
+ size_t nEntries = maControls.size();
+ for ( size_t n = 0; n < nEntries; n++ )
{
- UnoControlModelEntry* pEntry = maControls.GetObject( n );
+ UnoControlModelEntry* pEntry = maControls[ n ];
if ( pEntry->bGroup )
{
if ( pEntry->pGroup->GetName() == rName )
@@ -366,7 +390,7 @@ void StdTabControllerModel::getGroupByName( const ::rtl::OUString& rName, ::com:
void StdTabControllerModel::write( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& OutStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
::com::sun::star::uno::Reference< ::com::sun::star::io::XMarkableStream > xMark( OutStream, ::com::sun::star::uno::UNO_QUERY );
DBG_ASSERT( xMark.is(), "write: no XMarkableStream!" );
@@ -390,7 +414,7 @@ void StdTabControllerModel::write( const ::com::sun::star::uno::Reference< ::com
void StdTabControllerModel::read( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& InStream ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
+
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > aSeq = ImplReadControls( InStream );
setControlModels( aSeq );
More information about the Libreoffice-commits
mailing list