xref: /AOO41X/main/sfx2/inc/macro.hxx (revision 353d8f4d17010cd2d0ea815067cad67e477f2bee)
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 #ifndef _SFXMACRO_HXX
23 #define _SFXMACRO_HXX
24 
25 //====================================================================
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/uno/Sequence.hxx>
28 
29 #include <tools/string.hxx>
30 
31 class SfxSlot;
32 class SfxShell;
33 struct SfxMacro_Impl;
34 class SfxMacro;
35 
36 //====================================================================
37 
38 class SfxMacroStatement
39 {
40     sal_uInt16              nSlotId;    // ausgef"uhrte Slot-Id oder 0, wenn manuell
41     ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > aArgs;      // aktuelle Parameter, falls nSlotId != 0
42     String              aStatement; // Statement in BASIC-Syntax (ggf. mit CR/LF)
43     sal_Bool                bDone;      // auskommentieren wenn kein Done() gerufen
44     void*               pDummy;     // f"ur alle F"alle zum kompatibel bleiben
45 
46 #ifdef _SFXMACRO_HXX
47 private:
48     void                GenerateNameAndArgs_Impl( SfxMacro *pMacro,
49                                                   const SfxSlot &rSlot,
50                                                   sal_Bool bRequestDone,
51                                                   ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& aArgs );
52 #endif
53 
54 public:
55                         SfxMacroStatement( const SfxMacroStatement &rOrig );
56 
57                         SfxMacroStatement( const String &rTarget,
58                                            const SfxSlot &rSlot,
59                                            sal_Bool bRequestDone,
60                                            ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& aArgs );
61 
62                         SfxMacroStatement( const SfxShell &rShell,
63                                            const String &rTarget,
64                                            sal_Bool bAbsolute,
65                                            const SfxSlot &rSlot,
66                                            sal_Bool bRequestDone,
67                                            ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& aArgs );
68 
69                         SfxMacroStatement( const String &rStatment );
70                         ~SfxMacroStatement();
71 
72     sal_uInt16              GetSlotId() const;
73     const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& GetArgs() const;
74     sal_Bool                IsDone() const;
75     const String&       GetStatement() const;
76 };
77 
78 //--------------------------------------------------------------------
79 
GetSlotId() const80 inline sal_uInt16 SfxMacroStatement::GetSlotId() const
81 
82 /*  [Beschreibung]
83 
84     Liefert die Slot-Id die das Statement beim Abspielen wieder ausf"uhren
85     soll oder 0, falls das Statement manuell (<SFX_SLOT_RECORDMANUAL>)
86     aufgezeichnet wurde.
87 */
88 
89 {
90     return nSlotId;
91 }
92 
93 //--------------------------------------------------------------------
94 
GetArgs() const95 inline const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& SfxMacroStatement::GetArgs() const
96 
97 /*  [Beschreibung]
98 
99     Liefert die Parameter mit denen Statement ausgef"uhrt wurde oder 0,
100     falls das Statement manuell (<SFX_SLOT_RECORDMANUAL>) aufgezeichnet
101     wurde.
102 
103     Der R"uckgabewert geh"ort dem SfxMacroStatement und ist nur im
104     unmittelbar aufrufenden Stackframe g"ultig.
105 */
106 
107 {
108     return aArgs;
109 }
110 
111 //--------------------------------------------------------------------
112 
IsDone() const113 inline sal_Bool SfxMacroStatement::IsDone() const
114 
115 /*  [Beschreibung]
116 
117     Liefert TRUE, wenn das Statement wirklich ausgef"uhrt wurde,
118     also z.B. nicht vom Benutzer abgebrochen wurde. Wurde es nicht
119     wirklich ausgef"uhrt, dann wird es im BASIC-Source auskommentiert.
120 */
121 
122 {
123     return bDone;
124 }
125 
126 //--------------------------------------------------------------------
127 
128 /*  [Beschreibung]
129 
130     Liefert das Statement in BASIC-Syntax. Wurde das Makro manuell erzeugt,
131     wird genau der im Konstruktor angegebene String zur"uckgegeben, sonst
132     der generierte Source-Code.
133 
134     Bei beiden Arten ist es m"oglich, da\s mehrere BASIC-Statements, jeweils
135     mit CR/LF getrennt in dem String enthalten sind, da ein SFx-Statement
136     ggf. in mehrere BASIC-Statements "ubersetzt wird.
137 
138     Statements f"ur die nicht <SfxRequest::Done()> gerufen wurde, werden
139     mit einem vorangestellten 'rem' gekennzeichnet.
140 */
141 
GetStatement() const142 inline const String& SfxMacroStatement::GetStatement() const
143 {
144     return aStatement;
145 }
146 
147 //====================================================================
148 
149 enum SfxMacroMode
150 
151 /*  [Beschreibung]
152 
153     Mit diesem enum wird bestimmt, ob eine <SfxMacro>-Instanz zum
154     absoluten oder relativen Recorden erzeugt wurde, oder um ein
155     existierendendes Makro zu Referenzieren.
156 */
157 
158 {
159     SFX_MACRO_EXISTING,         /*  es handelt sich um ein bereits
160                                     exitistierendes Makro, welches lediglich
161                                     referenziert wird */
162 
163     SFX_MACRO_RECORDINGABSOLUTE,/*  dieses Makro soll aufgezeichnet werden,
164                                     wobei die betroffenen Objekte m"oglichst
165                                     direkt angesprochen werden sollen
166                                     (Beispiel: "[doc.sdc]") */
167 
168     SFX_MACRO_RECORDINGRELATIVE/*   dieses Makro soll aufgezeichnet werden,
169                                     wobei die betroffenen Objekte so
170                                     angesprochen werden sollen, da\s sich das
171                                     Abspielen auf die dann g"ultige Selektion
172                                     bezieht (Beispiel: "ActiveDocument()") */
173 };
174 
175 //====================================================================
176 
177 class SfxMacro
178 
179 /*  [Beschreibung]
180 
181     "Uber diese Klasse (bzw. genaugenommen ihre Subklassen) wird zum
182     einen die Lokation einer BASIC-Funktion (also in welcher Library,
183     in welchem Modul sowie der Funktions-Name) beschrieben, als auch
184     ein aufzuzeichnendes Makro w"ahrend der Aufzeichnung zwischen-
185     gespeichert.
186 */
187 
188 {
189     SfxMacro_Impl*          pImp;
190 
191 public:
192                             SfxMacro( SfxMacroMode eMode = SFX_MACRO_RECORDINGRELATIVE );
193     virtual                 ~SfxMacro();
194 
195     SfxMacroMode            GetMode() const;
196     void                    Record( SfxMacroStatement *pStatement );
197     void                    Replace( SfxMacroStatement *pStatement );
198     void                    Remove();
199     const SfxMacroStatement*GetLastStatement() const;
200 
201     String                  GenerateSource() const;
202 };
203 
204 #endif
205