xref: /trunk/main/fpicker/test/svdem.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*b557fc96SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b557fc96SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b557fc96SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b557fc96SAndrew Rist  * distributed with this work for additional information
6*b557fc96SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b557fc96SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b557fc96SAndrew Rist  * "License"); you may not use this file except in compliance
9*b557fc96SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b557fc96SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b557fc96SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b557fc96SAndrew Rist  * software distributed under the License is distributed on an
15*b557fc96SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b557fc96SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b557fc96SAndrew Rist  * specific language governing permissions and limitations
18*b557fc96SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b557fc96SAndrew Rist  *************************************************************/
21*b557fc96SAndrew Rist 
22*b557fc96SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir //_________________________________________________________________________________________________________________________
26cdf0e10cSrcweir //  interface includes
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________________
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
30cdf0e10cSrcweir #include <com/sun/star/registry/XSimpleRegistry.hpp>
31cdf0e10cSrcweir #include <osl/file.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //_________________________________________________________________________________________________________________________
34cdf0e10cSrcweir //  other includes
35cdf0e10cSrcweir //_________________________________________________________________________________________________________________________
36cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifndef _RTL_USTRING_
39cdf0e10cSrcweir #include <rtl/ustring>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #include <sal/types.h>
42cdf0e10cSrcweir #include <osl/diagnose.h>
43cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
44cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UI_DIALOGS_FILEDIALOGRESULTS_HPP_
47cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
50cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
51cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
52cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
53cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
54cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
55cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
56cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
57cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #include <sal/main.h>
60cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #include <vcl/event.hxx>
63cdf0e10cSrcweir #include <vcl/svapp.hxx>
64cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
65cdf0e10cSrcweir #include <vcl/msgbox.hxx>
66cdf0e10cSrcweir #include <vcl/button.hxx>
67cdf0e10cSrcweir 
68cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
69cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
70cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx>
71cdf0e10cSrcweir 
72cdf0e10cSrcweir #include "../source/office/iodlg.hxx"
73cdf0e10cSrcweir 
74cdf0e10cSrcweir using namespace ::com::sun::star::uno;
75cdf0e10cSrcweir using namespace ::com::sun::star::lang;
76cdf0e10cSrcweir // -----------------------------------------------------------------------
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // Forward declaration
79cdf0e10cSrcweir void Main();
80cdf0e10cSrcweir 
81cdf0e10cSrcweir String aEmptyStr;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir // -----------------------------------------------------------------------
84cdf0e10cSrcweir 
SAL_IMPLEMENT_MAIN()85cdf0e10cSrcweir SAL_IMPLEMENT_MAIN()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir     Reference< XMultiServiceFactory > xMS;
88cdf0e10cSrcweir     xMS = cppu::createRegistryServiceFactory( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir    com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> xMSch;
91cdf0e10cSrcweir    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xComponentContext;
92cdf0e10cSrcweir            xComponentContext = cppu::defaultBootstrap_InitialComponentContext();
93cdf0e10cSrcweir        xMSch.set(xComponentContext->getServiceManager(), com::sun::star::uno::UNO_QUERY);
94cdf0e10cSrcweir        comphelper::setProcessServiceFactory(xMSch);
95cdf0e10cSrcweir 
96cdf0e10cSrcweir //    comphelper::setProcessServiceFactory( xMS);
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     InitVCL( xMS );
99cdf0e10cSrcweir     ::Main();
100cdf0e10cSrcweir     DeInitVCL();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     return 0;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir // -----------------------------------------------------------------------
106cdf0e10cSrcweir 
107cdf0e10cSrcweir class MyWin : public WorkWindow
108cdf0e10cSrcweir {
109cdf0e10cSrcweir public:
110cdf0e10cSrcweir                 MyWin( Window* pParent, WinBits nWinStyle );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     void        MouseMove( const MouseEvent& rMEvt );
113cdf0e10cSrcweir     void        MouseButtonDown( const MouseEvent& rMEvt );
114cdf0e10cSrcweir     void        MouseButtonUp( const MouseEvent& rMEvt );
115cdf0e10cSrcweir     void        KeyInput( const KeyEvent& rKEvt );
116cdf0e10cSrcweir     void        KeyUp( const KeyEvent& rKEvt );
117cdf0e10cSrcweir     void        Paint( const Rectangle& rRect );
118cdf0e10cSrcweir     void        Resize();
119cdf0e10cSrcweir 
120cdf0e10cSrcweir private:
121cdf0e10cSrcweir     OKButton    aOKBtn;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir                     DECL_LINK( Test, PushButton* );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir };
126cdf0e10cSrcweir 
127cdf0e10cSrcweir // -----------------------------------------------------------------------
128cdf0e10cSrcweir 
Main()129cdf0e10cSrcweir void Main()
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
132cdf0e10cSrcweir     aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCL - Workbench" ) ) );
133cdf0e10cSrcweir     aMainWin.Show();
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     Application::Execute();
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // -----------------------------------------------------------------------
139cdf0e10cSrcweir 
MyWin(Window * pParent,WinBits nWinStyle)140cdf0e10cSrcweir MyWin::MyWin( Window* pParent, WinBits nWinStyle )
141cdf0e10cSrcweir     :WorkWindow( pParent, nWinStyle )
142cdf0e10cSrcweir     ,aOKBtn(this)
143cdf0e10cSrcweir {
144cdf0e10cSrcweir     aOKBtn.SetPosSizePixel( Point( 10, 10 ), Size( 140, 140 ) );
145cdf0e10cSrcweir     aOKBtn.SetClickHdl( LINK( this, MyWin, Test ) );
146cdf0e10cSrcweir     aOKBtn.Show();
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // -----------------------------------------------------------------------
150cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)151cdf0e10cSrcweir void MyWin::MouseMove( const MouseEvent& rMEvt )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir     WorkWindow::MouseMove( rMEvt );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir // -----------------------------------------------------------------------
157cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)158cdf0e10cSrcweir void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir     WorkWindow::MouseButtonDown( rMEvt );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir // -----------------------------------------------------------------------
164cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)165cdf0e10cSrcweir void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     WorkWindow::MouseButtonUp( rMEvt );
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir // -----------------------------------------------------------------------
171cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvt)172cdf0e10cSrcweir void MyWin::KeyInput( const KeyEvent& rKEvt )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     WorkWindow::KeyInput( rKEvt );
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir // -----------------------------------------------------------------------
178cdf0e10cSrcweir 
KeyUp(const KeyEvent & rKEvt)179cdf0e10cSrcweir void MyWin::KeyUp( const KeyEvent& rKEvt )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     WorkWindow::KeyUp( rKEvt );
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir // -----------------------------------------------------------------------
185cdf0e10cSrcweir 
Paint(const Rectangle & rRect)186cdf0e10cSrcweir void MyWin::Paint( const Rectangle& rRect )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     WorkWindow::Paint( rRect );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir // -----------------------------------------------------------------------
192cdf0e10cSrcweir 
Resize()193cdf0e10cSrcweir void MyWin::Resize()
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     WorkWindow::Resize();
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir // -----------------------------------------------------------------------
199cdf0e10cSrcweir 
IMPL_LINK(MyWin,Test,PushButton *,pBtn)200cdf0e10cSrcweir IMPL_LINK( MyWin, Test, PushButton*, pBtn )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir printf("Test\n");
203cdf0e10cSrcweir     if ( pBtn == &aOKBtn )
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir         SvtFileDialog* pDlg = new SvtFileDialog( this,SFXWB_PATHDIALOG);
206cdf0e10cSrcweir         pDlg->Execute();
207cdf0e10cSrcweir         delete pDlg;
208cdf0e10cSrcweir         printf("ok\n");
209cdf0e10cSrcweir     }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     return 0;
212cdf0e10cSrcweir }
213