xref: /aoo42x/main/basic/source/inc/object.hxx (revision 234bd5c5)
1*234bd5c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*234bd5c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*234bd5c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*234bd5c5SAndrew Rist  * distributed with this work for additional information
6*234bd5c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*234bd5c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*234bd5c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*234bd5c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*234bd5c5SAndrew Rist  *
11*234bd5c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*234bd5c5SAndrew Rist  *
13*234bd5c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*234bd5c5SAndrew Rist  * software distributed under the License is distributed on an
15*234bd5c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*234bd5c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*234bd5c5SAndrew Rist  * specific language governing permissions and limitations
18*234bd5c5SAndrew Rist  * under the License.
19*234bd5c5SAndrew Rist  *
20*234bd5c5SAndrew Rist  *************************************************************/
21*234bd5c5SAndrew Rist 
22*234bd5c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SAMPLE_OBJECT_HXX
25cdf0e10cSrcweir #define _SAMPLE_OBJECT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <basic/sbxfac.hxx>
28cdf0e10cSrcweir #ifndef __SBX_SBXVARIABLE_HXX //autogen
29cdf0e10cSrcweir #include <basic/sbxvar.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <basic/sbxobj.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // 1) Properties:
34cdf0e10cSrcweir //    Name      der Name, R/O
35cdf0e10cSrcweir //    Value     ein double-Wert, R/W
36cdf0e10cSrcweir // 2) Methoden:
37cdf0e10cSrcweir //    Display   Ausgabe eines Textes
38cdf0e10cSrcweir //    Square    Argument * Argument
39cdf0e10cSrcweir //    Event     Aufruf eines Basic-Programms
40cdf0e10cSrcweir // 3) Unterobjekte:
41cdf0e10cSrcweir //    eine Collection names "Elements". Der Zugriff ist sowohl als
42cdf0e10cSrcweir //    Property (fuer das gesamte Objekt) als auch als Methode (fuer
43cdf0e10cSrcweir //    einzelne Elemente, wird durchgereicht) implementiert.
44cdf0e10cSrcweir // Diese Implementation ist ein Beispiel fuer eine tabellengesteuerte
45cdf0e10cSrcweir // Version, die sehr viele Elemente enthalten kann.
46cdf0e10cSrcweir // Die Collection findet sich in COLLECTN.*, die in der Collection
47cdf0e10cSrcweir // enthaltenen Objekte in COLLELEM.*
48cdf0e10cSrcweir 
49cdf0e10cSrcweir class SampleObject : public SbxObject
50cdf0e10cSrcweir {
51cdf0e10cSrcweir using SbxVariable::GetInfo;
52cdf0e10cSrcweir 	// Definition eines Tabelleneintrags. Dies wird hier gemacht,
53cdf0e10cSrcweir 	// da dadurch die Methoden und Properties als private deklariert
54cdf0e10cSrcweir 	// werden koennen.
55cdf0e10cSrcweir #if defined ( ICC ) || defined ( HPUX ) || defined ( C50 ) || defined ( C52 )
56cdf0e10cSrcweir public:
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir 	typedef void( SampleObject::*pMeth )
59cdf0e10cSrcweir 		( SbxVariable* pThis, SbxArray* pArgs, sal_Bool bWrite );
60cdf0e10cSrcweir #if defined ( ICC ) || defined ( HPUX )
61cdf0e10cSrcweir private:
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	struct Methods {
65cdf0e10cSrcweir 		const char* pName;      // Name des Eintrags
66cdf0e10cSrcweir 		SbxDataType eType;      // Datentyp
67cdf0e10cSrcweir 		pMeth pFunc;            // Function Pointer
68cdf0e10cSrcweir 		short nArgs;            // Argumente und Flags
69cdf0e10cSrcweir 	};
70cdf0e10cSrcweir 	static Methods aMethods[];  // Methodentabelle
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	// Methoden
73cdf0e10cSrcweir 	void Display( SbxVariable*, SbxArray*, sal_Bool );
74cdf0e10cSrcweir 	void Event( SbxVariable*, SbxArray*, sal_Bool );
75cdf0e10cSrcweir 	void Square( SbxVariable*, SbxArray*, sal_Bool );
76cdf0e10cSrcweir 	void Create( SbxVariable*, SbxArray*, sal_Bool );
77cdf0e10cSrcweir 	// Infoblock auffuellen
78cdf0e10cSrcweir 	SbxInfo* GetInfo( short nIdx );
79cdf0e10cSrcweir 	// Broadcaster Notification
80cdf0e10cSrcweir 	virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
81cdf0e10cSrcweir 							 const SfxHint& rHint, const TypeId& rHintType );
82cdf0e10cSrcweir public:
83cdf0e10cSrcweir 	SampleObject( const String& );
84cdf0e10cSrcweir 	// Suchen eines Elements
85cdf0e10cSrcweir 	virtual SbxVariable* Find( const String&, SbxClassType );
86cdf0e10cSrcweir };
87cdf0e10cSrcweir 
88cdf0e10cSrcweir // Die dazugehoerige Factory:
89cdf0e10cSrcweir 
90cdf0e10cSrcweir class SampleObjectFac : public SbxFactory
91cdf0e10cSrcweir {
92cdf0e10cSrcweir public:
93cdf0e10cSrcweir 	virtual SbxObject* CreateObject( const String& );
94cdf0e10cSrcweir };
95cdf0e10cSrcweir 
96cdf0e10cSrcweir #endif
97