summaryrefslogtreecommitdiff
path: root/sfx2/inc/macro.hxx
blob: b6a0a2a655d557cc966220017cc42de539fe0863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#ifndef _SFXMACRO_HXX
#define _SFXMACRO_HXX

//====================================================================
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/uno/Sequence.hxx>

#include <tools/string.hxx>

class SfxSlot;
class SfxShell;
struct SfxMacro_Impl;
class SfxMacro;

//====================================================================

class SfxMacroStatement
{
    sal_uInt16              nSlotId;    // ausgef"uhrte Slot-Id oder 0, wenn manuell
    ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > aArgs;      // aktuelle Parameter, falls nSlotId != 0
    String              aStatement; // Statement in BASIC-Syntax (ggf. mit CR/LF)
    sal_Bool                bDone;      // auskommentieren wenn kein Done() gerufen
    void*               pDummy;     // f"ur alle F"alle zum kompatibel bleiben

#ifdef _SFXMACRO_HXX
private:
    void                GenerateNameAndArgs_Impl( SfxMacro *pMacro,
                                                  const SfxSlot &rSlot,
                                                  sal_Bool bRequestDone,
                                                  ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& aArgs );
#endif

public:
                        SfxMacroStatement( const SfxMacroStatement &rOrig );

                        SfxMacroStatement( const String &rTarget,
                                           const SfxSlot &rSlot,
                                           sal_Bool bRequestDone,
                                           ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& aArgs );

                        SfxMacroStatement( const SfxShell &rShell,
                                           const String &rTarget,
                                           sal_Bool bAbsolute,
                                           const SfxSlot &rSlot,
                                           sal_Bool bRequestDone,
                                           ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& aArgs );

                        SfxMacroStatement( const String &rStatment );
                        ~SfxMacroStatement();

    sal_uInt16              GetSlotId() const;
    const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& GetArgs() const;
    sal_Bool                IsDone() const;
    const String&       GetStatement() const;
};

//--------------------------------------------------------------------

inline sal_uInt16 SfxMacroStatement::GetSlotId() const

/*  [Beschreibung]

    Liefert die Slot-Id die das Statement beim Abspielen wieder ausf"uhren
    soll oder 0, falls das Statement manuell (<SFX_SLOT_RECORDMANUAL>)
    aufgezeichnet wurde.
*/

{
    return nSlotId;
}

//--------------------------------------------------------------------

inline const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& SfxMacroStatement::GetArgs() const

/*  [Beschreibung]

    Liefert die Parameter mit denen Statement ausgef"uhrt wurde oder 0,
    falls das Statement manuell (<SFX_SLOT_RECORDMANUAL>) aufgezeichnet
    wurde.

    Der R"uckgabewert geh"ort dem SfxMacroStatement und ist nur im
    unmittelbar aufrufenden Stackframe g"ultig.
*/

{
    return aArgs;
}

//--------------------------------------------------------------------

inline sal_Bool SfxMacroStatement::IsDone() const

/*  [Beschreibung]

    Liefert TRUE, wenn das Statement wirklich ausgef"uhrt wurde,
    also z.B. nicht vom Benutzer abgebrochen wurde. Wurde es nicht
    wirklich ausgef"uhrt, dann wird es im BASIC-Source auskommentiert.
*/

{
    return bDone;
}

//--------------------------------------------------------------------

/*  [Beschreibung]

    Liefert das Statement in BASIC-Syntax. Wurde das Makro manuell erzeugt,
    wird genau der im Konstruktor angegebene String zur"uckgegeben, sonst
    der generierte Source-Code.

    Bei beiden Arten ist es m"oglich, da\s mehrere BASIC-Statements, jeweils
    mit CR/LF getrennt in dem String enthalten sind, da ein SFx-Statement
    ggf. in mehrere BASIC-Statements "ubersetzt wird.

    Statements f"ur die nicht <SfxRequest::Done()> gerufen wurde, werden
    mit einem vorangestellten 'rem' gekennzeichnet.
*/

inline const String& SfxMacroStatement::GetStatement() const
{
    return aStatement;
}

//====================================================================

enum SfxMacroMode

/*  [Beschreibung]

    Mit diesem enum wird bestimmt, ob eine <SfxMacro>-Instanz zum
    absoluten oder relativen Recorden erzeugt wurde, oder um ein
    existierendendes Makro zu Referenzieren.
*/

{
    SFX_MACRO_EXISTING,         /*  es handelt sich um ein bereits
                                    exitistierendes Makro, welches lediglich
                                    referenziert wird */

    SFX_MACRO_RECORDINGABSOLUTE,/*  dieses Makro soll aufgezeichnet werden,
                                    wobei die betroffenen Objekte m"oglichst
                                    direkt angesprochen werden sollen
                                    (Beispiel: "[doc.sdc]") */

    SFX_MACRO_RECORDINGRELATIVE/*   dieses Makro soll aufgezeichnet werden,
                                    wobei die betroffenen Objekte so
                                    angesprochen werden sollen, da\s sich das
                                    Abspielen auf die dann g"ultige Selektion
                                    bezieht (Beispiel: "ActiveDocument()") */
};

//====================================================================

class SfxMacro

/*  [Beschreibung]

    "Uber diese Klasse (bzw. genaugenommen ihre Subklassen) wird zum
    einen die Lokation einer BASIC-Funktion (also in welcher Library,
    in welchem Modul sowie der Funktions-Name) beschrieben, als auch
    ein aufzuzeichnendes Makro w"ahrend der Aufzeichnung zwischen-
    gespeichert.
*/

{
    SfxMacro_Impl*          pImp;

public:
                            SfxMacro( SfxMacroMode eMode = SFX_MACRO_RECORDINGRELATIVE );
    virtual                 ~SfxMacro();

    SfxMacroMode            GetMode() const;
    void                    Record( SfxMacroStatement *pStatement );
    void                    Replace( SfxMacroStatement *pStatement );
    void                    Remove();
    const SfxMacroStatement*GetLastStatement() const;

    String                  GenerateSource() const;
};

#endif