sync master with lastest vba changes
[ooovba.git] / sc / inc / progress.hxx
blobe90d7237b99ea186dabb84529191b3885d560c61
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: progress.hxx,v $
10 * $Revision: 1.3.32.1 $
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 #ifndef SC_PROGRESS_HXX
32 #define SC_PROGRESS_HXX
34 #include <sfx2/progress.hxx>
35 #include "scdllapi.h"
37 class ScDocument;
39 class SC_DLLPUBLIC ScProgress
41 private:
42 static SfxProgress* pGlobalProgress;
43 static ULONG nGlobalRange;
44 static ULONG nGlobalPercent;
45 static BOOL bGlobalNoUserBreak;
46 static ScProgress* pInterpretProgress;
47 static ScProgress* pOldInterpretProgress;
48 static ULONG nInterpretProgress;
49 static BOOL bAllowInterpretProgress;
50 static ScDocument* pInterpretDoc;
51 static BOOL bIdleWasDisabled;
53 SfxProgress* pProgress;
55 // not implemented
56 ScProgress( const ScProgress& );
57 ScProgress& operator=( const ScProgress& );
59 static void CalcGlobalPercent( ULONG nVal )
61 nGlobalPercent = nGlobalRange ?
62 nVal * 100 / nGlobalRange : 0;
65 public:
66 static SfxProgress* GetGlobalSfxProgress() { return pGlobalProgress; }
67 static BOOL IsUserBreak() { return !bGlobalNoUserBreak; }
68 static void CreateInterpretProgress( ScDocument* pDoc,
69 BOOL bWait = TRUE );
70 static ScProgress* GetInterpretProgress() { return pInterpretProgress; }
71 static void DeleteInterpretProgress();
72 static ULONG GetInterpretCount() { return nInterpretProgress; }
73 static ULONG GetGlobalRange() { return nGlobalRange; }
74 static ULONG GetGlobalPercent() { return nGlobalPercent; }
76 ScProgress( SfxObjectShell* pObjSh,
77 const String& rText,
78 ULONG nRange, BOOL bAllDocs = FALSE,
79 BOOL bWait = TRUE );
80 ~ScProgress();
82 #ifdef SC_PROGRESS_CXX
83 // nur fuer DummyInterpret, sonst nie benutzen!!!
84 ScProgress();
85 #endif
86 // kann NULL sein!
87 SfxProgress* GetSfxProgress() const { return pProgress; }
89 BOOL SetStateText( ULONG nVal, const String &rVal, ULONG nNewRange = 0 )
91 if ( pProgress )
93 if ( nNewRange )
94 nGlobalRange = nNewRange;
95 CalcGlobalPercent( nVal );
96 if ( !pProgress->SetStateText( nVal, rVal, nNewRange ) )
97 bGlobalNoUserBreak = FALSE;
98 return bGlobalNoUserBreak;
100 return TRUE;
102 BOOL SetState( ULONG nVal, ULONG nNewRange = 0 )
104 if ( pProgress )
106 if ( nNewRange )
107 nGlobalRange = nNewRange;
108 CalcGlobalPercent( nVal );
109 if ( !pProgress->SetState( nVal, nNewRange ) )
110 bGlobalNoUserBreak = FALSE;
111 return bGlobalNoUserBreak;
113 return TRUE;
115 BOOL SetStateCountDown( ULONG nVal )
117 if ( pProgress )
119 CalcGlobalPercent( nGlobalRange - nVal );
120 if ( !pProgress->SetState( nGlobalRange - nVal ) )
121 bGlobalNoUserBreak = FALSE;
122 return bGlobalNoUserBreak;
124 return TRUE;
126 BOOL SetStateOnPercent( ULONG nVal )
127 { // nur wenn Prozent mehr als vorher
128 if ( nGlobalRange && (nVal * 100 /
129 nGlobalRange) > nGlobalPercent )
130 return SetState( nVal );
131 return TRUE;
133 BOOL SetStateCountDownOnPercent( ULONG nVal )
134 { // nur wenn Prozent mehr als vorher
135 if ( nGlobalRange &&
136 ((nGlobalRange - nVal) * 100 /
137 nGlobalRange) > nGlobalPercent )
138 return SetStateCountDown( nVal );
139 return TRUE;
141 ULONG GetState()
143 if ( pProgress )
144 return pProgress->GetState();
145 return 0;
150 #endif