1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*d119d52dSAndrew Rist * distributed with this work for additional information
6*d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at
10*d119d52dSAndrew Rist *
11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist *
13*d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist * KIND, either express or implied. See the License for the
17*d119d52dSAndrew Rist * specific language governing permissions and limitations
18*d119d52dSAndrew Rist * under the License.
19*d119d52dSAndrew Rist *
20*d119d52dSAndrew Rist *************************************************************/
21*d119d52dSAndrew Rist
22*d119d52dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <com/sun/star/frame/DispatchStatement.hpp>
29cdf0e10cSrcweir #include <com/sun/star/container/XIndexReplace.hpp>
30cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
31cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
34cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
35cdf0e10cSrcweir #include <svl/itemiter.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #ifndef _ARGS_HXX //autogen
38cdf0e10cSrcweir #include <svl/itempool.hxx>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include <svtools/itemdel.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
43cdf0e10cSrcweir
44cdf0e10cSrcweir #ifndef GCC
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include <svl/smplhint.hxx>
48cdf0e10cSrcweir
49cdf0e10cSrcweir #include <sfx2/request.hxx>
50cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
51cdf0e10cSrcweir #include <sfx2/msg.hxx>
52cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
53cdf0e10cSrcweir #include "macro.hxx"
54cdf0e10cSrcweir #include <sfx2/objface.hxx>
55cdf0e10cSrcweir #include <sfx2/appuno.hxx>
56cdf0e10cSrcweir
57cdf0e10cSrcweir //===================================================================
58cdf0e10cSrcweir
59cdf0e10cSrcweir using namespace ::com::sun::star;
60cdf0e10cSrcweir
61cdf0e10cSrcweir struct SfxRequest_Impl: public SfxListener
62cdf0e10cSrcweir
63cdf0e10cSrcweir /* [Beschreibung]
64cdf0e10cSrcweir
65cdf0e10cSrcweir Implementations-Struktur der Klasse <SfxRequest>.
66cdf0e10cSrcweir */
67cdf0e10cSrcweir
68cdf0e10cSrcweir {
69cdf0e10cSrcweir SfxRequest* pAnti; // Owner wegen sterbendem Pool
70cdf0e10cSrcweir String aTarget; // ggf. von App gesetztes Zielobjekt
71cdf0e10cSrcweir SfxItemPool* pPool; // ItemSet mit diesem Pool bauen
72cdf0e10cSrcweir SfxPoolItem* pRetVal; // R"uckgabewert geh"ort sich selbst
73cdf0e10cSrcweir SfxShell* pShell; // ausgef"uhrt an dieser Shell
74cdf0e10cSrcweir const SfxSlot* pSlot; // ausgef"uhrter Slot
75cdf0e10cSrcweir sal_uInt16 nModifier; // welche Modifier waren gedrueckt?
76cdf0e10cSrcweir sal_Bool bDone; // "uberhaupt ausgef"uhrt
77cdf0e10cSrcweir sal_Bool bIgnored; // vom User abgebrochen
78cdf0e10cSrcweir sal_Bool bCancelled; // nicht mehr zustellen
79cdf0e10cSrcweir sal_Bool bUseTarget; // aTarget wurde von Applikation gesetzt
80cdf0e10cSrcweir sal_uInt16 nCallMode; // Synch/Asynch/API/Record
81cdf0e10cSrcweir sal_Bool bAllowRecording;
82cdf0e10cSrcweir SfxAllItemSet* pInternalArgs;
83cdf0e10cSrcweir SfxViewFrame* pViewFrame;
84cdf0e10cSrcweir
85cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
86cdf0e10cSrcweir
SfxRequest_ImplSfxRequest_Impl87cdf0e10cSrcweir SfxRequest_Impl( SfxRequest *pOwner )
88cdf0e10cSrcweir : pAnti( pOwner)
89cdf0e10cSrcweir , pPool(0)
90cdf0e10cSrcweir , nModifier(0)
91cdf0e10cSrcweir , bCancelled(sal_False)
92cdf0e10cSrcweir , nCallMode( SFX_CALLMODE_SYNCHRON )
93cdf0e10cSrcweir , bAllowRecording( sal_False )
94cdf0e10cSrcweir , pInternalArgs( 0 )
95cdf0e10cSrcweir , pViewFrame(0)
96cdf0e10cSrcweir {}
~SfxRequest_ImplSfxRequest_Impl97cdf0e10cSrcweir ~SfxRequest_Impl() { delete pInternalArgs; }
98cdf0e10cSrcweir
99cdf0e10cSrcweir
100cdf0e10cSrcweir void SetPool( SfxItemPool *pNewPool );
101cdf0e10cSrcweir virtual void Notify( SfxBroadcaster &rBC, const SfxHint &rHint );
102cdf0e10cSrcweir void Record( const uno::Sequence < beans::PropertyValue >& rArgs );
103cdf0e10cSrcweir };
104cdf0e10cSrcweir
105cdf0e10cSrcweir
106cdf0e10cSrcweir //====================================================================
107cdf0e10cSrcweir
Notify(SfxBroadcaster &,const SfxHint & rHint)108cdf0e10cSrcweir void SfxRequest_Impl::Notify( SfxBroadcaster&, const SfxHint &rHint )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir SfxSimpleHint *pSimpleHint = PTR_CAST(SfxSimpleHint, &rHint);
111cdf0e10cSrcweir if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DYING )
112cdf0e10cSrcweir pAnti->Cancel();
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
115cdf0e10cSrcweir //====================================================================
116cdf0e10cSrcweir
SetPool(SfxItemPool * pNewPool)117cdf0e10cSrcweir void SfxRequest_Impl::SetPool( SfxItemPool *pNewPool )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir if ( pNewPool != pPool )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir if ( pPool )
122cdf0e10cSrcweir EndListening( pPool->BC() );
123cdf0e10cSrcweir pPool = pNewPool;
124cdf0e10cSrcweir if ( pNewPool )
125cdf0e10cSrcweir StartListening( pNewPool->BC() );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir //====================================================================
130cdf0e10cSrcweir
131cdf0e10cSrcweir
~SfxRequest()132cdf0e10cSrcweir SfxRequest::~SfxRequest()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir DBG_MEMTEST();
135cdf0e10cSrcweir
136cdf0e10cSrcweir // nicht mit Done() marktierte Requests mit 'rem' rausschreiben
137cdf0e10cSrcweir if ( pImp->xRecorder.is() && !pImp->bDone && !pImp->bIgnored )
138cdf0e10cSrcweir pImp->Record( uno::Sequence < beans::PropertyValue >() );
139cdf0e10cSrcweir
140cdf0e10cSrcweir // Objekt abr"aumen
141cdf0e10cSrcweir delete pArgs;
142cdf0e10cSrcweir if ( pImp->pRetVal )
143cdf0e10cSrcweir DeleteItemOnIdle(pImp->pRetVal);
144cdf0e10cSrcweir delete pImp;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir //--------------------------------------------------------------------
147cdf0e10cSrcweir
148cdf0e10cSrcweir
SfxRequest(const SfxRequest & rOrig)149cdf0e10cSrcweir SfxRequest::SfxRequest
150cdf0e10cSrcweir (
151cdf0e10cSrcweir const SfxRequest& rOrig
152cdf0e10cSrcweir )
153cdf0e10cSrcweir : SfxHint( rOrig ),
154cdf0e10cSrcweir nSlot(rOrig.nSlot),
155cdf0e10cSrcweir pArgs(rOrig.pArgs? new SfxAllItemSet(*rOrig.pArgs): 0),
156cdf0e10cSrcweir pImp( new SfxRequest_Impl(this) )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir DBG_MEMTEST();
159cdf0e10cSrcweir
160cdf0e10cSrcweir pImp->bAllowRecording = rOrig.pImp->bAllowRecording;
161cdf0e10cSrcweir pImp->bDone = sal_False;
162cdf0e10cSrcweir pImp->bIgnored = sal_False;
163cdf0e10cSrcweir pImp->pRetVal = 0;
164cdf0e10cSrcweir pImp->pShell = 0;
165cdf0e10cSrcweir pImp->pSlot = 0;
166cdf0e10cSrcweir pImp->nCallMode = rOrig.pImp->nCallMode;
167cdf0e10cSrcweir pImp->bUseTarget = rOrig.pImp->bUseTarget;
168cdf0e10cSrcweir pImp->aTarget = rOrig.pImp->aTarget;
169cdf0e10cSrcweir pImp->nModifier = rOrig.pImp->nModifier;
170cdf0e10cSrcweir
171cdf0e10cSrcweir // deep copy needed !
172cdf0e10cSrcweir pImp->pInternalArgs = (rOrig.pImp->pInternalArgs ? new SfxAllItemSet(*rOrig.pImp->pInternalArgs) : 0);
173cdf0e10cSrcweir
174cdf0e10cSrcweir if ( pArgs )
175cdf0e10cSrcweir pImp->SetPool( pArgs->GetPool() );
176cdf0e10cSrcweir else
177cdf0e10cSrcweir pImp->SetPool( rOrig.pImp->pPool );
178cdf0e10cSrcweir }
179cdf0e10cSrcweir //--------------------------------------------------------------------
180cdf0e10cSrcweir
181cdf0e10cSrcweir
SfxRequest(SfxViewFrame * pViewFrame,sal_uInt16 nSlotId)182cdf0e10cSrcweir SfxRequest::SfxRequest
183cdf0e10cSrcweir (
184cdf0e10cSrcweir SfxViewFrame* pViewFrame,
185cdf0e10cSrcweir sal_uInt16 nSlotId
186cdf0e10cSrcweir
187cdf0e10cSrcweir )
188cdf0e10cSrcweir
189cdf0e10cSrcweir /* [Beschreibung]
190cdf0e10cSrcweir
191cdf0e10cSrcweir Mit diesem Konstruktor k"onnen Events, die nicht "uber den SfxDispatcher
192cdf0e10cSrcweir gelaufen sind (z.B aus KeyInput() oder Mouse-Events) nachtr"aglich
193cdf0e10cSrcweir recorded werden. Dazu wird eine SfxRequest-Instanz mit diesem Konstruktor
194cdf0e10cSrcweir erzeugt und dann genauso verfahren, wie mit einem SfxRequest, der in
195cdf0e10cSrcweir eine <Slot-Execute-Methode> als Parameter gegeben wird.
196cdf0e10cSrcweir */
197cdf0e10cSrcweir
198cdf0e10cSrcweir : nSlot(nSlotId),
199cdf0e10cSrcweir pArgs(0),
200cdf0e10cSrcweir pImp( new SfxRequest_Impl(this) )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir DBG_MEMTEST();
203cdf0e10cSrcweir
204cdf0e10cSrcweir pImp->bDone = sal_False;
205cdf0e10cSrcweir pImp->bIgnored = sal_False;
206cdf0e10cSrcweir pImp->SetPool( &pViewFrame->GetPool() );
207cdf0e10cSrcweir pImp->pRetVal = 0;
208cdf0e10cSrcweir pImp->pShell = 0;
209cdf0e10cSrcweir pImp->pSlot = 0;
210cdf0e10cSrcweir pImp->nCallMode = SFX_CALLMODE_SYNCHRON;
211cdf0e10cSrcweir pImp->bUseTarget = sal_False;
212cdf0e10cSrcweir pImp->pViewFrame = pViewFrame;
213cdf0e10cSrcweir if( pImp->pViewFrame->GetDispatcher()->GetShellAndSlot_Impl( nSlotId, &pImp->pShell, &pImp->pSlot, sal_True, sal_True ) )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir pImp->SetPool( &pImp->pShell->GetPool() );
216cdf0e10cSrcweir pImp->xRecorder = SfxRequest::GetMacroRecorder( pViewFrame );
217cdf0e10cSrcweir pImp->aTarget = pImp->pShell->GetName();
218cdf0e10cSrcweir }
219cdf0e10cSrcweir #ifdef DBG_UTIL
220cdf0e10cSrcweir else
221cdf0e10cSrcweir {
222cdf0e10cSrcweir ByteString aStr( "Recording unsupported slot: ");
223cdf0e10cSrcweir aStr += ByteString::CreateFromInt32( pImp->pPool->GetSlotId(nSlotId) );
224cdf0e10cSrcweir DBG_ERROR( aStr.GetBuffer() );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir #endif
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir //--------------------------------------------------------------------
230cdf0e10cSrcweir
231cdf0e10cSrcweir
SfxRequest(sal_uInt16 nSlotId,SfxCallMode nMode,SfxItemPool & rPool)232cdf0e10cSrcweir SfxRequest::SfxRequest
233cdf0e10cSrcweir (
234cdf0e10cSrcweir sal_uInt16 nSlotId, // auszuf"uhrende <Slot-Id>
235cdf0e10cSrcweir SfxCallMode nMode, // Synch/API/...
236cdf0e10cSrcweir SfxItemPool& rPool // ggf. f"ur das SfxItemSet f"ur Parameter
237cdf0e10cSrcweir )
238cdf0e10cSrcweir
239cdf0e10cSrcweir // creates a SfxRequest without arguments
240cdf0e10cSrcweir
241cdf0e10cSrcweir : nSlot(nSlotId),
242cdf0e10cSrcweir pArgs(0),
243cdf0e10cSrcweir pImp( new SfxRequest_Impl(this) )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir DBG_MEMTEST();
246cdf0e10cSrcweir
247cdf0e10cSrcweir pImp->bDone = sal_False;
248cdf0e10cSrcweir pImp->bIgnored = sal_False;
249cdf0e10cSrcweir pImp->SetPool( &rPool );
250cdf0e10cSrcweir pImp->pRetVal = 0;
251cdf0e10cSrcweir pImp->pShell = 0;
252cdf0e10cSrcweir pImp->pSlot = 0;
253cdf0e10cSrcweir pImp->nCallMode = nMode;
254cdf0e10cSrcweir pImp->bUseTarget = sal_False;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir
SfxRequest(const SfxSlot * pSlot,const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & rArgs,SfxCallMode nMode,SfxItemPool & rPool)257cdf0e10cSrcweir SfxRequest::SfxRequest
258cdf0e10cSrcweir (
259cdf0e10cSrcweir const SfxSlot* pSlot, // auszuf"uhrende <Slot-Id>
260cdf0e10cSrcweir const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& rArgs,
261cdf0e10cSrcweir SfxCallMode nMode, // Synch/API/...
262cdf0e10cSrcweir SfxItemPool& rPool // ggf. f"ur das SfxItemSet f"ur Parameter
263cdf0e10cSrcweir )
264cdf0e10cSrcweir : nSlot(pSlot->GetSlotId()),
265cdf0e10cSrcweir pArgs(new SfxAllItemSet(rPool)),
266cdf0e10cSrcweir pImp( new SfxRequest_Impl(this) )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir DBG_MEMTEST();
269cdf0e10cSrcweir
270cdf0e10cSrcweir pImp->bDone = sal_False;
271cdf0e10cSrcweir pImp->bIgnored = sal_False;
272cdf0e10cSrcweir pImp->SetPool( &rPool );
273cdf0e10cSrcweir pImp->pRetVal = 0;
274cdf0e10cSrcweir pImp->pShell = 0;
275cdf0e10cSrcweir pImp->pSlot = 0;
276cdf0e10cSrcweir pImp->nCallMode = nMode;
277cdf0e10cSrcweir pImp->bUseTarget = sal_False;
278cdf0e10cSrcweir TransformParameters( nSlot, rArgs, *pArgs, pSlot );
279cdf0e10cSrcweir }
280cdf0e10cSrcweir
281cdf0e10cSrcweir //-----------------------------------------------------------------------
282cdf0e10cSrcweir
SfxRequest(sal_uInt16 nSlotId,sal_uInt16 nMode,const SfxAllItemSet & rSfxArgs)283cdf0e10cSrcweir SfxRequest::SfxRequest
284cdf0e10cSrcweir (
285cdf0e10cSrcweir sal_uInt16 nSlotId,
286cdf0e10cSrcweir sal_uInt16 nMode,
287cdf0e10cSrcweir const SfxAllItemSet& rSfxArgs
288cdf0e10cSrcweir )
289cdf0e10cSrcweir
290cdf0e10cSrcweir // creates a SfxRequest with arguments
291cdf0e10cSrcweir
292cdf0e10cSrcweir : nSlot(nSlotId),
293cdf0e10cSrcweir pArgs(new SfxAllItemSet(rSfxArgs)),
294cdf0e10cSrcweir pImp( new SfxRequest_Impl(this) )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir DBG_MEMTEST();
297cdf0e10cSrcweir
298cdf0e10cSrcweir pImp->bDone = sal_False;
299cdf0e10cSrcweir pImp->bIgnored = sal_False;
300cdf0e10cSrcweir pImp->SetPool( rSfxArgs.GetPool() );
301cdf0e10cSrcweir pImp->pRetVal = 0;
302cdf0e10cSrcweir pImp->pShell = 0;
303cdf0e10cSrcweir pImp->pSlot = 0;
304cdf0e10cSrcweir pImp->nCallMode = nMode;
305cdf0e10cSrcweir pImp->bUseTarget = sal_False;
306cdf0e10cSrcweir }
307cdf0e10cSrcweir //--------------------------------------------------------------------
308cdf0e10cSrcweir
GetCallMode() const309cdf0e10cSrcweir sal_uInt16 SfxRequest::GetCallMode() const
310cdf0e10cSrcweir {
311cdf0e10cSrcweir return pImp->nCallMode;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
314cdf0e10cSrcweir //--------------------------------------------------------------------
315cdf0e10cSrcweir
IsSynchronCall() const316cdf0e10cSrcweir sal_Bool SfxRequest::IsSynchronCall() const
317cdf0e10cSrcweir {
318cdf0e10cSrcweir return SFX_CALLMODE_SYNCHRON == ( SFX_CALLMODE_SYNCHRON & pImp->nCallMode );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir //--------------------------------------------------------------------
322cdf0e10cSrcweir
SetSynchronCall(sal_Bool bSynchron)323cdf0e10cSrcweir void SfxRequest::SetSynchronCall( sal_Bool bSynchron )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir if ( bSynchron )
326cdf0e10cSrcweir pImp->nCallMode |= SFX_CALLMODE_SYNCHRON;
327cdf0e10cSrcweir else
328cdf0e10cSrcweir pImp->nCallMode &= ~(sal_uInt16) SFX_CALLMODE_SYNCHRON;
329cdf0e10cSrcweir }
330cdf0e10cSrcweir
SetInternalArgs_Impl(const SfxAllItemSet & rArgs)331cdf0e10cSrcweir void SfxRequest::SetInternalArgs_Impl( const SfxAllItemSet& rArgs )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir delete pImp->pInternalArgs;
334cdf0e10cSrcweir pImp->pInternalArgs = new SfxAllItemSet( rArgs );
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
GetInternalArgs_Impl() const337cdf0e10cSrcweir const SfxItemSet* SfxRequest::GetInternalArgs_Impl() const
338cdf0e10cSrcweir {
339cdf0e10cSrcweir return pImp->pInternalArgs;
340cdf0e10cSrcweir }
341cdf0e10cSrcweir
342cdf0e10cSrcweir //--------------------------------------------------------------------
343cdf0e10cSrcweir
344cdf0e10cSrcweir
Record(const uno::Sequence<beans::PropertyValue> & rArgs)345cdf0e10cSrcweir void SfxRequest_Impl::Record
346cdf0e10cSrcweir (
347cdf0e10cSrcweir const uno::Sequence < beans::PropertyValue >& rArgs // aktuelle Parameter
348cdf0e10cSrcweir )
349cdf0e10cSrcweir
350cdf0e10cSrcweir /* [Beschreibung]
351cdf0e10cSrcweir
352cdf0e10cSrcweir Interne Hilfsmethode zum erzeugen einer <SfxMacroStatement>-Instanz,
353cdf0e10cSrcweir welche den bereits ausgef"uhrten SfxRequest wiederholbar beschreibt.
354cdf0e10cSrcweir
355cdf0e10cSrcweir Die erzeugte Instanz, auf die ein Pointer zur"uckgeliefert wird
356cdf0e10cSrcweir geht in das Eigentum des Aufrufers "uber.
357cdf0e10cSrcweir */
358cdf0e10cSrcweir
359cdf0e10cSrcweir {
360cdf0e10cSrcweir String aCommand = String::CreateFromAscii(".uno:");
361cdf0e10cSrcweir aCommand.AppendAscii( pSlot->GetUnoName() );
362cdf0e10cSrcweir ::rtl::OUString aCmd( aCommand );
363cdf0e10cSrcweir if(xRecorder.is())
364cdf0e10cSrcweir {
365cdf0e10cSrcweir uno::Reference< container::XIndexReplace > xReplace( xRecorder, uno::UNO_QUERY );
366cdf0e10cSrcweir if ( xReplace.is() && aCmd.compareToAscii(".uno:InsertText") == COMPARE_EQUAL )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir sal_Int32 nCount = xReplace->getCount();
369cdf0e10cSrcweir if ( nCount )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir frame::DispatchStatement aStatement;
372cdf0e10cSrcweir uno::Any aElement = xReplace->getByIndex(nCount-1);
373cdf0e10cSrcweir if ( (aElement >>= aStatement) && aStatement.aCommand == aCmd )
374cdf0e10cSrcweir {
375cdf0e10cSrcweir ::rtl::OUString aStr;
376cdf0e10cSrcweir ::rtl::OUString aNew;
377cdf0e10cSrcweir aStatement.aArgs[0].Value >>= aStr;
378cdf0e10cSrcweir rArgs[0].Value >>= aNew;
379cdf0e10cSrcweir aStr += aNew;
380cdf0e10cSrcweir aStatement.aArgs[0].Value <<= aStr;
381cdf0e10cSrcweir aElement <<= aStatement;
382cdf0e10cSrcweir xReplace->replaceByIndex( nCount-1, aElement );
383cdf0e10cSrcweir return;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir }
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
388cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xFactory(
389cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(),
390cdf0e10cSrcweir com::sun::star::uno::UNO_QUERY);
391cdf0e10cSrcweir
392cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > xTransform(
393cdf0e10cSrcweir xFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")),
394cdf0e10cSrcweir com::sun::star::uno::UNO_QUERY);
395cdf0e10cSrcweir
396cdf0e10cSrcweir com::sun::star::util::URL aURL;
397cdf0e10cSrcweir aURL.Complete = aCmd;
398cdf0e10cSrcweir xTransform->parseStrict(aURL);
399cdf0e10cSrcweir
400cdf0e10cSrcweir if (bDone)
401cdf0e10cSrcweir xRecorder->recordDispatch(aURL,rArgs);
402cdf0e10cSrcweir else
403cdf0e10cSrcweir xRecorder->recordDispatchAsComment(aURL,rArgs);
404cdf0e10cSrcweir }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
407cdf0e10cSrcweir //--------------------------------------------------------------------
408cdf0e10cSrcweir
Record_Impl(SfxShell & rSh,const SfxSlot & rSlot,com::sun::star::uno::Reference<com::sun::star::frame::XDispatchRecorder> xRecorder,SfxViewFrame * pViewFrame)409cdf0e10cSrcweir void SfxRequest::Record_Impl
410cdf0e10cSrcweir (
411cdf0e10cSrcweir SfxShell& rSh, // die <SfxShell>, die den Request ausgef"uhrt hat
412cdf0e10cSrcweir const SfxSlot& rSlot, // der <SfxSlot>, der den Request ausgef"uhrt hat
413cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder, // der Recorder, mit dem aufgezeichnet wird
414cdf0e10cSrcweir SfxViewFrame* pViewFrame
415cdf0e10cSrcweir )
416cdf0e10cSrcweir
417cdf0e10cSrcweir /* [Beschreibung]
418cdf0e10cSrcweir
419cdf0e10cSrcweir Diese interne Methode markiert den SfxRequest als in dem angegebenen
420cdf0e10cSrcweir SfxMakro aufzuzeichnen.
421cdf0e10cSrcweir
422cdf0e10cSrcweir Pointer auf die Parameter werden in Done() wieder verwendet, m"usseb
423cdf0e10cSrcweir dann also noch leben.
424cdf0e10cSrcweir */
425cdf0e10cSrcweir
426cdf0e10cSrcweir {
427cdf0e10cSrcweir DBG_MEMTEST();
428cdf0e10cSrcweir pImp->pShell = &rSh;
429cdf0e10cSrcweir pImp->pSlot = &rSlot;
430cdf0e10cSrcweir pImp->xRecorder = xRecorder;
431cdf0e10cSrcweir pImp->aTarget = rSh.GetName();
432cdf0e10cSrcweir pImp->pViewFrame = pViewFrame;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir
435cdf0e10cSrcweir //--------------------------------------------------------------------
436cdf0e10cSrcweir
SetArgs(const SfxAllItemSet & rArgs)437cdf0e10cSrcweir void SfxRequest::SetArgs( const SfxAllItemSet& rArgs )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir delete pArgs;
440cdf0e10cSrcweir pArgs = new SfxAllItemSet(rArgs);
441cdf0e10cSrcweir pImp->SetPool( pArgs->GetPool() );
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir //--------------------------------------------------------------------
445cdf0e10cSrcweir
AppendItem(const SfxPoolItem & rItem)446cdf0e10cSrcweir void SfxRequest::AppendItem(const SfxPoolItem &rItem)
447cdf0e10cSrcweir {
448cdf0e10cSrcweir if(!pArgs)
449cdf0e10cSrcweir pArgs = new SfxAllItemSet(*pImp->pPool);
450cdf0e10cSrcweir pArgs->Put(rItem, rItem.Which());
451cdf0e10cSrcweir }
452cdf0e10cSrcweir
453cdf0e10cSrcweir //--------------------------------------------------------------------
454cdf0e10cSrcweir
RemoveItem(sal_uInt16 nID)455cdf0e10cSrcweir void SfxRequest::RemoveItem( sal_uInt16 nID )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir if (pArgs)
458cdf0e10cSrcweir {
459cdf0e10cSrcweir pArgs->ClearItem(nID);
460cdf0e10cSrcweir if ( !pArgs->Count() )
461cdf0e10cSrcweir DELETEZ(pArgs);
462cdf0e10cSrcweir }
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir //--------------------------------------------------------------------
466cdf0e10cSrcweir
GetArg(sal_uInt16 nSlotId,bool bDeep,TypeId aType) const467cdf0e10cSrcweir const SfxPoolItem* SfxRequest::GetArg
468cdf0e10cSrcweir (
469cdf0e10cSrcweir sal_uInt16 nSlotId, // Slot-Id oder Which-Id des Parameters
470cdf0e10cSrcweir bool bDeep, // false: nicht in Parent-ItemSets suchen
471cdf0e10cSrcweir TypeId aType // != 0: RTTI Pruefung mit Assertion
472cdf0e10cSrcweir ) const
473cdf0e10cSrcweir {
474cdf0e10cSrcweir return GetItem( pArgs, nSlotId, bDeep, aType );
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
477cdf0e10cSrcweir
478cdf0e10cSrcweir //--------------------------------------------------------------------
GetItem(const SfxItemSet * pArgs,sal_uInt16 nSlotId,bool bDeep,TypeId aType)479cdf0e10cSrcweir const SfxPoolItem* SfxRequest::GetItem
480cdf0e10cSrcweir (
481cdf0e10cSrcweir const SfxItemSet* pArgs,
482cdf0e10cSrcweir sal_uInt16 nSlotId, // Slot-Id oder Which-Id des Parameters
483cdf0e10cSrcweir bool bDeep, // false: nicht in Parent-ItemSets suchen
484cdf0e10cSrcweir TypeId aType // != 0: RTTI Pruefung mit Assertion
485cdf0e10cSrcweir )
486cdf0e10cSrcweir
487cdf0e10cSrcweir /* [Beschreibung]
488cdf0e10cSrcweir
489cdf0e10cSrcweir Mit dieser Methode wird der Zugriff auf einzelne Parameter im
490cdf0e10cSrcweir SfxRequest wesentlich vereinfacht. Insbesondere wird die Typpr"ufung
491cdf0e10cSrcweir (per Assertion) durchgef"uhrt, wodurch die Applikations-Sourcen
492cdf0e10cSrcweir wesentlich "ubersichtlicher werden. In der PRODUCT-Version wird
493cdf0e10cSrcweir eine 0 zur"uckgegeben, wenn das gefundene Item nicht von der
494cdf0e10cSrcweir angegebenen Klasse ist.
495cdf0e10cSrcweir
496cdf0e10cSrcweir
497cdf0e10cSrcweir [Beispiel]
498cdf0e10cSrcweir
499cdf0e10cSrcweir void MyShell::Execute( SfxRequest &rReq )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir switch ( rReq.GetSlot() )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir case SID_MY:
504cdf0e10cSrcweir {
505cdf0e10cSrcweir ...
506cdf0e10cSrcweir // ein Beispiel ohne Verwendung des Makros
507cdf0e10cSrcweir const SfxInt32Item *pPosItem = (const SfxUInt32Item*)
508cdf0e10cSrcweir rReq.GetArg( SID_POS, sal_False, TYPE(SfxInt32Item) );
509cdf0e10cSrcweir sal_uInt16 nPos = pPosItem ? pPosItem->GetValue() : 0;
510cdf0e10cSrcweir
511cdf0e10cSrcweir // ein Beispiel mit Verwendung des Makros
512cdf0e10cSrcweir SFX_REQUEST_ARG(rReq, pSizeItem, SfxInt32Item, SID_SIZE, sal_False);
513cdf0e10cSrcweir sal_uInt16 nSize = pSizeItem ? pPosItem->GetValue() : 0;
514cdf0e10cSrcweir
515cdf0e10cSrcweir ...
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
518cdf0e10cSrcweir ...
519cdf0e10cSrcweir }
520cdf0e10cSrcweir }
521cdf0e10cSrcweir */
522cdf0e10cSrcweir
523cdf0e10cSrcweir {
524cdf0e10cSrcweir if ( pArgs )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir // ggf. in Which-Id umrechnen
527cdf0e10cSrcweir sal_uInt16 nWhich = pArgs->GetPool()->GetWhich(nSlotId);
528cdf0e10cSrcweir
529cdf0e10cSrcweir // ist das Item gesetzt oder bei bDeep==TRUE verf"ugbar?
530cdf0e10cSrcweir const SfxPoolItem *pItem = 0;
531cdf0e10cSrcweir if ( ( bDeep ? SFX_ITEM_AVAILABLE : SFX_ITEM_SET )
532cdf0e10cSrcweir <= pArgs->GetItemState( nWhich, bDeep, &pItem ) )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir // stimmt der Typ "uberein?
535cdf0e10cSrcweir if ( !pItem || pItem->IsA(aType) )
536cdf0e10cSrcweir return pItem;
537cdf0e10cSrcweir
538cdf0e10cSrcweir // Item da aber falsch => Programmierfehler
539cdf0e10cSrcweir DBG_ERROR( "invalid argument type" );
540cdf0e10cSrcweir }
541cdf0e10cSrcweir }
542cdf0e10cSrcweir
543cdf0e10cSrcweir // keine Parameter, nicht gefunden oder falschen Typ gefunden
544cdf0e10cSrcweir return 0;
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir //--------------------------------------------------------------------
548cdf0e10cSrcweir
SetReturnValue(const SfxPoolItem & rItem)549cdf0e10cSrcweir void SfxRequest::SetReturnValue(const SfxPoolItem &rItem)
550cdf0e10cSrcweir {
551cdf0e10cSrcweir DBG_ASSERT(!pImp->pRetVal, "Returnwert mehrfach setzen?");
552cdf0e10cSrcweir if(pImp->pRetVal)
553cdf0e10cSrcweir delete pImp->pRetVal;
554cdf0e10cSrcweir pImp->pRetVal = rItem.Clone();
555cdf0e10cSrcweir }
556cdf0e10cSrcweir
557cdf0e10cSrcweir //--------------------------------------------------------------------
558cdf0e10cSrcweir
GetReturnValue() const559cdf0e10cSrcweir const SfxPoolItem* SfxRequest::GetReturnValue() const
560cdf0e10cSrcweir {
561cdf0e10cSrcweir return pImp->pRetVal;
562cdf0e10cSrcweir }
563cdf0e10cSrcweir
564cdf0e10cSrcweir //--------------------------------------------------------------------
565cdf0e10cSrcweir
Done(const SfxItemSet & rSet,bool bKeep)566cdf0e10cSrcweir void SfxRequest::Done
567cdf0e10cSrcweir (
568cdf0e10cSrcweir const SfxItemSet& rSet, /* von der Applikation mitgeteilte Parameter,
569cdf0e10cSrcweir die z.B. in einem Dialog vom Benuter
570cdf0e10cSrcweir erfragt wurden, ggf. 0 falls keine
571cdf0e10cSrcweir Parameter gesetzt wurden */
572cdf0e10cSrcweir
573cdf0e10cSrcweir bool bKeep /* true (default)
574cdf0e10cSrcweir 'rSet' wird gepeichert und ist "uber
575cdf0e10cSrcweir GetArgs() abfragbar
576cdf0e10cSrcweir
577cdf0e10cSrcweir false
578cdf0e10cSrcweir 'rSet' wird nicht kopiert (schneller) */
579cdf0e10cSrcweir )
580cdf0e10cSrcweir
581cdf0e10cSrcweir /* [Beschreibung]
582cdf0e10cSrcweir
583cdf0e10cSrcweir Diese Methode mu\s in der <Execute-Methode> des <SfxSlot>s gerufen
584cdf0e10cSrcweir werden, der den SfxRequest ausgef"uhrt hat, wenn die Ausf"uhrung
585cdf0e10cSrcweir tats"achlich stattgefunden hat. Wird 'Done()' nicht gerufen, gilt
586cdf0e10cSrcweir der SfxRequest als abgebrochen.
587cdf0e10cSrcweir
588cdf0e10cSrcweir Etwaige Returnwerte werden nur durchgereicht, wenn 'Done()' gerufen
589cdf0e10cSrcweir wurde. Ebenso werden beim Aufzeichnen von Makros nur echte
590cdf0e10cSrcweir Statements erzeugt, wenn 'Done()' gerufen wurde; f"ur SfxRequests,
591cdf0e10cSrcweir die nicht derart gekennzeichnet wurden, wird anstelle dessen eine
592cdf0e10cSrcweir auf die abgebrochene Funktion hinweisende Bemerkung ('rem') eingf"ugt.
593cdf0e10cSrcweir
594cdf0e10cSrcweir
595cdf0e10cSrcweir [Anmerkung]
596cdf0e10cSrcweir
597cdf0e10cSrcweir 'Done()' wird z.B. nicht gerufen, wenn ein durch die Funktion gestarteter
598cdf0e10cSrcweir Dialog vom Benutzer abgebrochen wurde oder das Ausf"uhren aufgrund
599cdf0e10cSrcweir eines falschen Kontextes (ohne Verwendung separater <SfxShell>s)
600cdf0e10cSrcweir nicht durchgef"uhrt werden konnte. 'Done()' mu\s sehr wohl gerufen
601cdf0e10cSrcweir werden, wenn das Ausf"uhren der Funktion zu einem regul"aren Fehler
602cdf0e10cSrcweir f"uhrte (z.B. Datei konnte nicht ge"offnet werden).
603cdf0e10cSrcweir */
604cdf0e10cSrcweir
605cdf0e10cSrcweir {
606cdf0e10cSrcweir Done_Impl( &rSet );
607cdf0e10cSrcweir
608cdf0e10cSrcweir // ggf. Items merken, damit StarDraw sie abfragen kann
609cdf0e10cSrcweir if ( bKeep )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir if ( !pArgs )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir pArgs = new SfxAllItemSet( rSet );
614cdf0e10cSrcweir pImp->SetPool( pArgs->GetPool() );
615cdf0e10cSrcweir }
616cdf0e10cSrcweir else
617cdf0e10cSrcweir {
618cdf0e10cSrcweir SfxItemIter aIter(rSet);
619cdf0e10cSrcweir const SfxPoolItem* pItem = aIter.FirstItem();
620cdf0e10cSrcweir while(pItem)
621cdf0e10cSrcweir {
622cdf0e10cSrcweir if(!IsInvalidItem(pItem))
623cdf0e10cSrcweir pArgs->Put(*pItem,pItem->Which());
624cdf0e10cSrcweir pItem = aIter.NextItem();
625cdf0e10cSrcweir }
626cdf0e10cSrcweir }
627cdf0e10cSrcweir }
628cdf0e10cSrcweir }
629cdf0e10cSrcweir
630cdf0e10cSrcweir //--------------------------------------------------------------------
631cdf0e10cSrcweir
632cdf0e10cSrcweir
Done(sal_Bool bRelease)633cdf0e10cSrcweir void SfxRequest::Done( sal_Bool bRelease )
634cdf0e10cSrcweir // [<SfxRequest::Done(SfxItemSet&)>]
635cdf0e10cSrcweir {
636cdf0e10cSrcweir Done_Impl( pArgs );
637cdf0e10cSrcweir if( bRelease )
638cdf0e10cSrcweir DELETEZ( pArgs );
639cdf0e10cSrcweir }
640cdf0e10cSrcweir
641cdf0e10cSrcweir //--------------------------------------------------------------------
642cdf0e10cSrcweir
ForgetAllArgs()643cdf0e10cSrcweir void SfxRequest::ForgetAllArgs()
644cdf0e10cSrcweir {
645cdf0e10cSrcweir DELETEZ( pArgs );
646cdf0e10cSrcweir DELETEZ( pImp->pInternalArgs );
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
649cdf0e10cSrcweir //--------------------------------------------------------------------
650cdf0e10cSrcweir
IsCancelled() const651cdf0e10cSrcweir sal_Bool SfxRequest::IsCancelled() const
652cdf0e10cSrcweir {
653cdf0e10cSrcweir return pImp->bCancelled;
654cdf0e10cSrcweir }
655cdf0e10cSrcweir
656cdf0e10cSrcweir //--------------------------------------------------------------------
657cdf0e10cSrcweir
Cancel()658cdf0e10cSrcweir void SfxRequest::Cancel()
659cdf0e10cSrcweir
660cdf0e10cSrcweir /* [Beschreibung]
661cdf0e10cSrcweir
662cdf0e10cSrcweir Markiert diesen Request als nicht mehr auszufuehren. Wird z.B. gerufen,
663cdf0e10cSrcweir wenn das Ziel (genauer dessen Pool) stirbt.
664cdf0e10cSrcweir */
665cdf0e10cSrcweir
666cdf0e10cSrcweir {
667cdf0e10cSrcweir pImp->bCancelled = sal_True;
668cdf0e10cSrcweir pImp->SetPool( 0 );
669cdf0e10cSrcweir DELETEZ( pArgs );
670cdf0e10cSrcweir }
671cdf0e10cSrcweir
672cdf0e10cSrcweir //--------------------------------------------------------------------
673cdf0e10cSrcweir
674cdf0e10cSrcweir
Ignore()675cdf0e10cSrcweir void SfxRequest::Ignore()
676cdf0e10cSrcweir
677cdf0e10cSrcweir /* [Beschreibung]
678cdf0e10cSrcweir
679cdf0e10cSrcweir Wird diese Methode anstelle von <SfxRequest::Done()> gerufen, dann
680cdf0e10cSrcweir wird dieser Request nicht recorded.
681cdf0e10cSrcweir
682cdf0e10cSrcweir
683cdf0e10cSrcweir [Bespiel]
684cdf0e10cSrcweir
685cdf0e10cSrcweir Das Selektieren von Tools im StarDraw soll nicht aufgezeichnet werden,
686cdf0e10cSrcweir dieselben Slots sollen aber zum erzeugen der von den Tools zu
687cdf0e10cSrcweir erzeugenden Objekte verwendet werde. Also kann nicht NoRecord
688cdf0e10cSrcweir angegeben werden, dennoch soll u.U. nicht aufgezeichnet werden.
689cdf0e10cSrcweir */
690cdf0e10cSrcweir
691cdf0e10cSrcweir {
692cdf0e10cSrcweir // als tats"achlich ausgef"uhrt markieren
693cdf0e10cSrcweir pImp->bIgnored = sal_True;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir
696cdf0e10cSrcweir //--------------------------------------------------------------------
697cdf0e10cSrcweir
Done_Impl(const SfxItemSet * pSet)698cdf0e10cSrcweir void SfxRequest::Done_Impl
699cdf0e10cSrcweir (
700cdf0e10cSrcweir const SfxItemSet* pSet /* von der Applikation mitgeteilte Parameter,
701cdf0e10cSrcweir die z.B. in einem Dialog vom Benuter
702cdf0e10cSrcweir erfragt wurden, ggf. 0 falls keine
703cdf0e10cSrcweir Parameter gesetzt wurden */
704cdf0e10cSrcweir )
705cdf0e10cSrcweir
706cdf0e10cSrcweir /* [Beschreibung]
707cdf0e10cSrcweir
708cdf0e10cSrcweir Interne Methode zum als 'done' markieren des SfxRequest und zum Auswerten
709cdf0e10cSrcweir der Parameter in 'pSet' falls aufgezeichnet wird.
710cdf0e10cSrcweir */
711cdf0e10cSrcweir
712cdf0e10cSrcweir {
713cdf0e10cSrcweir // als tats"achlich ausgef"uhrt markieren
714cdf0e10cSrcweir pImp->bDone = sal_True;
715cdf0e10cSrcweir
716cdf0e10cSrcweir // nicht Recorden
717cdf0e10cSrcweir if ( !pImp->xRecorder.is() )
718cdf0e10cSrcweir return;
719cdf0e10cSrcweir
720cdf0e10cSrcweir // wurde ein anderer Slot ausgef"uhrt als angefordert (Delegation)
721cdf0e10cSrcweir if ( nSlot != pImp->pSlot->GetSlotId() )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir // Slot neu suchen
724cdf0e10cSrcweir pImp->pSlot = pImp->pShell->GetInterface()->GetSlot(nSlot);
725cdf0e10cSrcweir DBG_ASSERT( pImp->pSlot, "delegated SlotId not found" );
726cdf0e10cSrcweir if ( !pImp->pSlot ) // Hosentr"ger und G"urtel
727cdf0e10cSrcweir return;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir
730cdf0e10cSrcweir // record-f"ahig?
731cdf0e10cSrcweir // neues Recorden verwendet UnoName!
732cdf0e10cSrcweir if ( !pImp->pSlot->pUnoName )
733cdf0e10cSrcweir {
734cdf0e10cSrcweir ByteString aStr( "Recording not exported slot: ");
735cdf0e10cSrcweir aStr += ByteString::CreateFromInt32( pImp->pSlot->GetSlotId() );
736cdf0e10cSrcweir DBG_ERROR( aStr.GetBuffer() );
737cdf0e10cSrcweir }
738cdf0e10cSrcweir
739cdf0e10cSrcweir if ( !pImp->pSlot->pUnoName ) // Hosentr"ger und G"urtel
740cdf0e10cSrcweir return;
741cdf0e10cSrcweir
742cdf0e10cSrcweir // "ofters ben"otigte Werte
743cdf0e10cSrcweir SfxItemPool &rPool = pImp->pShell->GetPool();
744cdf0e10cSrcweir
745cdf0e10cSrcweir // Property-Slot?
746cdf0e10cSrcweir if ( !pImp->pSlot->IsMode(SFX_SLOT_METHOD) )
747cdf0e10cSrcweir {
748cdf0e10cSrcweir // des Property als SfxPoolItem besorgen
749cdf0e10cSrcweir const SfxPoolItem *pItem;
750cdf0e10cSrcweir sal_uInt16 nWhich = rPool.GetWhich(pImp->pSlot->GetSlotId());
751cdf0e10cSrcweir SfxItemState eState = pSet ? pSet->GetItemState( nWhich, sal_False, &pItem ) : SFX_ITEM_UNKNOWN;
752cdf0e10cSrcweir #ifdef DBG_UTIL
753cdf0e10cSrcweir if ( SFX_ITEM_SET != eState )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir ByteString aStr( "Recording property not available: ");
756cdf0e10cSrcweir aStr += ByteString::CreateFromInt32( pImp->pSlot->GetSlotId() );
757cdf0e10cSrcweir DBG_ERROR( aStr.GetBuffer() );
758cdf0e10cSrcweir }
759cdf0e10cSrcweir #endif
760cdf0e10cSrcweir uno::Sequence < beans::PropertyValue > aSeq;
761cdf0e10cSrcweir if ( eState == SFX_ITEM_SET )
762cdf0e10cSrcweir TransformItems( pImp->pSlot->GetSlotId(), *pSet, aSeq, pImp->pSlot );
763cdf0e10cSrcweir pImp->Record( aSeq );
764cdf0e10cSrcweir }
765cdf0e10cSrcweir
766cdf0e10cSrcweir // alles in ein einziges Statement aufzeichnen?
767cdf0e10cSrcweir else if ( pImp->pSlot->IsMode(SFX_SLOT_RECORDPERSET) )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir uno::Sequence < beans::PropertyValue > aSeq;
770cdf0e10cSrcweir if ( pSet )
771cdf0e10cSrcweir TransformItems( pImp->pSlot->GetSlotId(), *pSet, aSeq, pImp->pSlot );
772cdf0e10cSrcweir pImp->Record( aSeq );
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
775cdf0e10cSrcweir // jedes Item als einzelnes Statement recorden
776cdf0e10cSrcweir else if ( pImp->pSlot->IsMode(SFX_SLOT_RECORDPERITEM) )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir if ( pSet )
779cdf0e10cSrcweir {
780cdf0e10cSrcweir // "uber die Items iterieren
781cdf0e10cSrcweir SfxItemIter aIter(*pSet);
782cdf0e10cSrcweir for ( const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem() )
783cdf0e10cSrcweir {
784cdf0e10cSrcweir // die Slot-Id f"ur das einzelne Item ermitteln
785cdf0e10cSrcweir sal_uInt16 nSlotId = rPool.GetSlotId( pItem->Which() );
786cdf0e10cSrcweir if ( nSlotId == nSlot )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir // mit Hosentr"ager und G"urtel reparieren des falschen Flags
789cdf0e10cSrcweir DBG_ERROR( "recursion RecordPerItem - use RecordPerSet!" );
790cdf0e10cSrcweir SfxSlot *pSlot = (SfxSlot*) pImp->pSlot;
791cdf0e10cSrcweir pSlot->nFlags &= ~((sal_uIntPtr)SFX_SLOT_RECORDPERITEM);
792cdf0e10cSrcweir pSlot->nFlags &= SFX_SLOT_RECORDPERSET;
793cdf0e10cSrcweir }
794cdf0e10cSrcweir
795cdf0e10cSrcweir // einen Sub-Request recorden
796cdf0e10cSrcweir SfxRequest aReq( pImp->pViewFrame, nSlotId );
797cdf0e10cSrcweir if ( aReq.pImp->pSlot )
798cdf0e10cSrcweir aReq.AppendItem( *pItem );
799cdf0e10cSrcweir aReq.Done();
800cdf0e10cSrcweir }
801cdf0e10cSrcweir }
802cdf0e10cSrcweir else
803cdf0e10cSrcweir {
804cdf0e10cSrcweir HACK(hierueber nochmal nachdenken)
805cdf0e10cSrcweir pImp->Record( uno::Sequence < beans::PropertyValue >() );
806cdf0e10cSrcweir }
807cdf0e10cSrcweir }
808cdf0e10cSrcweir }
809cdf0e10cSrcweir
810cdf0e10cSrcweir //--------------------------------------------------------------------
811cdf0e10cSrcweir
IsDone() const812cdf0e10cSrcweir sal_Bool SfxRequest::IsDone() const
813cdf0e10cSrcweir
814cdf0e10cSrcweir /* [Beschreibung]
815cdf0e10cSrcweir
816cdf0e10cSrcweir Mit dieser Methode kann abgefragt werden, ob der SfxRequest tats"achlich
817cdf0e10cSrcweir ausgef"uhrt wurde oder nicht. Wurde ein SfxRequest nicht ausgef"uhrt,
818cdf0e10cSrcweir liegt dies z.B. daran, da\s der Benutzer abgebrochen hat oder
819cdf0e10cSrcweir der Kontext f"ur diesen Request falsch war, dieses aber nicht "uber
820cdf0e10cSrcweir eine separate <SfxShell> realisiert wurde.
821cdf0e10cSrcweir
822cdf0e10cSrcweir SfxRequest-Instanzen, die hier sal_False liefern, werden nicht recorded.
823cdf0e10cSrcweir
824cdf0e10cSrcweir
825cdf0e10cSrcweir [Querverweise]
826cdf0e10cSrcweir
827cdf0e10cSrcweir <SfxRequest::Done(const SfxItemSet&)>
828cdf0e10cSrcweir <SfxRequest::Done()>
829cdf0e10cSrcweir */
830cdf0e10cSrcweir
831cdf0e10cSrcweir {
832cdf0e10cSrcweir return pImp->bDone;
833cdf0e10cSrcweir }
834cdf0e10cSrcweir
835cdf0e10cSrcweir //--------------------------------------------------------------------
836cdf0e10cSrcweir
GetRecordingMacro()837cdf0e10cSrcweir SfxMacro* SfxRequest::GetRecordingMacro()
838cdf0e10cSrcweir
839cdf0e10cSrcweir /* [Beschreibung]
840cdf0e10cSrcweir
841cdf0e10cSrcweir Mit dieser Methode kann abgefragt werden, ob und in welchem <SfxMacro>
842cdf0e10cSrcweir die SfxRequests gerade aufgezeichnet werden.
843cdf0e10cSrcweir */
844cdf0e10cSrcweir
845cdf0e10cSrcweir {
846cdf0e10cSrcweir return NULL;
847cdf0e10cSrcweir }
848cdf0e10cSrcweir
849cdf0e10cSrcweir //--------------------------------------------------------------------
850cdf0e10cSrcweir
GetMacroRecorder(SfxViewFrame * pView)851cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > SfxRequest::GetMacroRecorder( SfxViewFrame* pView )
852cdf0e10cSrcweir
853cdf0e10cSrcweir /* [Beschreibung]
854cdf0e10cSrcweir
855cdf0e10cSrcweir Hier wird versucht einen Recorder fuer dispatch() Aufrufe vom Frame zu bekommen.
856cdf0e10cSrcweir Dieser ist dort per Property an einem Supplier verfuegbar - aber nur dann, wenn
857cdf0e10cSrcweir recording angeschaltet wurde.
858cdf0e10cSrcweir (Siehe auch SfxViewFrame::MiscExec_Impl() und SID_RECORDING)
859cdf0e10cSrcweir */
860cdf0e10cSrcweir
861cdf0e10cSrcweir {
862cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
863cdf0e10cSrcweir
864cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
865cdf0e10cSrcweir (pView ? pView : SfxViewFrame::Current())->GetFrame().GetFrameInterface(),
866cdf0e10cSrcweir com::sun::star::uno::UNO_QUERY);
867cdf0e10cSrcweir
868cdf0e10cSrcweir if(xSet.is())
869cdf0e10cSrcweir {
870cdf0e10cSrcweir com::sun::star::uno::Any aProp = xSet->getPropertyValue(rtl::OUString::createFromAscii("DispatchRecorderSupplier"));
871cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
872cdf0e10cSrcweir aProp >>= xSupplier;
873cdf0e10cSrcweir if(xSupplier.is())
874cdf0e10cSrcweir xRecorder = xSupplier->getDispatchRecorder();
875cdf0e10cSrcweir }
876cdf0e10cSrcweir
877cdf0e10cSrcweir return xRecorder;
878cdf0e10cSrcweir }
879cdf0e10cSrcweir
HasMacroRecorder(SfxViewFrame * pView)880cdf0e10cSrcweir sal_Bool SfxRequest::HasMacroRecorder( SfxViewFrame* pView )
881cdf0e10cSrcweir {
882cdf0e10cSrcweir return GetMacroRecorder( pView ).is();
883cdf0e10cSrcweir }
884cdf0e10cSrcweir
885cdf0e10cSrcweir
886cdf0e10cSrcweir //--------------------------------------------------------------------
887cdf0e10cSrcweir
IsAPI() const888cdf0e10cSrcweir sal_Bool SfxRequest::IsAPI() const
889cdf0e10cSrcweir
890cdf0e10cSrcweir /* [Beschreibung]
891cdf0e10cSrcweir
892cdf0e10cSrcweir Liefert sal_True, wenn dieser SfxRequest von einer API (z.B. BASIC)
893cdf0e10cSrcweir erzeugt wurde, sonst sal_False.
894cdf0e10cSrcweir */
895cdf0e10cSrcweir
896cdf0e10cSrcweir {
897cdf0e10cSrcweir return SFX_CALLMODE_API == ( SFX_CALLMODE_API & pImp->nCallMode );
898cdf0e10cSrcweir }
899cdf0e10cSrcweir
900cdf0e10cSrcweir //--------------------------------------------------------------------
901cdf0e10cSrcweir
902cdf0e10cSrcweir
IsRecording() const903cdf0e10cSrcweir bool SfxRequest::IsRecording() const
904cdf0e10cSrcweir
905cdf0e10cSrcweir /* [Beschreibung]
906cdf0e10cSrcweir
907cdf0e10cSrcweir Liefert sal_True, wenn dieser SfxRequest recorded werden soll, d.h.
908cdf0e10cSrcweir 1. zu Zeit ein Makro aufgezeichnet wird
909cdf0e10cSrcweir 2. dieser Request "uberhaupt aufgezeichnet wird
910cdf0e10cSrcweir 3. der Request nicht von reiner API (z.B. BASIC) ausgeht,
911cdf0e10cSrcweir sonst sal_False.
912cdf0e10cSrcweir */
913cdf0e10cSrcweir
914cdf0e10cSrcweir {
915cdf0e10cSrcweir return ( AllowsRecording() && GetMacroRecorder().is() );
916cdf0e10cSrcweir }
917cdf0e10cSrcweir
918cdf0e10cSrcweir //--------------------------------------------------------------------
SetModifier(sal_uInt16 nModi)919cdf0e10cSrcweir void SfxRequest::SetModifier( sal_uInt16 nModi )
920cdf0e10cSrcweir {
921cdf0e10cSrcweir pImp->nModifier = nModi;
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
924cdf0e10cSrcweir //--------------------------------------------------------------------
GetModifier() const925cdf0e10cSrcweir sal_uInt16 SfxRequest::GetModifier() const
926cdf0e10cSrcweir {
927cdf0e10cSrcweir return pImp->nModifier;
928cdf0e10cSrcweir }
929cdf0e10cSrcweir
930cdf0e10cSrcweir //--------------------------------------------------------------------
931cdf0e10cSrcweir
SetTarget(const String & rTarget)932cdf0e10cSrcweir void SfxRequest::SetTarget( const String &rTarget )
933cdf0e10cSrcweir
934cdf0e10cSrcweir /* [Beschreibung]
935cdf0e10cSrcweir
936cdf0e10cSrcweir Mit dieser Methode kann das zu recordende Zielobjekt umgesetzt werden.
937cdf0e10cSrcweir
938cdf0e10cSrcweir
939cdf0e10cSrcweir [Beispiel]
940cdf0e10cSrcweir
941cdf0e10cSrcweir Die BASIC-Methode 'Open' wird zwar von der Shell 'Application' ausgef"uhrt,
942cdf0e10cSrcweir aber am Objekt 'Documents' (global) recorded:
943cdf0e10cSrcweir
944cdf0e10cSrcweir rReq.SetTarget( "Documents" );
945cdf0e10cSrcweir
946cdf0e10cSrcweir Dies f"uhrt dann zu:
947cdf0e10cSrcweir
948cdf0e10cSrcweir Documents.Open( ... )
949cdf0e10cSrcweir */
950cdf0e10cSrcweir
951cdf0e10cSrcweir {
952cdf0e10cSrcweir pImp->aTarget = rTarget;
953cdf0e10cSrcweir pImp->bUseTarget = sal_True;
954cdf0e10cSrcweir }
955cdf0e10cSrcweir
AllowRecording(sal_Bool bSet)956cdf0e10cSrcweir void SfxRequest::AllowRecording( sal_Bool bSet )
957cdf0e10cSrcweir {
958cdf0e10cSrcweir pImp->bAllowRecording = bSet;
959cdf0e10cSrcweir }
960cdf0e10cSrcweir
AllowsRecording() const961cdf0e10cSrcweir sal_Bool SfxRequest::AllowsRecording() const
962cdf0e10cSrcweir {
963cdf0e10cSrcweir sal_Bool bAllow = pImp->bAllowRecording;
964cdf0e10cSrcweir if( !bAllow )
965cdf0e10cSrcweir bAllow = ( SFX_CALLMODE_API != ( SFX_CALLMODE_API & pImp->nCallMode ) ) &&
966cdf0e10cSrcweir ( SFX_CALLMODE_RECORD == ( SFX_CALLMODE_RECORD & pImp->nCallMode ) );
967cdf0e10cSrcweir return bAllow;
968cdf0e10cSrcweir }
969cdf0e10cSrcweir
ReleaseArgs()970cdf0e10cSrcweir void SfxRequest::ReleaseArgs()
971cdf0e10cSrcweir {
972cdf0e10cSrcweir DELETEZ( pArgs );
973cdf0e10cSrcweir DELETEZ( pImp->pInternalArgs );
974cdf0e10cSrcweir }
975