merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / dlg / assclass.cxx
blobd987dc1b0cd3c1c2b099c9bbfce4d1dff54e2af6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: assclass.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include <tools/list.hxx>
36 #include <tools/debug.hxx>
37 #include <vcl/ctrl.hxx>
39 #include "assclass.hxx"
42 Assistent::Assistent(int nNoOfPages)
44 mnPages=nNoOfPages;
45 if(mnPages>MAX_PAGES)
47 mnPages=MAX_PAGES;
50 mpPageStatus = new bool[mnPages];
52 for(UINT8 i=0;i<mnPages;i++)
54 mpPages[i]=new List();
55 mpPageStatus[i] = TRUE;
57 mnCurrentPage=1;
62 bool Assistent::InsertControl(int nDestPage,Control* pUsedControl)
64 DBG_ASSERT( (nDestPage > 0) && (nDestPage <= mnPages), "Seite nicht vorhanden!");
65 if((nDestPage>0)&&(nDestPage<=mnPages))
67 mpPages[nDestPage-1]->Insert(pUsedControl,LIST_APPEND);
68 pUsedControl->Hide();
69 pUsedControl->Disable();
70 return true;
72 else
74 return false;
79 bool Assistent::NextPage()
81 if(mnCurrentPage<mnPages)
83 int nPage = mnCurrentPage+1;
84 while(nPage <= mnPages && !mpPageStatus[nPage-1])
85 nPage++;
87 if(nPage <= mnPages)
88 return GotoPage(nPage);
90 return false;
94 bool Assistent::PreviousPage()
96 if(mnCurrentPage>1)
98 int nPage = mnCurrentPage-1;
99 while(nPage >= 0 && !mpPageStatus[nPage-1])
100 nPage--;
102 if(nPage >= 0)
103 return GotoPage(nPage);
105 return false;
109 bool Assistent::GotoPage(const int nPageToGo)
111 DBG_ASSERT( (nPageToGo > 0) && (nPageToGo <= mnPages), "Seite nicht vorhanden!");
113 if((nPageToGo>0)&&(nPageToGo<=mnPages)&&mpPageStatus[nPageToGo-1])
115 int i;
116 Control* pCurControl;
117 int nIndex=mnCurrentPage-1;
119 for(i=0;i<(int)mpPages[nIndex]->Count();i++)
121 pCurControl=(Control*)mpPages[nIndex]->GetObject(i);
122 pCurControl->Disable();
123 pCurControl->Hide();
124 //schaltet die Controls der vorherigen Seite
125 //zurueck
127 mnCurrentPage=nPageToGo;
128 nIndex=mnCurrentPage-1;
129 for(i=0;i<(int)mpPages[nIndex]->Count();i++)
132 pCurControl=(Control*)mpPages[nIndex]->GetObject(i);
133 pCurControl->Enable();
134 pCurControl->Show();
135 //zeigt die neue Seite im Fenster an
137 return true;
139 else
141 return false;
146 bool Assistent::IsLastPage()
148 if(mnCurrentPage==mnPages)
150 return true;
152 else
154 int nPage = mnCurrentPage+1;
155 while(nPage <= mnPages && !mpPageStatus[nPage-1])
156 nPage++;
158 return nPage > mnPages;
163 bool Assistent::IsFirstPage()
165 if(mnCurrentPage==1)
167 return true;
169 else
171 int nPage = mnCurrentPage-1;
172 while(nPage > 0 && !mpPageStatus[nPage-1])
173 nPage--;
175 return nPage == 0;
181 int Assistent::GetCurrentPage()
183 return mnCurrentPage;
186 Assistent::~Assistent()
188 for( int i=0;i<mnPages;i++)
190 delete mpPages[i];
193 delete [] mpPageStatus;
196 bool Assistent::IsEnabled( int nPage )
198 DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
200 return (nPage>0) && (nPage <= mnPages && mpPageStatus[nPage-1]);
203 void Assistent::EnablePage( int nPage )
205 DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
207 if((nPage>0) && (nPage < mnPages && !mpPageStatus[nPage-1]))
209 mpPageStatus[nPage-1] = true;
213 void Assistent::DisablePage( int nPage )
215 DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
217 if((nPage>0) && (nPage <= mnPages && mpPageStatus[nPage-1]))
219 mpPageStatus[nPage-1] = false;
220 if(mnCurrentPage == nPage)
221 GotoPage(1);