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>
36#include <osl/diagnose.h>
38#include <svtools/strings.hrc>
75 const OUString& rUIXMLDescription,
const OUString& rID,
76 css::uno::Reference < css::embed::XStorage > xStorage)
77 : GenericDialogController(pParent, rUIXMLDescription, rID)
78 , m_xStorage(
std::move( xStorage ))
93 const Reference< XFilePicker3 >& xFilePicker =
aHelper.GetFilePicker();
98 xFilePicker->appendFilter(
CuiResId(RID_CUISTR_FILTER_ALL),
"*.*");
100 catch(
const IllegalArgumentException& )
102 TOOLS_WARN_EXCEPTION(
"cui.dialogs",
"caught IllegalArgumentException when registering filter" );
105 if( xFilePicker->execute() == ExecutableDialogResults::OK )
115 if (!rButton.get_active())
118 if (m_xRbNewObject->get_active())
120 m_xObjectTypeFrame->show();
121 m_xFileFrame->hide();
125 m_xFileFrame->show();
126 m_xObjectTypeFrame->hide();
133 , m_pServers( pServers )
134 , m_xRbNewObject(m_xBuilder->weld_radio_button(
"createnew"))
135 , m_xRbObjectFromfile(m_xBuilder->weld_radio_button(
"createfromfile"))
136 , m_xObjectTypeFrame(m_xBuilder->weld_frame(
"objecttypeframe"))
137 , m_xLbObjecttype(m_xBuilder->weld_tree_view(
"types"))
138 , m_xFileFrame(m_xBuilder->weld_frame(
"fileframe"))
139 , m_xEdFilepath(m_xBuilder->weld_entry(
"urled"))
140 , m_xBtnFilepath(m_xBuilder->weld_button(
"urlbtn"))
141 , m_xCbFilelink(m_xBuilder->weld_check_button(
"linktofile"))
142 , m_xCbAsIcon(m_xBuilder->weld_check_button(
"asicon"))
190 embed::MSOLEObjectSystemCreator::create( ::comphelper::getProcessComponentContext() ),
193 if ( xDialogCreator.is() )
198 OUString aProgressText;
203 = pFrame->GetFrame().GetFrameInterface();
206 if (xProgressFactory.is())
208 xProgress = xProgressFactory->createStatusIndicator();
211 aProgressText =
CuiResId(RID_CUISTR_OLE_INSERT);
216 const embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
222 OSL_ENSURE( aNewInf.Object.is(),
"The object must be created or an exception must be thrown!" );
224 for (
const auto& opt : aNewInf.Options )
225 if ( opt.Name ==
"Icon" )
229 else if ( opt.Name ==
"IconFormat" )
231 datatransfer::DataFlavor aFlavor;
232 if ( opt.Value >>= aFlavor )
238 catch( ucb::CommandAbortedException& )
242 catch( uno::Exception& )
255 if( !aFileName.isEmpty() )
259 OUString aErr(
SvtResId(STR_ERROR_OBJNOCREATE_FROM_FILE));
260 aErr = aErr.replaceFirst(
"%", aFileName );
263 VclMessageType::Warning, VclButtonsType::Ok, aErr));
270 OUString aErr(
SvtResId(STR_ERROR_OBJNOCREATE));
271 aErr = aErr.replaceFirst(
"%", aServerName );
274 VclMessageType::Warning, VclButtonsType::Ok, aErr));
284 aURL.SetSmartProtocol( INetProtocol::File );
285 aURL.SetSmartURL( aFileName );
289 if ( !aFileName.isEmpty() )
293 task::InteractionHandler::createWithParent(xContext,
nullptr) );
309 if (xProgressFactory.is())
311 xProgress = xProgressFactory->createStatusIndicator();
314 OUString aOleInsert(
CuiResId(RID_CUISTR_OLE_INSERT));
315 xProgress->start(aOleInsert, 100);
335 OUString aErr(
SvtResId(STR_ERROR_OBJNOCREATE_FROM_FILE));
336 aErr = aErr.replaceFirst(
"%", aFileName );
339 VclMessageType::Warning, VclButtonsType::Ok, aErr));
352 m_aIconMediaType =
"application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"";
366 if ( pGraphicMediaType )
377 const css::uno::Reference < css::embed::XStorage >& xStorage)
432 if (
m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
433 m_xObj->changeState( embed::EmbedStates::RUNNING );
434 xSet.set(
m_xObj->getComponent(), uno::UNO_QUERY );
436 uno::Any aAny = xSet->getPropertyValue(
"FrameURL" );
439 aAny = xSet->getPropertyValue(
"FrameName" );
444 aAny = xSet->getPropertyValue(
"FrameMarginWidth" );
457 aAny = xSet->getPropertyValue(
"FrameMarginHeight" );
470 bool bScrollOn =
false;
471 bool bScrollOff =
false;
472 bool bScrollAuto =
false;
475 aAny = xSet->getPropertyValue(
"FrameIsAutoScroll" );
479 aAny = xSet->getPropertyValue(
"FrameIsScrollingMode" );
492 aAny = xSet->getPropertyValue(
"FrameIsAutoBorder" );
496 aAny = xSet->getPropertyValue(
"FrameIsBorder" );
504 catch ( uno::Exception& )
506 OSL_FAIL(
"No IFrame!" );
522 if (!
m_xEDURL->get_text().isEmpty())
537 if (
m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
538 m_xObj->changeState( embed::EmbedStates::RUNNING );
539 xSet.set(
m_xObj->getComponent(), uno::UNO_QUERY );
546 bool bIPActive =
m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
548 m_xObj->changeState( embed::EmbedStates::RUNNING );
553 eScroll = ScrollingMode::Yes;
555 eScroll = ScrollingMode::No;
557 eScroll = ScrollingMode::Auto;
573 xSet->setPropertyValue(
"FrameURL",
Any(
aURL ) );
574 xSet->setPropertyValue(
"FrameName",
Any(
aName ) );
576 if ( eScroll == ScrollingMode::Auto )
577 xSet->setPropertyValue(
"FrameIsAutoScroll",
Any(
true ) );
579 xSet->setPropertyValue(
"FrameIsScrollingMode",
Any( eScroll == ScrollingMode::Yes ) );
581 xSet->setPropertyValue(
"FrameIsBorder",
Any( bHasBorder ) );
582 xSet->setPropertyValue(
"FrameMarginWidth",
Any( sal_Int32( lMarginWidth ) ) );
583 xSet->setPropertyValue(
"FrameMarginHeight",
Any( sal_Int32( lMarginHeight ) ) );
586 m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
588 catch ( uno::Exception& )
590 OSL_FAIL(
"No IFrame!" );
601 if (&rCB == m_xCBMarginWidthDefault.get())
606 m_xNMMarginWidth->set_sensitive(!rCB.
get_active());
609 if (&rCB == m_xCBMarginHeightDefault.get())
613 m_xFTMarginHeight->set_sensitive(!rCB.
get_active());
614 m_xNMMarginHeight->set_sensitive(!rCB.
get_active());
622 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, OUString(),
623 SfxFilterFlags::NONE, SfxFilterFlags::NONE,
m_xDialog.get());
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
void SetSmartProtocol(INetProtocol eTheSmartScheme)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
OUString PathToFileName() const
BitmapEx GetBitmapEx() const
virtual bool IsCreateNew() const
css::uno::Reference< css::embed::XEmbeddedObject > m_xObj
const css::uno::Reference< css::embed::XStorage > m_xStorage
comphelper::EmbeddedObjectContainer aCnt
InsertObjectDialog_Impl(weld::Window *pParent, const OUString &rUIXMLDescription, const OUString &rID, css::uno::Reference< css::embed::XStorage > xStorage)
virtual css::uno::Reference< css::io::XInputStream > GetIconIfIconified(OUString *pGraphicMediaType)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
css::uno::Sequence< sal_Int8 > GetByteSequence() const
std::unique_ptr< weld::Entry > m_xEdFilepath
std::unique_ptr< weld::RadioButton > m_xRbNewObject
bool IsCreateNew() const override
std::unique_ptr< weld::Button > m_xBtnFilepath
const SvObjectServerList * m_pServers
std::unique_ptr< weld::CheckButton > m_xCbAsIcon
virtual short run() override
std::unique_ptr< weld::RadioButton > m_xRbObjectFromfile
std::unique_ptr< weld::CheckButton > m_xCbFilelink
std::unique_ptr< weld::TreeView > m_xLbObjecttype
SvInsertOleDlg(weld::Window *pParent, const css::uno::Reference< css::embed::XStorage > &xStorage, const SvObjectServerList *pServers)
css::uno::Reference< css::io::XInputStream > GetIconIfIconified(OUString *pGraphicMediaType) override
get replacement for the iconified embedded object and the mediatype of the replacement
css::uno::Sequence< sal_Int8 > m_aIconMetaFile
OUString m_aIconMediaType
virtual sal_uInt64 TellEnd() override
const SvObjectServer * Get(std::u16string_view rHumanName) const
OUString CreateUniqueObjectName()
css::uno::Reference< css::embed::XEmbeddedObject > InsertEmbeddedLink(const css::uno::Sequence< css::beans::PropertyValue > &, OUString &)
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
#define SO3_IFRAME_CLASSID
void SetTitle(const OUString &rNewTitle)
std::shared_ptr< weld::Dialog > m_xDialog
std::unique_ptr< weld::Builder > m_xBuilder
virtual bool get_active() const=0
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
IMPL_LINK_NOARG(SvInsertOleDlg, DoubleClickHdl, weld::TreeView &, bool)
IMPL_LINK(SvInsertOleDlg, RadioHdl, weld::Toggleable &, rButton, void)
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Reference< XFrame > xFrame
SVT_DLLPUBLIC OUString SvtResId(TranslateId aId)
#define DEFAULT_MARGIN_HEIGHT
#define DEFAULT_MARGIN_WIDTH