1e1f63238SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3e1f63238SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4e1f63238SAndrew Rist * or more contributor license agreements. See the NOTICE file 5e1f63238SAndrew Rist * distributed with this work for additional information 6e1f63238SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7e1f63238SAndrew Rist * to you under the Apache License, Version 2.0 (the 8e1f63238SAndrew Rist * "License"); you may not use this file except in compliance 9e1f63238SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11e1f63238SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13e1f63238SAndrew Rist * Unless required by applicable law or agreed to in writing, 14e1f63238SAndrew Rist * software distributed under the License is distributed on an 15e1f63238SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16e1f63238SAndrew Rist * KIND, either express or implied. See the License for the 17e1f63238SAndrew Rist * specific language governing permissions and limitations 18e1f63238SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20e1f63238SAndrew Rist *************************************************************/ 21e1f63238SAndrew Rist 22e1f63238SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25*7fef15a0SDamjan Jovanovic #include "precompiled_sample.hxx" 26cdf0e10cSrcweir #include <tools/errcode.hxx> 27cdf0e10cSrcweir #include <vcl/msgbox.hxx> 28cdf0e10cSrcweir #include <basic/sbx.hxx> 29cdf0e10cSrcweir #include "collelem.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir // Das Sample-Element ist ein kleines Objekt, das die Properties 32cdf0e10cSrcweir // Name und Value enth�lt sowie die Methode Say, die den �bergebenen 33cdf0e10cSrcweir // Text mit dem eigenen Namen verkoppelt und ausgibt. 34cdf0e10cSrcweir 35cdf0e10cSrcweir SampleElement::SampleElement( const String& r ) : SbxObject( r ) 36cdf0e10cSrcweir { 37cdf0e10cSrcweir // Methode Say mit einem String-Parameter 38cdf0e10cSrcweir SbxVariable* pMeth = Make( String( RTL_CONSTASCII_USTRINGPARAM("Say") ), SbxCLASS_METHOD, SbxEMPTY ); 39cdf0e10cSrcweir pMeth->SetUserData( 0x12345678 ); 40cdf0e10cSrcweir pMeth->ResetFlag( SBX_FIXED ); 41cdf0e10cSrcweir SbxInfo* pInfo_ = new SbxInfo; 42cdf0e10cSrcweir pInfo_->AddParam( String( RTL_CONSTASCII_USTRINGPARAM("text") ), SbxSTRING, SBX_READ ); 43cdf0e10cSrcweir pMeth->SetInfo( pInfo_ ); 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir void SampleElement::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, 47cdf0e10cSrcweir const SfxHint& rHint, const TypeId& rHintType ) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir const SbxHint* pHint = PTR_CAST(SbxHint,&rHint); 50cdf0e10cSrcweir if( pHint ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir SbxVariable* pVar = pHint->GetVar(); 53cdf0e10cSrcweir SbxArray* pPar_ = pVar->GetParameters(); 54cdf0e10cSrcweir sal_uIntPtr t = pHint->GetId(); 55cdf0e10cSrcweir if( t == SBX_HINT_DATAWANTED && pVar->GetUserData() == 0x12345678 ) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir // Die Say-Methode: 58cdf0e10cSrcweir // 1 Parameter + Returnwert 59cdf0e10cSrcweir if( !pPar_ || pPar_->Count() != 2 ) 60cdf0e10cSrcweir SetError( SbxERR_WRONG_ARGS ); 61cdf0e10cSrcweir else 62cdf0e10cSrcweir { 63cdf0e10cSrcweir String s( GetName() ); 64cdf0e10cSrcweir s.AppendAscii( " says: " ); 65cdf0e10cSrcweir s += pPar_->Get( 1 )->GetString(); 66cdf0e10cSrcweir pPar_->Get( 0 )->SetType(SbxSTRING); 67cdf0e10cSrcweir pPar_->Get( 0 )->PutString( s ); 68cdf0e10cSrcweir InfoBox( NULL, s ).Execute(); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir return; 71cdf0e10cSrcweir } 72cdf0e10cSrcweir SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType ); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76