22#include <com/sun/star/frame/XDispatchProvider.hpp>
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/awt/KeyEvent.hpp>
25#include <com/sun/star/frame/XLayoutManager.hpp>
26#include <com/sun/star/lang/XServiceInfo.hpp>
27#include <com/sun/star/lang/XInitialization.hpp>
28#include <com/sun/star/awt/XWindow.hpp>
29#include <com/sun/star/awt/XKeyListener.hpp>
30#include <com/sun/star/uno/XComponentContext.hpp>
31#include <com/sun/star/frame/XFrame.hpp>
32#include <com/sun/star/frame/XDispatch.hpp>
33#include <com/sun/star/lang/XEventListener.hpp>
34#include <com/sun/star/lang/XComponent.hpp>
35#include <com/sun/star/lang/XTypeProvider.hpp>
61class BackingComp :
public css::lang::XTypeProvider
62 ,
public css::lang::XServiceInfo
63 ,
public css::lang::XInitialization
64 ,
public css::frame::XController
65 ,
public css::awt::XKeyListener
66 ,
public css::frame::XDispatchProvider
67 ,
public css::frame::XDispatch
72 css::uno::Reference< css::awt::XWindow > m_xWindow;
75 css::uno::Reference< css::frame::XFrame >
m_xFrame;
77 Size m_aInitialWindowMinSize;
81 explicit BackingComp();
84 virtual css::uno::Any SAL_CALL
queryInterface(
const css::uno::Type& aType )
override;
85 virtual void SAL_CALL
acquire ( ) noexcept override;
86 virtual
void SAL_CALL release ( ) noexcept override;
89 virtual css::
uno::Sequence< css::
uno::
Type > SAL_CALL getTypes () override;
90 virtual css::
uno::Sequence<
sal_Int8 > SAL_CALL getImplementationId() override;
93 virtual OUString SAL_CALL getImplementationName ( ) override;
94 virtual
sal_Bool SAL_CALL supportsService ( const OUString& sServiceName ) override;
95 virtual css::
uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
98 virtual
void SAL_CALL initialize( const css::
uno::Sequence< css::
uno::Any >& lArgs ) override;
101 virtual
void SAL_CALL attachFrame( const css::
uno::Reference< css::frame::XFrame >& xFrame ) override;
102 virtual
sal_Bool SAL_CALL attachModel( const css::
uno::Reference< css::frame::XModel >& xModel ) override;
104 virtual css::
uno::Any SAL_CALL getViewData() override;
105 virtual
void SAL_CALL restoreViewData( const css::
uno::Any&
aData ) override;
106 virtual css::
uno::Reference< css::frame::XModel > SAL_CALL getModel() override;
107 virtual css::
uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override;
110 virtual
void SAL_CALL keyPressed ( const css::awt::
KeyEvent& aEvent ) override;
111 virtual
void SAL_CALL keyReleased( const css::awt::
KeyEvent& aEvent ) override;
114 virtual
void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override;
117 virtual
void SAL_CALL dispose ( ) override;
118 virtual
void SAL_CALL addEventListener ( const css::
uno::Reference< css::lang::XEventListener >& xListener ) override;
119 virtual
void SAL_CALL removeEventListener( const css::
uno::Reference< css::lang::XEventListener >& xListener ) override;
122 virtual css::
uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const OUString& sTargetFrameName , sal_Int32 nSearchFlags ) override;
123 virtual css::
uno::Sequence< css::
uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::
uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions ) override;
126 virtual
void SAL_CALL dispatch( const css::util::URL& aURL, const css::
uno::Sequence< css::beans::PropertyValue >& lArguments ) override;
127 virtual
void SAL_CALL addStatusListener( const css::
uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) override;
128 virtual
void SAL_CALL removeStatusListener( const css::
uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) override;
131BackingComp::BackingComp()
150css::uno::Any SAL_CALL BackingComp::queryInterface(
const css::uno::Type& aType )
153 css::uno::Any aResult = ::cppu::queryInterface(
155 static_cast< css::lang::XTypeProvider*
>(
this),
156 static_cast< css::lang::XServiceInfo*
>(
this),
157 static_cast< css::lang::XInitialization*
>(
this),
158 static_cast< css::frame::XController*
>(
this),
159 static_cast< css::lang::XComponent*
>(
this),
160 static_cast< css::lang::XEventListener*
>(
this),
161 static_cast< css::awt::XKeyListener*
>(
static_cast< css::lang::XEventListener*
>(
this)),
162 static_cast< css::frame::XDispatchProvider*
>(
this),
163 static_cast< css::frame::XDispatch*
>(
this) );
168 if (!aResult.hasValue())
173 aResult = m_xWindow->queryInterface(aType);
178 if (!aResult.hasValue())
179 aResult = OWeakObject::queryInterface(aType);
188void SAL_CALL BackingComp::acquire()
191 OWeakObject::acquire();
198void SAL_CALL BackingComp::release()
201 OWeakObject::release();
216css::uno::Sequence< css::uno::Type > SAL_CALL BackingComp::getTypes()
220 css::uno::Reference<css::lang::XTypeProvider> xProvider(m_xWindow, css::uno::UNO_QUERY);
222 css::uno::Sequence<css::uno::Type> lWindowTypes;
224 lWindowTypes = xProvider->getTypes();
249css::uno::Sequence< sal_Int8 > SAL_CALL BackingComp::getImplementationId()
251 return css::uno::Sequence<sal_Int8>();
254OUString SAL_CALL BackingComp::getImplementationName()
256 return "com.sun.star.comp.sfx2.BackingComp";
259sal_Bool SAL_CALL BackingComp::supportsService(
const OUString& sServiceName )
264css::uno::Sequence< OUString > SAL_CALL BackingComp::getSupportedServiceNames()
266 return {
"com.sun.star.frame.StartModule",
"com.sun.star.frame.ProtocolHandler" };
323void SAL_CALL BackingComp::attachFrame(
const css::uno::Reference< css::frame::XFrame >& xFrame )
330 throw css::uno::RuntimeException(
335 throw css::uno::RuntimeException(
336 "invalid frame reference",
346 css::uno::Reference< css::awt::XWindow > xParentWindow =
xFrame->getContainerWindow();
351 if (pParent && pParent->IsFullScreenMode())
353 pParent->ShowFullScreenMode(
false);
354 pParent->SetMenuBarMode(MenuBarMode::Normal);
358 css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY_THROW);
359 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
360 xPropSet->getPropertyValue(
"LayoutManager") >>= xLayoutManager;
361 if (xLayoutManager.is())
363 xLayoutManager->lock();
364 xLayoutManager->createElement(
"private:resource/menubar/menubar");
365 xLayoutManager->unlock();
371 pWindow->SetHelpId(
"FWK_HID_BACKINGWINDOW");
380 if( !pParent || !pBack )
384 vcl::Window* pMenu = pParent->GetWindow(GetWindowType::Next);
388 m_aInitialWindowMinSize = pParent->GetMinOutputSizePixel();
389 if (!m_aInitialWindowMinSize.
Width())
391 if (!m_aInitialWindowMinSize.
Height())
394 pParent->SetMinOutputSizePixel(
411sal_Bool SAL_CALL BackingComp::attachModel(
const css::uno::Reference< css::frame::XModel >& )
425css::uno::Reference< css::frame::XModel > SAL_CALL BackingComp::getModel()
427 return css::uno::Reference< css::frame::XModel >();
436css::uno::Any SAL_CALL BackingComp::getViewData()
438 return css::uno::Any();
448void SAL_CALL BackingComp::restoreViewData(
const css::uno::Any& )
461css::uno::Reference< css::frame::XFrame > SAL_CALL BackingComp::getFrame()
505void SAL_CALL BackingComp::disposing(
const css::lang::EventObject& aEvent )
513 if (!
aEvent.Source.is() ||
aEvent.Source!=m_xWindow || !m_xWindow.is())
514 throw css::uno::RuntimeException(
515 "unexpected source or called twice",
532void SAL_CALL BackingComp::dispose()
539 css::uno::Reference< css::awt::XWindow > xParentWindow =
m_xFrame->getContainerWindow();
543 pParent->SetMinOutputSizePixel(m_aInitialWindowMinSize);
552 m_xWindow->removeEventListener(
this);
553 m_xWindow->removeKeyListener(
this);
574void SAL_CALL BackingComp::addEventListener(
const css::uno::Reference< css::lang::XEventListener >& )
576 throw css::uno::RuntimeException(
590void SAL_CALL BackingComp::removeEventListener(
const css::uno::Reference< css::lang::XEventListener >& )
613void SAL_CALL BackingComp::initialize(
const css::uno::Sequence< css::uno::Any >& lArgs )
619 throw css::uno::Exception(
620 "already initialized",
623 css::uno::Reference< css::awt::XWindow > xParentWindow;
625 (lArgs.getLength()!=1 ) ||
626 (!(lArgs[0] >>= xParentWindow)) ||
627 (!xParentWindow.is() )
630 throw css::uno::Exception(
631 "wrong or corrupt argument list",
641 throw css::uno::RuntimeException(
642 "couldn't create component window",
647 m_xWindow->addEventListener(
static_cast< css::lang::XEventListener*
>(
this));
649 m_xWindow->setVisible(
true);
655void SAL_CALL BackingComp::keyPressed(
const css::awt::KeyEvent& )
660void SAL_CALL BackingComp::keyReleased(
const css::awt::KeyEvent& )
672css::uno::Reference< css::frame::XDispatch > SAL_CALL BackingComp::queryDispatch(
const css::util::URL& aURL,
const OUString& , sal_Int32 )
674 css::uno::Reference< css::frame::XDispatch >
xDispatch;
675 if (
aURL.Protocol ==
"vnd.org.libreoffice.recentdocs:" )
681css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL BackingComp::queryDispatches(
const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescripts )
683 sal_Int32
nCount = seqDescripts.getLength();
684 css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount );
686 std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(),
687 [
this](
const css::frame::DispatchDescriptor& rDesc) -> css::uno::Reference<XDispatch> {
688 return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); });
694void SAL_CALL BackingComp::dispatch(
const css::util::URL& aURL,
const css::uno::Sequence < css::beans::PropertyValue >& )
697 if (
aURL.Path !=
"ClearRecentFileList" )
708 css::uno::Reference< css::awt::XWindow > xParentWindow =
m_xFrame->getContainerWindow();
712 pParent->SetMinOutputSizePixel(
Size(
714 pParent->GetMinOutputSizePixel().Height()) );
718void SAL_CALL BackingComp::addStatusListener(
const css::uno::Reference< css::frame::XStatusListener >& ,
const css::util::URL& )
722void SAL_CALL BackingComp::removeStatusListener(
const css::uno::Reference< css::frame::XStatusListener >& ,
const css::util::URL& )
728extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
730 css::uno::XComponentContext *,
731 css::uno::Sequence<css::uno::Any>
const &)
733 return cppu::acquire(
new BackingComp);
css::uno::Reference< css::lang::XComponent > m_xFrame
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_sfx2_BackingComp_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
void clearRecentFileList()
void setOwningFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
static void CloseMethod(SfxBindings &rBindings)
sal_Int32 get_height_request() const
virtual Size GetSizePixel() const
sal_Int32 get_width_request() const
Reference< XDispatch > xDispatch
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference< XFrame > xFrame