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>
33 #include <dialmgr.hxx>
34 #include <osl/diagnose.h>
36 #include <svtools/strings.hrc>
52 #include <strings.hrc>
67 return uno::Reference< io::XInputStream >();
71 const OUString& rUIXMLDescription,
const OString& rID,
72 const css::uno::Reference < css::embed::XStorage >& xStorage)
73 : GenericDialogController(pParent, rUIXMLDescription, rID)
74 , m_xStorage( xStorage )
88 const Reference< XFilePicker3 >& xFilePicker =
aHelper.GetFilePicker();
93 xFilePicker->appendFilter(
CuiResId(RID_SVXSTR_FILTER_ALL),
"*.*");
95 catch(
const IllegalArgumentException& )
100 if( xFilePicker->execute() == ExecutableDialogResults::OK )
104 m_xEdFilepath->set_text(aObj.PathToFileName());
110 if (m_xRbNewObject->get_active())
112 m_xObjectTypeFrame->show();
113 m_xFileFrame->hide();
117 m_xFileFrame->show();
118 m_xObjectTypeFrame->hide();
125 , m_pServers( pServers )
126 , m_xRbNewObject(m_xBuilder->weld_radio_button(
"createnew"))
127 , m_xRbObjectFromfile(m_xBuilder->weld_radio_button(
"createfromfile"))
128 , m_xObjectTypeFrame(m_xBuilder->weld_frame(
"objecttypeframe"))
129 , m_xLbObjecttype(m_xBuilder->weld_tree_view(
"types"))
130 , m_xFileFrame(m_xBuilder->weld_frame(
"fileframe"))
131 , m_xEdFilepath(m_xBuilder->weld_entry(
"urled"))
132 , m_xBtnFilepath(m_xBuilder->weld_button(
"urlbtn"))
133 , m_xCbFilelink(m_xBuilder->weld_check_button(
"linktofile"))
134 , m_xCbAsIcon(m_xBuilder->weld_check_button(
"asicon"))
181 uno::Reference < embed::XInsertObjectDialog > xDialogCreator(
185 if ( xDialogCreator.is() )
188 const embed::InsertedObjectInfo aNewInf = xDialogCreator->createInstanceByDialog(
191 uno::Sequence < beans::PropertyValue >() );
193 OSL_ENSURE( aNewInf.Object.is(),
"The object must be created or an exception must be thrown!" );
195 for (
const auto& opt : aNewInf.Options )
196 if ( opt.Name ==
"Icon" )
200 else if ( opt.Name ==
"IconFormat" )
202 datatransfer::DataFlavor aFlavor;
203 if ( opt.Value >>= aFlavor )
209 catch( ucb::CommandAbortedException& )
213 catch( uno::Exception& )
226 if( !aFileName.isEmpty() )
230 OUString aErr(
SvtResId(STR_ERROR_OBJNOCREATE_FROM_FILE));
231 aErr = aErr.replaceFirst(
"%", aFileName );
234 VclMessageType::Warning, VclButtonsType::Ok, aErr));
241 OUString aErr(
SvtResId(STR_ERROR_OBJNOCREATE));
242 aErr = aErr.replaceFirst(
"%", aServerName );
245 VclMessageType::Warning, VclButtonsType::Ok, aErr));
260 if ( !aFileName.isEmpty() )
263 uno::Sequence < beans::PropertyValue > aMedium( 2 );
264 aMedium[0].Name =
"URL";
265 aMedium[0].Value <<= aFileName;
267 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
268 uno::Reference< task::XInteractionHandler2 > xInteraction(
269 task::InteractionHandler::createWithParent(xContext,
nullptr) );
271 aMedium[1].Name =
"InteractionHandler";
272 aMedium[1].Value <<= xInteraction;
285 OUString aErr(
SvtResId(STR_ERROR_OBJNOCREATE_FROM_FILE));
286 aErr = aErr.replaceFirst(
"%", aFileName );
289 VclMessageType::Warning, VclButtonsType::Ok, aErr));
302 m_aIconMediaType =
"application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"";
316 if ( pGraphicMediaType )
319 return uno::Reference< io::XInputStream >( new ::comphelper::SequenceInputStream(
m_aIconMetaFile ) );
322 return uno::Reference< io::XInputStream >();
327 const css::uno::Reference < css::embed::XStorage >& xStorage)
335 const uno::Reference < embed::XEmbeddedObject >& xObj)
377 uno::Reference < beans::XPropertySet > xSet;
382 if (
m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
383 m_xObj->changeState( embed::EmbedStates::RUNNING );
384 xSet.set(
m_xObj->getComponent(), uno::UNO_QUERY );
386 uno::Any aAny = xSet->getPropertyValue(
"FrameURL" );
389 aAny = xSet->getPropertyValue(
"FrameName" );
394 aAny = xSet->getPropertyValue(
"FrameMarginWidth" );
407 aAny = xSet->getPropertyValue(
"FrameMarginHeight" );
420 bool bScrollOn =
false;
421 bool bScrollOff =
false;
422 bool bScrollAuto =
false;
425 aAny = xSet->getPropertyValue(
"FrameIsAutoScroll" );
429 aAny = xSet->getPropertyValue(
"FrameIsScrollingMode" );
442 aAny = xSet->getPropertyValue(
"FrameIsAutoBorder" );
446 aAny = xSet->getPropertyValue(
"FrameIsBorder" );
454 catch ( uno::Exception& )
456 OSL_FAIL(
"No IFrame!" );
472 if (!
m_xEDURL->get_text().isEmpty())
481 if ( !
m_xObj.is() && !aURL.isEmpty() )
487 if (
m_xObj->getCurrentState() == embed::EmbedStates::LOADED )
488 m_xObj->changeState( embed::EmbedStates::RUNNING );
489 xSet.set(
m_xObj->getComponent(), uno::UNO_QUERY );
496 bool bIPActive =
m_xObj->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE;
498 m_xObj->changeState( embed::EmbedStates::RUNNING );
503 eScroll = ScrollingMode::Yes;
505 eScroll = ScrollingMode::No;
507 eScroll = ScrollingMode::Auto;
513 lMarginWidth = static_cast<tools::Long>(
m_xNMMarginWidth->get_text().toInt32());
519 lMarginHeight = static_cast<tools::Long>(
m_xNMMarginHeight->get_text().toInt32());
523 xSet->setPropertyValue(
"FrameURL",
Any( aURL ) );
524 xSet->setPropertyValue(
"FrameName",
Any( aName ) );
526 if ( eScroll == ScrollingMode::Auto )
527 xSet->setPropertyValue(
"FrameIsAutoScroll",
Any(
true ) );
529 xSet->setPropertyValue(
"FrameIsScrollingMode",
Any( eScroll == ScrollingMode::Yes ) );
531 xSet->setPropertyValue(
"FrameIsBorder",
Any( bHasBorder ) );
532 xSet->setPropertyValue(
"FrameMarginWidth",
Any( sal_Int32( lMarginWidth ) ) );
533 xSet->setPropertyValue(
"FrameMarginHeight",
Any( sal_Int32( lMarginHeight ) ) );
536 m_xObj->changeState( embed::EmbedStates::INPLACE_ACTIVE );
538 catch ( uno::Exception& )
540 OSL_FAIL(
"No IFrame!" );
551 if (&rCB == m_xCBMarginWidthDefault.get())
556 m_xNMMarginWidth->set_sensitive(!rCB.
get_active());
559 if (&rCB == m_xCBMarginHeightDefault.get())
563 m_xFTMarginHeight->set_sensitive(!rCB.
get_active());
564 m_xNMMarginHeight->set_sensitive(!rCB.
get_active());
572 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, OUString(),
573 SfxFilterFlags::NONE, SfxFilterFlags::NONE,
m_xDialog.get());
#define LINK(Instance, Class, Member)
std::shared_ptr< weld::Dialog > m_xDialog
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
OUString SvtResId(const char *pId)
SvInsertOleDlg(weld::Window *pParent, const css::uno::Reference< css::embed::XStorage > &xStorage, const SvObjectServerList *pServers)
std::unique_ptr< weld::Builder > m_xBuilder
std::unique_ptr< weld::CheckButton > m_xCbAsIcon
#define SO3_IFRAME_CLASSID
InsertObjectDialog_Impl(weld::Window *pParent, const OUString &rUIXMLDescription, const OString &rID, const css::uno::Reference< css::embed::XStorage > &xStorage)
exports com.sun.star. embed
css::uno::Sequence< sal_Int8 > GetByteSequence() const
std::unique_ptr< weld::Button > m_xBtnFilepath
css::uno::Reference< css::embed::XEmbeddedObject > InsertEmbeddedLink(const css::uno::Sequence< css::beans::PropertyValue > &, OUString &)
IMPL_LINK_NOARG(SvInsertOleDlg, DoubleClickHdl, weld::TreeView &, bool)
#define DEFAULT_MARGIN_WIDTH
virtual css::uno::Reference< css::io::XInputStream > GetIconIfIconified(OUString *pGraphicMediaType)
virtual sal_uInt64 TellEnd() override
const SvObjectServer * Get(std::u16string_view rHumanName) const
OUString CreateUniqueObjectName()
#define TOOLS_WARN_EXCEPTION(area, stream)
std::unique_ptr< weld::RadioButton > m_xRbObjectFromfile
#define DBG_ASSERT(sCon, aError)
void SetSmartProtocol(INetProtocol eTheSmartScheme)
comphelper::EmbeddedObjectContainer aCnt
#define DEFAULT_MARGIN_HEIGHT
std::unique_ptr< weld::CheckButton > m_xCbFilelink
virtual short run() override
OUString m_aIconMediaType
const css::uno::Reference< css::embed::XStorage > m_xStorage
css::uno::Reference< css::embed::XEmbeddedObject > m_xObj
css::uno::Reference< css::io::XInputStream > GetIconIfIconified(OUString *pGraphicMediaType) override
get replacement for the iconified embedded object and the mediatype of the replacement ...
OUString CuiResId(const char *pKey)
void SetTitle(const OUString &rNewTitle)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
css::uno::Sequence< sal_Int8 > m_aIconMetaFile
const SvGlobalName & GetClassName() const
std::unique_ptr< weld::TreeView > m_xLbObjecttype
Reference< XExecutableDialog > m_xDialog
Reference< XComponentContext > getProcessComponentContext()
BitmapEx GetBitmapEx() const
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
virtual bool IsCreateNew() const
std::unique_ptr< weld::Entry > m_xEdFilepath
std::unique_ptr< weld::RadioButton > m_xRbNewObject
IMPL_LINK(SfxInsertFloatingFrameDialog, CheckHdl, weld::Button &, rButton, void)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
bool SetSmartURL(OUString const &rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
const SvObjectServerList * m_pServers
bool IsCreateNew() const override