22#include <com/sun/star/awt/XVclWindowPeer.hpp>
23#include <com/sun/star/frame/XDispatch.hpp>
24#include <com/sun/star/frame/Frame.hpp>
25#include <com/sun/star/frame/XFrame2.hpp>
26#include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
27#include <com/sun/star/task/InteractionHandler.hpp>
28#include <com/sun/star/util/URLTransformer.hpp>
29#include <com/sun/star/util/XURLTransformer.hpp>
30#include <com/sun/star/util/XCloseable.hpp>
31#include <com/sun/star/lang/XEventListener.hpp>
32#include <com/sun/star/lang/XServiceInfo.hpp>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
35#include <com/sun/star/embed/XEmbeddedObject.hpp>
40#include <officecfg/Office/Common.hxx>
57class IFrameObject :
public ::cppu::WeakImplHelper <
58 css::util::XCloseable,
59 css::lang::XEventListener,
60 css::frame::XSynchronousFrameLoader,
61 css::ui::dialogs::XExecutableDialog,
62 css::lang::XServiceInfo,
63 css::beans::XPropertySet >
65 css::uno::Reference < css::uno::XComponentContext >
mxContext;
66 css::uno::Reference < css::frame::XFrame2 > mxFrame;
67 css::uno::Reference < css::embed::XEmbeddedObject > mxObj;
74 IFrameObject(css::uno::Reference < css::uno::XComponentContext> xContext,
const css::uno::Sequence< css::uno::Any >& aArguments);
78 return "com.sun.star.comp.sfx2.IFrameObject";
88 css::uno::Sequence< OUString >
aSeq {
"com.sun.star.frame.SpecialEmbeddedObject" };
92 virtual sal_Bool SAL_CALL load(
const css::uno::Sequence < css::beans::PropertyValue >& lDescriptor,
93 const css::uno::Reference < css::frame::XFrame >& xFrame )
override;
94 virtual void SAL_CALL cancel()
override;
95 virtual void SAL_CALL
close(
sal_Bool bDeliverOwnership )
override;
96 virtual void SAL_CALL addCloseListener(
const css::uno::Reference < css::util::XCloseListener >& xListener )
override;
97 virtual void SAL_CALL removeCloseListener(
const css::uno::Reference < css::util::XCloseListener >& xListener )
override;
98 virtual void SAL_CALL disposing(
const css::lang::EventObject& aEvent )
override ;
99 virtual void SAL_CALL setTitle(
const OUString& aTitle )
override;
100 virtual ::sal_Int16 SAL_CALL execute( )
override;
101 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
override;
102 virtual void SAL_CALL addPropertyChangeListener(
const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener > & aListener)
override;
103 virtual void SAL_CALL removePropertyChangeListener(
const OUString& aPropertyName,
const css::uno::Reference< css::beans::XPropertyChangeListener > & aListener)
override;
104 virtual void SAL_CALL addVetoableChangeListener(
const OUString& aPropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener)
override;
105 virtual void SAL_CALL removeVetoableChangeListener(
const OUString& aPropertyName,
const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener)
override;
106 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
107 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
113 IFrameWindow_Impl(
vcl::Window *pParent,
bool bHasBorder );
116IFrameWindow_Impl::IFrameWindow_Impl(
vcl::Window *pParent,
bool bHasBorder )
120 SetBorderStyle( WindowBorderStyle::NOBORDER );
122 SetBorderStyle( WindowBorderStyle::NORMAL );
125#define PROPERTY_UNBOUND 0
127#define WID_FRAME_URL 1
128#define WID_FRAME_NAME 2
129#define WID_FRAME_IS_AUTO_SCROLL 3
130#define WID_FRAME_IS_SCROLLING_MODE 4
131#define WID_FRAME_IS_BORDER 5
132#define WID_FRAME_IS_AUTO_BORDER 6
133#define WID_FRAME_MARGIN_WIDTH 7
134#define WID_FRAME_MARGIN_HEIGHT 8
149 return aIFramePropertyMap_Impl;
152IFrameObject::IFrameObject(uno::Reference < uno::XComponentContext > xContext,
const css::uno::Sequence< css::uno::Any >& aArguments)
154 , maPropMap( lcl_GetIFramePropertyMap_Impl() )
160sal_Bool SAL_CALL IFrameObject::load(
161 const uno::Sequence < css::beans::PropertyValue >& ,
162 const uno::Reference < frame::XFrame >& xFrame )
164 if ( officecfg::Office::Common::Misc::PluginsEnabled::get() )
168 uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) );
169 xTrans->parseStrict( aTargetURL );
172 if (aURLObject.GetProtocol() == INetProtocol::Macro || aURLObject.isSchemeEqualTo(u
"vnd.sun.star.script"))
175 uno::Reference<frame::XFramesSupplier> xParentFrame =
xFrame->getCreator();
178 const bool bIsFactoryURL =
aTargetURL.Complete.startsWith(
"private:factory/");
181 bool bUpdateAllowed(
true);
195 uno::Reference<css::awt::XWindow> xParentWindow(
xFrame->getContainerWindow());
201 pWin->SetSizePixel( pParent->GetOutputSizePixel() );
202 pWin->SetBackground();
205 uno::Reference < awt::XWindow > xWindow( pWin->GetComponentInterface(), uno::UNO_QUERY );
206 xFrame->setComponent( xWindow, uno::Reference < frame::XController >() );
209 xWindow->addEventListener(
this );
211 mxFrame = frame::Frame::create( mxContext );
212 uno::Reference < awt::XWindow > xWin( pWin->GetComponentInterface(), uno::UNO_QUERY );
213 mxFrame->initialize( xWin );
214 mxFrame->setName( maFrmDescr.GetName() );
216 uno::Reference < frame::XFramesSupplier > xFramesSupplier( xFrame, uno::UNO_QUERY );
217 if ( xFramesSupplier.is() )
218 mxFrame->setCreator( xFramesSupplier );
221 uno::Reference<task::XInteractionHandler> xInteractionHandler(task::InteractionHandler::createWithParent(mxContext, xParentWindow));
222 uno::Sequence < beans::PropertyValue > aProps{
228 uno::Reference < frame::XDispatch > xDisp = mxFrame->queryDispatch( aTargetURL,
"_self", 0 );
230 xDisp->dispatch( aTargetURL, aProps );
238void SAL_CALL IFrameObject::cancel()
242 uno::Reference < util::XCloseable > xClose( mxFrame, uno::UNO_QUERY );
244 xClose->close(
true );
247 catch (
const uno::Exception&)
252void SAL_CALL IFrameObject::close(
sal_Bool )
256void SAL_CALL IFrameObject::addCloseListener(
const css::uno::Reference < css::util::XCloseListener >& )
260void SAL_CALL IFrameObject::removeCloseListener(
const css::uno::Reference < css::util::XCloseListener >& )
264void SAL_CALL IFrameObject::disposing(
const css::lang::EventObject& )
269uno::Reference< beans::XPropertySetInfo > SAL_CALL IFrameObject::getPropertySetInfo()
275void SAL_CALL IFrameObject::setPropertyValue(
const OUString& aPropertyName,
const uno::Any& aAny)
279 throw beans::UnknownPropertyException(aPropertyName);
280 switch( pEntry->
nWID )
286 maFrmDescr.SetURL( aURL );
292 if ( aAny >>= aName )
293 maFrmDescr.SetName( aName );
299 if ( (aAny >>= bIsAutoScroll) && bIsAutoScroll )
306 if ( aAny >>= bIsScroll )
313 if ( aAny >>= bIsBorder )
314 maFrmDescr.SetFrameBorder( bIsBorder );
320 if ( aAny >>= bIsAutoBorder )
322 bool bBorder = maFrmDescr.IsFrameBorderOn();
323 maFrmDescr.ResetBorder();
325 maFrmDescr.SetFrameBorder( bBorder );
331 sal_Int32 nMargin = 0;
332 Size aSize = maFrmDescr.GetMargin();
333 if ( aAny >>= nMargin )
336 maFrmDescr.SetMargin( aSize );
342 sal_Int32 nMargin = 0;
343 Size aSize = maFrmDescr.GetMargin();
344 if ( aAny >>= nMargin )
347 maFrmDescr.SetMargin( aSize );
355uno::Any SAL_CALL IFrameObject::getPropertyValue(
const OUString& aPropertyName)
359 throw beans::UnknownPropertyException(aPropertyName);
361 switch( pEntry->
nWID )
370 aAny <<= maFrmDescr.GetName();
376 aAny <<= bIsAutoScroll;
387 bool bIsBorder = maFrmDescr.IsFrameBorderOn();
393 bool bIsAutoBorder = !maFrmDescr.IsFrameBorderSet();
394 aAny <<= bIsAutoBorder;
399 aAny <<= static_cast<sal_Int32>(maFrmDescr.GetMargin().Width());
404 aAny <<= static_cast<sal_Int32>(maFrmDescr.GetMargin().Height());
412void SAL_CALL IFrameObject::addPropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener > & )
416void SAL_CALL IFrameObject::removePropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener > & )
420void SAL_CALL IFrameObject::addVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener > & )
424void SAL_CALL IFrameObject::removeVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener > & )
428::sal_Int16 SAL_CALL IFrameObject::execute()
437void SAL_CALL IFrameObject::setTitle(
const OUString& )
443extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
445 css::uno::XComponentContext *context,
446 css::uno::Sequence<css::uno::Any>
const &arguments)
448 return cppu::acquire(
new IFrameObject(context, arguments));
virtual VclPtr< VclAbstractDialog > CreateEditObjectDialog(weld::Window *pParent, const OUString &rCommand, const css::uno::Reference< css::embed::XEmbeddedObject > &xObj)=0
static SfxAbstractDialogFactory * Create()
static SfxObjectShell * GetObjectShell(const css::uno::Reference< css::frame::XFrame > &xFrame)
const OUString & GetName() const
SfxMedium * GetMedium() const
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
static VclPtr< reference_type > Create(Arg &&... arg)
bool getUserAllowsLinkUpdate() const
css::uno::Type const & get()
#define WID_FRAME_MARGIN_HEIGHT
#define WID_FRAME_IS_SCROLLING_MODE
#define WID_FRAME_IS_AUTO_SCROLL
#define WID_FRAME_MARGIN_WIDTH
#define WID_FRAME_IS_AUTO_BORDER
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_sfx2_IFrameObject_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &arguments)
#define WID_FRAME_IS_BORDER
Sequence< PropertyValue > aArguments
Sequence< sal_Int8 > aSeq
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
Reference< XFrame > xFrame
WinBits const WB_NODIALOGCONTROL
WinBits const WB_CLIPCHILDREN