30#include <com/sun/star/frame/XDesktop.hpp>
31#include <com/sun/star/frame/FrameSearchFlag.hpp>
32#include <com/sun/star/uno/Exception.hpp>
33#include <com/sun/star/lang/XMultiServiceFactory.hpp>
34#include <com/sun/star/lang/XInitialization.hpp>
35#include <com/sun/star/util/XCacheInfo.hpp>
37#include <rtl/ustring.hxx>
60 const css::uno::Reference< css::frame::XFrame >& xFrame )
94 const OUString& sTargetFrameName ,
95 sal_Int32 nSearchFlags )
97 css::uno::Reference< css::frame::XDispatch > xDispatcher;
99 css::uno::Reference< css::frame::XFrame > xOwner(
m_xFrame);
101 css::uno::Reference< css::frame::XDesktop > xDesktopCheck( xOwner, css::uno::UNO_QUERY );
103 if (xDesktopCheck.is())
126css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL
DispatchProvider::queryDispatches(
const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions )
130 sal_Int32
nCount = lDescriptions.getLength();
131 css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher(
nCount );
132 auto lDispatcherRange = asNonConstRange(lDispatcher);
137 lDescriptions[
i].FrameName ,
138 lDescriptions[
i].SearchFlags );
152 const css::util::URL& aURL ,
153 const OUString& sTargetFrameName ,
154 sal_Int32 nSearchFlags )
156 css::uno::Reference< css::frame::XDispatch > xDispatcher;
202 (sTargetFrameName.isEmpty())
215 sal_Int32 nRightFlags = nSearchFlags & ~css::frame::FrameSearchFlag::CREATE;
218 css::uno::Reference< css::frame::XFrame > xFoundFrame = xDesktop->findFrame(sTargetFrameName, nRightFlags);
219 if (xFoundFrame.is())
221 css::uno::Reference< css::frame::XDispatchProvider > xProvider( xFoundFrame, css::uno::UNO_QUERY );
226 else if (nSearchFlags & css::frame::FrameSearchFlag::CREATE)
234 const css::util::URL& aURL ,
235 const OUString& sTargetFrameName ,
236 sal_Int32 nSearchFlags )
238 css::uno::Reference< css::frame::XDispatch > xDispatcher;
255 css::uno::Reference< css::frame::XDispatchProvider > xParent(
xFrame->getCreator(), css::uno::UNO_QUERY );
257 xDispatcher = xParent->queryDispatch(
aURL, sTargetFrameName, 0);
266 css::uno::Reference< css::frame::XDispatchProvider > xBeamer(
xFrame->findFrame(
SPECIALTARGET_BEAMER, css::frame::FrameSearchFlag::CHILDREN | css::frame::FrameSearchFlag::SELF ), css::uno::UNO_QUERY );
273 css::uno::Reference< css::frame::XDispatchProvider >
xController(
xFrame->getController(), css::uno::UNO_QUERY );
286 css::uno::Reference< css::frame::XDispatchProvider > xParent(
xFrame->getCreator(), css::uno::UNO_QUERY );
307 css::uno::Reference< css::frame::XDispatchProvider > xParent(
xFrame->getCreator(), css::uno::UNO_QUERY );
323 (sTargetFrameName.isEmpty())
327 if (
aURL.Complete ==
".uno:CloseDoc" ||
aURL.Complete ==
".uno:CloseWin" )
329 css::uno::Reference< css::frame::XDispatchProvider > xParent(
xFrame->getCreator(), css::uno::UNO_QUERY );
342 else if (
aURL.Complete ==
".uno:CloseFrame" )
345 if ( ! xDispatcher.is())
350 css::uno::Reference< css::frame::XDispatchProvider >
xController(
xFrame->getController(), css::uno::UNO_QUERY );
357 if (!xDispatcher.is())
367 ( ! xDispatcher.is() ) &&
382 sal_Int32 nRightFlags = nSearchFlags & ~css::frame::FrameSearchFlag::CREATE;
385 css::uno::Reference< css::frame::XFrame > xFoundFrame =
xFrame->findFrame(sTargetFrameName, nRightFlags);
386 if (xFoundFrame.is())
397 css::uno::Reference< css::frame::XDispatchProvider > xProvider( xFoundFrame, css::uno::UNO_QUERY );
408 if (nSearchFlags & css::frame::FrameSearchFlag::CREATE)
410 css::uno::Reference< css::frame::XDispatchProvider > xParent(
xFrame->getCreator(), css::uno::UNO_QUERY );
412 xDispatcher = xParent->queryDispatch(
aURL, sTargetFrameName, css::frame::FrameSearchFlag::CREATE);
435 css::uno::Reference< css::frame::XDispatch > xDispatcher;
441 css::uno::Reference< css::frame::XDispatchProvider > xHandler;
446 bool bInitialize =
true;
454 css::uno::Reference<css::lang::XMultiServiceFactory>(
m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW)
456 css::uno::UNO_QUERY);
459 css::uno::Reference<css::util::XCacheInfo> xCacheInfo(xHandler, css::uno::UNO_QUERY);
460 if (!xCacheInfo.is() || xCacheInfo->isCachingAllowed())
467 xHandler = it->second;
471 catch(
const css::uno::Exception&) {}
474 css::uno::Reference< css::lang::XInitialization > xInit( xHandler, css::uno::UNO_QUERY );
475 if (xInit.is() && bInitialize)
477 css::uno::Reference< css::frame::XFrame > xOwner(
m_xFrame.get(), css::uno::UNO_QUERY );
478 SAL_WARN_IF(!xOwner.is(),
"fwk",
"DispatchProvider::implts_searchProtocolHandler(): Couldn't get reference to my owner frame. So I can't set may needed context information for this protocol handler.");
484 css::uno::Sequence< css::uno::Any > lContext{ css::uno::Any(xOwner) };
485 xInit->initialize(lContext);
487 catch(
const css::uno::Exception&) {}
523 const css::uno::Reference< css::frame::XFrame >& xOwner ,
524 const OUString& sTarget ,
525 sal_Int32 nSearchFlags)
527 css::uno::Reference< css::frame::XDispatch > xDispatchHelper;
562 return xDispatchHelper;
css::uno::Reference< css::lang::XComponent > m_xFrame
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
helper to dispatch the URLs ".uno:CloseDoc"/".uno:CloseWin"/".uno:CloseFrame" to close a frame/docume...
css::uno::Reference< css::frame::XDispatch > implts_queryDesktopDispatch(const css::uno::Reference< css::frame::XFrame > &xDesktop, const css::util::URL &aURL, const OUString &sTargetFrameName, sal_Int32 nSearchFlags)
helper for queryDispatch() @descr Every member of the frame tree (frame, desktop) must handle such re...
css::uno::Reference< css::frame::XDispatch > implts_getOrCreateDispatchHelper(EDispatchHelper eHelper, const css::uno::Reference< css::frame::XFrame > &xOwner, const OUString &sTarget=OUString(), sal_Int32 nSearchFlags=0)
get or create new dispatch helper @descr Sometimes we need some helper implementations to support dis...
css::uno::Reference< css::frame::XDispatch > implts_searchProtocolHandler(const css::util::URL &aURL)
search for a registered protocol handler and ask him for a dispatch object @descr We search a suitabl...
css::uno::Reference< css::frame::XDispatch > implts_queryFrameDispatch(const css::uno::Reference< css::frame::XFrame > &xFrame, const css::util::URL &aURL, const OUString &sTargetFrameName, sal_Int32 nSearchFlags)
css::uno::WeakReference< css::frame::XFrame > m_xFrame
weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!...
virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(const css::uno::Sequence< css::frame::DispatchDescriptor > &lDescriptions) override
std::unordered_map< OUString, css::uno::Reference< css::frame::XDispatchProvider > > m_aProtocolHandlers
DispatchProvider(css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XFrame > &xFrame)
standard ctor/dtor @descr These initialize a new instance of this class with needed information for w...
HandlerCache m_aProtocolHandlerCache
cache of some other dispatch provider which are registered inside configuration to handle special URL...
bool implts_isLoadableContent(const css::util::URL &aURL)
check URL for support by our used loader or handler @descr If we must return our own dispatch helper ...
virtual ~DispatchProvider() override
protected(!) dtor for deinitializing @descr We made it protected to prevent using of us as base class...
css::uno::Reference< css::uno::XComponentContext > m_xContext
reference to global service manager to create new services
virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL &aURL, const OUString &sTargetFrameName, sal_Int32 nSearchFlags) override
bool search(const OUString &sURL, ProtocolHandler *pReturn) const
dtor of the cache @descr It frees all used memory.
implements a dispatch object which can be used to load non-visible components (by using the mechanism...
static EContentType classifyContent(const OUString &sURL, const css::uno::Sequence< css::beans::PropertyValue > &lMediaDescriptor)
checks if the specified content can be handled by a ContentHandler only and is not related to a targe...
EContentType
classify a content.
@ E_CAN_BE_LOADED
identifies a content, which can be loaded into a target frame
helper to handle all URLs related to the StartModule
static bool isTopWindow(const css::uno::Reference< css::awt::XWindow > &xWindow)
bool IsSystemWindow() const
css::uno::Reference< css::uno::XComponentContext > m_xContext
#define SAL_WARN_IF(condition, area, stream)
EDispatchHelper
@descr We know some special dispatch objects with different functionality.
@ E_STARTMODULEDISPATCHER
constexpr OUStringLiteral SPECIALTARGET_BEAMER
constexpr OUStringLiteral SPECIALTARGET_TOP
constexpr OUStringLiteral SPECIALTARGET_BLANK
constexpr OUStringLiteral SPECIALTARGET_DEFAULT
constexpr OUStringLiteral SPECIALTARGET_SELF
bool isStartModuleDispatch(css::util::URL const &url)
Programmer can register his own services to handle different protocols.
OUString m_sUNOName
the uno implementation name of this handler
Reference< XController > xController
Reference< XFrame > xFrame
#define SPECIALTARGET_PARENT