1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _XMLOFF_PROGRESSBARHELPER_HXX 25 #define _XMLOFF_PROGRESSBARHELPER_HXX 26 27 #include "sal/config.h" 28 #include "xmloff/dllapi.h" 29 #include <com/sun/star/task/XStatusIndicator.hpp> 30 #include <com/sun/star/frame/XModel.hpp> 31 32 #define XML_PROGRESSRANGE "ProgressRange" 33 #define XML_PROGRESSMAX "ProgressMax" 34 #define XML_PROGRESSCURRENT "ProgressCurrent" 35 #define XML_PROGRESSREPEAT "ProgressRepeat" 36 37 class XMLOFF_DLLPUBLIC ProgressBarHelper 38 { 39 ::com::sun::star::uno::Reference < ::com::sun::star::task::XStatusIndicator > xStatusIndicator; 40 sal_Int32 nRange; 41 sal_Int32 nReference; 42 sal_Int32 nValue; 43 double fOldPercent; 44 sal_Bool bStrict; 45 // #96469#; if the value goes over the Range the progressbar starts again 46 sal_Bool bRepeat; 47 48 #ifdef DBG_UTIL 49 sal_Bool bFailure; 50 #endif 51 public: 52 ProgressBarHelper(const ::com::sun::star::uno::Reference < ::com::sun::star::task::XStatusIndicator>& xStatusIndicator, 53 const sal_Bool bStrict); 54 ~ProgressBarHelper(); 55 SetText(::rtl::OUString & rText)56 void SetText(::rtl::OUString& rText) { if (xStatusIndicator.is()) xStatusIndicator->setText(rText); } SetRange(sal_Int32 nVal)57 void SetRange(sal_Int32 nVal) { nRange = nVal; } SetReference(sal_Int32 nVal)58 void SetReference(sal_Int32 nVal) { nReference = nVal; } 59 void SetValue(sal_Int32 nValue); SetRepeat(sal_Bool bValue)60 void SetRepeat(sal_Bool bValue) { bRepeat = bValue; } Increment(sal_Int32 nInc=1)61 inline void Increment(sal_Int32 nInc = 1) { SetValue( nValue+nInc ); } End()62 void End() { if (xStatusIndicator.is()) xStatusIndicator->end(); } 63 64 // set the new reference and returns the new value which gives the 65 // Progress Bar the sam position as before 66 sal_Int32 ChangeReference(sal_Int32 nNewReference); 67 GetReference()68 sal_Int32 GetReference() { return nReference; } GetValue()69 sal_Int32 GetValue() { return nValue; } GetRepeat()70 sal_Bool GetRepeat() { return bRepeat; } 71 }; 72 73 #endif 74 75