xref: /trunk/main/sfx2/inc/sfx2/request.hxx (revision 353d8f4d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFXREQUEST_HXX
24 #define _SFXREQUEST_HXX
25 
26 #include "sal/config.h"
27 #include "sfx2/dllapi.h"
28 #include "sal/types.h"
29 #include <svl/itemset.hxx>
30 #include <svl/hint.hxx>
31 
32 #include <com/sun/star/uno/Sequence.hxx>
33 #include <com/sun/star/beans/PropertyValue.hpp>
34 #include <com/sun/star/frame/XDispatchRecorder.hpp>
35 
36 class SfxMacro;
37 class SfxPoolItem;
38 class SfxAllItemSet;
39 class SfxItemSet;
40 class SfxItemPool;
41 class SfxShell;
42 class SfxSlot;
43 class SfxMacroStatement;
44 class SfxArguments;
45 class String;
46 class SfxViewFrame;
47 struct SfxRequest_Impl;
48 
49 //==================================================================
50 
51 class SFX2_DLLPUBLIC SfxRequest: public SfxHint
52 {
53 friend struct SfxRequest_Impl;
54 
55 	sal_uInt16				nSlot;
56 	SfxAllItemSet*		pArgs;
57 	SfxRequest_Impl*	pImp;
58 
59 	//---------------------------------------------------------------------
60 //#if 0 // _SOLAR__PRIVATE
61 public:
62     SAL_DLLPRIVATE void Record_Impl( SfxShell &rSh, const SfxSlot &rSlot,
63                                      com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder,
64                                      SfxViewFrame* );
65 private:
66 	SAL_DLLPRIVATE void Done_Impl( const SfxItemSet *pSet );
67 
68 //#endif
69 	//---------------------------------------------------------------------
70 
71 public:
72                         SfxRequest( SfxViewFrame*, sal_uInt16 nSlotId );
73 						SfxRequest( sal_uInt16 nSlot, sal_uInt16 nCallMode, SfxItemPool &rPool );
74 						SfxRequest( const SfxSlot* pSlot, const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& rArgs,
75 											sal_uInt16 nCallMode, SfxItemPool &rPool );
76 						SfxRequest( sal_uInt16 nSlot, sal_uInt16 nCallMode, const SfxAllItemSet& rSfxArgs );
77 						SfxRequest( const SfxRequest& rOrig );
78 						~SfxRequest();
79 
GetSlot() const80 	sal_uInt16				GetSlot() const { return nSlot; }
SetSlot(sal_uInt16 nNewSlot)81 	void				SetSlot(sal_uInt16 nNewSlot) { nSlot = nNewSlot; }
82 
83 	sal_uInt16              GetModifier() const;
84 	void                SetModifier( sal_uInt16 nModi );
85 	SAL_DLLPRIVATE void SetInternalArgs_Impl( const SfxAllItemSet& rArgs );
86     SAL_DLLPRIVATE const SfxItemSet* GetInternalArgs_Impl() const;
GetArgs() const87 	const SfxItemSet* 	GetArgs() const { return pArgs; }
88 	void				SetArgs( const SfxAllItemSet& rArgs );
89 	void				AppendItem(const SfxPoolItem &);
90 	void				RemoveItem( sal_uInt16 nSlotId );
91 
92 	static const SfxPoolItem* GetItem( const SfxItemSet*, sal_uInt16 nSlotId,
93 									   bool bDeep = false,
94 									   TypeId aType = 0 );
95     const SfxPoolItem*  GetArg( sal_uInt16 nSlotId, bool bDeep = false, TypeId aType = 0 ) const;
96     void                ReleaseArgs();
97 	void				SetReturnValue(const SfxPoolItem &);
98 	const SfxPoolItem*	GetReturnValue() const;
99 
100 	static SfxMacro*	GetRecordingMacro();
101     static com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > GetMacroRecorder( SfxViewFrame* pFrame=NULL );
102     static sal_Bool         HasMacroRecorder( SfxViewFrame* pFrame=NULL );
103 	sal_uInt16  			GetCallMode() const;
104 	bool			IsRecording() const;
105     void                AllowRecording( sal_Bool );
106     sal_Bool                AllowsRecording() const;
107 	sal_Bool				IsAPI() const;
108 	sal_Bool                IsSynchronCall() const;
109 	void                SetSynchronCall( sal_Bool bSynchron );
110 	void				SetTarget( const String &rTarget );
111 
112 	sal_Bool				IsDone() const;
113 	void				Done( sal_Bool bRemove = sal_False );
114 
115 	void				Ignore();
116 	void				Cancel();
117 	sal_Bool				IsCancelled() const;
118 	void				Done(const SfxItemSet &, bool bKeep = true );
119 
120     void                ForgetAllArgs();
121 
122 private:
123 	const SfxRequest&	operator=(const SfxRequest &); // n.i.!!
124 };
125 
126 //------------------------------------------------------------------------
127 
128 #define SFX_REQUEST_ARG(rReq, pItem, ItemType, nSlotId, bDeep) \
129 		const ItemType *pItem = (const ItemType*) \
130 				rReq.GetArg( nSlotId, bDeep, TYPE(ItemType) )
131 #define SFX_ITEMSET_ARG(pArgs, pItem, ItemType, nSlotId, bDeep) \
132 	const ItemType *pItem = (const ItemType*) \
133 		SfxRequest::GetItem( pArgs, nSlotId, bDeep, TYPE(ItemType) )
134 
135 #endif
136