1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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>
39 class SC_DLLPUBLIC ScProgress
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
;
56 ScProgress( const ScProgress
& );
57 ScProgress
& operator=( const ScProgress
& );
59 static void CalcGlobalPercent( ULONG nVal
)
61 nGlobalPercent
= nGlobalRange
?
62 nVal
* 100 / nGlobalRange
: 0;
66 static SfxProgress
* GetGlobalSfxProgress() { return pGlobalProgress
; }
67 static BOOL
IsUserBreak() { return !bGlobalNoUserBreak
; }
68 static void CreateInterpretProgress( ScDocument
* pDoc
,
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
,
78 ULONG nRange
, BOOL bAllDocs
= FALSE
,
82 #ifdef SC_PROGRESS_CXX
83 // nur fuer DummyInterpret, sonst nie benutzen!!!
87 SfxProgress
* GetSfxProgress() const { return pProgress
; }
89 BOOL
SetStateText( ULONG nVal
, const String
&rVal
, ULONG nNewRange
= 0 )
94 nGlobalRange
= nNewRange
;
95 CalcGlobalPercent( nVal
);
96 if ( !pProgress
->SetStateText( nVal
, rVal
, nNewRange
) )
97 bGlobalNoUserBreak
= FALSE
;
98 return bGlobalNoUserBreak
;
102 BOOL
SetState( ULONG nVal
, ULONG nNewRange
= 0 )
107 nGlobalRange
= nNewRange
;
108 CalcGlobalPercent( nVal
);
109 if ( !pProgress
->SetState( nVal
, nNewRange
) )
110 bGlobalNoUserBreak
= FALSE
;
111 return bGlobalNoUserBreak
;
115 BOOL
SetStateCountDown( ULONG nVal
)
119 CalcGlobalPercent( nGlobalRange
- nVal
);
120 if ( !pProgress
->SetState( nGlobalRange
- nVal
) )
121 bGlobalNoUserBreak
= FALSE
;
122 return bGlobalNoUserBreak
;
126 BOOL
SetStateOnPercent( ULONG nVal
)
127 { // nur wenn Prozent mehr als vorher
128 if ( nGlobalRange
&& (nVal
* 100 /
129 nGlobalRange
) > nGlobalPercent
)
130 return SetState( nVal
);
133 BOOL
SetStateCountDownOnPercent( ULONG nVal
)
134 { // nur wenn Prozent mehr als vorher
136 ((nGlobalRange
- nVal
) * 100 /
137 nGlobalRange
) > nGlobalPercent
)
138 return SetStateCountDown( nVal
);
144 return pProgress
->GetState();