/* -*- 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 .
*/
Implementation structure of the <SfxRequest> class.
*/
{
SfxRequest* pAnti; // Owner because of dying pool
OUString aTarget; // if possible from target object set by App
SfxItemPool* pPool; // ItemSet build with this pool
SfxPoolItemHolder aRetVal; // Return value belongs to itself
SfxShell* pShell; // run from this shell const SfxSlot* pSlot; // executed Slot
sal_uInt16 nModifier; // which Modifier was pressed? bool bDone; // at all executed bool bIgnored; // Cancelled by the User bool bCancelled; // no longer notify
SfxCallMode nCallMode; // Synch/Asynch/API/Record bool bAllowRecording;
std::unique_ptr<SfxAllItemSet>
pInternalArgs;
SfxViewFrame* pViewFrame; int m_nLokViewId = -1;
With this constructor events can subsequently be recorded that are not run across SfxDispatcher (eg from KeyInput() or mouse events). For this, a SfxRequest instance is created by this constructor and then proceed exactly as with a SfxRequest that in a <Slot-Execute-Method> is given as a parameter.
*/
if (bDone)
xRecorder->recordDispatch(aURL,rArgs); else
xRecorder->recordDispatchAsComment(aURL,rArgs);
}
void SfxRequest::Record_Impl
(
SfxShell& rSh, // the <SfxShell>, which has executed the Request const SfxSlot& rSlot, // the <SfxSlot>, which has executed the Request const css::uno::Reference< css::frame::XDispatchRecorder >& xRecorder,
SfxViewFrame* pViewFrame
)
/* [Description]
This internal method marks the specified SfxMakro SfxRequest as recorded in SfxMakro. Pointer to the parameters in Done() is used again, thus has to still be alive.
*/
void SfxRequest::Done
( const SfxItemSet& rSet /* parameters passed on by the application, that for example were asked for by the user in a dialogue, 0 if no parameters have been
set */
)
/* [Description]
This method must be called in the <Execute-Method> of the <SfxSlot>s, which has performed the SfxRequest when the execution actually took place. If 'Done()' is not called, then the SfxRequest is considered canceled.
Any return values are passed only when 'Done()' was called. Similar, when recording a macro only true statements are generated if 'Done()' was called; for SfxRequests that were not identified as such will instead be commented out by inserting ('rem').
[Note]
'Done ()' is not called, for example when a dialog started by the function was canceled by the user or if the execution could not be performed due to a wrong context (without use of separate <SfxShell>s). 'Done ()' will be launched, when executing the function led to a regular error (for example, file could not be opened).
*/
{
Done_Impl( &rSet );
// Keep items if possible, so they can be queried by StarDraw. if ( !pArgs )
{
pArgs.reset( new SfxAllItemSet( rSet ) );
pImpl->SetPool( pArgs->GetPool() );
} else
{
SfxItemIter aIter(rSet); for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
{ if(!IsInvalidItem(pItem))
pArgs->Put(*pItem);
}
}
}
If this method is called instead of <SfxRequest::Done()>, then this request is not recorded.
[Example]
The selecting of tools in StarDraw should not be recorded, but the same slots are to be used from the generation of the tools to the generated objects. Thus can NoRecords not be specified, i.e. should not be recorded.
*/
{ // Mark as actually executed
pImpl->bIgnored = true;
}
void SfxRequest::Done_Impl
( const SfxItemSet* pSet /* parameters passed on by the application, that for example were asked for by the user in a dialogue, 0 if no parameters have been
set */
)
/* [Description]
Internal method to mark SfxRequest with 'done' and to evaluate the parameters in 'pSet' in case it is recorded.
*/
{ // Mark as actually executed
pImpl->bDone = true;
// not Recording if ( !pImpl->xRecorder.is() ) return;
// was running a different slot than requested (Delegation) if ( nSlot != pImpl->pSlot->GetSlotId() )
{ // Search Slot again
pImpl->pSlot = pImpl->pShell->GetInterface()->GetSlot(nSlot);
DBG_ASSERT( pImpl->pSlot, "delegated SlotId not found" ); if ( !pImpl->pSlot ) // playing it safe return;
}
// recordable? // new Recording uses UnoName!
SAL_WARN_IF( pImpl->pSlot->aUnoName.isEmpty(), "sfx", "Recording not exported slot: "
<< pImpl->pSlot->GetSlotId() );
if ( pImpl->pSlot->aUnoName.isEmpty() ) // playing it safe return;
// often required values
SfxItemPool &rPool = pImpl->pShell->GetPool();
// record everything in a single statement? elseif ( pImpl->pSlot->IsMode(SfxSlotMode::RECORDPERSET) )
{
uno::Sequence < beans::PropertyValue > aSeq; if ( pSet )
TransformItems( pImpl->pSlot->GetSlotId(), *pSet, aSeq, pImpl->pSlot );
pImpl->Record( aSeq );
}
// record each item as a single statement elseif ( pImpl->pSlot->IsMode(SfxSlotMode::RECORDPERITEM) )
{ if ( pSet )
{ // iterate over Items
SfxItemIter aIter(*pSet); for ( const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem() )
{ // to determine the slot ID for the individual item
sal_uInt16 nSlotId = rPool.GetSlotId( pItem->Which() ); if ( nSlotId == nSlot )
{ // play it safe; repair the wrong flags
OSL_FAIL( "recursion RecordPerItem - use RecordPerSet!" );
SfxSlot *pSlot = const_cast<SfxSlot*>(pImpl->pSlot);
pSlot->nFlags &= ~SfxSlotMode::RECORDPERITEM;
pSlot->nFlags &= SfxSlotMode::RECORDPERSET;
}
// Record a Sub-Request
SfxRequest aReq( *pImpl->pViewFrame, nSlotId ); if ( aReq.pImpl->pSlot )
aReq.AppendItem( *pItem );
aReq.Done();
}
} else
{ //HACK(think about this again)
pImpl->Record( uno::Sequence < beans::PropertyValue >() );
}
}
}
bool SfxRequest::IsDone() const
/* [Description]
With this method it can be queried whether the SfxRequest was actually executed or not. If a SfxRequest was not executed, then this is for example because it was canceled by the user or the context for this request was wrong, this was not implemented on a separate <SfxShell>.
SfxRequest instances that return false will not be recorded.
This recorder is an attempt for dispatch () to get calls from the Frame. This is then available through a property by a supplier but only when recording was turned on.
(See also SfxViewFrame::MiscExec_Impl() and SID_RECORDING)
*/
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.