merge the formfield patch from ooo-build
[ooovba.git] / fpicker / test / svdem.cxx
blob0d5342fcb08dc100f7cb8cd389f2891f67a5c484
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdem.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 //_________________________________________________________________________________________________________________________
33 // interface includes
34 //_________________________________________________________________________________________________________________________
36 #include <com/sun/star/lang/XComponent.hpp>
37 #include <com/sun/star/registry/XSimpleRegistry.hpp>
38 #include <osl/file.hxx>
40 //_________________________________________________________________________________________________________________________
41 // other includes
42 //_________________________________________________________________________________________________________________________
43 #include <cppuhelper/servicefactory.hxx>
45 #ifndef _RTL_USTRING_
46 #include <rtl/ustring>
47 #endif
48 #include <sal/types.h>
49 #include <osl/diagnose.h>
50 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
51 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
53 #ifndef _COM_SUN_STAR_UI_DIALOGS_FILEDIALOGRESULTS_HPP_
54 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
55 #endif
56 #include <cppuhelper/implbase1.hxx>
57 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
58 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
59 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
60 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
61 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
62 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
63 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
64 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
66 #include <sal/main.h>
67 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
69 #include <vcl/event.hxx>
70 #include <vcl/svapp.hxx>
71 #include <vcl/wrkwin.hxx>
72 #include <vcl/msgbox.hxx>
73 #include <vcl/button.hxx>
75 #include <comphelper/processfactory.hxx>
76 #include <cppuhelper/servicefactory.hxx>
77 #include <cppuhelper/bootstrap.hxx>
79 #include "../source/office/iodlg.hxx"
81 using namespace ::com::sun::star::uno;
82 using namespace ::com::sun::star::lang;
83 // -----------------------------------------------------------------------
85 // Forward declaration
86 void Main();
88 String aEmptyStr;
90 // -----------------------------------------------------------------------
92 SAL_IMPLEMENT_MAIN()
94 Reference< XMultiServiceFactory > xMS;
95 xMS = cppu::createRegistryServiceFactory( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True );
97 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> xMSch;
98 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xComponentContext;
99 xComponentContext = cppu::defaultBootstrap_InitialComponentContext();
100 xMSch.set(xComponentContext->getServiceManager(), com::sun::star::uno::UNO_QUERY);
101 comphelper::setProcessServiceFactory(xMSch);
103 // comphelper::setProcessServiceFactory( xMS);
105 InitVCL( xMS );
106 ::Main();
107 DeInitVCL();
109 return 0;
112 // -----------------------------------------------------------------------
114 class MyWin : public WorkWindow
116 public:
117 MyWin( Window* pParent, WinBits nWinStyle );
119 void MouseMove( const MouseEvent& rMEvt );
120 void MouseButtonDown( const MouseEvent& rMEvt );
121 void MouseButtonUp( const MouseEvent& rMEvt );
122 void KeyInput( const KeyEvent& rKEvt );
123 void KeyUp( const KeyEvent& rKEvt );
124 void Paint( const Rectangle& rRect );
125 void Resize();
127 private:
128 OKButton aOKBtn;
130 DECL_LINK( Test, PushButton* );
134 // -----------------------------------------------------------------------
136 void Main()
138 MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
139 aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCL - Workbench" ) ) );
140 aMainWin.Show();
142 Application::Execute();
145 // -----------------------------------------------------------------------
147 MyWin::MyWin( Window* pParent, WinBits nWinStyle )
148 :WorkWindow( pParent, nWinStyle )
149 ,aOKBtn(this)
151 aOKBtn.SetPosSizePixel( Point( 10, 10 ), Size( 140, 140 ) );
152 aOKBtn.SetClickHdl( LINK( this, MyWin, Test ) );
153 aOKBtn.Show();
156 // -----------------------------------------------------------------------
158 void MyWin::MouseMove( const MouseEvent& rMEvt )
160 WorkWindow::MouseMove( rMEvt );
163 // -----------------------------------------------------------------------
165 void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
167 WorkWindow::MouseButtonDown( rMEvt );
170 // -----------------------------------------------------------------------
172 void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
174 WorkWindow::MouseButtonUp( rMEvt );
177 // -----------------------------------------------------------------------
179 void MyWin::KeyInput( const KeyEvent& rKEvt )
181 WorkWindow::KeyInput( rKEvt );
184 // -----------------------------------------------------------------------
186 void MyWin::KeyUp( const KeyEvent& rKEvt )
188 WorkWindow::KeyUp( rKEvt );
191 // -----------------------------------------------------------------------
193 void MyWin::Paint( const Rectangle& rRect )
195 WorkWindow::Paint( rRect );
198 // -----------------------------------------------------------------------
200 void MyWin::Resize()
202 WorkWindow::Resize();
205 // -----------------------------------------------------------------------
207 IMPL_LINK( MyWin, Test, PushButton*, pBtn )
209 printf("Test\n");
210 if ( pBtn == &aOKBtn )
212 SvtFileDialog* pDlg = new SvtFileDialog( this,SFXWB_PATHDIALOG);
213 pDlg->Execute();
214 delete pDlg;
215 printf("ok\n");
218 return 0;