21#include <com/sun/star/frame/DispatchStatement.hpp>
22#include <com/sun/star/container/XIndexReplace.hpp>
23#include <com/sun/star/beans/PropertyValue.hpp>
24#include <com/sun/star/uno/Sequence.hxx>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/util/URLTransformer.hpp>
27#include <com/sun/star/util/XURLTransformer.hpp>
28#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
31#include <osl/diagnose.h>
71 std::unique_ptr<SfxAllItemSet>
75 css::uno::Reference< css::frame::XDispatchRecorder >
xRecorder;
76 css::uno::Reference< css::util::XURLTransformer >
xTransform;
95 void Record(
const uno::Sequence < beans::PropertyValue >& rArgs );
101 if ( rHint.
GetId() == SfxHintId::Dying )
108 if ( pNewPool !=
pPool )
123 pImpl->Record( uno::Sequence < beans::PropertyValue >() );
127 if (
pImpl->pRetVal )
138 pArgs(rOrig.pArgs? new
SfxAllItemSet(*rOrig.pArgs): nullptr),
141 pImpl->bAllowRecording = rOrig.
pImpl->bAllowRecording;
142 pImpl->bDone =
false;
143 pImpl->bIgnored =
false;
144 pImpl->pShell =
nullptr;
145 pImpl->pSlot =
nullptr;
159 if (!rOrig.
pImpl->pViewFrame || !rOrig.
pImpl->xRecorder.is())
164 if (
pImpl->pViewFrame->GetDispatcher()->GetShellAndSlot_Impl(
nSlot, &
pImpl->pShell, &
pImpl->pSlot,
true,
true))
168 if (
pImpl->xRecorder)
192 pImpl->bDone =
false;
193 pImpl->bIgnored =
false;
195 pImpl->pShell =
nullptr;
196 pImpl->pSlot =
nullptr;
198 pImpl->pViewFrame = &rViewFrame;
199 if(
pImpl->pViewFrame->GetDispatcher()->GetShellAndSlot_Impl( nSlotId, &
pImpl->pShell, &
pImpl->pSlot,
true,
true ) )
203 if (
pImpl->xRecorder)
209 SAL_WARN(
"sfx",
"Recording unsupported slot: " <<
pImpl->pPool->GetSlotId(nSlotId) );
226 pImpl->bDone =
false;
227 pImpl->bIgnored =
false;
228 pImpl->SetPool( &rPool );
229 pImpl->pShell =
nullptr;
230 pImpl->pSlot =
nullptr;
231 pImpl->nCallMode = nMode;
237 const css::uno::Sequence < css::beans::PropertyValue >& rArgs,
241: nSlot(pSlot->GetSlotId()),
245 pImpl->bDone =
false;
246 pImpl->bIgnored =
false;
247 pImpl->SetPool( &rPool );
248 pImpl->pShell =
nullptr;
249 pImpl->pSlot =
nullptr;
250 pImpl->nCallMode = nMode;
268 pImpl->bDone =
false;
269 pImpl->bIgnored =
false;
271 pImpl->pShell =
nullptr;
272 pImpl->pSlot =
nullptr;
273 pImpl->nCallMode = nMode;
291 return pImpl->nCallMode;
316 return pImpl->pInternalArgs.get();
322 const uno::Sequence < beans::PropertyValue >& rArgs
337 uno::Reference< container::XIndexReplace > xReplace(
xRecorder, uno::UNO_QUERY );
338 if ( xReplace.is() && aCmd ==
".uno:InsertText" )
340 sal_Int32
nCount = xReplace->getCount();
343 frame::DispatchStatement aStatement;
345 if ( (aElement >>= aStatement) && aStatement.aCommand == aCmd )
349 aStatement.aArgs[0].Value >>=
aStr;
350 rArgs[0].Value >>= aNew;
352 aStatement.aArgs.getArray()[0].Value <<=
aStr;
353 aElement <<= aStatement;
354 xReplace->replaceByIndex(
nCount-1, aElement );
361 aURL.Complete = aCmd;
375 const css::uno::Reference< css::frame::XDispatchRecorder >& xRecorder,
387 pImpl->pShell = &rSh;
388 pImpl->pSlot = &rSlot;
389 pImpl->xRecorder = xRecorder;
393 pImpl->pViewFrame = pViewFrame;
416 pArgs->ClearItem(nID);
417 if ( !
pArgs->Count() )
431 return pImpl->pRetVal.get();
478 pArgs->Put(*pItem,pItem->Which());
496 pImpl->pInternalArgs.reset();
502 return pImpl->bCancelled;
515 pImpl->bCancelled =
true;
516 pImpl->SetPool(
nullptr );
537 pImpl->bIgnored =
true;
561 if ( !
pImpl->xRecorder.is() )
576 SAL_WARN_IF(
pImpl->pSlot->pUnoName.isEmpty(),
"sfx",
"Recording not exported slot: "
577 <<
pImpl->pSlot->GetSlotId() );
579 if (
pImpl->pSlot->pUnoName.isEmpty() )
590 const sal_uInt16 nWhich(rPool.
GetWhich(
pImpl->pSlot->GetSlotId()));
591 const bool bItemStateSet(
nullptr != pSet);
593 SAL_WARN_IF( !bItemStateSet || SfxItemState::SET != eState,
"sfx",
"Recording property not available: "
594 <<
pImpl->pSlot->GetSlotId() );
595 uno::Sequence < beans::PropertyValue >
aSeq;
597 if ( bItemStateSet && SfxItemState::SET == eState )
606 uno::Sequence < beans::PropertyValue >
aSeq;
622 sal_uInt16 nSlotId = rPool.
GetSlotId( pItem->Which() );
623 if ( nSlotId ==
nSlot )
626 OSL_FAIL(
"recursion RecordPerItem - use RecordPerSet!" );
634 if ( aReq.
pImpl->pSlot )
642 pImpl->Record( uno::Sequence < beans::PropertyValue >() );
682 css::uno::Reference< css::frame::XDispatchRecorder > xRecorder;
684 css::uno::Reference< css::beans::XPropertySet > xSet(
686 css::uno::UNO_QUERY);
690 css::uno::Any aProp = xSet->getPropertyValue(
"DispatchRecorderSupplier");
691 css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier;
694 xRecorder = xSupplier->getDispatchRecorder();
720 pImpl->nModifier = nModi;
726 return pImpl->nModifier;
732 pImpl->bAllowRecording = bSet;
737 bool bAllow =
pImpl->bAllowRecording;
747 pImpl->pInternalArgs.reset();
void TransformItems(sal_uInt16 nSlotId, const SfxItemSet &rSet, uno::Sequence< beans::PropertyValue > &rArgs, const SfxSlot *pSlot)
void TransformParameters(sal_uInt16 nSlotId, const uno::Sequence< beans::PropertyValue > &rArgs, SfxAllItemSet &rSet, const SfxSlot *pSlot)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
SAL_DLLPRIVATE const SfxItemSet * GetInternalArgs_Impl() const
void RemoveItem(sal_uInt16 nSlotId)
bool AllowsRecording() const
const SfxPoolItem * GetReturnValue() const
SfxRequest(SfxViewFrame &, sal_uInt16 nSlotId)
std::unique_ptr< SfxAllItemSet > pArgs
virtual ~SfxRequest() override
void AppendItem(const SfxPoolItem &)
void SetReturnValue(const SfxPoolItem &)
SAL_DLLPRIVATE void Done_Impl(const SfxItemSet *pSet)
sal_uInt16 GetModifier() const
SfxCallMode GetCallMode() const
bool IsSynchronCall() const
void SetSynchronCall(bool bSynchron)
void SetArgs(const SfxAllItemSet &rArgs)
SAL_DLLPRIVATE void Record_Impl(SfxShell &rSh, const SfxSlot &rSlot, const css::uno::Reference< css::frame::XDispatchRecorder > &xRecorder, SfxViewFrame *)
void SetModifier(sal_uInt16 nModi)
static css::uno::Reference< css::frame::XDispatchRecorder > GetMacroRecorder(const SfxViewFrame &rFrame)
static bool HasMacroRecorder(const SfxViewFrame &rFrame)
void SetInternalArgs_Impl(const SfxAllItemSet &rArgs)
void Done(bool bRemove=false)
std::unique_ptr< SfxRequest_Impl > pImpl
void AllowRecording(bool)
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
const OUString & GetName() const
Returns the name of the Shell object.
SFX2_DLLPUBLIC OUString GetCommand() const
SfxFrame & GetFrame() const
#define DBG_ASSERT(sCon, aError)
void DeleteItemOnIdle(std::unique_ptr< SfxPoolItem > pItem)
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()
bool IsInvalidItem(const SfxPoolItem *pItem)
std::unique_ptr< SfxPoolItem > pRetVal
css::uno::Reference< css::frame::XDispatchRecorder > xRecorder
SfxRequest_Impl(SfxRequest *pOwner)
SfxViewFrame * pViewFrame
std::unique_ptr< SfxAllItemSet > pInternalArgs
css::uno::Reference< css::util::XURLTransformer > xTransform
void SetPool(SfxItemPool *pNewPool)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
void Record(const uno::Sequence< beans::PropertyValue > &rArgs)