/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void Desktop::constructorInit()
{ // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess. // We only hold the member as reference and not as pointer! // Attention: we share our frame container with this helper. // The container itself is threadsafe, so we should be able to do that. // But look at dispose() for the right order of deinitialization.
m_xFramesHelper = new OFrames( this, &m_aChildTaskContainer );
// Initialize a new DispatchHelper-object to handle dispatches. // We use this helper as a slave for our interceptor helper - not directly! // But the helper is an event listener in THIS instance!
rtl::Reference<DispatchProvider> xDispatchProvider = new DispatchProvider( m_xContext, this );
// Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism. // Set created dispatch provider as its slowest slave. // Hold interception helper by reference only - not by pointer! // So it's easier to destroy it.
m_xDispatchHelper = new InterceptionHelper( this, xDispatchProvider );
// Safe impossible cases. // We can't work without this helper!
SAL_WARN_IF( !m_xFramesHelper.is(), "fwk.desktop", "Desktop::Desktop(): Frames helper is not valid. XFrames, XIndexAccess and XElementAccess are not supported!");
SAL_WARN_IF( !m_xDispatchHelper.is(), "fwk.desktop", "Desktop::Desktop(): Dispatch helper is not valid. XDispatch will not work correctly!" );
// Enable object for real work! // Otherwise all calls will be rejected.
m_aTransactionManager.setWorkingMode( E_WORK );
}
/*-************************************************************************************************************ @short standard constructor to create instance by factory @descr This constructor initializes a new instance of this class by valid factory, and valid values will be set for its member and base classes.
@attention a) Don't use your own reference during a UNO-Service-ctor! There is no guarantee, that you will get over this. (e.g. using your reference as parameter to initialize some member). Do such things in DEFINE_INIT_SERVICE() method, which is called automatically after your ctor!!! b) base class OBroadcastHelper is a typedef in namespace cppu! The Microsoft compiler has some problems in handling it right when using namespace explicitly ::cppu::OBroadcastHelper. If we write it without a namespace or expand the typedef to OBroadcastHelperVar<...> -> it will be OK!? I don't know why! (other compilers not tested, but it works!)
@seealso method DEFINE_INIT_SERVICE()
@param "xFactory" is the multi service manager, which creates this instance. The value must be different from NULL! @onerror We throw an ASSERT in debug version or do nothing in release version.
*/
Desktop::Desktop( css::uno::Reference< css::uno::XComponentContext > xContext )
: Desktop_BASE ( m_aMutex )
, cppu::OPropertySetHelper( cppu::WeakComponentImplHelperBase::rBHelper ) // Init member
, m_bIsTerminated(false)
, m_bIsShutdown(false) // see dispose() for further information!
, m_bSession ( false )
, m_xContext (std::move( xContext ))
, m_aListenerContainer ( m_aMutex )
, m_eLoadState ( E_NOTSET )
, m_bSuspendQuickstartVeto( false )
{
}
/*-************************************************************************************************************ @short standard destructor @descr This one does NOTHING! Use dispose() instead of this.
@seealso method dispose()
*/
Desktop::~Desktop()
{
SAL_WARN_IF(!m_bIsShutdown, "fwk.desktop", "Desktop not terminated before being destructed");
SAL_WARN_IF( m_aTransactionManager.getWorkingMode()!=E_CLOSE, "fwk.desktop", "Desktop::~Desktop(): Who forgot to dispose this service?" );
}
// Allow use of any UI, because Desktop.terminate() was designed as UI functionality in the past. // Try to close all open frames. bool bFramesClosed = impl_closeFrames(!bRestartableMainLoop);
// Ask normal terminate listener. They could veto terminating the process.
Desktop::TTerminateListenerList lCalledTerminationListener; if (!impl_sendQueryTerminationEvent(lCalledTerminationListener))
{
impl_sendCancelTerminationEvent(lCalledTerminationListener); returnfalse;
}
if (!bFramesClosed)
{
impl_sendCancelTerminationEvent(lCalledTerminationListener); returnfalse;
}
// Normal listener had no problem. // All frames were closed. // Now it's time to ask our specialized listener. // They are handled in this way because they wish to hinder the office on termination, // but they also wish to close all frames.
// Note: // We shouldn't ask quicklauncher in case it was allowed from outside only. // This is a special trick to "ignore existing quickstarter" for debug purposes.
// Attention: // Order of called listeners is important! // Some of them are harmless, // but some can be dangerous. E.g. it would be dangerous if we close our pipe // and don't terminate for real because another listener throws a veto exception .-)
aGuard.reset(); if (m_bIsTerminated) returntrue;
m_bIsTerminated = true;
if (!bRestartableMainLoop)
{
CrashReporter::addKeyValue(u"ShutDown"_ustr, OUString::boolean(true), CrashReporter::Write);
// The clipboard listener needs to be the first. It can create copies of the // existing document which needs basically all the available infrastructure.
impl_sendTerminateToClipboard();
{
SolarMutexReleaser aReleaser;
impl_sendNotifyTerminationEvent();
}
Scheduler::ProcessEventsToIdle();
if ( xSWThreadManager.is() )
xSWThreadManager->notifyTermination( aEvent );
if ( xPipeTerminator.is() )
xPipeTerminator->notifyTermination( aEvent );
// further termination is postponed to shutdown, if LO already runs the main loop if (!Application::IsInExecute())
shutdown();
} else
m_bIsShutdown = true;
#ifndef IOS // or ANDROID?
aGuard.clear(); // In the iOS app, posting the ImplQuitMsg user event will be too late, it will not be handled during the // lifetime of the current document, but handled for the next document opened, which thus will break horribly.
Application::Quit(); #endif
// we need a copy here as the notifyTermination call might cause a removeTerminateListener call
std::vector< css::uno::Reference<css::frame::XTerminateListener> > xComponentDllListeners;
xComponentDllListeners.swap(m_xComponentDllListeners); for (auto& xListener : xComponentDllListeners)
xListener->notifyTermination(aEvent);
xComponentDllListeners.clear();
// Must be really the last listener to be called. // Because it shuts down the whole process asynchronously! if (xSfxTerminator.is())
xSfxTerminator->notifyTermination(aEvent);
}
// No lock required, the container itself is threadsafe.
m_aListenerContainer.addInterface( cppu::UnoType<css::frame::XTerminateListener>::get(), xListener );
}
// No lock required, the container itself is threadsafe.
m_aListenerContainer.removeInterface( cppu::UnoType<css::frame::XTerminateListener>::get(), xListener );
}
/*-************************************************************************************************************ @interface XDesktop @short get access to create enumerations of all current components @descr You will be the owner of the returned object and must delete it if you don't use it again.
@seealso class TasksAccess @seealso class TasksEnumeration @return A reference to an XEnumerationAccess-object.
@onerror We return a null-reference. @threadsafe yes
*/
css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getComponents()
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
// We use a helper class OComponentAccess to have access to all child components. // Create it on demand and return it as a reference. returnnew OComponentAccess( this );
}
/*-************************************************************************************************************ @interface XDesktop @short return the current active component @descr The most current component is the window, model or the controller of the current active frame.
@seealso method getCurrentFrame() @seealso method impl_getFrameComponent() @return A reference to the component.
@onerror We return a null-reference. @threadsafe yes
*/
css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::getCurrentComponent()
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
// Set return value if method failed.
css::uno::Reference< css::lang::XComponent > xComponent;
// Get reference to current frame ... // ... get component of this frame ... (It can be the window, the model or the controller.) // ... and return the result.
css::uno::Reference< css::frame::XFrame > xCurrentFrame = getCurrentFrame(); if( xCurrentFrame.is() )
{
xComponent = impl_getFrameComponent( xCurrentFrame );
} return xComponent;
}
/*-************************************************************************************************************ @interface XDesktop @short return the current active frame in hierarchy @descr There can be more than one different active paths in our frame hierarchy. But only one of them can be the most active frame (normally it has the focus). Don't mix it with getActiveFrame()! That will return our current active frame, which must be a direct child of us and should be a part(!) of an active path.
@seealso method getActiveFrame() @return A valid reference, if there is an active frame. A null reference , otherwise.
@onerror We return a null reference. @threadsafe yes
*/
css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getCurrentFrame()
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
// Start search with our direct active frame (if it exists!). // Search its children for other active frames too. // Stop if none could be found and return the last of the found ones.
css::uno::Reference< css::frame::XFramesSupplier > xLast( getActiveFrame(), css::uno::UNO_QUERY ); if( xLast.is() )
{
css::uno::Reference< css::frame::XFramesSupplier > xNext( xLast->getActiveFrame(), css::uno::UNO_QUERY ); while( xNext.is() )
{
xLast = xNext;
xNext.set( xNext->getActiveFrame(), css::uno::UNO_QUERY );
}
} return xLast;
}
/*-************************************************************************************************************ @interface XComponentLoader @short try to load given URL into a task @descr You can give us some information about the content, which you will load into a frame. We search or create this target for you, make a type detection of given URL and try to load it. As a result of this operation we return the new created component or nothing, if loading failed. @param "sURL" , URL, which represents the content @param "sTargetFrameName" , name of target frame or special value like "_self", "_blank" @param "nSearchFlags" , optional arguments for frame search, if target isn't a special one @param "lArguments" , optional arguments for loading @return A valid component reference, if loading was successful. A null reference otherwise.
if (bOnMainThread)
{ // Make sure that we own the solar mutex, otherwise later // vcl::SolarThreadExecutor::execute() will release the solar mutex, even if it's owned by // another thread, leading to an std::abort() at the end.
SolarMutexGuard g;
/*-************************************************************************************************************ @interface XTasksSupplier @short get access to create enumerations of our task children @descr Direct children of desktop are tasks every time. Calling this method allows to create enumerations of the children.
But, don't forget - you will be the owner of the returned object and must release it! We use a helper class to implement the access interface. They hold a weak reference to us. It can be, that the desktop is dead, but not your TasksAccess-object! Then they will do nothing! You can't create enumerations then.
@attention Normally we don't need any lock here. We don't work on internal members!
@seealso class TasksAccess @return A reference to an access object, which can create enumerations of our child tasks.
@onerror A null reference is returned. @threadsafe yes
*/
css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getTasks()
{
SAL_INFO("fwk.desktop", "Desktop::getTasks(): Use of obsolete interface XTaskSupplier"); return nullptr;
}
/*-************************************************************************************************************ @interface XTasksSupplier @short return current active task of our direct children @descr Desktop children are tasks only ! If we have an active path from desktop as top to any frame on bottom, we must have an active direct child. Its reference is returned here.
@attention a) Do not confuse it with getCurrentFrame()! The current frame might not be one of our direct children. It can be every frame in subtree and must have the focus (is the last one of an active path!). b) We don't need any lock here. Our container itself is threadsafe and lives, if we live!
@seealso method getCurrentFrame() @return A reference to our current active taskchild.
@onerror A null reference is returned. @threadsafe yes
*/
css::uno::Reference< css::frame::XTask > SAL_CALL Desktop::getActiveTask()
{
SAL_INFO("fwk.desktop", "Desktop::getActiveTask(): Use of obsolete interface XTaskSupplier"); return nullptr;
}
/*-************************************************************************************************************ @interface XDispatchProvider @short search a dispatcher for given URL @descr We use a helper implementation (class DispatchProvider) to do so. So we don't have to implement this algorithm twice!
@attention We don't need any lock here. Our helper itself is threadsafe and lives, if we live!
@seealso class DispatchProvider
@param "aURL" , URL to dispatch @param "sTargetFrameName" , name of target frame, who should dispatch this URL @param "nSearchFlags" , flags to regulate the search @param "lQueries" , list of queryDispatch() calls! @return A reference or list of dispatch objects found for this URL.
// Remove uno and cmd protocol part as we want to support both of them. We store only the command part // in our hash map. All other protocols are stored with the protocol part.
OUString aCommand( aURL.Main ); if ( aURL.Protocol.equalsIgnoreAsciiCase(".uno:") )
aCommand = aURL.Path;
if (!m_xCommandOptions && !comphelper::IsFuzzing())
m_xCommandOptions.reset(new SvtCommandOptions);
// Make std::unordered_map lookup if the current URL is in the disabled list if (m_xCommandOptions && m_xCommandOptions->LookupDisabled(aCommand)) return css::uno::Reference< css::frame::XDispatch >(); else
{ // We use a helper to support this interface and an interceptor mechanism. // Our helper itself is threadsafe! return m_xDispatchHelper->queryDispatch( aURL, sTargetFrameName, nSearchFlags );
}
}
/*-************************************************************************************************************ @interface XDispatchProviderInterception @short supports registration/deregistration of interception objects, which are interested in special dispatches.
@descr It's really provided by an internal helper, which is used inside the dispatch API too. @param xInterceptor the interceptor object, which wishes to be (de)registered.
/*-************************************************************************************************************ @interface XFramesSupplier @short return access to append or remove children on desktop @descr We don't implement this interface directly. We use a helper class to do this. If you wish to add or delete children to/from the container, call this method to get a reference to the helper.
@attention The helper itself is threadsafe. So we don't need any lock here.
@seealso class OFrames @return A reference to the helper.
@onerror A null reference is returned. @threadsafe yes
*/
css::uno::Reference< css::frame::XFrames > SAL_CALL Desktop::getFrames()
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
return m_xFramesHelper;
}
/*-************************************************************************************************************ @interface XFramesSupplier @short set/get the current active child frame @descr It must be a task. Direct children of desktop are tasks only! No frames are accepted. We don't save this information directly in this class. We use our container-helper to do that.
@attention The helper itself is threadsafe. So we don't need any lock here.
@seealso class OFrameContainer
@param "xFrame", new active frame (must be valid!) @return A reference to our current active childtask, if any exists.
@onerror A null reference is returned. @threadsafe yes
*/ void SAL_CALL Desktop::setActiveFrame( const css::uno::Reference< css::frame::XFrame >& xFrame )
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
// Get old active frame first. // If nothing will change - do nothing! // Otherwise set new active frame ... // and deactivate last frame. // It's necessary for our FrameActionEvent listener on a frame!
css::uno::Reference< css::frame::XFrame > xLastActiveChild = m_aChildTaskContainer.getActive(); if( xLastActiveChild != xFrame )
{
m_aChildTaskContainer.setActive( xFrame ); if( xLastActiveChild.is() )
{
xLastActiveChild->deactivate();
}
}
}
/* @interface XFrame @short unimplemented methods! @descr Some methods make no sense for our desktop! It has no window or parent or ... So we should have an empty implementation and warn the programmer, if it is used!
*/ void SAL_CALL Desktop::initialize( const css::uno::Reference< css::awt::XWindow >& )
{
}
void SAL_CALL Desktop::activate()
{ // Desktop is active always... but sometimes our frames try to activate // the complete path from bottom to top... And our desktop is the topmost frame :-( // So - please don't show any assertions here. Do nothing!
}
void SAL_CALL Desktop::deactivate()
{ // Desktop is active always... but sometimes our frames try to deactivate // the complete path from bottom to top... And our desktop is the topmost frame :-( // So - please don't show any assertions here. Do nothing!
}
/*-************************************************************************************************************ @interface XFrame @short try to find a frame with special parameters @descr This method searches for a frame with the specified name. Frames may contain other frames (e.g. a frameset) and may be contained in other frames. This hierarchy is searched by this method. First some special names are taken into account, i.e. "", "_self", "_top", "_parent" etc. The FrameSearchFlags are ignored when comparing these names with aTargetFrameName, further steps are controlled by the FrameSearchFlags. If allowed, the name of the frame itself is compared with the desired one, then ( again if allowed ) the method findFrame is called for all children of the frame. If no Frame with the given name is found until the top frames container, a new top Frame is created, if this is allowed by a special FrameSearchFlag. The new Frame also gets the desired name. We use a helper to get the desired search direction and react in the expected manner.
@seealso class TargetFinder
@param "sTargetFrameName" , name of searched frame @param "nSearchFlags" , flags to regulate search @return A reference to an existing frame in hierarchy, if it exists.
// 0) Ignore wrong parameters! // We don't support searching for the following special targets. // If we reject these requests, we don't have to keep checking for such names // in the code that follows. If we do not reject them, very wrong // search results may occur!
if (
(sTargetFrameName==SPECIALTARGET_DEFAULT ) || // valid for dispatches - not for findFrame()!
(sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition
(sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as children of tasks only - // and they exist more than once. We have no idea which of our sub tasks is the right one
)
{ return nullptr;
}
// I) Check for special defined targets first which must be handled exclusively. // Force using of "if() else if() ..."
// I.I) "_blank" // Create a new task as child of this desktop instance. // Note: the used helper TaskCreator uses us automatically.
// II) Otherwise use optional given search flags. // Force using of combinations of such flags. It means there is no "else" part in the used if() statements. // But we must break further searches if target was already found. // The order of using flags is fixed: SELF - CHILDREN - SIBLINGS - PARENT // TASK and CREATE are handled as special cases. // But note: such flags are not valid for the desktop - especially SIBLINGS or PARENT.
// II.I) SELF // Check for the right name. If it's the searched one, return ourselves - otherwise // ignore this flag.
// II.II) TASKS // This is a special flag. Normally it regulates search inside tasks and forbids access to parent trees. // But the desktop exists outside such task trees. They are our sub trees. So the desktop implements // a special feature: we use it to start searching on our direct children only. That means we suppress // search on ALL child frames. It may be useful to get access to opened document tasks // only without filtering out all sub frames that are not really required. // The helper method used on our container doesn't create any frame - it's only for searching.
// II.III) CHILDREN // Search all children for the given target name. // An empty name value can't occur here - because it must be already handled as "_self" // before. The used helper function of the container doesn't create any frame. // It makes a deep search only.
// II.IV) CREATE // If we haven't found any valid target frame by using normal flags, but the user allowed us to create // a new one, we should do that. The used TaskCreator uses us automatically as parent!
// Disable this instance for further work. // This will wait for all current running transactions // and rejects all new incoming requests!
m_aTransactionManager.setWorkingMode(E_BEFORECLOSE);
}
// The following lines of code can be called outside a synchronized block, // because our transaction manager will block all new requests to this object. // So nobody can use us any longer. // Exception: only removing of listeners will work and this code can't be dangerous.
// First we have to kill all listener connections. // They might rely on our member and can hinder us on releasing them.
css::uno::Reference< css::uno::XInterface > xThis ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
css::lang::EventObject aEvent( xThis );
m_aListenerContainer.disposeAndClear( aEvent );
// Clear our child task container and forcefully forget all task references. // Normally all open documents were already closed by our terminate() function. // New opened frames will have a problem now .-)
m_aChildTaskContainer.clear();
// At least clean up other member references.
m_xDispatchHelper.clear();
m_xFramesHelper.clear();
m_xContext.clear();
// we need a copy because the disposing might call the removeEventListener method
std::vector< css::uno::Reference<css::frame::XTerminateListener> > xComponentDllListeners;
xComponentDllListeners.swap(m_xComponentDllListeners); for (auto& xListener: xComponentDllListeners)
{
xListener->disposing(aEvent);
}
xComponentDllListeners.clear();
m_xSfxTerminator.clear();
m_xCommandOptions.reset();
// From this point nothing will do further work on this object, // excepting our dtor() .-)
m_aTransactionManager.setWorkingMode( E_CLOSE );
}
/* @interface XComponent @short add/remove listener for dispose events @descr Add an event listener to this object, if you wish to get information about our dying! You must release this listener reference during your own disposing() method.
@attention Our container itself is threadsafe. So we don't need any lock here. @param "xListener", reference to a valid listener. We don't accept invalid values! @threadsafe yes
*/ void SAL_CALL Desktop::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Safe impossible cases // Method not defined for all incoming parameters.
SAL_WARN_IF( !xListener.is(), "fwk.desktop", "Desktop::addEventListener(): Invalid parameter detected!" ); // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
/*-************************************************************************************************************ @interface XDispatchResultListener @short callback for dispatches @descr To support our method "loadComponentFromURL()" we are a listener on temporarily created dispatchers. They call us back in this method "statusChanged()". As source of a given state event, they hand us a reference to the target frame in which dispatch was loaded! So we can use it to return its component to caller! If no target exists ... ??!!
@seealso method loadComponentFromURL()
@param "aEvent", state event with (hopefully) valid information @threadsafe yes
*/ void SAL_CALL Desktop::dispatchFinished( const css::frame::DispatchResultEvent& aEvent )
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
/*-************************************************************************************************************ @interface XEventListener @short not implemented! @descr We are a status listener and so we must be an event listener, too. But we don't actually need to be! We are only a temporary listener and our lifetime isn't smaller than our temporarily used dispatcher.
@seealso method loadComponentFromURL()
*/ void SAL_CALL Desktop::disposing( const css::lang::EventObject& )
{
SAL_WARN( "fwk.desktop", "Desktop::disposing(): Algorithm error! Normally desktop is temp. listener ... not all the time. So this method shouldn't be called." );
}
/*-************************************************************************************************************ @interface XInteractionHandler @short callback for loadComponentFromURL for exceptions detected during load process @descr In this case we must cancel loading and throw this detected exception again as a result of our own called method.
@attention a) Normal loop in loadComponentFromURL() breaks on set member m_eLoadState during callback statusChanged(). But this interaction feature implements second way to do so! So we must look at different callbacks for the same operation and live with it. b) Search for given continuations, too. If any XInteractionAbort exists, use it to abort further operations for the currently running operation!
@seealso method loadComponentFromURL() @seealso member m_eLoadState
@param "xRequest", request for interaction - normally a wrapped target exception from lower services @threadsafe yes
*/ void SAL_CALL Desktop::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest )
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
// Don't check incoming request! // If interaction starts somewhere without a correct parameter, a mistake was made. // loadComponentFromURL() waits for this event - otherwise it yields forever!
// Get packed request and work on it first. // Attention: don't set it on internal member BEFORE interaction is finished - because // "loadComponentFromURL()" yields until this member is changed. If we do it before // interaction finishes we can't guarantee correct functionality. Maybe we cancel load process to earlier...
css::uno::Any aRequest = xRequest->getRequest();
// Differ between abortable interactions (error, unknown filter...) // and other ones (ambiguous but not unknown filter...)
css::task::ErrorCodeRequest aErrorCodeRequest; if( aRequest >>= aErrorCodeRequest )
{ bool bWarning = ErrCode(aErrorCodeRequest.ErrCode).IsWarning(); if (xApprove.is() && bWarning)
xApprove->select(); else if (xAbort.is())
{
xAbort->select();
bAbort = true;
}
} elseif( xAbort.is() )
{
xAbort->select();
bAbort = true;
}
// Ok now it's time to break yield loop of loadComponentFromURL(). // But only for actually aborted requests! // For example, warnings will be approved and we wait for any success story. if (bAbort)
{
SolarMutexGuard g;
m_eLoadState = E_INTERACTION;
}
}
/*-************************************************************************************************************ @short try to convert a property value @descr This method is called from helper class "OPropertySetHelper". Don't use this directly! You must try to convert the value of a given PropHandle and return the results of this operation. This will be used to ask vetoable listeners. If no listener has a veto, we will change the value! ( in method setFastPropertyValue_NoBroadcast(...) )
@attention Methods of OPropertySethelper are made safe by using our shared osl mutex (see ctor!). So we must use different locks to make our implementation threadsafe.
@seealso class OPropertySetHelper @seealso method setFastPropertyValue_NoBroadcast()
@param "aConvertedValue" new converted value of property @param "aOldValue" old value of property @param "nHandle" handle of property @param "aValue" new value of property @return sal_True if value will be changed, sal_FALSE otherwise
@onerror IllegalArgumentException, if you call this with an invalid argument @threadsafe yes
*/
sal_Bool SAL_CALL Desktop::convertFastPropertyValue( css::uno::Any& aConvertedValue ,
css::uno::Any& aOldValue ,
sal_Int32 nHandle , const css::uno::Any& aValue )
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
// Initialize state with sal_False !!! // (Handle can be invalid) bool bReturn = false;
/*-************************************************************************************************************ @short set value of a transient property @descr This method is calling from helper class "OPropertySetHelper". Don't use this directly! Handle and value are valid in every way! You must set the new value only. After this, base class sends messages to all listener automatically.
@seealso class OPropertySetHelper
@param "nHandle" handle of property to change @param "aValue" new value of property @onerror An exception is thrown. @threadsafe yes
*/ void SAL_CALL Desktop::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , const css::uno::Any& aValue )
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
switch( nHandle )
{ case PropHandle::SuspendQuickstartVeto: aValue >>= m_bSuspendQuickstartVeto; break; case PropHandle::DispatchRecorderSupplier: aValue >>= m_xDispatchRecorderSupplier; break; case PropHandle::Title: aValue >>= m_sTitle; break;
}
}
/*-************************************************************************************************************ @short get value of a transient property @descr This method is calling from helper class "OPropertySetHelper". Don't use this directly!
@attention We don't need any mutex or lock here. We only use threadsafe containers or methods here!
@seealso class OPropertySetHelper
@param "nHandle" handle of property to change @param "aValue" current value of property @threadsafe yes
*/ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue ,
sal_Int32 nHandle ) const
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
switch( nHandle )
{ case PropHandle::ActiveFrame : aValue <<= m_aChildTaskContainer.getActive(); break; case PropHandle::IsPlugged : aValue <<= false; break; case PropHandle::SuspendQuickstartVeto: aValue <<= m_bSuspendQuickstartVeto; break; case PropHandle::DispatchRecorderSupplier: aValue <<= m_xDispatchRecorderSupplier; break; case PropHandle::Title: aValue <<= m_sTitle; break;
}
}
/*-************************************************************************************************************ @short return propertysetinfo @descr You can call this method to get information about the transient properties of this object.
@attention You must use a global lock (method uses a static variable) and it must be its shareable osl mutex. Because our base class uses this mutex to make its code threadsafe. We use our lock! So we could have two different mutex/lock mechanisms for the same object.
@seealso class OPropertySetHelper @seealso interface XPropertySet @seealso interface XMultiPropertySet @return reference to object with information [XPropertySetInfo] @threadsafe yes
*/
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropertySetInfo()
{ /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ // Register transaction and reject wrong calls.
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
// Create structure of propertysetinfo for base class "OPropertySetHelper". // (Use method "getInfoHelper()".) static css::uno::Reference< css::beans::XPropertySetInfo > xInfo(
cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ) );
return xInfo;
}
/*-************************************************************************************************************ @short return current component of current frame @descr The desktop itself has no component. But every frame in subtree.
--> --------------------
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.