xref: /aoo41x/main/desktop/source/splash/splash.hxx (revision 0a1e2f0e)
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 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/uno/Exception.hpp>
26 #include <com/sun/star/uno/Reference.h>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/task/XStatusIndicator.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <cppuhelper/implbase2.hxx>
31 #include <cppuhelper/interfacecontainer.h>
32 #include <vcl/introwin.hxx>
33 #include <vcl/bitmapex.hxx>
34 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
35 #include <osl/mutex.hxx>
36 #include <vcl/virdev.hxx>
37 
38 
39 using namespace ::rtl;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::lang;
42 using namespace ::com::sun::star::task;
43 
44 namespace desktop {
45 
46 class  SplashScreen
47 	: public ::cppu::WeakImplHelper2< XStatusIndicator, XInitialization >
48 	, public IntroWindow
49 {
50 private:
51     struct FullScreenProgressRatioValue
52     {
53         double _fXRelPos;
54         double _fYRelPos;
55         double _fRelWidth;
56         double _fRelHeight;
57     };
58     enum BitmapMode { BM_FULLSCREEN, BM_DEFAULTMODE };
59 
60 	// don't allow anybody but ourselves to create instances of this class
61 	SplashScreen(const SplashScreen&);
62 	SplashScreen(void);
63 	SplashScreen operator =(const SplashScreen&);
64 
65 	SplashScreen(const Reference< XMultiServiceFactory >& xFactory);
66 
67 	DECL_LINK( AppEventListenerHdl, VclWindowEvent * );
68     virtual ~SplashScreen();
69     void loadConfig();
70 	void initBitmap();
71 	void updateStatus();
72     bool findScreenBitmap(rtl::OUString const & path);
73     bool findAppBitmap(rtl::OUString const & path);
74     bool findBitmap(rtl::OUString const & path);
75     bool loadBitmap(
76         rtl::OUString const & path, const rtl::OUString &rBmpFileName );
77     void determineProgressRatioValues( double& rXRelPos, double& rYRelPos, double& rRelWidth, double& rRelHeight );
78 
79 	static  SplashScreen *_pINSTANCE;
80 
81 	static osl::Mutex _aMutex;
82 	Reference< XMultiServiceFactory > _rFactory;
83 
84     VirtualDevice   _vdev;
85     BitmapEx        _aIntroBmp;
86     Color           _cProgressFrameColor;
87     Color           _cProgressBarColor;
88     bool            _bNativeProgress;
89     OUString        _sAppName;
90     OUString        _sProgressText;
91     std::vector< FullScreenProgressRatioValue > _sFullScreenProgressRatioValues;
92 
93 	sal_Int32   _iMax;
94 	sal_Int32   _iProgress;
95     BitmapMode  _eBitmapMode;
96 	sal_Bool    _bPaintBitmap;
97 	sal_Bool    _bPaintProgress;
98 	sal_Bool    _bVisible;
99     sal_Bool    _bShowLogo;
100     sal_Bool    _bFullScreenSplash;
101     sal_Bool    _bProgressEnd;
102 	long _height, _width, _tlx, _tly, _barwidth;
103     long _barheight, _barspace;
104     double _fXPos, _fYPos;
105     double _fWidth, _fHeight;
106     const long _xoffset, _yoffset;
107 
108 public:
109     static const char* interfaces[];
110 	static const sal_Char *serviceName;
111 	static const sal_Char *implementationName;
112 	static const sal_Char *supportedServiceNames[];
113 
114     static Reference< XInterface > getInstance(const Reference < XMultiServiceFactory >& xFactory);
115 
116 	// XStatusIndicator
117 	virtual void SAL_CALL end() throw ( RuntimeException );
118 	virtual void SAL_CALL reset() throw ( RuntimeException );
119 	virtual void SAL_CALL setText(const OUString& aText) throw ( RuntimeException );
120 	virtual void SAL_CALL setValue(sal_Int32 nValue) throw ( RuntimeException );
121 	virtual void SAL_CALL start(const OUString& aText, sal_Int32 nRange) throw ( RuntimeException );
122 
123 	// XInitialize
124 	virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
125 		throw ( RuntimeException );
126 
127 	// workwindow
128 	virtual void Paint( const Rectangle& );
129 
130 };
131 
132 }
133