15900e8ecSAndrew Rist /**************************************************************
25900e8ecSAndrew Rist  *
35900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55900e8ecSAndrew Rist  * distributed with this work for additional information
65900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
105900e8ecSAndrew Rist  *
115900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125900e8ecSAndrew Rist  *
135900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist  * software distributed under the License is distributed on an
155900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
175900e8ecSAndrew Rist  * specific language governing permissions and limitations
185900e8ecSAndrew Rist  * under the License.
195900e8ecSAndrew Rist  *
205900e8ecSAndrew Rist  *************************************************************/
215900e8ecSAndrew Rist 
225900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_svtools.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "../unowizard.hxx"
27cdf0e10cSrcweir #include "wizardshell.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir /** === begin UNO includes === **/
30cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
31cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
32cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
33cdf0e10cSrcweir #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
34cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XWizardController.hpp>
35cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/WizardButton.hpp>
36cdf0e10cSrcweir /** === end UNO includes === **/
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <tools/diagnose_ex.h>
39cdf0e10cSrcweir #include <rtl/strbuf.hxx>
40cdf0e10cSrcweir #include <vos/mutex.hxx>
41cdf0e10cSrcweir #include <vcl/svapp.hxx>
42cdf0e10cSrcweir #include <tools/urlobj.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir //......................................................................................................................
45cdf0e10cSrcweir namespace svt { namespace uno
46cdf0e10cSrcweir {
47cdf0e10cSrcweir //......................................................................................................................
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	/** === begin UNO using === **/
50cdf0e10cSrcweir 	using ::com::sun::star::uno::Reference;
51cdf0e10cSrcweir 	using ::com::sun::star::uno::XInterface;
52cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_QUERY;
53cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_QUERY_THROW;
54cdf0e10cSrcweir 	using ::com::sun::star::uno::UNO_SET_THROW;
55cdf0e10cSrcweir 	using ::com::sun::star::uno::Exception;
56cdf0e10cSrcweir 	using ::com::sun::star::uno::RuntimeException;
57cdf0e10cSrcweir 	using ::com::sun::star::uno::Any;
58cdf0e10cSrcweir 	using ::com::sun::star::uno::makeAny;
59cdf0e10cSrcweir 	using ::com::sun::star::uno::Sequence;
60cdf0e10cSrcweir 	using ::com::sun::star::uno::Type;
61cdf0e10cSrcweir     using ::com::sun::star::lang::XServiceInfo;
62cdf0e10cSrcweir     using ::com::sun::star::ui::dialogs::XWizard;
63cdf0e10cSrcweir     using ::com::sun::star::lang::XInitialization;
64cdf0e10cSrcweir     using ::com::sun::star::beans::XPropertySetInfo;
65cdf0e10cSrcweir     using ::com::sun::star::uno::XComponentContext;
66cdf0e10cSrcweir     using ::com::sun::star::beans::Property;
67cdf0e10cSrcweir     using ::com::sun::star::lang::IllegalArgumentException;
68cdf0e10cSrcweir     using ::com::sun::star::ucb::AlreadyInitializedException;
69cdf0e10cSrcweir     using ::com::sun::star::ui::dialogs::XWizardController;
70cdf0e10cSrcweir     using ::com::sun::star::ui::dialogs::XWizardPage;
71cdf0e10cSrcweir     using ::com::sun::star::container::NoSuchElementException;
72cdf0e10cSrcweir     using ::com::sun::star::util::InvalidStateException;
73cdf0e10cSrcweir     using ::com::sun::star::awt::XWindow;
74cdf0e10cSrcweir 	/** === end UNO using === **/
75cdf0e10cSrcweir     namespace WizardButton = ::com::sun::star::ui::dialogs::WizardButton;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	//------------------------------------------------------------------------------------------------------------------
78cdf0e10cSrcweir     namespace
79cdf0e10cSrcweir     {
lcl_convertWizardButtonToWZB(const sal_Int16 i_nWizardButton)80cdf0e10cSrcweir         sal_uInt32 lcl_convertWizardButtonToWZB( const sal_Int16 i_nWizardButton )
81cdf0e10cSrcweir         {
82cdf0e10cSrcweir             switch ( i_nWizardButton )
83cdf0e10cSrcweir             {
84cdf0e10cSrcweir             case WizardButton::NONE:        return WZB_NONE;
85cdf0e10cSrcweir             case WizardButton::NEXT:        return WZB_NEXT;
86cdf0e10cSrcweir             case WizardButton::PREVIOUS:    return WZB_PREVIOUS;
87cdf0e10cSrcweir             case WizardButton::FINISH:      return WZB_FINISH;
88cdf0e10cSrcweir             case WizardButton::CANCEL:      return WZB_CANCEL;
89cdf0e10cSrcweir             case WizardButton::HELP:        return WZB_HELP;
90cdf0e10cSrcweir             }
91cdf0e10cSrcweir             OSL_ENSURE( false, "lcl_convertWizardButtonToWZB: invalid WizardButton constant!" );
92cdf0e10cSrcweir             return WZB_NONE;
93cdf0e10cSrcweir         }
94cdf0e10cSrcweir     }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	//==================================================================================================================
97cdf0e10cSrcweir 	//= Wizard - implementation
98cdf0e10cSrcweir 	//==================================================================================================================
99cdf0e10cSrcweir 	//------------------------------------------------------------------------------------------------------------------
Wizard(const Reference<XComponentContext> & _rxContext)100cdf0e10cSrcweir     Wizard::Wizard( const Reference< XComponentContext >& _rxContext )
101cdf0e10cSrcweir         :Wizard_Base( _rxContext )
102cdf0e10cSrcweir         ,m_aContext( _rxContext )
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     //--------------------------------------------------------------------
~Wizard()107cdf0e10cSrcweir     Wizard::~Wizard()
108cdf0e10cSrcweir     {
109cdf0e10cSrcweir         // we do this here cause the base class' call to destroyDialog won't reach us anymore : we're within an dtor,
110cdf0e10cSrcweir         // so this virtual-method-call the base class does does not work, we're already dead then ...
111cdf0e10cSrcweir         if ( m_pDialog )
112cdf0e10cSrcweir         {
113cdf0e10cSrcweir             ::osl::MutexGuard aGuard( m_aMutex );
114cdf0e10cSrcweir             if ( m_pDialog )
115cdf0e10cSrcweir                 destroyDialog();
116cdf0e10cSrcweir         }
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     //--------------------------------------------------------------------
Create(const Reference<XComponentContext> & _rxContext)120cdf0e10cSrcweir     Reference< XInterface > SAL_CALL Wizard::Create( const Reference< XComponentContext >& _rxContext )
121cdf0e10cSrcweir     {
122cdf0e10cSrcweir         return *(new Wizard( _rxContext ) );
123cdf0e10cSrcweir     }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     //--------------------------------------------------------------------
126cdf0e10cSrcweir     namespace
127cdf0e10cSrcweir     {
lcl_checkPaths(const Sequence<Sequence<sal_Int16>> & i_rPaths,const Reference<XInterface> & i_rContext)128cdf0e10cSrcweir         static void lcl_checkPaths( const Sequence< Sequence< sal_Int16 > >& i_rPaths, const Reference< XInterface >& i_rContext )
129cdf0e10cSrcweir         {
130cdf0e10cSrcweir             // need at least one path
131cdf0e10cSrcweir             if ( i_rPaths.getLength() == 0 )
132cdf0e10cSrcweir                 throw IllegalArgumentException( ::rtl::OUString(), i_rContext, 2 );
133cdf0e10cSrcweir 
134cdf0e10cSrcweir             // each path must be of length 1, at least
135cdf0e10cSrcweir             for ( sal_Int32 i = 0; i < i_rPaths.getLength(); ++i )
136cdf0e10cSrcweir             {
137cdf0e10cSrcweir                 if ( i_rPaths[i].getLength() == 0 )
138cdf0e10cSrcweir                     throw IllegalArgumentException( ::rtl::OUString(), i_rContext, 2 );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir                 // page IDs must be in ascending order
141cdf0e10cSrcweir                 sal_Int16 nPreviousPageID = i_rPaths[i][0];
142cdf0e10cSrcweir                 for ( sal_Int32 j=1; j<i_rPaths[i].getLength(); ++j )
143cdf0e10cSrcweir                 {
144cdf0e10cSrcweir                     if ( i_rPaths[i][j] <= nPreviousPageID )
145cdf0e10cSrcweir                     {
146cdf0e10cSrcweir                         ::rtl::OStringBuffer message;
147cdf0e10cSrcweir                         message.append( "Path " );
148cdf0e10cSrcweir                         message.append( i );
149cdf0e10cSrcweir                         message.append( ": invalid page ID sequence - each page ID must be greater than the previous one." );
150cdf0e10cSrcweir                         throw IllegalArgumentException(
151cdf0e10cSrcweir                             ::rtl::OStringToOUString( message.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ),
152cdf0e10cSrcweir                             i_rContext, 2 );
153cdf0e10cSrcweir                     }
154cdf0e10cSrcweir                     nPreviousPageID = i_rPaths[i][j];
155cdf0e10cSrcweir                 }
156cdf0e10cSrcweir             }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir             // if we have one path, that's okay
159cdf0e10cSrcweir             if ( i_rPaths.getLength() == 1 )
160cdf0e10cSrcweir                 return;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir             // if we have multiple paths, they must start with the same page id
163cdf0e10cSrcweir             const sal_Int16 nFirstPageId = i_rPaths[0][0];
164cdf0e10cSrcweir             for ( sal_Int32 i = 0; i < i_rPaths.getLength(); ++i )
165cdf0e10cSrcweir             {
166cdf0e10cSrcweir                 if ( i_rPaths[i][0] != nFirstPageId )
167cdf0e10cSrcweir                     throw IllegalArgumentException(
168cdf0e10cSrcweir                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "All paths must start with the same page id." ) ),
169cdf0e10cSrcweir                         i_rContext, 2 );
170cdf0e10cSrcweir             }
171cdf0e10cSrcweir         }
172cdf0e10cSrcweir     }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     //--------------------------------------------------------------------
initialize(const Sequence<Any> & i_Arguments)175cdf0e10cSrcweir     void SAL_CALL Wizard::initialize( const Sequence< Any >& i_Arguments ) throw (Exception, RuntimeException)
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
178cdf0e10cSrcweir         if ( m_bInitialized )
179cdf0e10cSrcweir             throw AlreadyInitializedException( ::rtl::OUString(), *this );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir         if ( i_Arguments.getLength() != 2 )
182cdf0e10cSrcweir             throw IllegalArgumentException( ::rtl::OUString(), *this, -1 );
183cdf0e10cSrcweir 
184cdf0e10cSrcweir         // the second argument must be a XWizardController, for each constructor
185cdf0e10cSrcweir         m_xController.set( i_Arguments[1], UNO_QUERY );
186cdf0e10cSrcweir         if ( !m_xController.is() )
187cdf0e10cSrcweir             throw IllegalArgumentException( ::rtl::OUString(), *this, 2 );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir         // the first arg is either a single path (short[]), or multiple paths (short[][])
190cdf0e10cSrcweir         Sequence< sal_Int16 > aSinglePath;
191cdf0e10cSrcweir         i_Arguments[0] >>= aSinglePath;
192cdf0e10cSrcweir         Sequence< Sequence< sal_Int16 > > aMultiplePaths;
193cdf0e10cSrcweir         i_Arguments[0] >>= aMultiplePaths;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir         if ( !aMultiplePaths.getLength() )
196cdf0e10cSrcweir         {
197cdf0e10cSrcweir             aMultiplePaths.realloc(1);
198cdf0e10cSrcweir             aMultiplePaths[0] = aSinglePath;
199cdf0e10cSrcweir         }
200cdf0e10cSrcweir         lcl_checkPaths( aMultiplePaths, *this );
201cdf0e10cSrcweir         // if we survived this, the paths are valid, and we're done here ...
202cdf0e10cSrcweir         m_aWizardSteps = aMultiplePaths;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir         m_bInitialized = true;
205cdf0e10cSrcweir     }
206cdf0e10cSrcweir 
lcl_getHelpId(const::rtl::OUString & _rHelpURL)207cdf0e10cSrcweir 	static rtl::OString lcl_getHelpId( const ::rtl::OUString& _rHelpURL )
208cdf0e10cSrcweir     {
209cdf0e10cSrcweir         INetURLObject aHID( _rHelpURL );
210cdf0e10cSrcweir         if ( aHID.GetProtocol() == INET_PROT_HID )
211cdf0e10cSrcweir             return rtl::OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 );
212cdf0e10cSrcweir         else
213cdf0e10cSrcweir             return rtl::OUStringToOString( _rHelpURL, RTL_TEXTENCODING_UTF8 );
214cdf0e10cSrcweir     }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	//------------------------------------------------------------------------
lcl_getHelpURL(const rtl::OString & sHelpId)217cdf0e10cSrcweir     static ::rtl::OUString lcl_getHelpURL( const rtl::OString& sHelpId )
218cdf0e10cSrcweir     {
219cdf0e10cSrcweir         ::rtl::OUStringBuffer aBuffer;
22024c56ab9SHerbert Dürr         ::rtl::OUString aTmp( OStringToOUString( sHelpId, RTL_TEXTENCODING_UTF8 ));
221cdf0e10cSrcweir         INetURLObject aHID( aTmp );
222cdf0e10cSrcweir         if ( aHID.GetProtocol() == INET_PROT_NOT_VALID )
223cdf0e10cSrcweir             aBuffer.appendAscii( INET_HID_SCHEME );
224cdf0e10cSrcweir         aBuffer.append( aTmp.getStr() );
225cdf0e10cSrcweir         return aBuffer.makeStringAndClear();
226cdf0e10cSrcweir     }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     //--------------------------------------------------------------------
createDialog(Window * i_pParent)229cdf0e10cSrcweir 	Dialog*	Wizard::createDialog( Window* i_pParent )
230cdf0e10cSrcweir     {
231*89763fdbSAriel Constenla-Haile         WizardShell* pDialog( new WizardShell( i_pParent, m_xController, m_aWizardSteps ) );
232cdf0e10cSrcweir         pDialog->SetHelpId(  lcl_getHelpId( m_sHelpURL ) );
233cdf0e10cSrcweir         pDialog->setTitleBase( m_sTitle );
234cdf0e10cSrcweir         return pDialog;
235cdf0e10cSrcweir     }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     //--------------------------------------------------------------------
destroyDialog()238cdf0e10cSrcweir     void Wizard::destroyDialog()
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         if ( m_pDialog )
241cdf0e10cSrcweir             m_sHelpURL = lcl_getHelpURL( m_pDialog->GetHelpId() );
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	    Wizard_Base::destroyDialog();
244cdf0e10cSrcweir     }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     //--------------------------------------------------------------------
getImplementationName_static()247cdf0e10cSrcweir     ::rtl::OUString SAL_CALL Wizard::getImplementationName_static() throw(RuntimeException)
248cdf0e10cSrcweir     {
249cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.uno.Wizard" ) );
250cdf0e10cSrcweir     }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     //--------------------------------------------------------------------
getSupportedServiceNames_static()253cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL Wizard::getSupportedServiceNames_static() throw(RuntimeException)
254cdf0e10cSrcweir     {
255cdf0e10cSrcweir         Sequence< ::rtl::OUString > aServices(1);
256cdf0e10cSrcweir         aServices[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.Wizard" ) );
257cdf0e10cSrcweir         return aServices;
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     //--------------------------------------------------------------------
getImplementationName()261cdf0e10cSrcweir     ::rtl::OUString SAL_CALL Wizard::getImplementationName() throw(RuntimeException)
262cdf0e10cSrcweir     {
263cdf0e10cSrcweir         return getImplementationName_static();
264cdf0e10cSrcweir     }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     //--------------------------------------------------------------------
getSupportedServiceNames()267cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL Wizard::getSupportedServiceNames() throw(RuntimeException)
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         return getSupportedServiceNames_static();
270cdf0e10cSrcweir     }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir     //--------------------------------------------------------------------
getPropertySetInfo()273cdf0e10cSrcweir 	Reference< XPropertySetInfo > SAL_CALL Wizard::getPropertySetInfo() throw(RuntimeException)
274cdf0e10cSrcweir     {
275cdf0e10cSrcweir 	    return createPropertySetInfo( getInfoHelper() );
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     //--------------------------------------------------------------------
getInfoHelper()279cdf0e10cSrcweir 	::cppu::IPropertyArrayHelper& SAL_CALL Wizard::getInfoHelper()
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir     	return *const_cast< Wizard* >( this )->getArrayHelper();
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     //--------------------------------------------------------------------
createArrayHelper() const285cdf0e10cSrcweir 	::cppu::IPropertyArrayHelper* Wizard::createArrayHelper( ) const
286cdf0e10cSrcweir     {
287cdf0e10cSrcweir 	    Sequence< Property > aProps;
288cdf0e10cSrcweir 	    describeProperties( aProps );
289cdf0e10cSrcweir 	    return new ::cppu::OPropertyArrayHelper( aProps );
290cdf0e10cSrcweir     }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getHelpURL()293cdf0e10cSrcweir     ::rtl::OUString SAL_CALL Wizard::getHelpURL() throw (RuntimeException)
294cdf0e10cSrcweir     {
295cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
296cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
297cdf0e10cSrcweir 
298cdf0e10cSrcweir         if ( !m_pDialog )
299cdf0e10cSrcweir             return m_sHelpURL;
300cdf0e10cSrcweir 
301cdf0e10cSrcweir         return lcl_getHelpURL( m_pDialog->GetHelpId() );
302cdf0e10cSrcweir     }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
setHelpURL(const::rtl::OUString & i_HelpURL)305cdf0e10cSrcweir     void SAL_CALL Wizard::setHelpURL( const ::rtl::OUString& i_HelpURL ) throw (RuntimeException)
306cdf0e10cSrcweir     {
307cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
308cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
309cdf0e10cSrcweir 
310cdf0e10cSrcweir         if ( !m_pDialog )
311cdf0e10cSrcweir             m_sHelpURL = i_HelpURL;
312cdf0e10cSrcweir         else
313cdf0e10cSrcweir             m_pDialog->SetHelpId( lcl_getHelpId( i_HelpURL ) );
314cdf0e10cSrcweir     }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getDialogWindow()317cdf0e10cSrcweir     Reference< XWindow > SAL_CALL Wizard::getDialogWindow() throw (RuntimeException)
318cdf0e10cSrcweir     {
319cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
320cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
321cdf0e10cSrcweir 
322cdf0e10cSrcweir         ENSURE_OR_RETURN( m_pDialog, "Wizard::getDialogWindow: illegal call (execution did not start, yet)!", NULL );
323cdf0e10cSrcweir         return Reference< XWindow >( m_pDialog->GetComponentInterface(), UNO_QUERY );
324cdf0e10cSrcweir     }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
enableButton(::sal_Int16 i_WizardButton,::sal_Bool i_Enable)327cdf0e10cSrcweir     void SAL_CALL Wizard::enableButton( ::sal_Int16 i_WizardButton, ::sal_Bool i_Enable ) throw (RuntimeException)
328cdf0e10cSrcweir     {
329cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
330cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
331cdf0e10cSrcweir 
332cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
333cdf0e10cSrcweir         ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::enableButtons: invalid dialog implementation!" );
334cdf0e10cSrcweir 
335cdf0e10cSrcweir         pWizardImpl->enableButtons( lcl_convertWizardButtonToWZB( i_WizardButton ), i_Enable );
336cdf0e10cSrcweir     }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
setDefaultButton(::sal_Int16 i_WizardButton)339cdf0e10cSrcweir     void SAL_CALL Wizard::setDefaultButton( ::sal_Int16 i_WizardButton ) throw (RuntimeException)
340cdf0e10cSrcweir     {
341cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
342cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
343cdf0e10cSrcweir 
344cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
345cdf0e10cSrcweir         ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::setDefaultButton: invalid dialog implementation!" );
346cdf0e10cSrcweir 
347cdf0e10cSrcweir         pWizardImpl->defaultButton( lcl_convertWizardButtonToWZB( i_WizardButton ) );
348cdf0e10cSrcweir     }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
travelNext()351cdf0e10cSrcweir     sal_Bool SAL_CALL Wizard::travelNext(  ) throw (RuntimeException)
352cdf0e10cSrcweir     {
353cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
354cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
355cdf0e10cSrcweir 
356cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
357cdf0e10cSrcweir         ENSURE_OR_RETURN_FALSE( pWizardImpl, "Wizard::travelNext: invalid dialog implementation!" );
358cdf0e10cSrcweir 
359cdf0e10cSrcweir         return pWizardImpl->travelNext();
360cdf0e10cSrcweir     }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
travelPrevious()363cdf0e10cSrcweir     sal_Bool SAL_CALL Wizard::travelPrevious(  ) throw (RuntimeException)
364cdf0e10cSrcweir     {
365cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
366cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
367cdf0e10cSrcweir 
368cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
369cdf0e10cSrcweir         ENSURE_OR_RETURN_FALSE( pWizardImpl, "Wizard::travelPrevious: invalid dialog implementation!" );
370cdf0e10cSrcweir 
371cdf0e10cSrcweir         return pWizardImpl->travelPrevious();
372cdf0e10cSrcweir     }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
enablePage(::sal_Int16 i_PageID,::sal_Bool i_Enable)375cdf0e10cSrcweir     void SAL_CALL Wizard::enablePage( ::sal_Int16 i_PageID, ::sal_Bool i_Enable ) throw (NoSuchElementException, InvalidStateException, RuntimeException)
376cdf0e10cSrcweir     {
377cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
378cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
379cdf0e10cSrcweir 
380cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
381cdf0e10cSrcweir         ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::enablePage: invalid dialog implementation!" );
382cdf0e10cSrcweir 
383cdf0e10cSrcweir         if ( !pWizardImpl->knowsPage( i_PageID ) )
384cdf0e10cSrcweir             throw NoSuchElementException( ::rtl::OUString(), *this );
385cdf0e10cSrcweir 
386cdf0e10cSrcweir         if ( i_PageID == pWizardImpl->getCurrentPage() )
387cdf0e10cSrcweir             throw InvalidStateException( ::rtl::OUString(), *this );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir         pWizardImpl->enablePage( i_PageID, i_Enable );
390cdf0e10cSrcweir     }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
updateTravelUI()393cdf0e10cSrcweir     void SAL_CALL Wizard::updateTravelUI(  ) throw (RuntimeException)
394cdf0e10cSrcweir     {
395cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
396cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
397cdf0e10cSrcweir 
398cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
399cdf0e10cSrcweir         ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::updateTravelUI: invalid dialog implementation!" );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir         pWizardImpl->updateTravelUI();
402cdf0e10cSrcweir     }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
advanceTo(::sal_Int16 i_PageId)405cdf0e10cSrcweir     ::sal_Bool SAL_CALL Wizard::advanceTo( ::sal_Int16 i_PageId ) throw (RuntimeException)
406cdf0e10cSrcweir     {
407cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
408cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
409cdf0e10cSrcweir 
410cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
411cdf0e10cSrcweir         ENSURE_OR_RETURN_FALSE( pWizardImpl, "Wizard::advanceTo: invalid dialog implementation!" );
412cdf0e10cSrcweir 
413cdf0e10cSrcweir         return pWizardImpl->advanceTo( i_PageId );
414cdf0e10cSrcweir     }
415cdf0e10cSrcweir 
416cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
goBackTo(::sal_Int16 i_PageId)417cdf0e10cSrcweir     ::sal_Bool SAL_CALL Wizard::goBackTo( ::sal_Int16 i_PageId ) throw (RuntimeException)
418cdf0e10cSrcweir     {
419cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
420cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
421cdf0e10cSrcweir 
422cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
423cdf0e10cSrcweir         ENSURE_OR_RETURN_FALSE( pWizardImpl, "Wizard::goBackTo: invalid dialog implementation!" );
424cdf0e10cSrcweir 
425cdf0e10cSrcweir         return pWizardImpl->goBackTo( i_PageId );
426cdf0e10cSrcweir     }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
getCurrentPage()429cdf0e10cSrcweir     Reference< XWizardPage > SAL_CALL Wizard::getCurrentPage(  ) throw (RuntimeException)
430cdf0e10cSrcweir     {
431cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
432cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
433cdf0e10cSrcweir 
434cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
435cdf0e10cSrcweir         ENSURE_OR_RETURN( pWizardImpl, "Wizard::getCurrentPage: invalid dialog implementation!", Reference< XWizardPage >() );
436cdf0e10cSrcweir 
437cdf0e10cSrcweir         return pWizardImpl->getCurrentWizardPage();
438cdf0e10cSrcweir     }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
activatePath(::sal_Int16 i_PathIndex,::sal_Bool i_Final)441cdf0e10cSrcweir     void SAL_CALL Wizard::activatePath( ::sal_Int16 i_PathIndex, ::sal_Bool i_Final ) throw (NoSuchElementException, InvalidStateException, RuntimeException)
442cdf0e10cSrcweir     {
443cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
444cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
445cdf0e10cSrcweir 
446cdf0e10cSrcweir         if ( ( i_PathIndex < 0 ) || ( i_PathIndex >= m_aWizardSteps.getLength() ) )
447cdf0e10cSrcweir             throw NoSuchElementException( ::rtl::OUString(), *this );
448cdf0e10cSrcweir 
449cdf0e10cSrcweir         WizardShell* pWizardImpl = dynamic_cast< WizardShell* >( m_pDialog );
450cdf0e10cSrcweir         ENSURE_OR_RETURN_VOID( pWizardImpl, "Wizard::activatePath: invalid dialog implementation!" );
451cdf0e10cSrcweir 
452cdf0e10cSrcweir         pWizardImpl->activatePath( i_PathIndex, i_Final );
453cdf0e10cSrcweir     }
454cdf0e10cSrcweir 
455cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
setTitle(const::rtl::OUString & i_Title)456cdf0e10cSrcweir     void SAL_CALL Wizard::setTitle( const ::rtl::OUString& i_Title ) throw (RuntimeException)
457cdf0e10cSrcweir     {
458cdf0e10cSrcweir         // simply disambiguate
459cdf0e10cSrcweir         Wizard_Base::OGenericUnoDialog::setTitle( i_Title );
460cdf0e10cSrcweir     }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir     //------------------------------------------------------------------------------------------------------------------
execute()463cdf0e10cSrcweir     ::sal_Int16 SAL_CALL Wizard::execute(  ) throw (RuntimeException)
464cdf0e10cSrcweir     {
465cdf0e10cSrcweir         return Wizard_Base::OGenericUnoDialog::execute();
466cdf0e10cSrcweir     }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir //......................................................................................................................
469cdf0e10cSrcweir } } // namespace svt::uno
470cdf0e10cSrcweir //......................................................................................................................
471