Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <sal/main.h>
21 : #include <tools/extendapplicationenvironment.hxx>
22 :
23 : #include <cppuhelper/bootstrap.hxx>
24 : #include <comphelper/processfactory.hxx>
25 :
26 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 : #include <com/sun/star/uno/XComponentContext.hpp>
28 :
29 : #include <vcl/event.hxx>
30 : #include <vcl/svapp.hxx>
31 : #include <vcl/wrkwin.hxx>
32 : #include <vcl/msgbox.hxx>
33 :
34 : using namespace ::com::sun::star::uno;
35 : using namespace ::com::sun::star::lang;
36 : using namespace cppu;
37 :
38 : // Forward declaration
39 : void Main();
40 :
41 0 : SAL_IMPLEMENT_MAIN()
42 : {
43 : try
44 : {
45 0 : tools::extendApplicationEnvironment();
46 :
47 0 : Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
48 0 : Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
49 :
50 0 : if( !xServiceManager.is() )
51 0 : Application::Abort( "Failed to bootstrap" );
52 :
53 0 : comphelper::setProcessServiceFactory( xServiceManager );
54 :
55 0 : InitVCL();
56 0 : ::Main();
57 0 : DeInitVCL();
58 : }
59 0 : catch (const Exception& e)
60 : {
61 : SAL_WARN("vcl.app", "Fatal exception: " << e.Message);
62 0 : return 1;
63 : }
64 :
65 0 : return 0;
66 : }
67 :
68 0 : class MyWin : public WorkWindow
69 : {
70 : public:
71 : MyWin( vcl::Window* pParent, WinBits nWinStyle );
72 :
73 : void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
74 : void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
75 : void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
76 : void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
77 : void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
78 : void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE;
79 : void Resize() SAL_OVERRIDE;
80 : };
81 :
82 0 : void Main()
83 : {
84 0 : ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_APP | WB_STDWORK );
85 0 : aMainWin->SetText(OUString("VCL - Workbench"));
86 0 : aMainWin->Show();
87 :
88 0 : Application::Execute();
89 0 : }
90 :
91 0 : MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
92 0 : WorkWindow( pParent, nWinStyle )
93 : {
94 0 : }
95 :
96 0 : void MyWin::MouseMove( const MouseEvent& rMEvt )
97 : {
98 0 : WorkWindow::MouseMove( rMEvt );
99 0 : }
100 :
101 0 : void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
102 : {
103 0 : WorkWindow::MouseButtonDown( rMEvt );
104 0 : }
105 :
106 0 : void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
107 : {
108 0 : WorkWindow::MouseButtonUp( rMEvt );
109 0 : }
110 :
111 0 : void MyWin::KeyInput( const KeyEvent& rKEvt )
112 : {
113 0 : WorkWindow::KeyInput( rKEvt );
114 0 : }
115 :
116 0 : void MyWin::KeyUp( const KeyEvent& rKEvt )
117 : {
118 0 : WorkWindow::KeyUp( rKEvt );
119 0 : }
120 :
121 0 : void MyWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
122 : {
123 0 : WorkWindow::Paint(rRenderContext, rRect);
124 0 : }
125 :
126 0 : void MyWin::Resize()
127 : {
128 0 : WorkWindow::Resize();
129 0 : }
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|