diff options
author | Thorsten Behrens <thb@openoffice.org> | 2002-03-12 09:33:43 +0000 |
---|---|---|
committer | Thorsten Behrens <thb@openoffice.org> | 2002-03-12 09:33:43 +0000 |
commit | 5a2659dbc63d12f8974bd192504dc34867d2282a (patch) | |
tree | 21e69b0200f7b3ff9ac27494fee58a985e5670fe /svx/source/svdraw | |
parent | e1d55a7bac8d0cee33578276f5bd542ef7ba41aa (diff) |
#96270# Added ungroup functionality
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r-- | svx/source/svdraw/svdpage.cxx | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index af36a80a6173..c348634b1c7b 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -2,9 +2,9 @@ * * $RCSfile: svdpage.cxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: cl $ $Date: 2002-02-25 15:46:54 $ + * last change: $Author: thb $ $Date: 2002-03-12 10:33:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,6 +104,7 @@ #include "svdlayer.hxx" #include "svdotext.hxx" #include "svdpagv.hxx" +#include "svdundo.hxx" #include "fmglob.hxx" #include "polysc3d.hxx" @@ -1266,6 +1267,53 @@ void SdrObjList::AfterRead() } } +void SdrObjList::FlattenGroups() +{ + sal_Int32 nObj = GetObjCount(); + sal_Int32 i; + for( i=nObj-1; i>=0; --i) + UnGroupObj(i); +} + +void SdrObjList::UnGroupObj( ULONG nObjNum ) +{ + // if the given object is no group, this method is a noop + SdrObject* pUngroupObj = GetObj( nObjNum ); + if( pUngroupObj ) + { + SdrObjList* pSrcLst = pUngroupObj->GetSubList(); + sal_Int32 nCount( 0 ); + if( pUngroupObj->ISA( SdrObjGroup ) && pSrcLst ) + { + SdrObjGroup* pUngroupGroup = static_cast< SdrObjGroup* > (pUngroupObj); + + // ungroup recursively (has to be head recursion, + // otherwise our indices will get trashed when doing it in + // the loop) + pSrcLst->FlattenGroups(); + + // the position at which we insert the members of rUngroupGroup + sal_Int32 nInsertPos( pUngroupGroup->GetOrdNum() ); + + SdrObject* pObj; + sal_Int32 i, nAnz = pSrcLst->GetObjCount(); + for( i=0; i<nAnz; ++i ) + { + pObj = pSrcLst->RemoveObject(0); + SdrInsertReason aReason(SDRREASON_VIEWCALL, pUngroupGroup); + InsertObject(pObj, nInsertPos, &aReason); + ++nInsertPos; + } + + RemoveObject(nInsertPos); + } + } +#ifdef DBG_UTIL + else + DBG_ERROR("SdrObjList::UnGroupObj: object index invalid"); +#endif +} + //////////////////////////////////////////////////////////////////////////////////////////////////// SvStream& operator<<(SvStream& rOut, const SdrMasterPageDescriptor& rMDP) |