xref: /trunk/main/basic/inc/basic/sbxobj.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
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 _SBX_SBXOBJECT_HXX
25 #define _SBX_SBXOBJECT_HXX
26 
27 #include <svl/lstner.hxx>
28 #include "basic/basicdllapi.h"
29 #include <basic/sbxvar.hxx>
30 
31 ///////////////////////////////////////////////////////////////////////////
32 
33 class SbxProperty;
34 class SvDispatch;
35 
36 class SbxObjectImpl;
37 
38 class BASIC_DLLPUBLIC SbxObject : public SbxVariable, public SfxListener
39 {
40     SbxObjectImpl* mpSbxObjectImpl; // Impl data
41 
42     SbxArray* FindVar( SbxVariable*, sal_uInt16& );
43     // AB 23.3.1997, special method for VCPtrRemove (see below)
44     SbxArray* VCPtrFindVar( SbxVariable*, sal_uInt16& );
45 protected:
46     SbxArrayRef  pMethods;                  // Methods
47     SbxArrayRef  pProps;                    // Properties
48     SbxArrayRef  pObjs;                     // Objects
49     SbxProperty* pDfltProp;                 // Default-Property
50     String       aClassName;                // Classname
51     String       aDfltPropName;
52     virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
53     virtual sal_Bool StoreData( SvStream& ) const;
54     virtual ~SbxObject();
55     virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
56                              const SfxHint& rHint, const TypeId& rHintType );
57 public:
58     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_OBJECT,1);
59     TYPEINFO();
60     SbxObject( const String& rClassname );
61     SbxObject( const SbxObject& );
62     SbxObject& operator=( const SbxObject& );
63     virtual SbxDataType GetType() const;
64     virtual SbxClassType GetClass() const;
65     virtual void Clear();
66 
67     virtual sal_Bool  IsClass( const String& ) const;
GetClassName() const68     const String& GetClassName() const { return aClassName; }
SetClassName(const String & rNew)69     void          SetClassName( const String &rNew ) { aClassName = rNew; }
70     // Default-Property
71     SbxProperty* GetDfltProperty();
72     void SetDfltProperty( const String& r );
73     void SetDfltProperty( SbxProperty* );
74     // Search for an element
75     virtual SbxVariable* FindUserData( sal_uInt32 nUserData );
76     virtual SbxVariable* Find( const String&, SbxClassType );
77     SbxVariable* FindQualified( const String&, SbxClassType );
78     // Quick-Call-Interface for Methods
79     virtual sal_Bool Call( const String&, SbxArray* = NULL );
80     // Execution of DDE-Commands
81     SbxVariable* Execute( const String& );
82     // Manage elements
GetAll(SbxClassType)83     virtual sal_Bool GetAll( SbxClassType ) { return sal_True; }
84     SbxVariable* Make( const String&, SbxClassType, SbxDataType, bool bIsRuntimeFunction = false );
85     virtual SbxObject* MakeObject( const String&, const String& );
86     virtual void Insert( SbxVariable* );
87     // AB 23.4.1997, Optimization, Insertion without check for duplicate Entries and
88     // without Broadcasts, only used in SO2/auto.cxx
89     void QuickInsert( SbxVariable* );
90     // AB 23.3.1997, Special-Method, allow corresponding controls
91     void VCPtrInsert( SbxVariable* );
92     virtual void Remove( const String&, SbxClassType );
93     virtual void Remove( SbxVariable* );
94     // AB 23.3.1997, deletion per pointer for controls (duplicate names!)
95     void VCPtrRemove( SbxVariable* );
96     void SetPos( SbxVariable*, sal_uInt16 );
97 
98     // Macro-Recording
99     virtual String GenerateSource( const String &rLinePrefix,
100                                    const SbxObject *pRelativeTo );
101     // Direct access on arrays
GetMethods()102     SbxArray* GetMethods()      { return pMethods;  }
GetProperties()103     SbxArray* GetProperties()   { return pProps;    }
GetObjects()104     SbxArray* GetObjects()      { return pObjs;     }
105     // Hooks
106     virtual SvDispatch* GetSvDispatch();
107     // Debugging
108     void Dump( SvStream&, sal_Bool bDumpAll=sal_False );
109 
110     static void GarbageCollection( sal_uIntPtr nObjects = 0 /* ::= all */ );
111 };
112 
113 #ifndef __SBX_SBXOBJECTREF_HXX
114 
115 #ifndef SBX_OBJECT_DECL_DEFINED
116 #define SBX_OBJECT_DECL_DEFINED
117 SV_DECL_REF(SbxObject)
118 #endif
119 SV_IMPL_REF(SbxObject)
120 
121 #endif /* __SBX_SBXOBJECTREF_HXX */
122 #endif /* _SBX_SBXOBJECT_HXX */
123