Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sc / progress.hxx
blob6ee5eb40309298e119adefdf89b6a80b9ca24877
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.5 $
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 #ifndef _SFX_PROGRESS_HXX //autogen
35 #include <bf_sfx2/progress.hxx>
36 #endif
37 namespace binfilter {
39 class ScDocument;
41 class ScProgress
43 private:
44 static SfxProgress* pGlobalProgress;
45 static ULONG nGlobalRange;
46 static ULONG nGlobalPercent;
47 static BOOL bGlobalNoUserBreak;
48 static ScProgress* pInterpretProgress;
49 static ScProgress* pOldInterpretProgress;
50 static ULONG nInterpretProgress;
51 static BOOL bAllowInterpretProgress;
52 static ScDocument* pInterpretDoc;
53 static BOOL bIdleWasDisabled;
55 SfxProgress* pProgress;
57 // not implemented
58 ScProgress( const ScProgress& );
59 ScProgress& operator=( const ScProgress& );
61 static void CalcGlobalPercent( ULONG nVal )
63 nGlobalPercent = nGlobalRange ?
64 nVal * 100 / nGlobalRange : 0;
67 public:
68 static SfxProgress* GetGlobalSfxProgress() { return pGlobalProgress; }
69 static BOOL IsUserBreak() { return !bGlobalNoUserBreak; }
70 static ScProgress* GetInterpretProgress() { return pInterpretProgress; }
71 static BOOL GetAllowInterpret() { return bAllowInterpretProgress; }
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 SetState( ULONG nVal, ULONG nNewRange = 0 )
91 if ( pProgress )
93 if ( nNewRange )
94 nGlobalRange = nNewRange;
95 CalcGlobalPercent( nVal );
96 if ( !pProgress->SetState( nVal, nNewRange ) )
97 bGlobalNoUserBreak = FALSE;
98 return bGlobalNoUserBreak;
100 return TRUE;
102 BOOL SetStateCountDown( ULONG nVal )
104 if ( pProgress )
106 CalcGlobalPercent( nGlobalRange - nVal );
107 if ( !pProgress->SetState( nGlobalRange - nVal ) )
108 bGlobalNoUserBreak = FALSE;
109 return bGlobalNoUserBreak;
111 return TRUE;
113 BOOL SetStateOnPercent( ULONG nVal )
114 { // nur wenn Prozent mehr als vorher
115 if ( nGlobalRange && (nVal * 100 /
116 nGlobalRange) > nGlobalPercent )
117 return SetState( nVal );
118 return TRUE;
120 BOOL SetStateCountDownOnPercent( ULONG nVal )
121 { // nur wenn Prozent mehr als vorher
122 if ( nGlobalRange &&
123 ((nGlobalRange - nVal) * 100 /
124 nGlobalRange) > nGlobalPercent )
125 return SetStateCountDown( nVal );
126 return TRUE;
128 ULONG GetState()
130 if ( pProgress )
131 return pProgress->GetState();
132 return 0;
137 } //namespace binfilter
138 #endif