xref: /aoo41x/main/basic/source/runtime/stdobj1.cxx (revision e1f63238)
1*e1f63238SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*e1f63238SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*e1f63238SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*e1f63238SAndrew Rist  * distributed with this work for additional information
6*e1f63238SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*e1f63238SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*e1f63238SAndrew Rist  * "License"); you may not use this file except in compliance
9*e1f63238SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*e1f63238SAndrew Rist  *
11*e1f63238SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*e1f63238SAndrew Rist  *
13*e1f63238SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*e1f63238SAndrew Rist  * software distributed under the License is distributed on an
15*e1f63238SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e1f63238SAndrew Rist  * KIND, either express or implied.  See the License for the
17*e1f63238SAndrew Rist  * specific language governing permissions and limitations
18*e1f63238SAndrew Rist  * under the License.
19*e1f63238SAndrew Rist  *
20*e1f63238SAndrew Rist  *************************************************************/
21*e1f63238SAndrew Rist 
22*e1f63238SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_basic.hxx"
26cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
27cdf0e10cSrcweir #include <vcl/svapp.hxx>
28cdf0e10cSrcweir #include <svtools/transfer.hxx>
29cdf0e10cSrcweir #include "runtime.hxx"
30cdf0e10cSrcweir #include <basic/sbstdobj.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #define ATTR_IMP_TYPE			1
33cdf0e10cSrcweir #define ATTR_IMP_WIDTH			2
34cdf0e10cSrcweir #define ATTR_IMP_HEIGHT			3
35cdf0e10cSrcweir #define ATTR_IMP_BOLD			4
36cdf0e10cSrcweir #define ATTR_IMP_ITALIC			5
37cdf0e10cSrcweir #define ATTR_IMP_STRIKETHROUGH	6
38cdf0e10cSrcweir #define ATTR_IMP_UNDERLINE		7
39cdf0e10cSrcweir #define ATTR_IMP_WEIGHT			8
40cdf0e10cSrcweir #define ATTR_IMP_SIZE			9
41cdf0e10cSrcweir #define ATTR_IMP_NAME			10
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #define METH_CLEAR				20
44cdf0e10cSrcweir #define METH_GETDATA			21
45cdf0e10cSrcweir #define METH_GETFORMAT			22
46cdf0e10cSrcweir #define METH_GETTEXT			23
47cdf0e10cSrcweir #define METH_SETDATA			24
48cdf0e10cSrcweir #define METH_SETTEXT			25
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //------------------------------------------------------------------------------
SbStdFactory()51cdf0e10cSrcweir SbStdFactory::SbStdFactory()
52cdf0e10cSrcweir {
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
CreateObject(const String & rClassName)55cdf0e10cSrcweir SbxObject* SbStdFactory::CreateObject( const String& rClassName )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 	if( rClassName.EqualsIgnoreCaseAscii( String( RTL_CONSTASCII_USTRINGPARAM("Picture") ) ) )
58cdf0e10cSrcweir 		return new SbStdPicture;
59cdf0e10cSrcweir 	else
60cdf0e10cSrcweir 		if( rClassName.EqualsIgnoreCaseAscii( String( RTL_CONSTASCII_USTRINGPARAM("Font") ) ) )
61cdf0e10cSrcweir 		return new SbStdFont;
62cdf0e10cSrcweir 	else
63cdf0e10cSrcweir 		return NULL;
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //------------------------------------------------------------------------------
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 
PropType(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)70cdf0e10cSrcweir void SbStdPicture::PropType( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	if( bWrite )
73cdf0e10cSrcweir 	{
74cdf0e10cSrcweir 		StarBASIC::Error( SbERR_PROP_READONLY );
75cdf0e10cSrcweir 		return;
76cdf0e10cSrcweir 	}
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	GraphicType eType = aGraphic.GetType();
79cdf0e10cSrcweir 	sal_Int16 nType = 0;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	if( eType == GRAPHIC_BITMAP )
82cdf0e10cSrcweir 		nType = 1;
83cdf0e10cSrcweir 	else
84cdf0e10cSrcweir 	if( eType != GRAPHIC_NONE )
85cdf0e10cSrcweir 		nType = 2;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	pVar->PutInteger( nType );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
PropWidth(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)91cdf0e10cSrcweir void SbStdPicture::PropWidth( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	if( bWrite )
94cdf0e10cSrcweir 	{
95cdf0e10cSrcweir 		StarBASIC::Error( SbERR_PROP_READONLY );
96cdf0e10cSrcweir 		return;
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	Size aSize = aGraphic.GetPrefSize();
100cdf0e10cSrcweir 	aSize =	GetpApp()->GetAppWindow()->LogicToPixel( aSize, aGraphic.GetPrefMapMode() );
101cdf0e10cSrcweir 	aSize = GetpApp()->GetAppWindow()->PixelToLogic( aSize, MapMode( MAP_TWIP ) );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	pVar->PutInteger( (sal_Int16)aSize.Width() );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
PropHeight(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)106cdf0e10cSrcweir void SbStdPicture::PropHeight( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	if( bWrite )
109cdf0e10cSrcweir 	{
110cdf0e10cSrcweir 		StarBASIC::Error( SbERR_PROP_READONLY );
111cdf0e10cSrcweir 		return;
112cdf0e10cSrcweir 	}
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	Size aSize = aGraphic.GetPrefSize();
115cdf0e10cSrcweir 	aSize =	GetpApp()->GetAppWindow()->LogicToPixel( aSize, aGraphic.GetPrefMapMode() );
116cdf0e10cSrcweir 	aSize = GetpApp()->GetAppWindow()->PixelToLogic( aSize, MapMode( MAP_TWIP ) );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	pVar->PutInteger( (sal_Int16)aSize.Height() );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122cdf0e10cSrcweir TYPEINIT1( SbStdPicture, SbxObject );
123cdf0e10cSrcweir 
SbStdPicture()124cdf0e10cSrcweir SbStdPicture::SbStdPicture() :
125cdf0e10cSrcweir 	SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("Picture") ) )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	// Properties
128cdf0e10cSrcweir 	SbxVariable* p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Type") ), SbxCLASS_PROPERTY, SbxVARIANT );
129cdf0e10cSrcweir 	p->SetFlags( SBX_READ | SBX_DONTSTORE );
130cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_TYPE );
131cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Width") ), SbxCLASS_PROPERTY, SbxVARIANT );
132cdf0e10cSrcweir 	p->SetFlags( SBX_READ | SBX_DONTSTORE );
133cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_WIDTH );
134cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Height") ), SbxCLASS_PROPERTY, SbxVARIANT );
135cdf0e10cSrcweir 	p->SetFlags( SBX_READ | SBX_DONTSTORE );
136cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_HEIGHT );
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
~SbStdPicture()139cdf0e10cSrcweir SbStdPicture::~SbStdPicture()
140cdf0e10cSrcweir {
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 
Find(const String & rName,SbxClassType t)144cdf0e10cSrcweir SbxVariable* SbStdPicture::Find( const String& rName, SbxClassType t )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	// Bereits eingetragen?
147cdf0e10cSrcweir 	return SbxObject::Find( rName, t );
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 
SFX_NOTIFY(SfxBroadcaster & rBC,const TypeId & rBCType,const SfxHint & rHint,const TypeId & rHintType)152cdf0e10cSrcweir void SbStdPicture::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
153cdf0e10cSrcweir 							   const SfxHint& rHint, const TypeId& rHintType )
154cdf0e10cSrcweir 
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	const SbxHint* pHint = PTR_CAST( SbxHint, &rHint );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	if( pHint )
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir 		if( pHint->GetId() == SBX_HINT_INFOWANTED )
161cdf0e10cSrcweir 		{
162cdf0e10cSrcweir 			SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
163cdf0e10cSrcweir 			return;
164cdf0e10cSrcweir 		}
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 		SbxVariable* pVar 	= pHint->GetVar();
167cdf0e10cSrcweir 		SbxArray*    pPar_ 	= pVar->GetParameters();
168cdf0e10cSrcweir 		sal_uInt16       nWhich	= (sal_uInt16)pVar->GetUserData();
169cdf0e10cSrcweir 		sal_Bool		 bWrite = pHint->GetId() == SBX_HINT_DATACHANGED;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 		// Propteries
172cdf0e10cSrcweir 		switch( nWhich )
173cdf0e10cSrcweir 		{
174cdf0e10cSrcweir 			case ATTR_IMP_TYPE:		PropType( pVar, pPar_, bWrite ); return;
175cdf0e10cSrcweir 			case ATTR_IMP_WIDTH:	PropWidth( pVar, pPar_, bWrite ); return;
176cdf0e10cSrcweir 			case ATTR_IMP_HEIGHT:	PropHeight( pVar, pPar_, bWrite ); return;
177cdf0e10cSrcweir 		}
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 		SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
180cdf0e10cSrcweir 	}
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir //-----------------------------------------------------------------------------
184cdf0e10cSrcweir 
PropBold(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)185cdf0e10cSrcweir void SbStdFont::PropBold( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir 	if( bWrite )
188cdf0e10cSrcweir 		SetBold( pVar->GetBool() );
189cdf0e10cSrcweir 	else
190cdf0e10cSrcweir 		pVar->PutBool( IsBold() );
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
PropItalic(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)193cdf0e10cSrcweir void SbStdFont::PropItalic( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir 	if( bWrite )
196cdf0e10cSrcweir 		SetItalic( pVar->GetBool() );
197cdf0e10cSrcweir 	else
198cdf0e10cSrcweir 		pVar->PutBool( IsItalic() );
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
PropStrikeThrough(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)201cdf0e10cSrcweir void SbStdFont::PropStrikeThrough( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	if( bWrite )
204cdf0e10cSrcweir 		SetStrikeThrough( pVar->GetBool() );
205cdf0e10cSrcweir 	else
206cdf0e10cSrcweir 		pVar->PutBool( IsStrikeThrough() );
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
PropUnderline(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)209cdf0e10cSrcweir void SbStdFont::PropUnderline( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir 	if( bWrite )
212cdf0e10cSrcweir 		SetUnderline( pVar->GetBool() );
213cdf0e10cSrcweir 	else
214cdf0e10cSrcweir 		pVar->PutBool( IsUnderline() );
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
PropSize(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)217cdf0e10cSrcweir void SbStdFont::PropSize( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	if( bWrite )
220cdf0e10cSrcweir 		SetSize( (sal_uInt16)pVar->GetInteger() );
221cdf0e10cSrcweir 	else
222cdf0e10cSrcweir 		pVar->PutInteger( (sal_Int16)GetSize() );
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
PropName(SbxVariable * pVar,SbxArray *,sal_Bool bWrite)225cdf0e10cSrcweir void SbStdFont::PropName( SbxVariable* pVar, SbxArray*, sal_Bool bWrite )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir 	if( bWrite )
228cdf0e10cSrcweir 		SetFontName( pVar->GetString() );
229cdf0e10cSrcweir 	else
230cdf0e10cSrcweir 		pVar->PutString( GetFontName() );
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 
234cdf0e10cSrcweir TYPEINIT1( SbStdFont, SbxObject );
235cdf0e10cSrcweir 
SbStdFont()236cdf0e10cSrcweir SbStdFont::SbStdFont() :
237cdf0e10cSrcweir 	SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("Font") ) )
238cdf0e10cSrcweir {
239cdf0e10cSrcweir 	// Properties
240cdf0e10cSrcweir 	SbxVariable* p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Bold") ), SbxCLASS_PROPERTY, SbxVARIANT );
241cdf0e10cSrcweir 	p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
242cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_BOLD );
243cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Italic") ), SbxCLASS_PROPERTY, SbxVARIANT );
244cdf0e10cSrcweir 	p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
245cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_ITALIC );
246cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("StrikeThrough") ), SbxCLASS_PROPERTY, SbxVARIANT );
247cdf0e10cSrcweir 	p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
248cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_STRIKETHROUGH );
249cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Underline") ), SbxCLASS_PROPERTY, SbxVARIANT );
250cdf0e10cSrcweir 	p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
251cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_UNDERLINE );
252cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Size") ), SbxCLASS_PROPERTY, SbxVARIANT );
253cdf0e10cSrcweir 	p->SetFlags( SBX_READWRITE | SBX_DONTSTORE );
254cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_SIZE );
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	// Name Property selbst verarbeiten
257cdf0e10cSrcweir 	p = Find( String( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_PROPERTY );
258cdf0e10cSrcweir 	DBG_ASSERT( p, "Keine Name Property" );
259cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_NAME );
260cdf0e10cSrcweir }
261cdf0e10cSrcweir 
~SbStdFont()262cdf0e10cSrcweir SbStdFont::~SbStdFont()
263cdf0e10cSrcweir {
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 
Find(const String & rName,SbxClassType t)267cdf0e10cSrcweir SbxVariable* SbStdFont::Find( const String& rName, SbxClassType t )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir 	// Bereits eingetragen?
270cdf0e10cSrcweir 	return SbxObject::Find( rName, t );
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 
SFX_NOTIFY(SfxBroadcaster & rBC,const TypeId & rBCType,const SfxHint & rHint,const TypeId & rHintType)275cdf0e10cSrcweir void SbStdFont::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
276cdf0e10cSrcweir 							const SfxHint& rHint, const TypeId& rHintType )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir 	const SbxHint* pHint = PTR_CAST( SbxHint, &rHint );
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	if( pHint )
281cdf0e10cSrcweir 	{
282cdf0e10cSrcweir 		if( pHint->GetId() == SBX_HINT_INFOWANTED )
283cdf0e10cSrcweir 		{
284cdf0e10cSrcweir 			SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
285cdf0e10cSrcweir 			return;
286cdf0e10cSrcweir 		}
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 		SbxVariable* pVar 	= pHint->GetVar();
289cdf0e10cSrcweir 		SbxArray*    pPar_ 	= pVar->GetParameters();
290cdf0e10cSrcweir 		sal_uInt16       nWhich	= (sal_uInt16)pVar->GetUserData();
291cdf0e10cSrcweir 		sal_Bool		 bWrite = pHint->GetId() == SBX_HINT_DATACHANGED;
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 		// Propteries
294cdf0e10cSrcweir 		switch( nWhich )
295cdf0e10cSrcweir 		{
296cdf0e10cSrcweir 			case ATTR_IMP_BOLD:			PropBold( pVar, pPar_, bWrite ); return;
297cdf0e10cSrcweir 			case ATTR_IMP_ITALIC:		PropItalic( pVar, pPar_, bWrite ); return;
298cdf0e10cSrcweir 			case ATTR_IMP_STRIKETHROUGH:PropStrikeThrough( pVar, pPar_, bWrite ); return;
299cdf0e10cSrcweir 			case ATTR_IMP_UNDERLINE:	PropUnderline( pVar, pPar_, bWrite ); return;
300cdf0e10cSrcweir 			case ATTR_IMP_SIZE:			PropSize( pVar, pPar_, bWrite ); return;
301cdf0e10cSrcweir 			case ATTR_IMP_NAME:			PropName( pVar, pPar_, bWrite ); return;
302cdf0e10cSrcweir 		}
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 		SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
305cdf0e10cSrcweir 	}
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 
309cdf0e10cSrcweir //-----------------------------------------------------------------------------
310cdf0e10cSrcweir 
311cdf0e10cSrcweir /*
312cdf0e10cSrcweir class TransferableHelperImpl : public TransferableHelper
313cdf0e10cSrcweir {
314cdf0e10cSrcweir     SotFormatStringId   mFormat;
315cdf0e10cSrcweir     String              mString;
316cdf0e10cSrcweir     Graphic             mGraphic;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     virtual void        AddSupportedFormats();
319cdf0e10cSrcweir     virtual sal_Bool    GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir public:
322cdf0e10cSrcweir     TransferableHelperImpl( void ) { mFormat = 0; }
323cdf0e10cSrcweir     TransferableHelperImpl( const String& rStr )
324cdf0e10cSrcweir         mFormat( FORMAT_STRING ), mString( rStr ) {}
325cdf0e10cSrcweir     TransferableHelperImpl( const Graphic& rGraphic );
326cdf0e10cSrcweir         mFormat( FORMAT_BITMAP ), mGraphic( rGraphic ) {}
327cdf0e10cSrcweir 
328cdf0e10cSrcweir };
329cdf0e10cSrcweir 
330cdf0e10cSrcweir void TransferableHelperImpl::AddSupportedFormats()
331cdf0e10cSrcweir {
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir sal_Bool TransferableHelperImpl::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir 	sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
337cdf0e10cSrcweir     if( nFormat == FORMAT_STRING )
338cdf0e10cSrcweir     {
339cdf0e10cSrcweir     }
340cdf0e10cSrcweir     else if( nFormat == FORMAT_BITMAP ||
341cdf0e10cSrcweir              nFormat == FORMAT_GDIMETAFILE )
342cdf0e10cSrcweir     {
343cdf0e10cSrcweir     }
344cdf0e10cSrcweir }
345cdf0e10cSrcweir */
346cdf0e10cSrcweir 
MethClear(SbxVariable *,SbxArray * pPar_,sal_Bool)347cdf0e10cSrcweir void SbStdClipboard::MethClear( SbxVariable*, SbxArray* pPar_, sal_Bool )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir 	if( pPar_ && (pPar_->Count() > 1) )
350cdf0e10cSrcweir 	{
351cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_NUMBER_OF_ARGS );
352cdf0e10cSrcweir 		return;
353cdf0e10cSrcweir 	}
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 	//Clipboard::Clear();
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
MethGetData(SbxVariable * pVar,SbxArray * pPar_,sal_Bool)358cdf0e10cSrcweir void SbStdClipboard::MethGetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir     (void)pVar;
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 	if( !pPar_ || (pPar_->Count() != 2) )
363cdf0e10cSrcweir 	{
364cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_NUMBER_OF_ARGS );
365cdf0e10cSrcweir 		return;
366cdf0e10cSrcweir 	}
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	sal_uInt16 nFormat = pPar_->Get(1)->GetInteger();
369cdf0e10cSrcweir 	if( !nFormat  || nFormat > 3 )
370cdf0e10cSrcweir 	{
371cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_ARGUMENT );
372cdf0e10cSrcweir 		return;
373cdf0e10cSrcweir 	}
374cdf0e10cSrcweir 
375cdf0e10cSrcweir     /*
376cdf0e10cSrcweir 	if( nFormat == FORMAT_STRING )
377cdf0e10cSrcweir 		pVar->PutString( Clipboard::PasteString() );
378cdf0e10cSrcweir 	else
379cdf0e10cSrcweir 	if( (nFormat == FORMAT_BITMAP) ||
380cdf0e10cSrcweir 		(nFormat == FORMAT_GDIMETAFILE ) )
381cdf0e10cSrcweir 	{
382cdf0e10cSrcweir 		SbxObjectRef xPic = new SbStdPicture;
383cdf0e10cSrcweir 		Graphic aGraph;
384cdf0e10cSrcweir 		aGraph.Paste();
385cdf0e10cSrcweir 		((SbStdPicture*)(SbxObject*)xPic)->SetGraphic( aGraph );
386cdf0e10cSrcweir 		pVar->PutObject( xPic );
387cdf0e10cSrcweir 	}
388cdf0e10cSrcweir     */
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
MethGetFormat(SbxVariable * pVar,SbxArray * pPar_,sal_Bool)391cdf0e10cSrcweir void SbStdClipboard::MethGetFormat( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir 	if( !pPar_ || (pPar_->Count() != 2) )
394cdf0e10cSrcweir 	{
395cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_NUMBER_OF_ARGS );
396cdf0e10cSrcweir 		return;
397cdf0e10cSrcweir 	}
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 	sal_uInt16 nFormat = pPar_->Get(1)->GetInteger();
400cdf0e10cSrcweir 	if( !nFormat  || nFormat > 3 )
401cdf0e10cSrcweir 	{
402cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_ARGUMENT );
403cdf0e10cSrcweir 		return;
404cdf0e10cSrcweir 	}
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	pVar->PutBool( sal_False );
407cdf0e10cSrcweir 	//pVar->PutBool( Clipboard::HasFormat( nFormat ) );
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
MethGetText(SbxVariable * pVar,SbxArray * pPar_,sal_Bool)410cdf0e10cSrcweir void SbStdClipboard::MethGetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir 	if( pPar_ && (pPar_->Count() > 1) )
413cdf0e10cSrcweir 	{
414cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_NUMBER_OF_ARGS );
415cdf0e10cSrcweir 		return;
416cdf0e10cSrcweir 	}
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 	pVar->PutString( String() );
419cdf0e10cSrcweir 	//pVar->PutString( Clipboard::PasteString() );
420cdf0e10cSrcweir }
421cdf0e10cSrcweir 
MethSetData(SbxVariable * pVar,SbxArray * pPar_,sal_Bool)422cdf0e10cSrcweir void SbStdClipboard::MethSetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir     (void)pVar;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	if( !pPar_ || (pPar_->Count() != 3) )
427cdf0e10cSrcweir 	{
428cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_NUMBER_OF_ARGS );
429cdf0e10cSrcweir 		return;
430cdf0e10cSrcweir 	}
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 	sal_uInt16 nFormat = pPar_->Get(2)->GetInteger();
433cdf0e10cSrcweir 	if( !nFormat  || nFormat > 3 )
434cdf0e10cSrcweir 	{
435cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_ARGUMENT );
436cdf0e10cSrcweir 		return;
437cdf0e10cSrcweir 	}
438cdf0e10cSrcweir 
439cdf0e10cSrcweir     /*
440cdf0e10cSrcweir 	if( nFormat == FORMAT_STRING )
441cdf0e10cSrcweir 	{
442cdf0e10cSrcweir 		Clipboard::CopyString( pPar_->Get(1)->GetString() );
443cdf0e10cSrcweir 	}
444cdf0e10cSrcweir 	else
445cdf0e10cSrcweir 	if( (nFormat == FORMAT_BITMAP) ||
446cdf0e10cSrcweir 		(nFormat == FORMAT_GDIMETAFILE) )
447cdf0e10cSrcweir 	{
448cdf0e10cSrcweir 		SbxObject* pObj = (SbxObject*)pPar_->Get(1)->GetObject();
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 		if( pObj && pObj->IsA( TYPE( SbStdPicture ) ) )
451cdf0e10cSrcweir 			((SbStdPicture*)(SbxObject*)pObj)->GetGraphic().Copy();
452cdf0e10cSrcweir 	}
453cdf0e10cSrcweir     */
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
MethSetText(SbxVariable * pVar,SbxArray * pPar_,sal_Bool)456cdf0e10cSrcweir void SbStdClipboard::MethSetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir     (void)pVar;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 	if( !pPar_ || (pPar_->Count() != 2) )
461cdf0e10cSrcweir 	{
462cdf0e10cSrcweir 		StarBASIC::Error( SbERR_BAD_NUMBER_OF_ARGS );
463cdf0e10cSrcweir 		return;
464cdf0e10cSrcweir 	}
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	// Clipboard::CopyString( pPar_->Get(1)->GetString() );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 
470cdf0e10cSrcweir TYPEINIT1( SbStdClipboard, SbxObject );
471cdf0e10cSrcweir 
SbStdClipboard()472cdf0e10cSrcweir SbStdClipboard::SbStdClipboard() :
473cdf0e10cSrcweir 	SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("Clipboard") ) )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir 	// Name Property selbst verarbeiten
476cdf0e10cSrcweir 	SbxVariable* p = Find( String( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_PROPERTY );
477cdf0e10cSrcweir 	DBG_ASSERT( p, "Keine Name Property" );
478cdf0e10cSrcweir 	p->SetUserData( ATTR_IMP_NAME );
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 	//Methoden registrieren
481cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("Clear") ), SbxCLASS_METHOD, SbxEMPTY );
482cdf0e10cSrcweir 	p->SetFlag( SBX_DONTSTORE );
483cdf0e10cSrcweir 	p->SetUserData( METH_CLEAR );
484cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("GetData") ), SbxCLASS_METHOD, SbxEMPTY );
485cdf0e10cSrcweir 	p->SetFlag( SBX_DONTSTORE );
486cdf0e10cSrcweir 	p->SetUserData( METH_GETDATA );
487cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("GetFormat") ), SbxCLASS_METHOD, SbxEMPTY );
488cdf0e10cSrcweir 	p->SetFlag( SBX_DONTSTORE );
489cdf0e10cSrcweir 	p->SetUserData( METH_GETFORMAT );
490cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("GetText") ), SbxCLASS_METHOD, SbxEMPTY );
491cdf0e10cSrcweir 	p->SetFlag( SBX_DONTSTORE );
492cdf0e10cSrcweir 	p->SetUserData( METH_GETTEXT );
493cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("SetData") ), SbxCLASS_METHOD, SbxEMPTY );
494cdf0e10cSrcweir 	p->SetFlag( SBX_DONTSTORE );
495cdf0e10cSrcweir 	p->SetUserData( METH_SETDATA );
496cdf0e10cSrcweir 	p = Make( String( RTL_CONSTASCII_USTRINGPARAM("SetText") ), SbxCLASS_METHOD, SbxEMPTY );
497cdf0e10cSrcweir 	p->SetFlag( SBX_DONTSTORE );
498cdf0e10cSrcweir 	p->SetUserData( METH_SETTEXT );
499cdf0e10cSrcweir }
500cdf0e10cSrcweir 
~SbStdClipboard()501cdf0e10cSrcweir SbStdClipboard::~SbStdClipboard()
502cdf0e10cSrcweir {
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 
Find(const String & rName,SbxClassType t)506cdf0e10cSrcweir SbxVariable* SbStdClipboard::Find( const String& rName, SbxClassType t )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	// Bereits eingetragen?
509cdf0e10cSrcweir 	return SbxObject::Find( rName, t );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 
SFX_NOTIFY(SfxBroadcaster & rBC,const TypeId & rBCType,const SfxHint & rHint,const TypeId & rHintType)514cdf0e10cSrcweir void SbStdClipboard::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
515cdf0e10cSrcweir 								 const SfxHint& rHint, const TypeId& rHintType )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir 	const SbxHint* pHint = PTR_CAST( SbxHint, &rHint );
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 	if( pHint )
520cdf0e10cSrcweir 	{
521cdf0e10cSrcweir 		if( pHint->GetId() == SBX_HINT_INFOWANTED )
522cdf0e10cSrcweir 		{
523cdf0e10cSrcweir 			SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
524cdf0e10cSrcweir 			return;
525cdf0e10cSrcweir 		}
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 		SbxVariable* pVar 	= pHint->GetVar();
528cdf0e10cSrcweir 		SbxArray*    pPar_ 	= pVar->GetParameters();
529cdf0e10cSrcweir 		sal_uInt16       nWhich	= (sal_uInt16)pVar->GetUserData();
530cdf0e10cSrcweir 		sal_Bool		 bWrite = pHint->GetId() == SBX_HINT_DATACHANGED;
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 		// Methods
533cdf0e10cSrcweir 		switch( nWhich )
534cdf0e10cSrcweir 		{
535cdf0e10cSrcweir 			case METH_CLEAR:			MethClear( pVar, pPar_, bWrite ); return;
536cdf0e10cSrcweir 			case METH_GETDATA:			MethGetData( pVar, pPar_, bWrite ); return;
537cdf0e10cSrcweir 			case METH_GETFORMAT:		MethGetFormat( pVar, pPar_, bWrite ); return;
538cdf0e10cSrcweir 			case METH_GETTEXT:			MethGetText( pVar, pPar_, bWrite ); return;
539cdf0e10cSrcweir 			case METH_SETDATA:			MethSetData( pVar, pPar_, bWrite ); return;
540cdf0e10cSrcweir 			case METH_SETTEXT:			MethSetText( pVar, pPar_, bWrite ); return;
541cdf0e10cSrcweir 		}
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 		SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
544cdf0e10cSrcweir 	}
545cdf0e10cSrcweir }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 
548