cid#1640468 Dereference after null check
[LibreOffice.git] / cui / source / dialogs / insdlg.cxx
blob41d50c17b336d02dddfe4aed352f840aef75b839
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/task/InteractionHandler.hpp>
26 #include <com/sun/star/ucb/CommandAbortedException.hpp>
27 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
28 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
29 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
30 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
31 #include <comphelper/processfactory.hxx>
32 #include <comphelper/propertyvalue.hxx>
34 #include <insdlg.hxx>
35 #include <dialmgr.hxx>
36 #include <osl/diagnose.h>
37 #include <svtools/imagemgr.hxx>
38 #include <svtools/strings.hrc>
39 #include <svtools/svtresid.hxx>
41 #include <tools/urlobj.hxx>
42 #include <tools/debug.hxx>
43 #include <tools/stream.hxx>
44 #include <comphelper/diagnose_ex.hxx>
45 #include <utility>
46 #include <vcl/image.hxx>
47 #include <vcl/weld.hxx>
48 #include <vcl/svapp.hxx>
49 #include <comphelper/classids.hxx>
50 #include <sfx2/filedlghelper.hxx>
51 #include <sfx2/frmdescr.hxx>
52 #include <sfx2/viewsh.hxx>
53 #include <comphelper/seqstream.hxx>
54 #include <sfx2/viewfrm.hxx>
56 #include <strings.hrc>
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::lang;
60 using namespace ::com::sun::star::uno;
61 using namespace ::com::sun::star::ui::dialogs;
63 bool InsertObjectDialog_Impl::IsCreateNew() const
65 return false;
68 uno::Reference< io::XInputStream > InsertObjectDialog_Impl::GetIconIfIconified( OUString* /*pGraphicMediaType*/ )
70 return uno::Reference< io::XInputStream >();
73 InsertObjectDialog_Impl::InsertObjectDialog_Impl(weld::Window* pParent,
74 const OUString& rUIXMLDescription, const OUString& rID,
75 css::uno::Reference < css::embed::XStorage > xStorage)
76 : GenericDialogController(pParent, rUIXMLDescription, rID)
77 , m_xStorage(std::move( xStorage ))
78 , aCnt( m_xStorage )
82 IMPL_LINK_NOARG(SvInsertOleDlg, DoubleClickHdl, weld::TreeView&, bool)
84 m_xDialog->response(RET_OK);
85 return true;
88 IMPL_LINK_NOARG(SvInsertOleDlg, BrowseHdl, weld::Button&, void)
90 sfx2::FileDialogHelper aHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_xDialog.get());
91 aHelper.SetContext(sfx2::FileDialogHelper::InsertOLE);
92 const Reference< XFilePicker3 >& xFilePicker = aHelper.GetFilePicker();
94 // add filter
95 try
97 xFilePicker->appendFilter(CuiResId(RID_CUISTR_FILTER_ALL), u"*.*"_ustr);
99 catch( const IllegalArgumentException& )
101 TOOLS_WARN_EXCEPTION("cui.dialogs", "caught IllegalArgumentException when registering filter" );
104 if( xFilePicker->execute() == ExecutableDialogResults::OK )
106 Sequence< OUString > aPathSeq( xFilePicker->getSelectedFiles() );
107 INetURLObject aObj( aPathSeq[0] );
108 m_xEdFilepath->set_text(aObj.PathToFileName());
112 IMPL_LINK(SvInsertOleDlg, RadioHdl, weld::Toggleable&, rButton, void)
114 if (!rButton.get_active())
115 return;
117 if (m_xRbNewObject->get_active())
119 m_xObjectTypeFrame->show();
120 m_xFileFrame->hide();
122 else
124 m_xFileFrame->show();
125 m_xObjectTypeFrame->hide();
129 SvInsertOleDlg::SvInsertOleDlg(weld::Window* pParent, const Reference<embed::XStorage>& xStorage,
130 const SvObjectServerList* pServers)
131 : InsertObjectDialog_Impl( pParent, u"cui/ui/insertoleobject.ui"_ustr, u"InsertOLEObjectDialog"_ustr, xStorage)
132 , m_pServers( pServers )
133 , m_xRbNewObject(m_xBuilder->weld_radio_button(u"createnew"_ustr))
134 , m_xRbObjectFromfile(m_xBuilder->weld_radio_button(u"createfromfile"_ustr))
135 , m_xObjectTypeFrame(m_xBuilder->weld_frame(u"objecttypeframe"_ustr))
136 , m_xLbObjecttype(m_xBuilder->weld_tree_view(u"types"_ustr))
137 , m_xFileFrame(m_xBuilder->weld_frame(u"fileframe"_ustr))
138 , m_xEdFilepath(m_xBuilder->weld_entry(u"urled"_ustr))
139 , m_xBtnFilepath(m_xBuilder->weld_button(u"urlbtn"_ustr))
140 , m_xCbFilelink(m_xBuilder->weld_check_button(u"linktofile"_ustr))
141 , m_xCbAsIcon(m_xBuilder->weld_check_button(u"asicon"_ustr))
143 m_xLbObjecttype->set_size_request(m_xLbObjecttype->get_approximate_digit_width() * 32,
144 m_xLbObjecttype->get_height_rows(6));
145 m_xLbObjecttype->connect_row_activated(LINK(this, SvInsertOleDlg, DoubleClickHdl));
146 m_xBtnFilepath->connect_clicked(LINK( this, SvInsertOleDlg, BrowseHdl));
147 Link<weld::Toggleable&,void> aLink( LINK( this, SvInsertOleDlg, RadioHdl ) );
148 m_xRbNewObject->connect_toggled( aLink );
149 m_xRbObjectFromfile->connect_toggled( aLink );
150 m_xRbNewObject->set_active(true);
153 short SvInsertOleDlg::run()
155 short nRet = RET_OK;
156 SvObjectServerList aObjS;
157 if ( !m_pServers )
159 // if no list was provided, take the complete one
160 aObjS.FillInsertObjects();
161 m_pServers = &aObjS;
164 // fill listbox and select default
165 m_xLbObjecttype->freeze();
166 for ( size_t i = 0; i < m_pServers->Count(); i++ )
167 m_xLbObjecttype->append_text((*m_pServers)[i].GetHumanName());
168 m_xLbObjecttype->thaw();
169 m_xLbObjecttype->select(0);
171 DBG_ASSERT( m_xStorage.is(), "No storage!");
172 if ( m_xStorage.is() && ( nRet = InsertObjectDialog_Impl::run() ) == RET_OK )
174 OUString aFileName;
175 OUString aName;
176 bool bCreateNew = IsCreateNew();
177 if ( bCreateNew )
179 // create and insert new embedded object
180 OUString aServerName = m_xLbObjecttype->get_selected_text();
181 const SvObjectServer* pS = m_pServers->Get( aServerName );
182 if ( pS )
184 if( pS->GetClassName() == SvGlobalName( SO3_OUT_CLASSID ) )
188 uno::Reference < embed::XInsertObjectDialog > xDialogCreator(
189 embed::MSOLEObjectSystemCreator::create( ::comphelper::getProcessComponentContext() ),
190 uno::UNO_QUERY );
192 if ( xDialogCreator.is() )
194 aName = aCnt.CreateUniqueObjectName();
196 uno::Reference<task::XStatusIndicator> xProgress;
197 OUString aProgressText;
198 if (SfxViewFrame* pFrame = SfxViewFrame::Current())
200 // Have a current frame, create a matching progressbar, but don't start it yet.
201 uno::Reference<frame::XFrame> xFrame
202 = pFrame->GetFrame().GetFrameInterface();
203 uno::Reference<task::XStatusIndicatorFactory> xProgressFactory(
204 xFrame, uno::UNO_QUERY);
205 if (xProgressFactory.is())
207 xProgress = xProgressFactory->createStatusIndicator();
208 if (xProgress)
210 aProgressText = CuiResId(RID_CUISTR_OLE_INSERT);
215 const embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
216 m_xStorage,
217 aName,
218 {comphelper::makePropertyValue(u"StatusIndicator"_ustr, xProgress),
219 comphelper::makePropertyValue(u"StatusIndicatorText"_ustr, aProgressText)} );
221 OSL_ENSURE( aNewInf.Object.is(), "The object must be created or an exception must be thrown!" );
222 m_xObj = aNewInf.Object;
223 for ( const auto& opt : aNewInf.Options )
224 if ( opt.Name == "Icon" )
226 opt.Value >>= m_aIconMetaFile;
228 else if ( opt.Name == "IconFormat" )
230 datatransfer::DataFlavor aFlavor;
231 if ( opt.Value >>= aFlavor )
232 m_aIconMediaType = aFlavor.MimeType;
237 catch( ucb::CommandAbortedException& )
239 // the user has pressed cancel
241 catch( uno::Exception& )
243 // TODO: Error handling
246 else
248 // create object with desired ClassId
249 m_xObj = aCnt.CreateEmbeddedObject( pS->GetClassName().GetByteSequence(), aName );
252 if ( !m_xObj.is() )
254 if( !aFileName.isEmpty() ) // from OLE Dialog
256 // object couldn't be created from file
257 // global Resource from svtools (former so3 resource)
258 OUString aErr(SvtResId(STR_ERROR_OBJNOCREATE_FROM_FILE));
259 aErr = aErr.replaceFirst( "%", aFileName );
261 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
262 VclMessageType::Warning, VclButtonsType::Ok, aErr));
263 xBox->run();
265 else
267 // object couldn't be created
268 // global Resource from svtools (former so3 resource)
269 OUString aErr(SvtResId(STR_ERROR_OBJNOCREATE));
270 aErr = aErr.replaceFirst( "%", aServerName );
272 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
273 VclMessageType::Warning, VclButtonsType::Ok, aErr));
274 xBox->run();
279 else
281 aFileName = m_xEdFilepath->get_text();
282 INetURLObject aURL;
283 aURL.SetSmartProtocol( INetProtocol::File );
284 aURL.SetSmartURL( aFileName );
285 aFileName = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
286 bool bLink = m_xCbFilelink->get_active();
288 if ( !aFileName.isEmpty() )
290 const uno::Reference< uno::XComponentContext >& xContext = ::comphelper::getProcessComponentContext();
291 uno::Reference< task::XInteractionHandler2 > xInteraction(
292 task::InteractionHandler::createWithParent(xContext, nullptr) );
294 // create MediaDescriptor for file to create object from
295 uno::Sequence < beans::PropertyValue > aMedium{
296 comphelper::makePropertyValue(u"URL"_ustr, aFileName),
297 comphelper::makePropertyValue(u"InteractionHandler"_ustr, xInteraction)
300 // create object from media descriptor
302 uno::Reference<task::XStatusIndicator> xProgress;
303 if (SfxViewFrame* pFrame = SfxViewFrame::Current())
305 // Have a current frame, create visual indication that insert is in progress.
306 uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame().GetFrameInterface();
307 uno::Reference<task::XStatusIndicatorFactory> xProgressFactory(xFrame, uno::UNO_QUERY);
308 if (xProgressFactory.is())
310 xProgress = xProgressFactory->createStatusIndicator();
311 if (xProgress)
313 OUString aOleInsert(CuiResId(RID_CUISTR_OLE_INSERT));
314 xProgress->start(aOleInsert, 100);
319 if ( bLink )
320 m_xObj = aCnt.InsertEmbeddedLink( aMedium, aName );
321 else
322 m_xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
324 if (xProgress.is())
326 xProgress->end();
330 if ( !m_xObj.is() )
332 // object couldn't be created from file
333 // global Resource from svtools (former so3 resource)
334 OUString aErr(SvtResId(STR_ERROR_OBJNOCREATE_FROM_FILE));
335 aErr = aErr.replaceFirst( "%", aFileName );
337 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
338 VclMessageType::Warning, VclButtonsType::Ok, aErr));
339 xBox->run();
341 else
343 if (m_xCbAsIcon->get_active())
345 //something nice here I guess would be to write the filename into
346 //the image with this icon above it
347 Image aImage = SvFileInformationManager::GetImage(aURL, true);
348 SvMemoryStream aTemp;
349 WriteDIBBitmapEx(aImage.GetBitmapEx(), aTemp);
350 m_aIconMetaFile = Sequence<sal_Int8>(static_cast<const sal_Int8*>(aTemp.GetData()), aTemp.TellEnd());
351 m_aIconMediaType = "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"";
357 m_pServers = nullptr;
358 return nRet;
361 uno::Reference< io::XInputStream > SvInsertOleDlg::GetIconIfIconified( OUString* pGraphicMediaType )
363 if ( m_aIconMetaFile.hasElements() )
365 if ( pGraphicMediaType )
366 *pGraphicMediaType = m_aIconMediaType;
368 return uno::Reference< io::XInputStream >( new ::comphelper::SequenceInputStream( m_aIconMetaFile ) );
371 return uno::Reference< io::XInputStream >();
375 SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog(weld::Window *pParent,
376 const css::uno::Reference < css::embed::XStorage >& xStorage)
377 : InsertObjectDialog_Impl(pParent, u"cui/ui/insertfloatingframe.ui"_ustr, u"InsertFloatingFrameDialog"_ustr,
378 xStorage)
380 Init();
383 SfxInsertFloatingFrameDialog::SfxInsertFloatingFrameDialog(weld::Window *pParent,
384 const uno::Reference < embed::XEmbeddedObject >& xObj)
385 : InsertObjectDialog_Impl(pParent, u"cui/ui/insertfloatingframe.ui"_ustr, u"InsertFloatingFrameDialog"_ustr,
386 uno::Reference<embed::XStorage>())
388 m_xObj = xObj;
390 Init();
393 void SfxInsertFloatingFrameDialog::Init()
395 m_xEDName = m_xBuilder->weld_entry(u"edname"_ustr);
396 m_xEDURL = m_xBuilder->weld_entry(u"edurl"_ustr);
397 m_xBTOpen = m_xBuilder->weld_button(u"buttonbrowse"_ustr);
398 m_xRBScrollingOn = m_xBuilder->weld_radio_button(u"scrollbaron"_ustr);
399 m_xRBScrollingOff = m_xBuilder->weld_radio_button(u"scrollbaroff"_ustr);
400 m_xRBScrollingAuto = m_xBuilder->weld_radio_button(u"scrollbarauto"_ustr);
401 m_xRBFrameBorderOn = m_xBuilder->weld_radio_button(u"borderon"_ustr);
402 m_xRBFrameBorderOff = m_xBuilder->weld_radio_button(u"borderoff"_ustr);
403 m_xFTMarginWidth = m_xBuilder->weld_label(u"widthlabel"_ustr);
404 m_xNMMarginWidth = m_xBuilder->weld_spin_button(u"width"_ustr);
405 m_xCBMarginWidthDefault = m_xBuilder->weld_check_button(u"defaultwidth"_ustr);
406 m_xFTMarginHeight = m_xBuilder->weld_label(u"heightlabel"_ustr);
407 m_xNMMarginHeight = m_xBuilder->weld_spin_button(u"height"_ustr);
408 m_xCBMarginHeightDefault = m_xBuilder->weld_check_button(u"defaultheight"_ustr);
410 Link<weld::Toggleable&, void> aLink(LINK(this, SfxInsertFloatingFrameDialog, CheckHdl));
411 m_xCBMarginWidthDefault->connect_toggled(aLink);
412 m_xCBMarginHeightDefault->connect_toggled(aLink);
414 m_xCBMarginWidthDefault->set_active(true);
415 m_xCBMarginHeightDefault->set_active(true);
416 m_xRBScrollingAuto->set_active(true);
417 m_xRBFrameBorderOn->set_active(true);
419 m_xBTOpen->connect_clicked(LINK(this, SfxInsertFloatingFrameDialog, OpenHdl));
422 short SfxInsertFloatingFrameDialog::run()
424 short nRet = RET_OK;
425 bool bOK = false;
426 uno::Reference < beans::XPropertySet > xSet;
427 if ( m_xObj.is() )
431 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
432 m_xObj->changeState( embed::EmbedStates::RUNNING );
433 xSet.set( m_xObj->getComponent(), uno::UNO_QUERY );
434 OUString aStr;
435 uno::Any aAny = xSet->getPropertyValue( u"FrameURL"_ustr );
436 if ( aAny >>= aStr )
437 m_xEDURL->set_text( aStr );
438 aAny = xSet->getPropertyValue( u"FrameName"_ustr );
439 if ( aAny >>= aStr )
440 m_xEDName->set_text(aStr);
442 sal_Int32 nSize = SIZE_NOT_SET;
443 aAny = xSet->getPropertyValue( u"FrameMarginWidth"_ustr );
444 aAny >>= nSize;
446 if ( nSize == SIZE_NOT_SET )
448 m_xCBMarginWidthDefault->set_active(true);
449 m_xNMMarginWidth->set_text(OUString::number(DEFAULT_MARGIN_WIDTH));
450 m_xFTMarginWidth->set_sensitive(false);
451 m_xNMMarginWidth->set_sensitive(false);
453 else
454 m_xNMMarginWidth->set_text(OUString::number(nSize));
456 aAny = xSet->getPropertyValue( u"FrameMarginHeight"_ustr );
457 aAny >>= nSize;
459 if ( nSize == SIZE_NOT_SET )
461 m_xCBMarginHeightDefault->set_active(true);
462 m_xNMMarginHeight->set_text(OUString::number(DEFAULT_MARGIN_HEIGHT));
463 m_xFTMarginHeight->set_sensitive(false);
464 m_xNMMarginHeight->set_sensitive(false);
466 else
467 m_xNMMarginHeight->set_text(OUString::number(nSize));
469 bool bScrollOn = false;
470 bool bScrollOff = false;
471 bool bScrollAuto = false;
473 bool bSet = false;
474 aAny = xSet->getPropertyValue( u"FrameIsAutoScroll"_ustr );
475 aAny >>= bSet;
476 if ( !bSet )
478 aAny = xSet->getPropertyValue( u"FrameIsScrollingMode"_ustr );
479 aAny >>= bSet;
480 bScrollOn = bSet;
481 bScrollOff = !bSet;
483 else
484 bScrollAuto = true;
486 m_xRBScrollingOn->set_sensitive(bScrollOn);
487 m_xRBScrollingOff->set_sensitive(bScrollOff);
488 m_xRBScrollingAuto->set_sensitive(bScrollAuto);
490 bSet = false;
491 aAny = xSet->getPropertyValue( u"FrameIsAutoBorder"_ustr );
492 aAny >>= bSet;
493 if ( !bSet )
495 aAny = xSet->getPropertyValue( u"FrameIsBorder"_ustr );
496 aAny >>= bSet;
497 m_xRBFrameBorderOn->set_active(bSet);
498 m_xRBFrameBorderOff->set_active(!bSet);
501 bOK = true;
503 catch ( uno::Exception& )
505 OSL_FAIL( "No IFrame!" );
508 else
510 DBG_ASSERT( m_xStorage.is(), "No storage!");
511 bOK = m_xStorage.is();
514 if (!bOK)
515 return RET_OK;
517 nRet = InsertObjectDialog_Impl::run();
518 if ( nRet == RET_OK )
520 OUString aURL;
521 if (!m_xEDURL->get_text().isEmpty())
523 // URL can be a valid and absolute URL or a system file name
524 INetURLObject aObj;
525 aObj.SetSmartProtocol( INetProtocol::File );
526 if ( aObj.SetSmartURL( m_xEDURL->get_text() ) )
527 aURL = aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
530 if ( !m_xObj.is() && !aURL.isEmpty() )
532 // create the object
533 OUString aName;
534 SvGlobalName aClassId( SO3_IFRAME_CLASSID );
535 m_xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aName );
536 if ( m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
537 m_xObj->changeState( embed::EmbedStates::RUNNING );
538 xSet.set( m_xObj->getComponent(), uno::UNO_QUERY );
541 if ( m_xObj.is() )
545 bool bIPActive = m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
546 if ( bIPActive )
547 m_xObj->changeState( embed::EmbedStates::RUNNING );
549 OUString aName = m_xEDName->get_text();
550 ScrollingMode eScroll = ScrollingMode::No;
551 if (m_xRBScrollingOn->get_active())
552 eScroll = ScrollingMode::Yes;
553 if (m_xRBScrollingOff->get_active())
554 eScroll = ScrollingMode::No;
555 if (m_xRBScrollingAuto->get_active())
556 eScroll = ScrollingMode::Auto;
558 bool bHasBorder = m_xRBFrameBorderOn->get_active();
560 tools::Long lMarginWidth;
561 if (!m_xCBMarginWidthDefault->get_active())
562 lMarginWidth = static_cast<tools::Long>(m_xNMMarginWidth->get_text().toInt32());
563 else
564 lMarginWidth = SIZE_NOT_SET;
566 tools::Long lMarginHeight;
567 if (!m_xCBMarginHeightDefault->get_active())
568 lMarginHeight = static_cast<tools::Long>(m_xNMMarginHeight->get_text().toInt32());
569 else
570 lMarginHeight = SIZE_NOT_SET;
572 xSet->setPropertyValue( u"FrameURL"_ustr, Any( aURL ) );
573 xSet->setPropertyValue( u"FrameName"_ustr, Any( aName ) );
575 if ( eScroll == ScrollingMode::Auto )
576 xSet->setPropertyValue( u"FrameIsAutoScroll"_ustr, Any( true ) );
577 else
578 xSet->setPropertyValue( u"FrameIsScrollingMode"_ustr, Any( eScroll == ScrollingMode::Yes ) );
580 xSet->setPropertyValue( u"FrameIsBorder"_ustr, Any( bHasBorder ) );
581 xSet->setPropertyValue( u"FrameMarginWidth"_ustr, Any( sal_Int32( lMarginWidth ) ) );
582 xSet->setPropertyValue( u"FrameMarginHeight"_ustr, Any( sal_Int32( lMarginHeight ) ) );
584 if ( bIPActive )
585 m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
587 catch ( uno::Exception& )
589 OSL_FAIL( "No IFrame!" );
594 return nRet;
597 IMPL_LINK(SfxInsertFloatingFrameDialog, CheckHdl, weld::Toggleable&, rButton, void)
599 weld::CheckButton& rCB = dynamic_cast<weld::CheckButton&>(rButton);
600 if (&rCB == m_xCBMarginWidthDefault.get())
602 if (rCB.get_active())
603 m_xNMMarginWidth->set_text(OUString::number(DEFAULT_MARGIN_WIDTH));
604 m_xFTMarginWidth->set_sensitive(!rCB.get_active());
605 m_xNMMarginWidth->set_sensitive(!rCB.get_active());
608 if (&rCB == m_xCBMarginHeightDefault.get())
610 if (rCB.get_active())
611 m_xNMMarginHeight->set_text(OUString::number(DEFAULT_MARGIN_HEIGHT));
612 m_xFTMarginHeight->set_sensitive(!rCB.get_active());
613 m_xNMMarginHeight->set_sensitive(!rCB.get_active());
617 IMPL_LINK_NOARG( SfxInsertFloatingFrameDialog, OpenHdl, weld::Button&, void)
619 // create the file dialog
620 sfx2::FileDialogHelper aFileDlg(
621 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, OUString(),
622 SfxFilterFlags::NONE, SfxFilterFlags::NONE, m_xDialog.get());
624 // set the title
625 aFileDlg.SetTitle(CuiResId(RID_CUISTR_SELECT_FILE_IFRAME));
627 // show the dialog
628 if ( aFileDlg.Execute() == ERRCODE_NONE )
629 m_xEDURL->set_text(INetURLObject(aFileDlg.GetPath()).GetMainURL(INetURLObject::DecodeMechanism::WithCharset));
632 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */