xref: /AOO41X/main/desktop/source/splash/splash.hxx (revision d3e0dd8eb215533c15e891ee35bd141abe9397ee)
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     bool            _bShowProgressFrame;
88     Color           _cProgressBarColor;
89     bool            _bNativeProgress;
90     OUString        _sAppName;
91     OUString        _sProgressText;
92     std::vector< FullScreenProgressRatioValue > _sFullScreenProgressRatioValues;
93 
94     sal_Int32   _iMax;
95     sal_Int32   _iProgress;
96     BitmapMode  _eBitmapMode;
97     sal_Bool    _bPaintBitmap;
98     sal_Bool    _bPaintProgress;
99     sal_Bool    _bVisible;
100     sal_Bool    _bShowLogo;
101     sal_Bool    _bFullScreenSplash;
102     sal_Bool    _bProgressEnd;
103     long _height, _width, _tlx, _tly, _barwidth;
104     long _barheight, _barspace;
105     double _fXPos, _fYPos;
106     double _fWidth, _fHeight;
107     const long _xoffset, _yoffset;
108 
109 public:
110     static const char* interfaces[];
111     static const sal_Char *serviceName;
112     static const sal_Char *implementationName;
113     static const sal_Char *supportedServiceNames[];
114 
115     static Reference< XInterface > getInstance(const Reference < XMultiServiceFactory >& xFactory);
116 
117     // XStatusIndicator
118     virtual void SAL_CALL end() throw ( RuntimeException );
119     virtual void SAL_CALL reset() throw ( RuntimeException );
120     virtual void SAL_CALL setText(const OUString& aText) throw ( RuntimeException );
121     virtual void SAL_CALL setValue(sal_Int32 nValue) throw ( RuntimeException );
122     virtual void SAL_CALL start(const OUString& aText, sal_Int32 nRange) throw ( RuntimeException );
123 
124     // XInitialize
125     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
126         throw ( RuntimeException );
127 
128     // workwindow
129     virtual void Paint( const Rectangle& );
130 
131 };
132 
133 }
134