xref: /trunk/main/fpicker/test/svdem.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 //_________________________________________________________________________________________________________________________
30 //	interface includes
31 //_________________________________________________________________________________________________________________________
32 
33 #include <com/sun/star/lang/XComponent.hpp>
34 #include <com/sun/star/registry/XSimpleRegistry.hpp>
35 #include <osl/file.hxx>
36 
37 //_________________________________________________________________________________________________________________________
38 //	other includes
39 //_________________________________________________________________________________________________________________________
40 #include <cppuhelper/servicefactory.hxx>
41 
42 #ifndef _RTL_USTRING_
43 #include <rtl/ustring>
44 #endif
45 #include <sal/types.h>
46 #include <osl/diagnose.h>
47 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
48 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
49 
50 #ifndef _COM_SUN_STAR_UI_DIALOGS_FILEDIALOGRESULTS_HPP_
51 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
52 #endif
53 #include <cppuhelper/implbase1.hxx>
54 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
55 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
56 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
57 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
58 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
59 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
60 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
61 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
62 
63 #include <sal/main.h>
64 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
65 
66 #include <vcl/event.hxx>
67 #include <vcl/svapp.hxx>
68 #include <vcl/wrkwin.hxx>
69 #include <vcl/msgbox.hxx>
70 #include <vcl/button.hxx>
71 
72 #include <comphelper/processfactory.hxx>
73 #include <cppuhelper/servicefactory.hxx>
74 #include <cppuhelper/bootstrap.hxx>
75 
76 #include "../source/office/iodlg.hxx"
77 
78 using namespace ::com::sun::star::uno;
79 using namespace ::com::sun::star::lang;
80 // -----------------------------------------------------------------------
81 
82 // Forward declaration
83 void Main();
84 
85 String aEmptyStr;
86 
87 // -----------------------------------------------------------------------
88 
89 SAL_IMPLEMENT_MAIN()
90 {
91     Reference< XMultiServiceFactory > xMS;
92     xMS = cppu::createRegistryServiceFactory( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True );
93 
94    com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> xMSch;
95    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xComponentContext;
96            xComponentContext = cppu::defaultBootstrap_InitialComponentContext();
97        xMSch.set(xComponentContext->getServiceManager(), com::sun::star::uno::UNO_QUERY);
98        comphelper::setProcessServiceFactory(xMSch);
99 
100 //    comphelper::setProcessServiceFactory( xMS);
101 
102     InitVCL( xMS );
103     ::Main();
104     DeInitVCL();
105 
106     return 0;
107 }
108 
109 // -----------------------------------------------------------------------
110 
111 class MyWin : public WorkWindow
112 {
113 public:
114 				MyWin( Window* pParent, WinBits nWinStyle );
115 
116 	void		MouseMove( const MouseEvent& rMEvt );
117 	void		MouseButtonDown( const MouseEvent& rMEvt );
118 	void		MouseButtonUp( const MouseEvent& rMEvt );
119 	void		KeyInput( const KeyEvent& rKEvt );
120 	void		KeyUp( const KeyEvent& rKEvt );
121 	void		Paint( const Rectangle& rRect );
122 	void		Resize();
123 
124 private:
125 	OKButton	aOKBtn;
126 
127 					DECL_LINK( Test, PushButton* );
128 
129 };
130 
131 // -----------------------------------------------------------------------
132 
133 void Main()
134 {
135 	MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
136 	aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCL - Workbench" ) ) );
137 	aMainWin.Show();
138 
139 	Application::Execute();
140 }
141 
142 // -----------------------------------------------------------------------
143 
144 MyWin::MyWin( Window* pParent, WinBits nWinStyle )
145 	:WorkWindow( pParent, nWinStyle )
146 	,aOKBtn(this)
147 {
148 	aOKBtn.SetPosSizePixel( Point( 10, 10 ), Size( 140, 140 ) );
149 	aOKBtn.SetClickHdl( LINK( this, MyWin, Test ) );
150 	aOKBtn.Show();
151 }
152 
153 // -----------------------------------------------------------------------
154 
155 void MyWin::MouseMove( const MouseEvent& rMEvt )
156 {
157 	WorkWindow::MouseMove( rMEvt );
158 }
159 
160 // -----------------------------------------------------------------------
161 
162 void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
163 {
164 	WorkWindow::MouseButtonDown( rMEvt );
165 }
166 
167 // -----------------------------------------------------------------------
168 
169 void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
170 {
171 	WorkWindow::MouseButtonUp( rMEvt );
172 }
173 
174 // -----------------------------------------------------------------------
175 
176 void MyWin::KeyInput( const KeyEvent& rKEvt )
177 {
178 	WorkWindow::KeyInput( rKEvt );
179 }
180 
181 // -----------------------------------------------------------------------
182 
183 void MyWin::KeyUp( const KeyEvent& rKEvt )
184 {
185 	WorkWindow::KeyUp( rKEvt );
186 }
187 
188 // -----------------------------------------------------------------------
189 
190 void MyWin::Paint( const Rectangle& rRect )
191 {
192 	WorkWindow::Paint( rRect );
193 }
194 
195 // -----------------------------------------------------------------------
196 
197 void MyWin::Resize()
198 {
199 	WorkWindow::Resize();
200 }
201 
202 // -----------------------------------------------------------------------
203 
204 IMPL_LINK( MyWin, Test, PushButton*, pBtn )
205 {
206 printf("Test\n");
207 	if ( pBtn == &aOKBtn )
208 	{
209 		SvtFileDialog* pDlg = new SvtFileDialog( this,SFXWB_PATHDIALOG);
210 		pDlg->Execute();
211 		delete pDlg;
212 		printf("ok\n");
213 	}
214 
215 	return 0;
216 }
217 
218