bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / filter / eppt / pptx-grouptable.cxx
blob2345716f0d49cc46fc1237a1eb14451a665a5e99
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "grouptable.hxx"
22 using ::com::sun::star::uno::Reference;
23 using ::com::sun::star::container::XIndexAccess;
25 GroupTable::GroupTable() :
26 mnCurrentGroupEntry ( 0 ),
27 mnMaxGroupEntry ( 0 ),
28 mnGroupsClosed ( 0 ),
29 mpGroupEntry ( NULL )
31 ImplResizeGroupTable( 32 );
34 // ---------------------------------------------------------------------------------------------
36 GroupTable::~GroupTable()
38 for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; delete mpGroupEntry[ i++ ] ) ;
39 delete[] mpGroupEntry;
42 // ---------------------------------------------------------------------------------------------
44 void GroupTable::ImplResizeGroupTable( sal_uInt32 nEntrys )
46 if ( nEntrys > mnMaxGroupEntry )
48 mnMaxGroupEntry = nEntrys;
49 GroupEntry** pTemp = new GroupEntry*[ nEntrys ];
50 for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; i++ )
51 pTemp[ i ] = mpGroupEntry[ i ];
52 if ( mpGroupEntry )
53 delete[] mpGroupEntry;
54 mpGroupEntry = pTemp;
58 // ---------------------------------------------------------------------------------------------
60 sal_Bool GroupTable::EnterGroup( ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rXIndexAccessRef )
62 sal_Bool bRet = sal_False;
63 if ( rXIndexAccessRef.is() )
65 GroupEntry* pNewGroup = new GroupEntry( rXIndexAccessRef );
66 if ( pNewGroup->mnCount )
68 if ( mnMaxGroupEntry == mnCurrentGroupEntry )
69 ImplResizeGroupTable( mnMaxGroupEntry + 8 );
70 mpGroupEntry[ mnCurrentGroupEntry++ ] = pNewGroup;
71 bRet = sal_True;
73 else
74 delete pNewGroup;
76 return bRet;
79 // ---------------------------------------------------------------------------------------------
81 sal_uInt32 GroupTable::GetGroupsClosed()
83 sal_uInt32 nRet = mnGroupsClosed;
84 mnGroupsClosed = 0;
85 return nRet;
88 // ---------------------------------------------------------------------------------------------
90 void GroupTable::ClearGroupTable()
92 for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; i++, delete mpGroupEntry[ i ] ) ;
93 mnCurrentGroupEntry = 0;
96 // ---------------------------------------------------------------------------------------------
98 void GroupTable::ResetGroupTable( sal_uInt32 nCount )
100 ClearGroupTable();
101 mpGroupEntry[ mnCurrentGroupEntry++ ] = new GroupEntry( nCount );
104 // ---------------------------------------------------------------------------------------------
106 sal_Bool GroupTable::GetNextGroupEntry()
108 while ( mnCurrentGroupEntry )
110 mnIndex = mpGroupEntry[ mnCurrentGroupEntry - 1 ]->mnCurrentPos++;
112 if ( mpGroupEntry[ mnCurrentGroupEntry - 1 ]->mnCount > mnIndex )
113 return sal_True;
115 delete ( mpGroupEntry[ --mnCurrentGroupEntry ] );
117 if ( mnCurrentGroupEntry )
118 mnGroupsClosed++;
120 return sal_False;
123 // ---------------------------------------------------------------------------------------------
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */