23#include <osl/diagnose.h>
25#include <com/sun/star/task/InteractionHandler.hpp>
26#include <com/sun/star/task/XInteractionAbort.hpp>
43 std::unique_lock aLock(
m_aLock);
54 css::uno::Reference<css::task::XInteractionHandler> xHandler(css::task::InteractionHandler::createWithParent(
58 std::unique_lock aLock(
m_aLock);
67 std::unique_lock aLock(
m_aLock);
68 css::uno::Reference< css::task::XInteractionHandler2 > xHandler(
m_xHandler, css::uno::UNO_QUERY );
70 return css::uno::Any();
72 return ::cppu::WeakImplHelper<css::lang::XInitialization, css::task::XInteractionHandler2>::queryInterface(aType);
77 css::uno::Any aRequest = xRequest->getRequest();
78 bool bHandleIt =
true;
81 std::unique_lock aLock(
m_aLock);
84 [&aRequest](
const InteractionInfo& rInfo) { return aRequest.isExtractableTo(rInfo.m_aInteraction); });
94 css::uno::Reference< css::task::XInteractionHandler > xHandler =
m_xHandler;
99 if ( bHandleIt && xHandler.is() )
101 xHandler->handle(xRequest);
105 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations();
106 for (
const auto& rContinuation : lContinuations)
108 css::uno::Reference< css::task::XInteractionAbort > xAbort(rContinuation, css::uno::UNO_QUERY);
120 css::uno::Any aRequest = xRequest->getRequest();
121 bool bHandleIt =
true;
124 std::unique_lock aLock(
m_aLock);
127 [&aRequest](
const InteractionInfo& rInfo) { return aRequest.isExtractableTo(rInfo.m_aInteraction); });
137 css::uno::Reference< css::task::XInteractionHandler2 > xHandler(
m_xHandler, css::uno::UNO_QUERY );
138 OSL_ENSURE( xHandler.is() || !
m_xHandler.is(),
139 "PreventDuplicateInteraction::handleInteractionRequest: inconsistency!" );
144 if ( bHandleIt && xHandler.is() )
146 return xHandler->handleInteractionRequest(xRequest);
150 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations();
151 for (
const auto& rContinuation : lContinuations)
153 css::uno::Reference< css::task::XInteractionAbort > xAbort(rContinuation, css::uno::UNO_QUERY);
167 std::unique_lock aLock(
m_aLock);
170 [&aInteractionInfo](
const InteractionInfo& rInfo) { return rInfo.m_aInteraction == aInteractionInfo.m_aInteraction; });
187 std::unique_lock aLock(
m_aLock);
190 [&aInteraction](
const InteractionInfo& rInfo) { return rInfo.m_aInteraction == aInteraction; });
205 css::uno::Reference<css::lang::XInitialization> xHandler(
m_xHandler, css::uno::UNO_QUERY);
209 xHandler->initialize(rArguments);
Reference< XComponentContext > m_xContext
std::vector< InteractionInfo > m_lInteractionRules
This list describe which and how incoming interactions must be handled.
std::unique_ptr< WarningDialogsParentScope > m_xWarningDialogsParent
css::uno::Reference< css::uno::XComponentContext > m_xContext
Used to create needed uno services at runtime.
bool getInteractionInfo(const css::uno::Type &aInteraction, PreventDuplicateInteraction::InteractionInfo *pReturn) const
return the info struct for the specified interaction.
virtual ~PreventDuplicateInteraction() override
dtor to free used memory.
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
virtual sal_Bool SAL_CALL handleInteractionRequest(const css::uno::Reference< css::task::XInteractionRequest > &xRequest) override
css::uno::Reference< css::task::XInteractionHandler > m_xHandler
The outside interaction handler, which is used to handle every incoming interaction,...
void useDefaultUUIHandler()
instead of setting an outside interaction handler, this method make sure the default UUI interaction ...
void addInteractionRule(const PreventDuplicateInteraction::InteractionInfo &aInteractionInfo)
add a new interaction to the list of interactions, which must be handled by this helper.
virtual void SAL_CALL handle(const css::uno::Reference< css::task::XInteractionRequest > &xRequest) override
void setHandler(const css::uno::Reference< css::task::XInteractionHandler > &xHandler)
set the outside interaction handler, which must be used internally if the interaction will not be blo...
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
PreventDuplicateInteraction(css::uno::Reference< css::uno::XComponentContext > xContext)
ctor to guarantee right initialized instances of this class @descr It uses the given uno service mana...
Reference< XComponentContext > getProcessComponentContext()
IMPL_STATIC_LINK_NOARG(WarningDialogsParent, TerminateDesktop, void *, void)
sal_Int32 m_nCallCount
count how often this interaction was called.
sal_Int32 m_nMaxCount
after max count was reached this interaction will be blocked.
css::uno::Reference< css::task::XInteractionRequest > m_xRequest
hold the last intercepted request (matching the set interaction type) alive so it can be used for fur...