LibreOffice Module framework (master) 1
|
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>
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< SystemWindow > | m_pSysWindow |
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.
|
private |
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.
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 .-)
rxContext | an un oservice manager, which is needed to create uno resource internally. |
xFrame | the frame where the corresponding dispatch was started. |
sTarget | help 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.
|
overridevirtual |
does nothing real.
Definition at line 81 of file closedispatcher.cxx.
References m_aAsyncCallback, m_pSysWindow, and VclPtr< class reference_type >::reset().
|
overridevirtual |
Definition at line 122 of file closedispatcher.cxx.
|
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...
|
overridevirtual |
Definition at line 88 of file closedispatcher.cxx.
References aURL, and dispatchWithNotification().
|
overridevirtual |
Definition at line 132 of file closedispatcher.cxx.
References aURL, E_CLOSE_DOC, E_CLOSE_FRAME, E_CLOSE_WIN, implts_notifyResultListener(), m_aAsyncCallback, m_eOperation, m_pSysWindow, m_xResultListener, m_xSelfHold, framework::URL_CLOSEDOC, framework::URL_CLOSEFRAME, and framework::URL_CLOSEWIN.
Referenced by dispatch().
|
overridevirtual |
Definition at line 99 of file closedispatcher.cxx.
References framework::URL_CLOSEDOC, and framework::URL_CLOSEWIN.
|
overridevirtual |
Definition at line 94 of file closedispatcher.cxx.
|
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...
Definition at line 485 of file closedispatcher.cxx.
References framework::pattern::frame::closeIt(), m_xCloseFrame, and xFrame.
|
private |
set the special BackingComponent (now StartModule) as new component of our m_xCloseFrame.
Definition at line 511 of file closedispatcher.cxx.
References m_xCloseFrame, m_xContext, and xFrame.
|
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!
nState | directly used as css::frame::DispatchResultState value. |
aResult | not used yet really ... |
Definition at line 555 of file closedispatcher.cxx.
References aEvent, and nState.
Referenced by dispatchWithNotification().
|
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.
bCloseAllOtherViewsToo | if 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. |
Definition at line 436 of file closedispatcher.cxx.
References All, framework::pattern::frame::closeIt(), i, m_xContext, xController, and xFrame.
|
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 :-)
Definition at line 542 of file closedispatcher.cxx.
References m_xContext.
|
overridevirtual |
Definition at line 127 of file closedispatcher.cxx.
|
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 !
xFrame | start point for search of right dispatch frame. |
sTarget | give 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().
|
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().
|
private |
used inside asynchronous callback to decide, which operation must be executed.
Definition at line 89 of file closedispatcher.hxx.
Referenced by dispatchWithNotification().
|
private |
Definition at line 97 of file closedispatcher.hxx.
Referenced by CloseDispatcher(), dispatchWithNotification(), and ~CloseDispatcher().
|
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().
|
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().
|
private |
holded alive for internally asynchronous operations!
Definition at line 95 of file closedispatcher.hxx.
Referenced by dispatchWithNotification().
|
private |
for asynchronous operations we must hold us self alive!
Definition at line 92 of file closedispatcher.hxx.
Referenced by dispatchWithNotification().