xref: /aoo41x/main/basic/source/inc/object.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SAMPLE_OBJECT_HXX
29 #define _SAMPLE_OBJECT_HXX
30 
31 #include <basic/sbxfac.hxx>
32 #ifndef __SBX_SBXVARIABLE_HXX //autogen
33 #include <basic/sbxvar.hxx>
34 #endif
35 #include <basic/sbxobj.hxx>
36 
37 // 1) Properties:
38 //    Name      der Name, R/O
39 //    Value     ein double-Wert, R/W
40 // 2) Methoden:
41 //    Display   Ausgabe eines Textes
42 //    Square    Argument * Argument
43 //    Event     Aufruf eines Basic-Programms
44 // 3) Unterobjekte:
45 //    eine Collection names "Elements". Der Zugriff ist sowohl als
46 //    Property (fuer das gesamte Objekt) als auch als Methode (fuer
47 //    einzelne Elemente, wird durchgereicht) implementiert.
48 // Diese Implementation ist ein Beispiel fuer eine tabellengesteuerte
49 // Version, die sehr viele Elemente enthalten kann.
50 // Die Collection findet sich in COLLECTN.*, die in der Collection
51 // enthaltenen Objekte in COLLELEM.*
52 
53 class SampleObject : public SbxObject
54 {
55 using SbxVariable::GetInfo;
56 	// Definition eines Tabelleneintrags. Dies wird hier gemacht,
57 	// da dadurch die Methoden und Properties als private deklariert
58 	// werden koennen.
59 #if defined ( ICC ) || defined ( HPUX ) || defined ( C50 ) || defined ( C52 )
60 public:
61 #endif
62 	typedef void( SampleObject::*pMeth )
63 		( SbxVariable* pThis, SbxArray* pArgs, sal_Bool bWrite );
64 #if defined ( ICC ) || defined ( HPUX )
65 private:
66 #endif
67 
68 	struct Methods {
69 		const char* pName;      // Name des Eintrags
70 		SbxDataType eType;      // Datentyp
71 		pMeth pFunc;            // Function Pointer
72 		short nArgs;            // Argumente und Flags
73 	};
74 	static Methods aMethods[];  // Methodentabelle
75 
76 	// Methoden
77 	void Display( SbxVariable*, SbxArray*, sal_Bool );
78 	void Event( SbxVariable*, SbxArray*, sal_Bool );
79 	void Square( SbxVariable*, SbxArray*, sal_Bool );
80 	void Create( SbxVariable*, SbxArray*, sal_Bool );
81 	// Infoblock auffuellen
82 	SbxInfo* GetInfo( short nIdx );
83 	// Broadcaster Notification
84 	virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
85 							 const SfxHint& rHint, const TypeId& rHintType );
86 public:
87 	SampleObject( const String& );
88 	// Suchen eines Elements
89 	virtual SbxVariable* Find( const String&, SbxClassType );
90 };
91 
92 // Die dazugehoerige Factory:
93 
94 class SampleObjectFac : public SbxFactory
95 {
96 public:
97 	virtual SbxObject* CreateObject( const String& );
98 };
99 
100 #endif
101