LibreOffice Module framework (master) 1
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
framework::CloseDispatcher Class Referencefinal

helper to dispatch the URLs ".uno:CloseDoc"/".uno:CloseWin"/".uno:CloseFrame" to close a frame/document or the whole application implicitly in case it was the last frame More...

#include <closedispatcher.hxx>

Inheritance diagram for framework::CloseDispatcher:
[legend]
Collaboration diagram for framework::CloseDispatcher:
[legend]

Public Member Functions

 CloseDispatcher (css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XFrame > &xFrame, std::u16string_view sTarget)
 connect a new CloseDispatcher instance to its frame. More...
 
virtual ~CloseDispatcher () override
 does nothing real. More...
 
virtual void SAL_CALL dispatchWithNotification (const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &lArguments, const css::uno::Reference< css::frame::XDispatchResultListener > &xListener) override
 
virtual void SAL_CALL dispatch (const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &lArguments) override
 
virtual void SAL_CALL addStatusListener (const css::uno::Reference< css::frame::XStatusListener > &xListener, const css::util::URL &aURL) override
 
virtual void SAL_CALL removeStatusListener (const css::uno::Reference< css::frame::XStatusListener > &xListener, const css::util::URL &aURL) override
 
virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups () override
 
virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation (sal_Int16 nCommandGroup) override
 

Private Types

enum  EOperation {
  E_CLOSE_DOC ,
  E_CLOSE_FRAME ,
  E_CLOSE_WIN
}
 describe, which request must be done here. More...
 

Private Member Functions

 DECL_LINK (impl_asyncCallback, LinkParamNone *, void)
 a callback for asynchronous started operations. More...
 
bool implts_prepareFrameForClosing (const css::uno::Reference< css::frame::XFrame > &xFrame, bool bCloseAllOtherViewsToo, bool &bControllerSuspended)
 prepare m_xCloseFrame so it should be closeable without problems. More...
 
bool implts_closeFrame ()
 close the member m_xCloseFrame. More...
 
bool implts_establishBackingMode ()
 set the special BackingComponent (now StartModule) as new component of our m_xCloseFrame. More...
 
bool implts_terminateApplication ()
 calls XDesktop->terminate(). More...
 
void implts_notifyResultListener (const css::uno::Reference< css::frame::XDispatchResultListener > &xListener, sal_Int16 nState, const css::uno::Any &aResult)
 notify a DispatchResultListener. More...
 

Static Private Member Functions

static css::uno::Reference< css::frame::XFrame > static_impl_searchRightTargetFrame (const css::uno::Reference< css::frame::XFrame > &xFrame, std::u16string_view sTarget)
 try to find the right target frame where this close request must be really done. More...
 

Private Attributes

css::uno::Reference< css::uno::XComponentContext > m_xContext
 reference to a uno service manager, which can be used to create own needed uno resources. More...
 
css::uno::WeakReference< css::frame::XFrame > m_xCloseFrame
 reference to the target frame, which should be closed by this dispatch. More...
 
std::unique_ptr< vcl::EventPoster > m_aAsyncCallback
 used for asynchronous callbacks within the main thread. More...
 
EOperation m_eOperation
 used inside asynchronous callback to decide, which operation must be executed. More...
 
css::uno::Reference< css::uno::XInterface > m_xSelfHold
 for asynchronous operations we must hold us self alive! More...
 
css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener
 holded alive for internally asynchronous operations! More...
 
VclPtr< SystemWindowm_pSysWindow
 

Detailed Description

helper to dispatch the URLs ".uno:CloseDoc"/".uno:CloseWin"/".uno:CloseFrame" to close a frame/document or the whole application implicitly in case it was the last frame

@descr These URLs implements a special functionality to close a document or the whole frame ... and handle the state, it was the last frame or document. Then we create the default backing document which can be used to open new ones using the file open dialog or some other menu entries. Or we terminate the whole application in case this backing mode should not be used.

Definition at line 50 of file closedispatcher.hxx.

Member Enumeration Documentation

◆ EOperation

describe, which request must be done here.

@descr The incoming URLs {.uno:CloseDoc/CloseWin and CloseFrame can be classified so and checked later performant.}

Enumerator
E_CLOSE_DOC 
E_CLOSE_FRAME 
E_CLOSE_WIN 

Definition at line 62 of file closedispatcher.hxx.

Constructor & Destructor Documentation

◆ CloseDispatcher()

framework::CloseDispatcher::CloseDispatcher ( css::uno::Reference< css::uno::XComponentContext >  xContext,
const css::uno::Reference< css::frame::XFrame > &  xFrame,
std::u16string_view  sTarget 
)

connect a new CloseDispatcher instance to its frame.

@descr One CloseDispatcher instance is bound to own frame only. That makes an implementation (e.g. of listener support) much more easier .-)

Parameters
rxContextan un oservice manager, which is needed to create uno resource internally.
xFramethe frame where the corresponding dispatch was started.
sTargethelp us to find the right target for this close operation.

Definition at line 59 of file closedispatcher.cxx.

References VclPtr< class reference_type >::get(), VCLUnoHelper::GetWindow(), LINK, m_aAsyncCallback, m_pSysWindow, m_xCloseFrame, static_impl_searchRightTargetFrame(), xFrame, and xTarget.

◆ ~CloseDispatcher()

framework::CloseDispatcher::~CloseDispatcher ( )
overridevirtual

does nothing real.

Definition at line 81 of file closedispatcher.cxx.

References m_aAsyncCallback, m_pSysWindow, and VclPtr< class reference_type >::reset().

Member Function Documentation

◆ addStatusListener()

void SAL_CALL framework::CloseDispatcher::addStatusListener ( const css::uno::Reference< css::frame::XStatusListener > &  xListener,
const css::util::URL &  aURL 
)
overridevirtual

Definition at line 122 of file closedispatcher.cxx.

◆ DECL_LINK()

framework::CloseDispatcher::DECL_LINK ( impl_asyncCallback  ,
LinkParamNone ,
void   
)
private

a callback for asynchronous started operations.

@descr As already mentioned, we make internally all operations asynchronous. Otherwise our callis kill its own environment during they call us...

◆ dispatch()

void SAL_CALL framework::CloseDispatcher::dispatch ( const css::util::URL &  aURL,
const css::uno::Sequence< css::beans::PropertyValue > &  lArguments 
)
overridevirtual

Definition at line 88 of file closedispatcher.cxx.

References aURL, and dispatchWithNotification().

◆ dispatchWithNotification()

void SAL_CALL framework::CloseDispatcher::dispatchWithNotification ( const css::util::URL &  aURL,
const css::uno::Sequence< css::beans::PropertyValue > &  lArguments,
const css::uno::Reference< css::frame::XDispatchResultListener > &  xListener 
)
overridevirtual

◆ getConfigurableDispatchInformation()

css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL framework::CloseDispatcher::getConfigurableDispatchInformation ( sal_Int16  nCommandGroup)
overridevirtual

Definition at line 99 of file closedispatcher.cxx.

References framework::URL_CLOSEDOC, and framework::URL_CLOSEWIN.

◆ getSupportedCommandGroups()

css::uno::Sequence< sal_Int16 > SAL_CALL framework::CloseDispatcher::getSupportedCommandGroups ( )
overridevirtual

Definition at line 94 of file closedispatcher.cxx.

◆ implts_closeFrame()

bool framework::CloseDispatcher::implts_closeFrame ( )
private

close the member m_xCloseFrame.

@descr This method does not look for any document inside this frame. Such views must be cleared before (e.g. by calling implts_closeView()!

Otherwise e.g. the XController->suspend() call is not made and no UI warn the user about losing document changes. Because the frame is closed...

Returns
[bool] sal_True if closing was successful.

Definition at line 485 of file closedispatcher.cxx.

References framework::pattern::frame::closeIt(), m_xCloseFrame, and xFrame.

◆ implts_establishBackingMode()

bool framework::CloseDispatcher::implts_establishBackingMode ( )
private

set the special BackingComponent (now StartModule) as new component of our m_xCloseFrame.

Returns
[bool] sal_True if operation was successful.

Definition at line 511 of file closedispatcher.cxx.

References m_xCloseFrame, m_xContext, and xFrame.

◆ implts_notifyResultListener()

void framework::CloseDispatcher::implts_notifyResultListener ( const css::uno::Reference< css::frame::XDispatchResultListener > &  xListener,
sal_Int16  nState,
const css::uno::Any &  aResult 
)
private

notify a DispatchResultListener.

@descr We check the listener reference before we use it. So this method can be called every time!

@parama xListener the listener, which should be notified. Can be null!

Parameters
nStatedirectly used as css::frame::DispatchResultState value.
aResultnot used yet really ...

Definition at line 555 of file closedispatcher.cxx.

References aEvent, and nState.

Referenced by dispatchWithNotification().

◆ implts_prepareFrameForClosing()

bool framework::CloseDispatcher::implts_prepareFrameForClosing ( const css::uno::Reference< css::frame::XFrame > &  xFrame,
bool  bCloseAllOtherViewsToo,
bool &  bControllerSuspended 
)
private

prepare m_xCloseFrame so it should be closeable without problems.

@descr That's needed to be sure, that the document can't disagree later with e.g. an office termination. The problem: Closing of documents can show UI. If the user ignores it and open/close other documents, we can't know which state the office has after closing of this frame.

Parameters
bCloseAllOtherViewsTooif there are other top level frames, which contains views to the same document then our m_xCloseFrame, they are forced to be closed too. We need it to implement the CLOSE_DOC semantic.
Returns
[boolean] sal_True if closing was successful.

Definition at line 436 of file closedispatcher.cxx.

References All, framework::pattern::frame::closeIt(), i, m_xContext, xController, and xFrame.

◆ implts_terminateApplication()

bool framework::CloseDispatcher::implts_terminateApplication ( )
private

calls XDesktop->terminate().

@descr No office code has to be called afterwards! Because the process is dying... The only exception is a might be registered listener at this instance here. Because he should know, that such things will happen :-)

Returns
[bool] sal_True if termination of the application was started ...

Definition at line 542 of file closedispatcher.cxx.

References m_xContext.

◆ removeStatusListener()

void SAL_CALL framework::CloseDispatcher::removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener > &  xListener,
const css::util::URL &  aURL 
)
overridevirtual

Definition at line 127 of file closedispatcher.cxx.

◆ static_impl_searchRightTargetFrame()

css::uno::Reference< css::frame::XFrame > framework::CloseDispatcher::static_impl_searchRightTargetFrame ( const css::uno::Reference< css::frame::XFrame > &  xFrame,
std::u16string_view  sTarget 
)
staticprivate

try to find the right target frame where this close request must be really done.

@descr The problem behind: closing some resources depends sometimes from the context where its dispatched. Sometimes the start frame of the dispatch has to be closed itself (target=_self) ... sometimes its parent frame has to be closed - BUT(!) it means a parent frame containing a top level window. _top can't be used then for dispatch - because it address TopFrames not frames containing top level windows. So normally _magic (which btw does not exists at the moment .-) ) should be used. So we interpret target=<empty> as _magic !

Parameters
xFramestart point for search of right dispatch frame.
sTargetgive us an idea how this target frame must be searched.

Definition at line 570 of file closedispatcher.cxx.

References o3tl::equalsIgnoreAsciiCase(), VCLUnoHelper::GetWindow(), u, xFrame, and xTarget.

Referenced by CloseDispatcher().

Member Data Documentation

◆ m_aAsyncCallback

std::unique_ptr<vcl::EventPoster> framework::CloseDispatcher::m_aAsyncCallback
private

used for asynchronous callbacks within the main thread.

@descr Internally we work asynchronously. Because our callees are not aware that their request can kill its own environment...

Definition at line 85 of file closedispatcher.hxx.

Referenced by dispatchWithNotification(), and ~CloseDispatcher().

◆ m_eOperation

EOperation framework::CloseDispatcher::m_eOperation
private

used inside asynchronous callback to decide, which operation must be executed.

Definition at line 89 of file closedispatcher.hxx.

Referenced by dispatchWithNotification().

◆ m_pSysWindow

VclPtr<SystemWindow> framework::CloseDispatcher::m_pSysWindow
private

Definition at line 97 of file closedispatcher.hxx.

Referenced by CloseDispatcher(), dispatchWithNotification(), and ~CloseDispatcher().

◆ m_xCloseFrame

css::uno::WeakReference< css::frame::XFrame > framework::CloseDispatcher::m_xCloseFrame
private

reference to the target frame, which should be closed by this dispatch.

Definition at line 80 of file closedispatcher.hxx.

Referenced by CloseDispatcher(), implts_closeFrame(), and implts_establishBackingMode().

◆ m_xContext

css::uno::Reference< css::uno::XComponentContext > framework::CloseDispatcher::m_xContext
private

reference to a uno service manager, which can be used to create own needed uno resources.

Definition at line 76 of file closedispatcher.hxx.

Referenced by implts_establishBackingMode(), implts_prepareFrameForClosing(), and implts_terminateApplication().

◆ m_xResultListener

css::uno::Reference< css::frame::XDispatchResultListener > framework::CloseDispatcher::m_xResultListener
private

holded alive for internally asynchronous operations!

Definition at line 95 of file closedispatcher.hxx.

Referenced by dispatchWithNotification().

◆ m_xSelfHold

css::uno::Reference< css::uno::XInterface > framework::CloseDispatcher::m_xSelfHold
private

for asynchronous operations we must hold us self alive!

Definition at line 92 of file closedispatcher.hxx.

Referenced by dispatchWithNotification().


The documentation for this class was generated from the following files: