update credits
[LibreOffice.git] / cui / source / dialogs / insdlg.cxx
blob3d53af241edb1aa85a1bde715592ad8ce200dd8e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/beans/PropertyValue.hpp>
22 #include <com/sun/star/embed/EmbedStates.hpp>
23 #include <com/sun/star/embed/XInsertObjectDialog.hpp>
24 #include <com/sun/star/embed/MSOLEObjectSystemCreator.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/lang/XInitialization.hpp>
27 #include <com/sun/star/task/InteractionHandler.hpp>
28 #include <com/sun/star/ucb/CommandAbortedException.hpp>
29 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
30 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
31 #include <com/sun/star/ui/dialogs/FilePicker.hpp>
32 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
33 #include <comphelper/processfactory.hxx>
35 #include "insdlg.hxx"
36 #include <dialmgr.hxx>
37 #include <svtools/sores.hxx>
39 #include <stdio.h>
40 #include <tools/urlobj.hxx>
41 #include <tools/debug.hxx>
42 #include <svl/urihelper.hxx>
43 #include <vcl/button.hxx>
44 #include <vcl/fixed.hxx>
45 #include <vcl/group.hxx>
46 #include <vcl/layout.hxx>
47 #include <vcl/lstbox.hxx>
48 #include <vcl/msgbox.hxx>
49 #include <vcl/svapp.hxx>
50 #include <comphelper/classids.hxx>
51 #include <sfx2/frmdescr.hxx>
52 #include <sfx2/viewsh.hxx>
53 #include <sfx2/filedlghelper.hxx>
54 #include <svl/ownlist.hxx>
55 #include <comphelper/seqstream.hxx>
57 #include "cuires.hrc"
59 #include <osl/file.hxx>
61 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
62 #include <com/sun/star/container/XNameAccess.hpp>
64 using namespace ::com::sun::star;
65 using namespace ::com::sun::star::lang;
66 using namespace ::com::sun::star::uno;
67 using namespace ::com::sun::star::container;
68 using namespace ::com::sun::star::ui::dialogs;
71 static String impl_getSvtResString( sal_uInt32 nId )
73 String aRet;
74 ResMgr* pMgr = ResMgr::CreateResMgr( "svt", Application::GetSettings().GetUILanguageTag() );
75 if( pMgr )
77 aRet = String( ResId( nId, *pMgr ) );
78 delete pMgr;
80 return aRet;
83 sal_Bool InsertObjectDialog_Impl::IsCreateNew() const
85 return sal_False;
88 uno::Reference< io::XInputStream > InsertObjectDialog_Impl::GetIconIfIconified( OUString* /*pGraphicMediaType*/ )
90 return uno::Reference< io::XInputStream >();
93 InsertObjectDialog_Impl::InsertObjectDialog_Impl(Window * pParent, const OString& rID,
94 const OUString& rUIXMLDescription,
95 const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage)
96 : ModalDialog(pParent, rID, rUIXMLDescription)
97 , m_xStorage( xStorage )
98 , aCnt( m_xStorage )
102 // -----------------------------------------------------------------------
104 IMPL_LINK_NOARG_INLINE_START(SvInsertOleDlg, DoubleClickHdl)
106 EndDialog( RET_OK );
107 return 0;
109 IMPL_LINK_INLINE_END( SvInsertOleDlg, DoubleClickHdl, ListBox *, pListBox )
111 // -----------------------------------------------------------------------
113 IMPL_LINK_NOARG(SvInsertOleDlg, BrowseHdl)
115 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
117 Reference< XFilePicker3 > xFilePicker = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE);
119 // add filter
122 xFilePicker->appendFilter(
123 OUString(),
124 OUString( "*.*" )
127 catch( const IllegalArgumentException& )
129 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
132 if( xFilePicker->execute() == ExecutableDialogResults::OK )
134 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
135 INetURLObject aObj( aPathSeq[0] );
136 m_pEdFilepath->SetText( aObj.PathToFileName() );
139 return 0;
142 // -----------------------------------------------------------------------
144 IMPL_LINK_NOARG(SvInsertOleDlg, RadioHdl)
146 if ( m_pRbNewObject->IsChecked() )
148 m_pObjectTypeFrame->Show();
149 m_pFileFrame->Hide();
151 else
153 m_pFileFrame->Show();
154 m_pObjectTypeFrame->Hide();
156 return 0;
159 // -----------------------------------------------------------------------
161 void SvInsertOleDlg::SelectDefault()
163 m_pLbObjecttype->SelectEntryPos(0);
166 // -----------------------------------------------------------------------
167 SvInsertOleDlg::SvInsertOleDlg
169 Window* pParent,
170 const Reference < embed::XStorage >& xStorage,
171 const SvObjectServerList* pServers
173 : InsertObjectDialog_Impl( pParent, "InsertOLEObjectDialog", "cui/ui/insertoleobject.ui", xStorage ),
174 m_pServers( pServers )
176 get(m_pRbNewObject, "createnew");
177 get(m_pRbObjectFromfile, "createfromfile");
178 get(m_pObjectTypeFrame, "objecttypeframe");
179 get(m_pLbObjecttype, "types");
180 get(m_pFileFrame, "fileframe");
181 get(m_pEdFilepath, "urled");
182 get(m_pBtnFilepath, "urlbtn");
183 get(m_pCbFilelink, "linktofile");
184 m_pLbObjecttype->SetDoubleClickHdl( LINK( this, SvInsertOleDlg, DoubleClickHdl ) );
185 m_pBtnFilepath->SetClickHdl( LINK( this, SvInsertOleDlg, BrowseHdl ) );
186 Link aLink( LINK( this, SvInsertOleDlg, RadioHdl ) );
187 m_pRbNewObject->SetClickHdl( aLink );
188 m_pRbObjectFromfile->SetClickHdl( aLink );
189 m_pRbNewObject->Check( sal_True );
190 RadioHdl( NULL );
193 short SvInsertOleDlg::Execute()
195 short nRet = RET_OK;
196 SvObjectServerList aObjS;
197 if ( !m_pServers )
199 // if no list was provided, take the complete one
200 aObjS.FillInsertObjects();
201 m_pServers = &aObjS;
204 // fill listbox and select default
205 ListBox& rBox = GetObjectTypes();
206 rBox.SetUpdateMode( sal_False );
207 for ( sal_uLong i = 0; i < m_pServers->Count(); i++ )
208 rBox.InsertEntry( (*m_pServers)[i].GetHumanName() );
209 rBox.SetUpdateMode( sal_True );
210 SelectDefault();
211 OUString aName;
213 DBG_ASSERT( m_xStorage.is(), "No storage!");
214 if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
216 String aFileName;
217 sal_Bool bLink = sal_False;
218 sal_Bool bCreateNew = IsCreateNew();
219 if ( bCreateNew )
221 // create and insert new embedded object
222 String aServerName = rBox.GetSelectEntry();
223 const SvObjectServer* pS = m_pServers->Get( aServerName );
224 if ( pS )
226 if( pS->GetClassName() == SvGlobalName( SO3_OUT_CLASSID ) )
230 uno::Reference < embed::XInsertObjectDialog > xDialogCreator(
231 embed::MSOLEObjectSystemCreator::create( ::comphelper::getProcessComponentContext() ),
232 uno::UNO_QUERY );
234 if ( xDialogCreator.is() )
236 aName = aCnt.CreateUniqueObjectName();
237 embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
238 m_xStorage,
239 aName,
240 uno::Sequence < beans::PropertyValue >() );
242 OSL_ENSURE( aNewInf.Object.is(), "The object must be created or an exception must be thrown!" );
243 m_xObj = aNewInf.Object;
244 for ( sal_Int32 nInd = 0; nInd < aNewInf.Options.getLength(); nInd++ )
245 if ( aNewInf.Options[nInd].Name == "Icon" )
247 aNewInf.Options[nInd].Value >>= m_aIconMetaFile;
249 else if ( aNewInf.Options[nInd].Name == "IconFormat" )
251 datatransfer::DataFlavor aFlavor;
252 if ( aNewInf.Options[nInd].Value >>= aFlavor )
253 m_aIconMediaType = aFlavor.MimeType;
258 catch( ucb::CommandAbortedException& )
260 // the user has pressed cancel
262 catch( uno::Exception& )
264 // TODO: Error handling
267 else
269 // create object with desired ClassId
270 m_xObj = aCnt.CreateEmbeddedObject( pS->GetClassName().GetByteSequence(), aName );
273 if ( !m_xObj.is() )
275 if( aFileName.Len() ) // from OLE Dialog
277 // object couldn't be created from file
278 // global Resource from svtools (former so3 resource)
279 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_FROM_FILE ) );
280 aErr.SearchAndReplace( OUString( '%' ), aFileName );
281 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
283 else
285 // object couldn't be created
286 // global Resource from svtools (former so3 resource)
287 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE ) );
288 aErr.SearchAndReplace( OUString( '%' ), aServerName );
289 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
294 else
296 aFileName = GetFilePath();
297 INetURLObject aURL;
298 aURL.SetSmartProtocol( INET_PROT_FILE );
299 aURL.SetSmartURL( aFileName );
300 aFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
301 bLink = IsLinked();
303 if ( aFileName.Len() )
305 // create MediaDescriptor for file to create object from
306 uno::Sequence < beans::PropertyValue > aMedium( 2 );
307 aMedium[0].Name = "URL";
308 aMedium[0].Value <<= OUString( aFileName );
310 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
311 uno::Reference< task::XInteractionHandler2 > xInteraction(
312 task::InteractionHandler::createWithParent(xContext, 0) );
314 aMedium[1].Name = "InteractionHandler";
315 aMedium[1].Value <<= xInteraction;
317 // create object from media descriptor
318 if ( bLink )
319 m_xObj = aCnt.InsertEmbeddedLink( aMedium, aName );
320 else
321 m_xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
324 if ( !m_xObj.is() )
326 // object couldn't be created from file
327 // global Resource from svtools (former so3 resource)
328 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_FROM_FILE ) );
329 aErr.SearchAndReplace( OUString( '%' ), aFileName );
330 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
335 m_pServers = 0;
336 return nRet;
339 uno::Reference< io::XInputStream > SvInsertOleDlg::GetIconIfIconified( OUString* pGraphicMediaType )
341 if ( m_aIconMetaFile.getLength() )
343 if ( pGraphicMediaType )
344 *pGraphicMediaType = m_aIconMediaType;
346 return uno::Reference< io::XInputStream >( new ::comphelper::SequenceInputStream( m_aIconMetaFile ) );
349 return uno::Reference< io::XInputStream >();
352 IMPL_LINK_NOARG(SvInsertPlugInDialog, BrowseHdl)
354 Sequence< OUString > aFilterNames, aFilterTypes;
355 void fillNetscapePluginFilters( Sequence< OUString >& rNames, Sequence< OUString >& rTypes );
356 fillNetscapePluginFilters( aFilterNames, aFilterTypes );
358 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
359 Reference< XFilePicker3 > xFilePicker = ui::dialogs::FilePicker::createWithMode( xContext, ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE );
361 // add the filters
364 const OUString* pNames = aFilterNames.getConstArray();
365 const OUString* pTypes = aFilterTypes.getConstArray();
366 for( int i = 0; i < aFilterNames.getLength(); i++ )
367 xFilePicker->appendFilter( pNames[i], pTypes[i] );
369 catch( IllegalArgumentException& )
371 DBG_ASSERT( 0, "caught IllegalArgumentException when registering filter\n" );
374 if( xFilePicker->execute() == ExecutableDialogResults::OK )
376 Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
377 INetURLObject aObj( aPathSeq[0] );
378 m_pEdFileurl->SetText(aObj.PathToFileName());
381 return 0;
384 // -----------------------------------------------------------------------
386 SvInsertPlugInDialog::SvInsertPlugInDialog(Window* pParent,
387 const uno::Reference < embed::XStorage >& xStorage)
388 : InsertObjectDialog_Impl(pParent, "InsertPluginDialog", "cui/ui/insertplugin.ui", xStorage)
389 , m_pURL(0)
391 get(m_pEdFileurl, "urled");
392 get(m_pBtnFileurl, "urlbtn");
393 get(m_pEdPluginsOptions, "pluginoptions");
394 m_pBtnFileurl->SetClickHdl(LINK(this, SvInsertPlugInDialog, BrowseHdl));
397 SvInsertPlugInDialog::~SvInsertPlugInDialog()
399 delete m_pURL;
402 // -----------------------------------------------------------------------
404 static void Plugin_ImplFillCommandSequence( const String& aCommands, uno::Sequence< beans::PropertyValue >& aCommandSequence )
406 sal_Int32 nEaten;
407 SvCommandList aLst;
408 aLst.AppendCommands( aCommands, &nEaten );
410 const size_t nCount = aLst.size();
411 aCommandSequence.realloc( nCount );
412 for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
414 aCommandSequence[nIndex].Name = aLst[ nIndex ].GetCommand();
415 aCommandSequence[nIndex].Handle = -1;
416 aCommandSequence[nIndex].Value = makeAny( aLst[ nIndex ].GetArgument() );
417 aCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE;
421 short SvInsertPlugInDialog::Execute()
423 short nRet = RET_OK;
424 m_aCommands = OUString();
425 DBG_ASSERT( m_xStorage.is(), "No storage!");
426 if ( m_xStorage.is() && ( nRet = Dialog::Execute() ) == RET_OK )
428 if ( !m_pURL )
429 m_pURL = new INetURLObject();
430 else
431 *m_pURL = INetURLObject();
433 m_aCommands = GetPlugInOptions();
434 String aURL = GetPlugInFile();
436 // URL can be a valid and absolute URL or a system file name
437 m_pURL->SetSmartProtocol( INET_PROT_FILE );
438 if ( !aURL.Len() || m_pURL->SetSmartURL( aURL ) )
440 // create a plugin object
441 OUString aName;
442 SvGlobalName aClassId( SO3_PLUGIN_CLASSID );
443 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
446 if ( m_xObj.is() )
448 // set properties from dialog
449 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
450 m_xObj->changeState( embed::EmbedStates::RUNNING );
452 uno::Reference < beans::XPropertySet > xSet( m_xObj->getComponent(), uno::UNO_QUERY );
453 if ( xSet.is() )
455 xSet->setPropertyValue( "PluginURL",
456 makeAny( OUString( m_pURL->GetMainURL( INetURLObject::NO_DECODE ) ) ) );
457 uno::Sequence< beans::PropertyValue > aCommandSequence;
458 Plugin_ImplFillCommandSequence( m_aCommands, aCommandSequence );
459 xSet->setPropertyValue( "PluginCommands", makeAny( aCommandSequence ) );
462 else
464 // PlugIn couldn't be created
465 // global Resource from svtools (former so3 resource)
466 String aErr( impl_getSvtResString( STR_ERROR_OBJNOCREATE_PLUGIN ) );
467 aErr.SearchAndReplace( OUString('%'), aURL );
468 ErrorBox( this, WB_3DLOOK | WB_OK, aErr ).Execute();
472 return nRet;
475 SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog( Window *pParent,
476 const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage )
477 : InsertObjectDialog_Impl( pParent, "InsertFloatingFrameDialog", "cui/ui/insertfloatingframe.ui",
478 xStorage )
480 Init();
483 SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog( Window *pParent,
484 const uno::Reference < embed::XEmbeddedObject >& xObj )
485 : InsertObjectDialog_Impl( pParent, "InsertFloatingFrameDialog", "cui/ui/insertfloatingframe.ui",
486 uno::Reference < embed::XStorage >() )
488 m_xObj = xObj;
490 Init();
493 void SfxInsertFloatingFrameDialog::Init()
495 get(m_pEDName, "edname");
496 get(m_pEDURL, "edurl");
497 get(m_pBTOpen, "buttonbrowse");
498 get(m_pRBScrollingOn, "scrollbaron");
499 get(m_pRBScrollingOff, "scrollbaroff");
500 get(m_pRBScrollingAuto, "scrollbarauto");
501 get(m_pRBFrameBorderOn, "borderon");
502 get(m_pRBFrameBorderOff, "borderoff");
503 get(m_pFTMarginWidth, "widthlabel");
504 get(m_pNMMarginWidth, "width");
505 get(m_pCBMarginWidthDefault, "defaultwidth");
506 get(m_pFTMarginHeight, "heightlabel");
507 get(m_pNMMarginHeight, "height");
508 get(m_pCBMarginHeightDefault, "defaultheight");
510 Link aLink( STATIC_LINK( this, SfxInsertFloatingFrameDialog, CheckHdl ) );
511 m_pCBMarginWidthDefault->SetClickHdl( aLink );
512 m_pCBMarginHeightDefault->SetClickHdl( aLink );
514 m_pCBMarginWidthDefault->Check();
515 m_pCBMarginHeightDefault->Check();
516 m_pRBScrollingAuto->Check();
517 m_pRBFrameBorderOn->Check();
519 m_pBTOpen->SetClickHdl( STATIC_LINK( this, SfxInsertFloatingFrameDialog, OpenHdl ) );
522 short SfxInsertFloatingFrameDialog::Execute()
524 short nRet = RET_OK;
525 sal_Bool bOK = sal_False;
526 uno::Reference < beans::XPropertySet > xSet;
527 if ( m_xObj.is() )
531 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
532 m_xObj->changeState( embed::EmbedStates::RUNNING );
533 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
534 OUString aStr;
535 uno::Any aAny = xSet->getPropertyValue( "FrameURL" );
536 if ( aAny >>= aStr )
537 m_pEDURL->SetText( aStr );
538 aAny = xSet->getPropertyValue( "FrameName" );
539 if ( aAny >>= aStr )
540 m_pEDName->SetText( aStr );
542 sal_Int32 nSize = SIZE_NOT_SET;
543 aAny = xSet->getPropertyValue( "FrameMarginWidth" );
544 aAny >>= nSize;
546 if ( nSize == SIZE_NOT_SET )
548 m_pCBMarginWidthDefault->Check( sal_True );
549 m_pNMMarginWidth->SetText( OUString::number(DEFAULT_MARGIN_WIDTH) );
550 m_pFTMarginWidth->Enable( sal_False );
551 m_pNMMarginWidth->Enable( sal_False );
553 else
554 m_pNMMarginWidth->SetText( OUString::number( nSize ) );
556 aAny = xSet->getPropertyValue( "FrameMarginHeight" );
557 aAny >>= nSize;
559 if ( nSize == SIZE_NOT_SET )
561 m_pCBMarginHeightDefault->Check( sal_True );
562 m_pNMMarginHeight->SetText( OUString::number(DEFAULT_MARGIN_HEIGHT) );
563 m_pFTMarginHeight->Enable( sal_False );
564 m_pNMMarginHeight->Enable( sal_False );
566 else
567 m_pNMMarginHeight->SetText( OUString::number( nSize ) );
569 sal_Bool bScrollOn = sal_False;
570 sal_Bool bScrollOff = sal_False;
571 sal_Bool bScrollAuto = sal_False;
573 sal_Bool bSet = sal_False;
574 aAny = xSet->getPropertyValue( "FrameIsAutoScroll" );
575 aAny >>= bSet;
576 if ( !bSet )
578 aAny = xSet->getPropertyValue( "FrameIsScrollingMode" );
579 aAny >>= bSet;
580 bScrollOn = bSet;
581 bScrollOff = !bSet;
583 else
584 bScrollAuto = sal_True;
586 m_pRBScrollingOn->Check( bScrollOn );
587 m_pRBScrollingOff->Check( bScrollOff );
588 m_pRBScrollingAuto->Check( bScrollAuto );
590 bSet = sal_False;
591 aAny = xSet->getPropertyValue( "FrameIsAutoBorder" );
592 aAny >>= bSet;
593 if ( !bSet )
595 aAny = xSet->getPropertyValue( "FrameIsBorder" );
596 aAny >>= bSet;
597 m_pRBFrameBorderOn->Check( bSet );
598 m_pRBFrameBorderOff->Check( !bSet );
601 SetUpdateMode( sal_True );
602 bOK = sal_True;
604 catch ( uno::Exception& )
606 OSL_FAIL( "No IFrame!" );
609 else
611 DBG_ASSERT( m_xStorage.is(), "No storage!");
612 bOK = m_xStorage.is();
615 if ( bOK && ( nRet = Dialog::Execute() ) == RET_OK )
617 OUString aURL;
618 if ( !m_pEDURL->GetText().isEmpty() )
620 // URL can be a valid and absolute URL or a system file name
621 INetURLObject aObj;
622 aObj.SetSmartProtocol( INET_PROT_FILE );
623 if ( aObj.SetSmartURL( m_pEDURL->GetText() ) )
624 aURL = aObj.GetMainURL( INetURLObject::NO_DECODE );
627 if ( !m_xObj.is() && !aURL.isEmpty() )
629 // create the object
630 OUString aName;
631 SvGlobalName aClassId( SO3_IFRAME_CLASSID );
632 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
633 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
634 m_xObj->changeState( embed::EmbedStates::RUNNING );
635 xSet = uno::Reference < beans::XPropertySet >( m_xObj->getComponent(), uno::UNO_QUERY );
638 if ( m_xObj.is() )
642 sal_Bool bIPActive = m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
643 if ( bIPActive )
644 m_xObj->changeState( embed::EmbedStates::RUNNING );
646 OUString aName = m_pEDName->GetText();
647 ScrollingMode eScroll = ScrollingNo;
648 if ( m_pRBScrollingOn->IsChecked() )
649 eScroll = ScrollingYes;
650 if ( m_pRBScrollingOff->IsChecked() )
651 eScroll = ScrollingNo;
652 if ( m_pRBScrollingAuto->IsChecked() )
653 eScroll = ScrollingAuto;
655 sal_Bool bHasBorder = m_pRBFrameBorderOn->IsChecked();
657 long lMarginWidth;
658 if ( !m_pCBMarginWidthDefault->IsChecked() )
659 lMarginWidth = (long) m_pNMMarginWidth->GetText().toInt32();
660 else
661 lMarginWidth = SIZE_NOT_SET;
663 long lMarginHeight;
664 if ( !m_pCBMarginHeightDefault->IsChecked() )
665 lMarginHeight = (long) m_pNMMarginHeight->GetText().toInt32();
666 else
667 lMarginHeight = SIZE_NOT_SET;
669 xSet->setPropertyValue( "FrameURL", makeAny( aURL ) );
670 xSet->setPropertyValue( "FrameName", makeAny( aName ) );
672 if ( eScroll == ScrollingAuto )
673 xSet->setPropertyValue( "FrameIsAutoScroll", makeAny( sal_True ) );
674 else
675 xSet->setPropertyValue( "FrameIsScrollingMode", makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
677 xSet->setPropertyValue( "FrameIsBorder", makeAny( bHasBorder ) );
678 xSet->setPropertyValue( "FrameMarginWidth", makeAny( sal_Int32( lMarginWidth ) ) );
679 xSet->setPropertyValue( "FrameMarginHeight", makeAny( sal_Int32( lMarginHeight ) ) );
681 if ( bIPActive )
682 m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
684 catch ( uno::Exception& )
686 OSL_FAIL( "No IFrame!" );
691 return nRet;
694 //------------------------------------------------------------------------------
696 IMPL_STATIC_LINK( SfxInsertFloatingFrameDialog, CheckHdl, CheckBox*, pCB )
698 if ( pCB == pThis->m_pCBMarginWidthDefault )
700 if ( pCB->IsChecked() )
701 pThis->m_pNMMarginWidth->SetText( OUString::number(DEFAULT_MARGIN_WIDTH) );
702 pThis->m_pFTMarginWidth->Enable( !pCB->IsChecked() );
703 pThis->m_pNMMarginWidth->Enable( !pCB->IsChecked() );
706 if ( pCB == pThis->m_pCBMarginHeightDefault )
708 if ( pCB->IsChecked() )
709 pThis->m_pNMMarginHeight->SetText( OUString::number(DEFAULT_MARGIN_HEIGHT) );
710 pThis->m_pFTMarginHeight->Enable( !pCB->IsChecked() );
711 pThis->m_pNMMarginHeight->Enable( !pCB->IsChecked() );
714 return 0L;
717 //------------------------------------------------------------------------------
719 IMPL_STATIC_LINK( SfxInsertFloatingFrameDialog, OpenHdl, PushButton*, EMPTYARG )
721 Window* pOldParent = Application::GetDefDialogParent();
722 Application::SetDefDialogParent( pThis );
724 // create the file dialog
725 sfx2::FileDialogHelper aFileDlg(
726 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0, String() );
728 // set the title
729 aFileDlg.SetTitle(CUI_RESSTR(RID_SVXSTR_SELECT_FILE_IFRAME));
731 // show the dialog
732 if ( aFileDlg.Execute() == ERRCODE_NONE )
733 pThis->m_pEDURL->SetText(
734 INetURLObject( aFileDlg.GetPath() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ) );
736 Application::SetDefDialogParent( pOldParent );
737 return 0L;
740 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */