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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_cui.hxx"
24
25 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
26 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
27 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
28 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <comphelper/processfactory.hxx>
32 #include <com/sun/star/embed/EmbedStates.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <com/sun/star/embed/XInsertObjectDialog.hpp>
36 #include <com/sun/star/ucb/CommandAbortedException.hpp>
37 #include <com/sun/star/task/XInteractionHandler.hpp>
38
39 #include "insdlg.hxx"
40 #include <dialmgr.hxx>
41 #include <svtools/sores.hxx>
42
43 #include <stdio.h>
44 #include <tools/urlobj.hxx>
45 #include <tools/debug.hxx>
46 #include <svl/urihelper.hxx>
47 #include <svtools/svmedit.hxx>
48 #include <vcl/button.hxx>
49 #include <vcl/fixed.hxx>
50 #include <vcl/group.hxx>
51 #include <vcl/lstbox.hxx>
52 #include <vcl/msgbox.hxx>
53 #include <vcl/svapp.hxx>
54 #include <sot/clsids.hxx>
55 #include <sfx2/frmdescr.hxx>
56 #include <sfx2/viewsh.hxx>
57 #include <sfx2/filedlghelper.hxx>
58 #include <svl/ownlist.hxx>
59 #include <comphelper/seqstream.hxx>
60
61 #include "svuidlg.hrc"
62
63 #include <osl/file.hxx>
64
65 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
66 #include <com/sun/star/container/XNameAccess.hpp>
67 #include <unotools/processfactory.hxx>
68
69 using namespace ::com::sun::star;
70 using namespace ::com::sun::star::lang;
71 using namespace ::com::sun::star::uno;
72 using namespace ::com::sun::star::container;
73 using namespace ::com::sun::star::ui::dialogs;
74 using ::rtl::OUString;
75
76 #define _SVSTDARR_STRINGSDTOR
77 #include <svl/svstdarr.hxx>
78
79
impl_getSvtResString(sal_uInt32 nId)80 static String impl_getSvtResString( sal_uInt32 nId )
81 {
82 String aRet;
83 com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
84 ResMgr* pMgr = ResMgr::CreateResMgr( "svt", aLocale );
85 if( pMgr )
86 {
87 aRet = String( ResId( nId, *pMgr ) );
88 delete pMgr;
89 }
90 return aRet;
91 }
92
IsCreateNew() const93 sal_Bool InsertObjectDialog_Impl::IsCreateNew() const
94 {
95 return sal_False;
96 }
97
GetIconIfIconified(::rtl::OUString *)98 uno::Reference< io::XInputStream > InsertObjectDialog_Impl::GetIconIfIconified( ::rtl::OUString* /*pGraphicMediaType*/ )
99 {
100 return uno::Reference< io::XInputStream >();
101 }
102
InsertObjectDialog_Impl(Window * pParent,const ResId & rResId,const com::sun::star::uno::Reference<com::sun::star::embed::XStorage> & xStorage)103 InsertObjectDialog_Impl::InsertObjectDialog_Impl( Window * pParent, const ResId & rResId, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage )
104 : ModalDialog( pParent, rResId )
105 , m_xStorage( xStorage )
106 , aCnt( m_xStorage )
107 {
108 }
109
110 // -----------------------------------------------------------------------
111
IMPL_LINK_INLINE_START(SvInsertOleDlg,DoubleClickHdl,ListBox *,EMPTYARG)112 IMPL_LINK_INLINE_START( SvInsertOleDlg, DoubleClickHdl, ListBox *, EMPTYARG )
113 {
114 EndDialog( RET_OK );
115 return 0;
116 }
IMPL_LINK_INLINE_END(SvInsertOleDlg,DoubleClickHdl,ListBox *,pListBox)117 IMPL_LINK_INLINE_END( SvInsertOleDlg, DoubleClickHdl, ListBox *, pListBox )
118
119 // -----------------------------------------------------------------------
120
121 IMPL_LINK( SvInsertOleDlg, BrowseHdl, PushButton *, EMPTYARG )
122 {
123 Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
124 if( xFactory.is() )
125 {
126 Reference< XFilePicker > xFilePicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ), UNO_QUERY );
127 DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
128
129 Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
130 Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
131 if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
132 {
133 Sequence< Any > aServiceType( 1 );
134 aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
135 xInit->initialize( aServiceType );
136
137 // add filter
138 try
139 {
140 xFilterMgr->appendFilter(
141 OUString(),
142 OUString( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) )
143 );
144 }
145 catch( IllegalArgumentException& )
146 {
147 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
148 }
149
150 if( xFilePicker->execute() == ExecutableDialogResults::OK )
151 {
152 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
153 INetURLObject aObj( aPathSeq[0] );
154 aEdFilepath.SetText( aObj.PathToFileName() );
155 }
156 }
157 }
158
159 return 0;
160 }
161
162 // -----------------------------------------------------------------------
163
IMPL_LINK(SvInsertOleDlg,RadioHdl,RadioButton *,EMPTYARG)164 IMPL_LINK( SvInsertOleDlg, RadioHdl, RadioButton *, EMPTYARG )
165 {
166 if ( aRbNewObject.IsChecked() )
167 {
168 aLbObjecttype.Show();
169 aEdFilepath.Hide();
170 aBtnFilepath.Hide();
171 aCbFilelink.Hide();
172 aGbObject.SetText( _aOldStr );
173 }
174 else
175 {
176 aCbFilelink.Show();
177 aLbObjecttype.Hide();
178 aEdFilepath.Show();
179 aBtnFilepath.Show();
180 aCbFilelink.Show();
181 aGbObject.SetText( aStrFile );
182 }
183 return 0;
184 }
185
186 // -----------------------------------------------------------------------
187
SelectDefault()188 void SvInsertOleDlg::SelectDefault()
189 {
190 aLbObjecttype.SelectEntryPos( 0 );
191 }
192
193 // -----------------------------------------------------------------------
SvInsertOleDlg(Window * pParent,const Reference<embed::XStorage> & xStorage,const SvObjectServerList * pServers)194 SvInsertOleDlg::SvInsertOleDlg
195 (
196 Window* pParent,
197 const Reference < embed::XStorage >& xStorage,
198 const SvObjectServerList* pServers
199 )
200 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OLEOBJECT ), xStorage ),
201 aRbNewObject( this, CUI_RES( RB_NEW_OBJECT ) ),
202 aRbObjectFromfile( this, CUI_RES( RB_OBJECT_FROMFILE ) ),
203 aGbObject( this, CUI_RES( GB_OBJECT ) ),
204 aLbObjecttype( this, CUI_RES( LB_OBJECTTYPE ) ),
205 aEdFilepath( this, CUI_RES( ED_FILEPATH ) ),
206 aBtnFilepath( this, CUI_RES( BTN_FILEPATH ) ),
207 aCbFilelink( this, CUI_RES( CB_FILELINK ) ),
208 aOKButton1( this, CUI_RES( 1 ) ),
209 aCancelButton1( this, CUI_RES( 1 ) ),
210 aHelpButton1( this, CUI_RES( 1 ) ),
211 aStrFile( CUI_RES( STR_FILE ) ),
212 m_pServers( pServers )
213 {
214 FreeResource();
215 _aOldStr = aGbObject.GetText();
216 aLbObjecttype.SetDoubleClickHdl( LINK( this, SvInsertOleDlg, DoubleClickHdl ) );
217 aBtnFilepath.SetClickHdl( LINK( this, SvInsertOleDlg, BrowseHdl ) );
218 Link aLink( LINK( this, SvInsertOleDlg, RadioHdl ) );
219 aRbNewObject.SetClickHdl( aLink );
220 aRbObjectFromfile.SetClickHdl( aLink );
221 aRbNewObject.Check( sal_True );
222 RadioHdl( NULL );
223 aBtnFilepath.SetAccessibleRelationMemberOf(&aGbObject);
224 }
225
Execute()226 short SvInsertOleDlg::Execute()
227 {
228 short nRet = RET_OK;
229 SvObjectServerList aObjS;
230 if ( !m_pServers )
231 {
232 // if no list was provided, take the complete one
233 aObjS.FillInsertObjects();
234 m_pServers = &aObjS;
235 }
236
237 // fill listbox and select default
238 ListBox& rBox = GetObjectTypes();
239 rBox.SetUpdateMode( sal_False );
240 for ( sal_uLong i = 0; i < m_pServers->Count(); i++ )
241 rBox.InsertEntry( (*m_pServers)[i].GetHumanName() );
242 rBox.SetUpdateMode( sal_True );
243 SelectDefault();
244 ::rtl::OUString aName;
245
246 DBG_ASSERT( m_xStorage.is(), "No storage!");
247 if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
248 {
249 String aFileName;
250 sal_Bool bLink = sal_False;
251 sal_Bool bCreateNew = IsCreateNew();
252 if ( bCreateNew )
253 {
254 // create and insert new embedded object
255 String aServerName = rBox.GetSelectEntry();
256 const SvObjectServer* pS = m_pServers->Get( aServerName );
257 if ( pS )
258 {
259 if( pS->GetClassName() == SvGlobalName( SO3_OUT_CLASSID ) )
260 {
261 try
262 {
263 uno::Reference < embed::XInsertObjectDialog > xDialogCreator(
264 ::comphelper::getProcessServiceFactory()->createInstance(
265 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
266 uno::UNO_QUERY );
267
268 if ( xDialogCreator.is() )
269 {
270 aName = aCnt.CreateUniqueObjectName();
271 embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
272 m_xStorage,
273 aName,
274 uno::Sequence < beans::PropertyValue >() );
275
276 OSL_ENSURE( aNewInf.Object.is(), "The object must be created or an exception must be thrown!" );
277 m_xObj = aNewInf.Object;
278 for ( sal_Int32 nInd = 0; nInd < aNewInf.Options.getLength(); nInd++ )
279 if ( aNewInf.Options[nInd].Name.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Icon" ) ) ) )
280 {
281 aNewInf.Options[nInd].Value >>= m_aIconMetaFile;
282 }
283 else if ( aNewInf.Options[nInd].Name.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IconFormat" ) ) ) )
284 {
285 datatransfer::DataFlavor aFlavor;
286 if ( aNewInf.Options[nInd].Value >>= aFlavor )
287 m_aIconMediaType = aFlavor.MimeType;
288 }
289
290 }
291 }
292 catch( ucb::CommandAbortedException& )
293 {
294 // the user has pressed cancel
295 }
296 catch( uno::Exception& )
297 {
298 // TODO: Error handling
299 }
300 }
301 else
302 {
303 // create object with desired ClassId
304 m_xObj = aCnt.CreateEmbeddedObject( pS->GetClassName().GetByteSequence(), aName );
305 }
306
307 if ( !m_xObj.is() )
308 {
309 if( aFileName.Len() ) // from OLE Dialog
310 {
311 // Objekt konnte nicht aus Datei erzeugt werden
312 // global Resource from svtools (former so3 resource)
313 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_FROM_FILE ) );
314 aErr.SearchAndReplace( String( '%' ), aFileName );
315 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
316 }
317 else
318 {
319 // Objekt konnte nicht erzeugt werden
320 // global Resource from svtools (former so3 resource)
321 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE ) );
322 aErr.SearchAndReplace( String( '%' ), aServerName );
323 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
324 }
325 }
326 }
327 }
328 else
329 {
330 aFileName = GetFilePath();
331 INetURLObject aURL;
332 aURL.SetSmartProtocol( INET_PROT_FILE );
333 aURL.SetSmartURL( aFileName );
334 aFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
335 bLink = IsLinked();
336
337 if ( aFileName.Len() )
338 {
339 // create MediaDescriptor for file to create object from
340 uno::Sequence < beans::PropertyValue > aMedium( 2 );
341 aMedium[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
342 aMedium[0].Value <<= ::rtl::OUString( aFileName );
343
344 uno::Reference< task::XInteractionHandler > xInteraction;
345 uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
346 if ( xFactory.is() )
347 xInteraction = uno::Reference< task::XInteractionHandler >(
348 xFactory->createInstance(
349 DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ),
350 uno::UNO_QUERY_THROW );
351
352 if ( xInteraction.is() )
353 {
354 aMedium[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) );
355 aMedium[1].Value <<= xInteraction;
356 }
357 else
358 {
359 OSL_ASSERT( "Can not get InteractionHandler!\n" );
360 aMedium.realloc( 1 );
361 }
362
363 // create object from media descriptor
364 if ( bLink )
365 m_xObj = aCnt.InsertEmbeddedLink( aMedium, aName );
366 else
367 m_xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
368 }
369
370 if ( !m_xObj.is() )
371 {
372 // Objekt konnte nicht aus Datei erzeugt werden
373 // global Resource from svtools (former so3 resource)
374 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_FROM_FILE ) );
375 aErr.SearchAndReplace( String( '%' ), aFileName );
376 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
377 }
378 }
379 }
380
381 m_pServers = 0;
382 return nRet;
383 }
384
GetIconIfIconified(::rtl::OUString * pGraphicMediaType)385 uno::Reference< io::XInputStream > SvInsertOleDlg::GetIconIfIconified( ::rtl::OUString* pGraphicMediaType )
386 {
387 if ( m_aIconMetaFile.getLength() )
388 {
389 if ( pGraphicMediaType )
390 *pGraphicMediaType = m_aIconMediaType;
391
392 return uno::Reference< io::XInputStream >( new ::comphelper::SequenceInputStream( m_aIconMetaFile ) );
393 }
394
395 return uno::Reference< io::XInputStream >();
396 }
397
IMPL_LINK(SvInsertPlugInDialog,BrowseHdl,PushButton *,EMPTYARG)398 IMPL_LINK( SvInsertPlugInDialog, BrowseHdl, PushButton *, EMPTYARG )
399 {
400 Sequence< OUString > aFilterNames, aFilterTypes;
401 void fillNetscapePluginFilters( Sequence< OUString >& rNames, Sequence< OUString >& rTypes );
402 fillNetscapePluginFilters( aFilterNames, aFilterTypes );
403
404 Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
405 if( xFactory.is() )
406 {
407 Reference< XFilePicker > xFilePicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ), UNO_QUERY );
408 DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
409
410 Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
411 Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
412 if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
413 {
414 Sequence< Any > aServiceType( 1 );
415 aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
416 xInit->initialize( aServiceType );
417
418 // add the filters
419 try
420 {
421 const OUString* pNames = aFilterNames.getConstArray();
422 const OUString* pTypes = aFilterTypes.getConstArray();
423 for( int i = 0; i < aFilterNames.getLength(); i++ )
424 xFilterMgr->appendFilter( pNames[i], pTypes[i] );
425 }
426 catch( IllegalArgumentException& )
427 {
428 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
429 }
430
431 if( xFilePicker->execute() == ExecutableDialogResults::OK )
432 {
433 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
434 INetURLObject aObj( aPathSeq[0] );
435 aEdFileurl.SetText( aObj.PathToFileName() );
436 }
437 }
438 }
439
440 return 0;
441 }
442
443 // -----------------------------------------------------------------------
444
SvInsertPlugInDialog(Window * pParent,const uno::Reference<embed::XStorage> & xStorage)445 SvInsertPlugInDialog::SvInsertPlugInDialog( Window* pParent, const uno::Reference < embed::XStorage >& xStorage )
446 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_PLUGIN ), xStorage ),
447 aGbFileurl( this, CUI_RES( GB_FILEURL ) ),
448 aEdFileurl( this, CUI_RES( ED_FILEURL ) ),
449 aBtnFileurl( this, CUI_RES( BTN_FILEURL ) ),
450 aGbPluginsOptions( this, CUI_RES( GB_PLUGINS_OPTIONS ) ),
451 aEdPluginsOptions( this, CUI_RES( ED_PLUGINS_OPTIONS ) ),
452 aOKButton1( this, CUI_RES( 1 ) ),
453 aCancelButton1( this, CUI_RES( 1 ) ),
454 aHelpButton1( this, CUI_RES( 1 ) ),
455 m_pURL(0)
456 {
457 FreeResource();
458 aBtnFileurl.SetClickHdl( LINK( this, SvInsertPlugInDialog, BrowseHdl ) );
459 }
460
~SvInsertPlugInDialog()461 SvInsertPlugInDialog::~SvInsertPlugInDialog()
462 {
463 delete m_pURL;
464 }
465
466 // -----------------------------------------------------------------------
467
Plugin_ImplFillCommandSequence(const String & aCommands,uno::Sequence<beans::PropertyValue> & aCommandSequence)468 static void Plugin_ImplFillCommandSequence( const String& aCommands, uno::Sequence< beans::PropertyValue >& aCommandSequence )
469 {
470 sal_uInt16 nEaten;
471 SvCommandList aLst;
472 aLst.AppendCommands( aCommands, &nEaten );
473
474 const sal_Int32 nCount = aLst.Count();
475 aCommandSequence.realloc( nCount );
476 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
477 {
478 const SvCommand& rCommand = aLst[ nIndex ];
479
480 aCommandSequence[nIndex].Name = rCommand.GetCommand();
481 aCommandSequence[nIndex].Handle = -1;
482 aCommandSequence[nIndex].Value = makeAny( OUString( rCommand.GetArgument() ) );
483 aCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE;
484 }
485 }
486
Execute()487 short SvInsertPlugInDialog::Execute()
488 {
489 short nRet = RET_OK;
490 m_aCommands.Erase();
491 DBG_ASSERT( m_xStorage.is(), "No storage!");
492 if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
493 {
494 if ( !m_pURL )
495 m_pURL = new INetURLObject();
496 else
497 *m_pURL = INetURLObject();
498
499 m_aCommands = GetPlugInOptions();
500 String aURL = GetPlugInFile();
501
502 // URL can be a valid and absolute URL or a system file name
503 m_pURL->SetSmartProtocol( INET_PROT_FILE );
504 if ( !aURL.Len() || m_pURL->SetSmartURL( aURL ) )
505 {
506 // create a plugin object
507 ::rtl::OUString aName;
508 SvGlobalName aClassId( SO3_PLUGIN_CLASSID );
509 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
510 }
511
512 if ( m_xObj.is() )
513 {
514 // set properties from dialog
515 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
516 m_xObj->changeState( embed::EmbedStates::RUNNING );
517
518 uno::Reference < beans::XPropertySet > xSet( m_xObj->getComponent(), uno::UNO_QUERY );
519 if ( xSet.is() )
520 {
521 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
522 makeAny( ::rtl::OUString( m_pURL->GetMainURL( INetURLObject::NO_DECODE ) ) ) );
523 uno::Sequence< beans::PropertyValue > aCommandSequence;
524 Plugin_ImplFillCommandSequence( m_aCommands, aCommandSequence );
525 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands"), makeAny( aCommandSequence ) );
526 }
527 }
528 else
529 {
530 // PlugIn konnte nicht erzeugt werden
531 // global Resource from svtools (former so3 resource)
532 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_PLUGIN ) );
533 aErr.SearchAndReplace( String( '%' ), aURL );
534 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
535 }
536 }
537
538 return nRet;
539 }
540
541 // class SvInsertAppletDlg -----------------------------------------------
542
IMPL_LINK(SvInsertAppletDialog,BrowseHdl,PushButton *,EMPTYARG)543 IMPL_LINK( SvInsertAppletDialog, BrowseHdl, PushButton *, EMPTYARG )
544 {
545 Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
546 if( xFactory.is() )
547 {
548 Reference< XFilePicker > xFilePicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ), UNO_QUERY );
549 DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
550
551 Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
552 Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
553 if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
554 {
555 Sequence< Any > aServiceType( 1 );
556 aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
557 xInit->initialize( aServiceType );
558
559 // add filter
560 try
561 {
562 xFilterMgr->appendFilter(
563 OUString( RTL_CONSTASCII_USTRINGPARAM( "Applet" ) ),
564 OUString( RTL_CONSTASCII_USTRINGPARAM( "*.class" ) )
565 );
566 }
567 catch( IllegalArgumentException& )
568 {
569 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
570 }
571
572 if( xFilePicker->execute() == ExecutableDialogResults::OK )
573 {
574 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
575
576 INetURLObject aObj( aPathSeq[0] );
577 aEdClassfile.SetText( aObj.getName() );
578 aObj.removeSegment();
579 aEdClasslocation.SetText( aObj.PathToFileName() );
580 }
581 }
582 }
583
584 return 0;
585 }
586
587 // -----------------------------------------------------------------------
588
SvInsertAppletDialog(Window * pParent,const uno::Reference<embed::XStorage> & xStorage)589 SvInsertAppletDialog::SvInsertAppletDialog( Window* pParent, const uno::Reference < embed::XStorage >& xStorage )
590 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_APPLET ), xStorage ),
591 aFtClassfile( this, CUI_RES( FT_CLASSFILE ) ),
592 aEdClassfile( this, CUI_RES( ED_CLASSFILE ) ),
593 aFtClasslocation( this, CUI_RES( FT_CLASSLOCATION ) ),
594 aEdClasslocation( this, CUI_RES( ED_CLASSLOCATION ) ),
595 aBtnClass( this, CUI_RES( BTN_CLASS ) ),
596 aGbClass( this, CUI_RES( GB_CLASS ) ),
597 aEdAppletOptions( this, CUI_RES( ED_APPLET_OPTIONS ) ),
598 aGbAppletOptions( this, CUI_RES( GB_APPLET_OPTIONS ) ),
599 aOKButton1( this, CUI_RES( 1 ) ),
600 aCancelButton1( this, CUI_RES( 1 ) ),
601 aHelpButton1( this, CUI_RES( 1 ) ),
602 m_pURL(0)
603 {
604 FreeResource();
605 aBtnClass.SetClickHdl( LINK( this, SvInsertAppletDialog, BrowseHdl ) );
606 }
607
SvInsertAppletDialog(Window * pParent,const uno::Reference<embed::XEmbeddedObject> & xObj)608 SvInsertAppletDialog::SvInsertAppletDialog( Window* pParent, const uno::Reference < embed::XEmbeddedObject >& xObj )
609 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_APPLET ), uno::Reference < embed::XStorage >() ),
610 aFtClassfile( this, CUI_RES( FT_CLASSFILE ) ),
611 aEdClassfile( this, CUI_RES( ED_CLASSFILE ) ),
612 aFtClasslocation( this, CUI_RES( FT_CLASSLOCATION ) ),
613 aEdClasslocation( this, CUI_RES( ED_CLASSLOCATION ) ),
614 aBtnClass( this, CUI_RES( BTN_CLASS ) ),
615 aGbClass( this, CUI_RES( GB_CLASS ) ),
616 aEdAppletOptions( this, CUI_RES( ED_APPLET_OPTIONS ) ),
617 aGbAppletOptions( this, CUI_RES( GB_APPLET_OPTIONS ) ),
618 aOKButton1( this, CUI_RES( 1 ) ),
619 aCancelButton1( this, CUI_RES( 1 ) ),
620 aHelpButton1( this, CUI_RES( 1 ) ),
621 m_pURL(0)
622 {
623 m_xObj = xObj;
624 FreeResource();
625 aBtnClass.SetClickHdl( LINK( this, SvInsertAppletDialog, BrowseHdl ) );
626 }
627
628
~SvInsertAppletDialog()629 SvInsertAppletDialog::~SvInsertAppletDialog()
630 {
631 delete m_pURL;
632 }
633
Execute()634 short SvInsertAppletDialog::Execute()
635 {
636 short nRet = RET_OK;
637 m_aClass.Erase();
638 m_aCommands.Erase();
639
640 sal_Bool bOK = sal_False;
641 uno::Reference < beans::XPropertySet > xSet;
642 if ( m_xObj.is() )
643 {
644 try
645 {
646 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
647 m_xObj->changeState( embed::EmbedStates::RUNNING );
648 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
649 ::rtl::OUString aStr;
650 uno::Any aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCode") );
651 if ( aAny >>= aStr )
652 SetClass( aStr );
653 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCodeBase") );
654 if ( aAny >>= aStr )
655 SetClassLocation( aStr );
656 uno::Sequence< beans::PropertyValue > aCommands;
657 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands") );
658 if ( aAny >>= aCommands )
659 {
660 SvCommandList aList;
661 aList.FillFromSequence( aCommands );
662 SetAppletOptions( aList.GetCommands() );
663 }
664
665 String aText( CUI_RES( STR_EDIT_APPLET ) );
666 SetText( aText );
667 bOK = sal_True;
668 }
669 catch ( uno::Exception& )
670 {
671 DBG_ERROR( "No Applet!" );
672 }
673 }
674 else
675 {
676 DBG_ASSERT( m_xStorage.is(), "No storage!");
677 bOK = m_xStorage.is();
678 }
679
680 if ( bOK && ( nRet = Dialog::Execute() ) == RET_OK )
681 {
682 if ( !m_xObj.is() )
683 {
684 ::rtl::OUString aName;
685 SvGlobalName aClassId( SO3_APPLET_CLASSID );
686 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
687 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
688 m_xObj->changeState( embed::EmbedStates::RUNNING );
689 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
690 }
691
692 if ( m_xObj.is() )
693 {
694 try
695 {
696 sal_Bool bIPActive = m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
697 if ( bIPActive )
698 m_xObj->changeState( embed::EmbedStates::RUNNING );
699
700 String aClassLocation = GetClassLocation();
701
702 // Hack, aFileName wird auch fuer Class benutzt
703 m_aClass = GetClass();
704 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("AppletCode"), makeAny( ::rtl::OUString( m_aClass ) ) );
705
706 ::rtl::OUString tmp = aClassLocation;
707 ::osl::File::getFileURLFromSystemPath(tmp, tmp);
708 aClassLocation = tmp;
709 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("AppletCodeBase"), makeAny( tmp ) );
710 m_aCommands = GetAppletOptions();
711
712 uno::Sequence< beans::PropertyValue > aCommandSequence;
713 Plugin_ImplFillCommandSequence( m_aCommands, aCommandSequence );
714 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands"), makeAny( aCommandSequence ) );
715
716 if ( bIPActive )
717 m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
718 }
719 catch ( uno::Exception& )
720 {
721 DBG_ERROR( "No Applet!" );
722 }
723 }
724 }
725
726 return nRet;
727 }
728
SfxInsertFloatingFrameDialog(Window * pParent,const com::sun::star::uno::Reference<com::sun::star::embed::XStorage> & xStorage)729 SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog( Window *pParent,
730 const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage )
731 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_IFRAME ), xStorage )
732 , aFTName ( this, CUI_RES( FT_FRAMENAME ) )
733 , aEDName ( this, CUI_RES( ED_FRAMENAME ) )
734 , aFTURL ( this, CUI_RES( FT_URL ) )
735 , aEDURL ( this, CUI_RES( ED_URL ) )
736 , aBTOpen ( this, CUI_RES(BT_FILEOPEN ) )
737
738 , aFLScrolling ( this, CUI_RES( GB_SCROLLING ) )
739 , aRBScrollingOn ( this, CUI_RES( RB_SCROLLINGON ) )
740 , aRBScrollingOff ( this, CUI_RES( RB_SCROLLINGOFF ) )
741 , aRBScrollingAuto ( this, CUI_RES( RB_SCROLLINGAUTO ) )
742 , aFLSepLeft( this, CUI_RES( FL_SEP_LEFT ) )
743 , aFLFrameBorder( this, CUI_RES( GB_BORDER ) )
744 , aRBFrameBorderOn ( this, CUI_RES( RB_FRMBORDER_ON ) )
745 , aRBFrameBorderOff ( this, CUI_RES( RB_FRMBORDER_OFF ) )
746 , aFLSepRight( this, CUI_RES( FL_SEP_RIGHT ) )
747 , aFLMargin( this, CUI_RES( GB_MARGIN ) )
748 , aFTMarginWidth ( this, CUI_RES( FT_MARGINWIDTH ) )
749 , aNMMarginWidth ( this, CUI_RES( NM_MARGINWIDTH ) )
750 , aCBMarginWidthDefault( this, CUI_RES( CB_MARGINWIDTHDEFAULT ) )
751 , aFTMarginHeight ( this, CUI_RES( FT_MARGINHEIGHT ) )
752 , aNMMarginHeight ( this, CUI_RES( NM_MARGINHEIGHT ) )
753 , aCBMarginHeightDefault( this, CUI_RES( CB_MARGINHEIGHTDEFAULT ) )
754 , aOKButton1( this, CUI_RES( 1 ) )
755 , aCancelButton1( this, CUI_RES( 1 ) )
756 , aHelpButton1( this, CUI_RES( 1 ) )
757 {
758 FreeResource();
759
760 aFLSepLeft.SetStyle(aFLSepLeft.GetStyle()|WB_VERT);
761 aFLSepRight.SetStyle(aFLSepRight.GetStyle()|WB_VERT);
762
763 Link aLink( STATIC_LINK( this, SfxInsertFloatingFrameDialog, CheckHdl ) );
764 aCBMarginWidthDefault.SetClickHdl( aLink );
765 aCBMarginHeightDefault.SetClickHdl( aLink );
766
767 aCBMarginWidthDefault.Check();
768 aCBMarginHeightDefault.Check();
769 aRBScrollingAuto.Check();
770 aRBFrameBorderOn.Check();
771
772 aBTOpen.SetClickHdl( STATIC_LINK( this, SfxInsertFloatingFrameDialog, OpenHdl ) );
773 }
774
SfxInsertFloatingFrameDialog(Window * pParent,const uno::Reference<embed::XEmbeddedObject> & xObj)775 SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog( Window *pParent, const uno::Reference < embed::XEmbeddedObject >& xObj )
776 : InsertObjectDialog_Impl( pParent, CUI_RES( MD_INSERT_OBJECT_IFRAME ), uno::Reference < embed::XStorage >() )
777 , aFTName ( this, CUI_RES( FT_FRAMENAME ) )
778 , aEDName ( this, CUI_RES( ED_FRAMENAME ) )
779 , aFTURL ( this, CUI_RES( FT_URL ) )
780 , aEDURL ( this, CUI_RES( ED_URL ) )
781 , aBTOpen ( this, CUI_RES(BT_FILEOPEN ) )
782
783 , aFLScrolling ( this, CUI_RES( GB_SCROLLING ) )
784 , aRBScrollingOn ( this, CUI_RES( RB_SCROLLINGON ) )
785 , aRBScrollingOff ( this, CUI_RES( RB_SCROLLINGOFF ) )
786 , aRBScrollingAuto ( this, CUI_RES( RB_SCROLLINGAUTO ) )
787
788 , aFLSepLeft( this, CUI_RES( FL_SEP_LEFT ) )
789 , aFLFrameBorder( this, CUI_RES( GB_BORDER ) )
790 , aRBFrameBorderOn ( this, CUI_RES( RB_FRMBORDER_ON ) )
791 , aRBFrameBorderOff ( this, CUI_RES( RB_FRMBORDER_OFF ) )
792
793 , aFLSepRight( this, CUI_RES( FL_SEP_RIGHT ) )
794 , aFLMargin( this, CUI_RES( GB_MARGIN ) )
795 , aFTMarginWidth ( this, CUI_RES( FT_MARGINWIDTH ) )
796 , aNMMarginWidth ( this, CUI_RES( NM_MARGINWIDTH ) )
797 , aCBMarginWidthDefault( this, CUI_RES( CB_MARGINWIDTHDEFAULT ) )
798 , aFTMarginHeight ( this, CUI_RES( FT_MARGINHEIGHT ) )
799 , aNMMarginHeight ( this, CUI_RES( NM_MARGINHEIGHT ) )
800 , aCBMarginHeightDefault( this, CUI_RES( CB_MARGINHEIGHTDEFAULT ) )
801 , aOKButton1( this, CUI_RES( 1 ) )
802 , aCancelButton1( this, CUI_RES( 1 ) )
803 , aHelpButton1( this, CUI_RES( 1 ) )
804 {
805 FreeResource();
806
807 m_xObj = xObj;
808
809 aFLSepLeft.SetStyle(aFLSepLeft.GetStyle()|WB_VERT);
810 aFLSepRight.SetStyle(aFLSepRight.GetStyle()|WB_VERT);
811
812 Link aLink( STATIC_LINK( this, SfxInsertFloatingFrameDialog, CheckHdl ) );
813 aCBMarginWidthDefault.SetClickHdl( aLink );
814 aCBMarginHeightDefault.SetClickHdl( aLink );
815
816 aCBMarginWidthDefault.Check();
817 aCBMarginHeightDefault.Check();
818 aRBScrollingAuto.Check();
819 aRBFrameBorderOn.Check();
820
821 aBTOpen.SetClickHdl( STATIC_LINK( this, SfxInsertFloatingFrameDialog, OpenHdl ) );
822 }
823
Execute()824 short SfxInsertFloatingFrameDialog::Execute()
825 {
826 short nRet = RET_OK;
827 sal_Bool bOK = sal_False;
828 uno::Reference < beans::XPropertySet > xSet;
829 if ( m_xObj.is() )
830 {
831 try
832 {
833 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
834 m_xObj->changeState( embed::EmbedStates::RUNNING );
835 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
836 ::rtl::OUString aStr;
837 uno::Any aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameURL") );
838 if ( aAny >>= aStr )
839 aEDURL.SetText( aStr );
840 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameName") );
841 if ( aAny >>= aStr )
842 aEDName.SetText( aStr );
843
844 sal_Int32 nSize = SIZE_NOT_SET;
845 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth") );
846 aAny >>= nSize;
847
848 if ( nSize == SIZE_NOT_SET )
849 {
850 aCBMarginWidthDefault.Check( sal_True );
851 aNMMarginWidth.SetText( String::CreateFromInt32( DEFAULT_MARGIN_WIDTH ) );
852 aFTMarginWidth.Enable( sal_False );
853 aNMMarginWidth.Enable( sal_False );
854 }
855 else
856 aNMMarginWidth.SetText( String::CreateFromInt32( nSize ) );
857
858 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight") );
859 aAny >>= nSize;
860
861 if ( nSize == SIZE_NOT_SET )
862 {
863 aCBMarginHeightDefault.Check( sal_True );
864 aNMMarginHeight.SetText( String::CreateFromInt32( DEFAULT_MARGIN_HEIGHT ) );
865 aFTMarginHeight.Enable( sal_False );
866 aNMMarginHeight.Enable( sal_False );
867 }
868 else
869 aNMMarginHeight.SetText( String::CreateFromInt32( nSize ) );
870
871 sal_Bool bScrollOn = sal_False;
872 sal_Bool bScrollOff = sal_False;
873 sal_Bool bScrollAuto = sal_False;
874
875 sal_Bool bSet = sal_False;
876 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll") );
877 aAny >>= bSet;
878 if ( !bSet )
879 {
880 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode") );
881 aAny >>= bSet;
882 bScrollOn = bSet;
883 bScrollOff = !bSet;
884 }
885 else
886 bScrollAuto = sal_True;
887
888 aRBScrollingOn.Check( bScrollOn );
889 aRBScrollingOff.Check( bScrollOff );
890 aRBScrollingAuto.Check( bScrollAuto );
891
892 bSet = sal_False;
893 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder") );
894 aAny >>= bSet;
895 if ( !bSet )
896 {
897 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder") );
898 aAny >>= bSet;
899 aRBFrameBorderOn.Check( bSet );
900 aRBFrameBorderOff.Check( !bSet );
901 }
902
903 SetUpdateMode( sal_True );
904 bOK = sal_True;
905 }
906 catch ( uno::Exception& )
907 {
908 DBG_ERROR( "No IFrame!" );
909 }
910 }
911 else
912 {
913 DBG_ASSERT( m_xStorage.is(), "No storage!");
914 bOK = m_xStorage.is();
915 }
916
917 if ( bOK && ( nRet = Dialog::Execute() ) == RET_OK )
918 {
919 ::rtl::OUString aURL;
920 if ( aEDURL.GetText().Len() )
921 {
922 // URL can be a valid and absolute URL or a system file name
923 INetURLObject aObj;
924 aObj.SetSmartProtocol( INET_PROT_FILE );
925 if ( aObj.SetSmartURL( aEDURL.GetText() ) )
926 aURL = aObj.GetMainURL( INetURLObject::NO_DECODE );
927 }
928
929 if ( !m_xObj.is() && aURL.getLength() )
930 {
931 // create the object
932 ::rtl::OUString aName;
933 SvGlobalName aClassId( SO3_IFRAME_CLASSID );
934 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
935 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
936 m_xObj->changeState( embed::EmbedStates::RUNNING );
937 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
938 }
939
940 if ( m_xObj.is() )
941 {
942 try
943 {
944 sal_Bool bIPActive = m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
945 if ( bIPActive )
946 m_xObj->changeState( embed::EmbedStates::RUNNING );
947
948 ::rtl::OUString aName = aEDName.GetText();
949 ScrollingMode eScroll = ScrollingNo;
950 if ( aRBScrollingOn.IsChecked() )
951 eScroll = ScrollingYes;
952 if ( aRBScrollingOff.IsChecked() )
953 eScroll = ScrollingNo;
954 if ( aRBScrollingAuto.IsChecked() )
955 eScroll = ScrollingAuto;
956
957 sal_Bool bHasBorder = aRBFrameBorderOn.IsChecked();
958
959 long lMarginWidth;
960 if ( !aCBMarginWidthDefault.IsChecked() )
961 lMarginWidth = (long) aNMMarginWidth.GetText().ToInt32();
962 else
963 lMarginWidth = SIZE_NOT_SET;
964
965 long lMarginHeight;
966 if ( !aCBMarginHeightDefault.IsChecked() )
967 lMarginHeight = (long) aNMMarginHeight.GetText().ToInt32();
968 else
969 lMarginHeight = SIZE_NOT_SET;
970
971 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameURL"), makeAny( aURL ) );
972 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameName"), makeAny( aName ) );
973
974 if ( eScroll == ScrollingAuto )
975 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll"),
976 makeAny( sal_True ) );
977 else
978 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode"),
979 makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
980
981 //if ( aFrmDescr.IsFrameBorderSet() )
982 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder"),
983 makeAny( bHasBorder ) );
984 /*else
985 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder"),
986 makeAny( sal_True ) );*/
987
988 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth"),
989 makeAny( sal_Int32( lMarginWidth ) ) );
990
991 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight"),
992 makeAny( sal_Int32( lMarginHeight ) ) );
993
994 if ( bIPActive )
995 m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
996 }
997 catch ( uno::Exception& )
998 {
999 DBG_ERROR( "No IFrame!" );
1000 }
1001 }
1002 }
1003
1004 return nRet;
1005 }
1006
1007 //------------------------------------------------------------------------------
1008
IMPL_STATIC_LINK(SfxInsertFloatingFrameDialog,CheckHdl,CheckBox *,pCB)1009 IMPL_STATIC_LINK( SfxInsertFloatingFrameDialog, CheckHdl, CheckBox*, pCB )
1010 {
1011 if ( pCB == &pThis->aCBMarginWidthDefault )
1012 {
1013 if ( pCB->IsChecked() )
1014 pThis->aNMMarginWidth.SetText( String::CreateFromInt32( DEFAULT_MARGIN_WIDTH ) );
1015 pThis->aFTMarginWidth.Enable( !pCB->IsChecked() );
1016 pThis->aNMMarginWidth.Enable( !pCB->IsChecked() );
1017 }
1018
1019 if ( pCB == &pThis->aCBMarginHeightDefault )
1020 {
1021 if ( pCB->IsChecked() )
1022 pThis->aNMMarginHeight.SetText( String::CreateFromInt32( DEFAULT_MARGIN_HEIGHT ) );
1023 pThis->aFTMarginHeight.Enable( !pCB->IsChecked() );
1024 pThis->aNMMarginHeight.Enable( !pCB->IsChecked() );
1025 }
1026
1027 return 0L;
1028 }
1029
1030 //------------------------------------------------------------------------------
1031
IMPL_STATIC_LINK(SfxInsertFloatingFrameDialog,OpenHdl,PushButton *,EMPTYARG)1032 IMPL_STATIC_LINK( SfxInsertFloatingFrameDialog, OpenHdl, PushButton*, EMPTYARG )
1033 {
1034 Window* pOldParent = Application::GetDefDialogParent();
1035 Application::SetDefDialogParent( pThis );
1036
1037 // create the file dialog
1038 sfx2::FileDialogHelper aFileDlg( WB_OPEN | SFXWB_PASSWORD, String() );
1039
1040 // set the title
1041 aFileDlg.SetTitle( OUString( String( CUI_RES( MD_INSERT_OBJECT_IFRAME ) ) ) );
1042
1043 // show the dialog
1044 if ( aFileDlg.Execute() == ERRCODE_NONE )
1045 pThis->aEDURL.SetText(
1046 INetURLObject( aFileDlg.GetPath() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ) );
1047
1048 Application::SetDefDialogParent( pOldParent );
1049 return 0L;
1050 }
1051
1052 /* vim: set noet sw=4 ts=4: */
1053