xref: /aoo4110/main/basic/source/inc/object.hxx (revision b1cdbd2c)
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 
24 #ifndef _SAMPLE_OBJECT_HXX
25 #define _SAMPLE_OBJECT_HXX
26 
27 #include <basic/sbxfac.hxx>
28 #ifndef __SBX_SBXVARIABLE_HXX //autogen
29 #include <basic/sbxvar.hxx>
30 #endif
31 #include <basic/sbxobj.hxx>
32 
33 // 1) Properties:
34 //    Name      der Name, R/O
35 //    Value     ein double-Wert, R/W
36 // 2) Methoden:
37 //    Display   Ausgabe eines Textes
38 //    Square    Argument * Argument
39 //    Event     Aufruf eines Basic-Programms
40 // 3) Unterobjekte:
41 //    eine Collection names "Elements". Der Zugriff ist sowohl als
42 //    Property (fuer das gesamte Objekt) als auch als Methode (fuer
43 //    einzelne Elemente, wird durchgereicht) implementiert.
44 // Diese Implementation ist ein Beispiel fuer eine tabellengesteuerte
45 // Version, die sehr viele Elemente enthalten kann.
46 // Die Collection findet sich in COLLECTN.*, die in der Collection
47 // enthaltenen Objekte in COLLELEM.*
48 
49 class SampleObject : public SbxObject
50 {
51 using SbxVariable::GetInfo;
52 	// Definition eines Tabelleneintrags. Dies wird hier gemacht,
53 	// da dadurch die Methoden und Properties als private deklariert
54 	// werden koennen.
55 #if defined ( ICC ) || defined ( HPUX ) || defined ( C50 ) || defined ( C52 )
56 public:
57 #endif
58 	typedef void( SampleObject::*pMeth )
59 		( SbxVariable* pThis, SbxArray* pArgs, sal_Bool bWrite );
60 #if defined ( ICC ) || defined ( HPUX )
61 private:
62 #endif
63 
64 	struct Methods {
65 		const char* pName;      // Name des Eintrags
66 		SbxDataType eType;      // Datentyp
67 		pMeth pFunc;            // Function Pointer
68 		short nArgs;            // Argumente und Flags
69 	};
70 	static Methods aMethods[];  // Methodentabelle
71 
72 	// Methoden
73 	void Display( SbxVariable*, SbxArray*, sal_Bool );
74 	void Event( SbxVariable*, SbxArray*, sal_Bool );
75 	void Square( SbxVariable*, SbxArray*, sal_Bool );
76 	void Create( SbxVariable*, SbxArray*, sal_Bool );
77 	// Infoblock auffuellen
78 	SbxInfo* GetInfo( short nIdx );
79 	// Broadcaster Notification
80 	virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
81 							 const SfxHint& rHint, const TypeId& rHintType );
82 public:
83 	SampleObject( const String& );
84 	// Suchen eines Elements
85 	virtual SbxVariable* Find( const String&, SbxClassType );
86 };
87 
88 // Die dazugehoerige Factory:
89 
90 class SampleObjectFac : public SbxFactory
91 {
92 public:
93 	virtual SbxObject* CreateObject( const String& );
94 };
95 
96 #endif
97