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