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