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 $
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>
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
;
58 ScProgress( const ScProgress
& );
59 ScProgress
& operator=( const ScProgress
& );
61 static void CalcGlobalPercent( ULONG nVal
)
63 nGlobalPercent
= nGlobalRange
?
64 nVal
* 100 / nGlobalRange
: 0;
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
,
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
SetState( ULONG nVal
, ULONG nNewRange
= 0 )
94 nGlobalRange
= nNewRange
;
95 CalcGlobalPercent( nVal
);
96 if ( !pProgress
->SetState( nVal
, nNewRange
) )
97 bGlobalNoUserBreak
= FALSE
;
98 return bGlobalNoUserBreak
;
102 BOOL
SetStateCountDown( ULONG nVal
)
106 CalcGlobalPercent( nGlobalRange
- nVal
);
107 if ( !pProgress
->SetState( nGlobalRange
- nVal
) )
108 bGlobalNoUserBreak
= FALSE
;
109 return bGlobalNoUserBreak
;
113 BOOL
SetStateOnPercent( ULONG nVal
)
114 { // nur wenn Prozent mehr als vorher
115 if ( nGlobalRange
&& (nVal
* 100 /
116 nGlobalRange
) > nGlobalPercent
)
117 return SetState( nVal
);
120 BOOL
SetStateCountDownOnPercent( ULONG nVal
)
121 { // nur wenn Prozent mehr als vorher
123 ((nGlobalRange
- nVal
) * 100 /
124 nGlobalRange
) > nGlobalPercent
)
125 return SetStateCountDown( nVal
);
131 return pProgress
->GetState();
137 } //namespace binfilter