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
25 //_________________________________________________________________________________________________________________________
26 // interface includes
27 //_________________________________________________________________________________________________________________________
28
29 #include <com/sun/star/lang/XComponent.hpp>
30 #include <com/sun/star/registry/XSimpleRegistry.hpp>
31 #include <osl/file.hxx>
32
33 //_________________________________________________________________________________________________________________________
34 // other includes
35 //_________________________________________________________________________________________________________________________
36 #include <cppuhelper/servicefactory.hxx>
37
38 #ifndef _RTL_USTRING_
39 #include <rtl/ustring>
40 #endif
41 #include <sal/types.h>
42 #include <osl/diagnose.h>
43 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
44 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
45
46 #ifndef _COM_SUN_STAR_UI_DIALOGS_FILEDIALOGRESULTS_HPP_
47 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
48 #endif
49 #include <cppuhelper/implbase1.hxx>
50 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
51 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
52 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
53 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
54 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
55 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
56 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
57 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
58
59 #include <sal/main.h>
60 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
61
62 #include <vcl/event.hxx>
63 #include <vcl/svapp.hxx>
64 #include <vcl/wrkwin.hxx>
65 #include <vcl/msgbox.hxx>
66 #include <vcl/button.hxx>
67
68 #include <comphelper/processfactory.hxx>
69 #include <cppuhelper/servicefactory.hxx>
70 #include <cppuhelper/bootstrap.hxx>
71
72 #include "../source/office/iodlg.hxx"
73
74 using namespace ::com::sun::star::uno;
75 using namespace ::com::sun::star::lang;
76 // -----------------------------------------------------------------------
77
78 // Forward declaration
79 void Main();
80
81 String aEmptyStr;
82
83 // -----------------------------------------------------------------------
84
SAL_IMPLEMENT_MAIN()85 SAL_IMPLEMENT_MAIN()
86 {
87 Reference< XMultiServiceFactory > xMS;
88 xMS = cppu::createRegistryServiceFactory( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True );
89
90 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> xMSch;
91 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xComponentContext;
92 xComponentContext = cppu::defaultBootstrap_InitialComponentContext();
93 xMSch.set(xComponentContext->getServiceManager(), com::sun::star::uno::UNO_QUERY);
94 comphelper::setProcessServiceFactory(xMSch);
95
96 // comphelper::setProcessServiceFactory( xMS);
97
98 InitVCL( xMS );
99 ::Main();
100 DeInitVCL();
101
102 return 0;
103 }
104
105 // -----------------------------------------------------------------------
106
107 class MyWin : public WorkWindow
108 {
109 public:
110 MyWin( Window* pParent, WinBits nWinStyle );
111
112 void MouseMove( const MouseEvent& rMEvt );
113 void MouseButtonDown( const MouseEvent& rMEvt );
114 void MouseButtonUp( const MouseEvent& rMEvt );
115 void KeyInput( const KeyEvent& rKEvt );
116 void KeyUp( const KeyEvent& rKEvt );
117 void Paint( const Rectangle& rRect );
118 void Resize();
119
120 private:
121 OKButton aOKBtn;
122
123 DECL_LINK( Test, PushButton* );
124
125 };
126
127 // -----------------------------------------------------------------------
128
Main()129 void Main()
130 {
131 MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
132 aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCL - Workbench" ) ) );
133 aMainWin.Show();
134
135 Application::Execute();
136 }
137
138 // -----------------------------------------------------------------------
139
MyWin(Window * pParent,WinBits nWinStyle)140 MyWin::MyWin( Window* pParent, WinBits nWinStyle )
141 :WorkWindow( pParent, nWinStyle )
142 ,aOKBtn(this)
143 {
144 aOKBtn.SetPosSizePixel( Point( 10, 10 ), Size( 140, 140 ) );
145 aOKBtn.SetClickHdl( LINK( this, MyWin, Test ) );
146 aOKBtn.Show();
147 }
148
149 // -----------------------------------------------------------------------
150
MouseMove(const MouseEvent & rMEvt)151 void MyWin::MouseMove( const MouseEvent& rMEvt )
152 {
153 WorkWindow::MouseMove( rMEvt );
154 }
155
156 // -----------------------------------------------------------------------
157
MouseButtonDown(const MouseEvent & rMEvt)158 void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
159 {
160 WorkWindow::MouseButtonDown( rMEvt );
161 }
162
163 // -----------------------------------------------------------------------
164
MouseButtonUp(const MouseEvent & rMEvt)165 void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
166 {
167 WorkWindow::MouseButtonUp( rMEvt );
168 }
169
170 // -----------------------------------------------------------------------
171
KeyInput(const KeyEvent & rKEvt)172 void MyWin::KeyInput( const KeyEvent& rKEvt )
173 {
174 WorkWindow::KeyInput( rKEvt );
175 }
176
177 // -----------------------------------------------------------------------
178
KeyUp(const KeyEvent & rKEvt)179 void MyWin::KeyUp( const KeyEvent& rKEvt )
180 {
181 WorkWindow::KeyUp( rKEvt );
182 }
183
184 // -----------------------------------------------------------------------
185
Paint(const Rectangle & rRect)186 void MyWin::Paint( const Rectangle& rRect )
187 {
188 WorkWindow::Paint( rRect );
189 }
190
191 // -----------------------------------------------------------------------
192
Resize()193 void MyWin::Resize()
194 {
195 WorkWindow::Resize();
196 }
197
198 // -----------------------------------------------------------------------
199
IMPL_LINK(MyWin,Test,PushButton *,pBtn)200 IMPL_LINK( MyWin, Test, PushButton*, pBtn )
201 {
202 printf("Test\n");
203 if ( pBtn == &aOKBtn )
204 {
205 SvtFileDialog* pDlg = new SvtFileDialog( this,SFXWB_PATHDIALOG);
206 pDlg->Execute();
207 delete pDlg;
208 printf("ok\n");
209 }
210
211 return 0;
212 }
213
214