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 #include "sampleaddin.hxx" 24 25 #include <cppuhelper/factory.hxx> 26 #include <osl/diagnose.h> 27 28 #include <com/sun/star/drawing/XDrawPageSupplier.hpp> 29 #include <com/sun/star/drawing/XDrawPage.hpp> 30 #include <com/sun/star/chart/XChartDataArray.hpp> 31 #include <com/sun/star/text/XTextRange.hpp> 32 #include <com/sun/star/chart/X3DDisplay.hpp> 33 34 using namespace com::sun::star; 35 using namespace rtl; 36 37 // code for creating instances of SampleAddIn 38 39 extern "C" { 40 41 void SAL_CALL component_getImplementationEnvironment( 42 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) 43 { 44 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 45 } 46 47 sal_Bool SAL_CALL component_writeInfo( 48 void * /*pServiceManager*/, registry::XRegistryKey * pRegistryKey ) 49 { 50 if( pRegistryKey ) 51 { 52 try 53 { 54 OUString aImpl = OUString::createFromAscii( "/" ); 55 aImpl += SampleAddIn::getImplementationName_Static(); 56 aImpl += OUString::createFromAscii( "/UNO/SERVICES" ); 57 58 uno::Reference< registry::XRegistryKey> xNewKey( 59 reinterpret_cast<registry::XRegistryKey*>( pRegistryKey )->createKey( aImpl ) ); 60 61 uno::Sequence< OUString > aSequ = SampleAddIn::getSupportedServiceNames_Static(); 62 const OUString * pArray = aSequ.getConstArray(); 63 for( sal_Int32 i = 0; i < aSequ.getLength(); i++ ) 64 xNewKey->createKey( pArray[i] ); 65 66 return sal_True; 67 } 68 catch( registry::InvalidRegistryException& ) 69 { 70 OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); 71 } 72 } 73 return sal_False; 74 } 75 76 void * SAL_CALL component_getFactory( 77 const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) 78 { 79 void* pRet = 0; 80 81 if ( pServiceManager && 82 OUString::createFromAscii( pImplName ) == SampleAddIn::getImplementationName_Static() ) 83 { 84 uno::Reference< lang::XSingleServiceFactory> xFactory( cppu::createSingleFactory( 85 reinterpret_cast<lang::XMultiServiceFactory*>( pServiceManager ), 86 SampleAddIn::getImplementationName_Static(), 87 SampleAddIn_CreateInstance, 88 SampleAddIn::getSupportedServiceNames_Static() ) ); 89 90 if( xFactory.is()) 91 { 92 xFactory->acquire(); 93 pRet = xFactory.get(); 94 } 95 } 96 97 return pRet; 98 } 99 100 } // extern C 101 102 103 // -------------------- 104 // class SampleAddIn 105 // -------------------- 106 107 SampleAddIn::SampleAddIn() 108 { 109 110 } 111 112 SampleAddIn::~SampleAddIn() 113 {} 114 115 116 // this functionality should be provided by the chart API some day 117 sal_Bool SampleAddIn::getLogicalPosition( uno::Reference< drawing::XShape >& xAxis, 118 double fValue, 119 sal_Bool bVertical, 120 awt::Point& aOutPosition ) 121 { 122 sal_Bool bRet = sal_False; 123 124 if( xAxis.is()) 125 { 126 awt::Size aSize = xAxis->getSize(); 127 sal_Int32 nLength = bVertical? aSize.Height: aSize.Width; 128 129 uno::Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); 130 if( xProp.is()) 131 { 132 try 133 { 134 double fMin(0.0), fMax(0.0); 135 uno::Any aAny = xProp->getPropertyValue( OUString::createFromAscii( "Min" )); 136 aAny >>= fMin; 137 aAny = xProp->getPropertyValue( OUString::createFromAscii( "Max" )); 138 aAny >>= fMax; 139 140 double fRange = fMax - fMin; 141 if( fMin <= fValue && fValue <= fMax && 142 fRange != 0.0 ) 143 { 144 double fPercentage = (fValue - fMin) / fRange; 145 awt::Point aPos = xAxis->getPosition(); 146 147 if( bVertical ) 148 { 149 aOutPosition.X = aPos.X; 150 aOutPosition.Y = static_cast<sal_Int32>(aPos.Y + nLength * (1.0 - fPercentage)); // y scale goes from top to bottom 151 } 152 else 153 { 154 aOutPosition.X = static_cast<sal_Int32>(aPos.X + nLength * fPercentage); 155 aOutPosition.Y = aPos.Y; 156 } 157 bRet = sal_True; 158 } 159 } 160 catch( beans::UnknownPropertyException ) 161 { 162 // the shape xAxis was no chart axis 163 } 164 } 165 } 166 167 return bRet; 168 } 169 170 OUString SampleAddIn::getImplementationName_Static() 171 { 172 return OUString::createFromAscii( "SampleAddIn" ); 173 } 174 175 uno::Sequence< ::rtl::OUString > SampleAddIn::getSupportedServiceNames_Static() 176 { 177 uno::Sequence< OUString > aSeq( 4 ); 178 179 aSeq[ 0 ] = OUString::createFromAscii( "com.sun.star.chart.ChartAxisXSupplier" ); 180 aSeq[ 1 ] = OUString::createFromAscii( "com.sun.star.chart.ChartAxisYSupplier" ); 181 aSeq[ 2 ] = OUString::createFromAscii( "com.sun.star.chart.Diagram" ); 182 aSeq[ 3 ] = OUString::createFromAscii( "com.sun.star.chart.SampleAddIn" ); 183 184 return aSeq; 185 } 186 187 uno::Reference< uno::XInterface > SAL_CALL SampleAddIn_CreateInstance( 188 const uno::Reference< lang::XMultiServiceFactory >& ) 189 { 190 uno::Reference< uno::XInterface > xInst = (cppu::OWeakObject*)new SampleAddIn(); 191 192 return xInst; 193 } 194 195 // implementation of interface methods 196 197 // XInitialization 198 void SAL_CALL SampleAddIn::initialize( const uno::Sequence< uno::Any >& aArguments ) 199 { 200 // first argument should be the XChartDocument 201 OSL_ENSURE( aArguments.getLength() > 0, "Please initialize Chart AddIn with ChartDocument!" ); 202 203 if( aArguments.getLength()) 204 { 205 aArguments[ 0 ] >>= mxChartDoc; 206 OSL_ENSURE( mxChartDoc.is(), "First argument in initialization is not an XChartDocument!" ); 207 208 // set XY chart as base type to be drawn 209 uno::Reference< beans::XPropertySet > xDocProp( mxChartDoc, uno::UNO_QUERY ); 210 if( xDocProp.is()) 211 { 212 uno::Any aBaseType; 213 aBaseType <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart.XYDiagram" )); 214 try 215 { 216 xDocProp->setPropertyValue( rtl::OUString::createFromAscii( "BaseDiagram" ), aBaseType ); 217 } 218 catch( ... ) 219 {} 220 } 221 222 // change background of plot area to light blue 223 uno::Reference< chart::X3DDisplay > xWallSupplier( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 224 if( xWallSupplier.is()) 225 { 226 uno::Reference< beans::XPropertySet > xDiaProp( xWallSupplier->getWall(), uno::UNO_QUERY ); 227 uno::Reference< beans::XPropertySet > xLegendProp( mxChartDoc->getLegend(), uno::UNO_QUERY ); 228 if( xDiaProp.is() && 229 xLegendProp.is()) 230 { 231 uno::Any aAny; 232 aAny <<= (sal_Int32)( 0xe0e0f0 ); 233 xDiaProp->setPropertyValue( OUString::createFromAscii( "FillColor" ), aAny ); 234 xLegendProp->setPropertyValue( OUString::createFromAscii( "FillColor" ), aAny ); 235 } 236 } 237 } 238 } 239 240 // XRefreshable 241 /******************************************************************************** 242 * 243 * The method refresh is the most important method - here all objects that 244 * are necessary for the chart are created 245 * 246 * in the first implementation you will have to insert everything in this 247 * routine - all old objects are deleted beforehand 248 * 249 ********************************************************************************/ 250 void SAL_CALL SampleAddIn::refresh() 251 { 252 if( ! mxChartDoc.is()) 253 return; 254 255 // first of all get the draw page 256 uno::Reference< drawing::XDrawPageSupplier > xPageSupp( mxChartDoc, uno::UNO_QUERY ); 257 uno::Reference< lang::XMultiServiceFactory > xFactory( mxChartDoc, uno::UNO_QUERY ); 258 if( xPageSupp.is() && 259 xFactory.is() ) 260 { 261 uno::Reference< drawing::XDrawPage > xPage = xPageSupp->getDrawPage(); 262 if( xPage.is()) 263 { 264 // now we have the page to insert objects 265 266 // add a horizontal line at the middle value of the first series 267 // ------------------------------------------------------------- 268 269 270 // get the logical position from the coordinate 271 // get x- and y-axis 272 uno::Reference< drawing::XShape > xYAxisShape( getYAxis(), uno::UNO_QUERY ); 273 uno::Reference< drawing::XShape > xXAxisShape( getXAxis(), uno::UNO_QUERY ); 274 275 if( xXAxisShape.is() && 276 xYAxisShape.is() ) 277 { 278 // create line first time 279 if( ! mxMyRedLine.is()) 280 { 281 mxMyRedLine = uno::Reference< drawing::XShape >( 282 xFactory->createInstance( OUString::createFromAscii( "com.sun.star.drawing.LineShape" )), 283 uno::UNO_QUERY ); 284 xPage->add( mxMyRedLine ); 285 286 // make line red and thick 287 uno::Reference< beans::XPropertySet > xShapeProp( mxMyRedLine, uno::UNO_QUERY ); 288 if( xShapeProp.is()) 289 { 290 uno::Any aColor, aWidth; 291 aColor <<= (sal_Int32)(0xe01010); 292 aWidth <<= (sal_Int32)(50); // 0.5 mm 293 try 294 { 295 xShapeProp->setPropertyValue( OUString::createFromAscii( "LineColor" ), aColor ); 296 xShapeProp->setPropertyValue( OUString::createFromAscii( "LineWidth" ), aWidth ); 297 } 298 catch( ... ) 299 {} 300 } 301 } 302 // create text object first time 303 if( ! mxMyText.is()) 304 { 305 mxMyText = uno::Reference< drawing::XShape >( 306 xFactory->createInstance( OUString::createFromAscii( "com.sun.star.drawing.TextShape" )), 307 uno::UNO_QUERY ); 308 xPage->add( mxMyText ); 309 310 // change text 311 OUString aText; 312 // if( maLocale.Language.equalsIgnoreCase( OUString::createFromAscii("DE"))) 313 // aText = OUString::createFromAscii( "Kleines Beispiel" ); 314 // else 315 aText = OUString::createFromAscii( "Little Example" ); 316 317 uno::Reference< beans::XPropertySet > xTextProp( mxMyText, uno::UNO_QUERY ); 318 if( xTextProp.is()) 319 { 320 uno::Any aTrueAny; 321 aTrueAny <<= (sal_Bool)(sal_True); 322 try 323 { 324 xTextProp->setPropertyValue( rtl::OUString::createFromAscii( "TextAutoGrowWidth" ), aTrueAny ); 325 } 326 catch( ... ) 327 {} 328 } 329 330 uno::Reference< text::XTextRange > xTextRange( mxMyText, uno::UNO_QUERY ); 331 if( xTextRange.is()) 332 { 333 xTextRange->setString( aText ); 334 } 335 } 336 337 338 // position line and text 339 340 // get the array. Note: the first dimension is the length 341 // of each series and the second one is the number of series 342 // this should be changed in the future 343 uno::Sequence< uno::Sequence< double > > aData; 344 uno::Reference< chart::XChartData > xData = mxChartDoc->getData(); 345 uno::Reference< chart::XChartDataArray > xDataArray( xData, uno::UNO_QUERY ); 346 if( xDataArray.is()) 347 aData = xDataArray->getData(); 348 349 // get row count == length of each series 350 sal_Int32 nSize = aData.getLength(); 351 sal_Int32 nMiddle = nSize / 2; 352 // get value for first series 353 double fMiddleVal = xData->getNotANumber(); // set to NaN 354 if( aData[ nMiddle ].getLength()) // we have at least one series 355 fMiddleVal = aData[ nMiddle ][ 0 ]; 356 357 awt::Point aPos; 358 getLogicalPosition( xYAxisShape, fMiddleVal, sal_True, aPos ); 359 awt::Size aSize = xXAxisShape->getSize(); 360 361 if( mxMyRedLine.is()) 362 { 363 awt::Point aEnd = aPos; 364 aEnd.X += aSize.Width; 365 366 uno::Sequence< uno::Sequence< awt::Point > > aPtSeq( 1 ); 367 aPtSeq[ 0 ].realloc( 2 ); 368 aPtSeq[ 0 ][ 0 ] = aPos; 369 aPtSeq[ 0 ][ 1 ] = aEnd; 370 371 uno::Reference< beans::XPropertySet > xShapeProp( mxMyRedLine, uno::UNO_QUERY ); 372 if( xShapeProp.is()) 373 { 374 uno::Any aAny; 375 aAny <<= aPtSeq; 376 xShapeProp->setPropertyValue( rtl::OUString::createFromAscii( "PolyPolygon" ), aAny ); 377 } 378 } 379 if( mxMyText.is()) 380 { 381 // put the text centered below the red line 382 aPos.X += ( aSize.Width - mxMyRedLine->getPosition().X ) / 2; 383 aPos.Y += 1000; 384 aPos.Y += static_cast<sal_Int32>(0.1 * xYAxisShape->getSize().Height); 385 mxMyText->setPosition( aPos ); 386 } 387 } 388 } 389 } 390 391 // set axis scale to 200 392 // uno::Reference< beans::XPropertySet > xXAxis( getXAxis(), uno::UNO_QUERY ); 393 // if( xXAxis.is()) 394 // { 395 // uno::Any aAny; 396 // aAny <<= (sal_Bool)(sal_False); 397 // xXAxis->setPropertyValue( rtl::OUString::createFromAscii( "AutoStepMain" ), 398 // aAny ); 399 // aAny <<= (double)(200.0); 400 // xXAxis->setPropertyValue( rtl::OUString::createFromAscii( "StepMain" ), 401 // aAny ); 402 // } 403 404 // try setting symbols 405 // uno::Reference< beans::XPropertySet > xProp = getDataRowProperties( 0 ); 406 // if( xProp.is()) 407 // { 408 // uno::Any aAny; 409 // aAny <<= (sal_Int32)(-1); 410 // xProp->setPropertyValue( OUString::createFromAscii( "SymbolType" ), aAny ); 411 // aAny <<= rtl::OUString::createFromAscii( "http://mib-1168/www/images/go.gif" ); 412 // xProp->setPropertyValue( OUString::createFromAscii( "SymbolBitmapURL" ), aAny ); 413 // } 414 } 415 416 void SAL_CALL SampleAddIn::addRefreshListener( const uno::Reference< util::XRefreshListener >& ) 417 { 418 // not implemented - this is not necessary 419 // (this method exists just because the interface requires it) 420 } 421 422 void SAL_CALL SampleAddIn::removeRefreshListener( const uno::Reference< util::XRefreshListener >& ) 423 { 424 // not implemented - this is not necessary 425 // (this method exists just because the interface requires it) 426 } 427 428 // XDiagram 429 OUString SAL_CALL SampleAddIn::getDiagramType() 430 { 431 return OUString::createFromAscii( "com.sun.star.chart.SampleDiagram" ); 432 } 433 434 // the following methods just delegate to the "parent diagram" (which in the future might no longer exist) 435 436 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getDataRowProperties( sal_Int32 nRow ) 437 { 438 if( mxChartDoc.is()) 439 { 440 uno::Reference< chart::XDiagram > xDia = mxChartDoc->getDiagram(); 441 if( xDia.is()) 442 return xDia->getDataRowProperties( nRow ); 443 } 444 445 return uno::Reference< beans::XPropertySet >(); 446 } 447 448 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow ) 449 { 450 if( mxChartDoc.is()) 451 { 452 uno::Reference< chart::XDiagram > xDia = mxChartDoc->getDiagram(); 453 if( xDia.is()) 454 return xDia->getDataPointProperties( nCol, nRow ); 455 } 456 457 return uno::Reference< beans::XPropertySet >(); 458 } 459 460 // XShape ( ::XDiagram ) 461 awt::Size SAL_CALL SampleAddIn::getSize() 462 { 463 if( mxChartDoc.is()) 464 { 465 uno::Reference< drawing::XShape > xShape( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 466 if( xShape.is()) 467 return xShape->getSize(); 468 } 469 470 return awt::Size(); 471 } 472 473 void SAL_CALL SampleAddIn::setSize( const awt::Size& aSize ) 474 { 475 if( mxChartDoc.is()) 476 { 477 uno::Reference< drawing::XShape > xShape( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 478 if( xShape.is()) 479 xShape->setSize( aSize ); 480 } 481 } 482 483 awt::Point SAL_CALL SampleAddIn::getPosition() 484 { 485 if( mxChartDoc.is()) 486 { 487 uno::Reference< drawing::XShape > xShape( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 488 if( xShape.is()) 489 return xShape->getPosition(); 490 } 491 492 return awt::Point(); 493 } 494 495 void SAL_CALL SampleAddIn::setPosition( const awt::Point& aPos ) 496 { 497 if( mxChartDoc.is()) 498 { 499 uno::Reference< drawing::XShape > xShape( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 500 if( xShape.is()) 501 xShape->setPosition( aPos ); 502 } 503 } 504 505 // XShapeDescriptor ( ::XShape ::XDiagram ) 506 rtl::OUString SAL_CALL SampleAddIn::getShapeType() 507 { 508 return OUString::createFromAscii( "com.sun.star.chart.SampleAddinShape" ); 509 } 510 511 // XAxisXSupplier 512 uno::Reference< drawing::XShape > SAL_CALL SampleAddIn::getXAxisTitle() 513 { 514 if( mxChartDoc.is()) 515 { 516 uno::Reference< chart::XAxisXSupplier > xAxisSupp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 517 if( xAxisSupp.is()) 518 return xAxisSupp->getXAxisTitle(); 519 } 520 521 return uno::Reference< drawing::XShape >(); 522 } 523 524 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getXAxis() 525 { 526 if( mxChartDoc.is()) 527 { 528 uno::Reference< chart::XAxisXSupplier > xAxisSupp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 529 if( xAxisSupp.is()) 530 return xAxisSupp->getXAxis(); 531 } 532 533 return uno::Reference< beans::XPropertySet >(); 534 } 535 536 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getXMainGrid() 537 { 538 if( mxChartDoc.is()) 539 { 540 uno::Reference< chart::XAxisXSupplier > xAxisSupp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 541 if( xAxisSupp.is()) 542 return xAxisSupp->getXMainGrid(); 543 } 544 545 return uno::Reference< beans::XPropertySet >(); 546 } 547 548 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getXHelpGrid() 549 { 550 if( mxChartDoc.is()) 551 { 552 uno::Reference< chart::XAxisXSupplier > xAxisSupp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 553 if( xAxisSupp.is()) 554 return xAxisSupp->getXHelpGrid(); 555 } 556 557 return uno::Reference< beans::XPropertySet >(); 558 } 559 560 // XAxisYSupplier 561 uno::Reference< drawing::XShape > SAL_CALL SampleAddIn::getYAxisTitle() 562 { 563 if( mxChartDoc.is()) 564 { 565 uno::Reference< chart::XAxisYSupplier > xAxisSupp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 566 if( xAxisSupp.is()) 567 return xAxisSupp->getYAxisTitle(); 568 } 569 570 return uno::Reference< drawing::XShape >(); 571 } 572 573 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getYAxis() 574 { 575 if( mxChartDoc.is()) 576 { 577 uno::Reference< chart::XAxisYSupplier > xAxisSupp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 578 if( xAxisSupp.is()) 579 return xAxisSupp->getYAxis(); 580 } 581 582 return uno::Reference< beans::XPropertySet >(); 583 } 584 585 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getYMainGrid() 586 { 587 if( mxChartDoc.is()) 588 { 589 uno::Reference< chart::XAxisYSupplier > xAxisSupp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 590 if( xAxisSupp.is()) 591 return xAxisSupp->getYMainGrid(); 592 } 593 594 return uno::Reference< beans::XPropertySet >(); 595 } 596 597 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getYHelpGrid() 598 { 599 if( mxChartDoc.is()) 600 { 601 uno::Reference< chart::XAxisYSupplier > xAxisSupp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 602 if( xAxisSupp.is()) 603 return xAxisSupp->getYHelpGrid(); 604 } 605 606 return uno::Reference< beans::XPropertySet >(); 607 } 608 609 // XStatisticDisplay 610 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getUpBar() 611 { 612 if( mxChartDoc.is()) 613 { 614 uno::Reference< chart::XStatisticDisplay > xStatDisp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 615 if( xStatDisp.is()) 616 return xStatDisp->getUpBar(); 617 } 618 619 return uno::Reference< beans::XPropertySet >(); 620 } 621 622 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getDownBar() 623 { 624 if( mxChartDoc.is()) 625 { 626 uno::Reference< chart::XStatisticDisplay > xStatDisp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 627 if( xStatDisp.is()) 628 return xStatDisp->getDownBar(); 629 } 630 631 return uno::Reference< beans::XPropertySet >(); 632 } 633 634 uno::Reference< beans::XPropertySet > SAL_CALL SampleAddIn::getMinMaxLine() 635 { 636 if( mxChartDoc.is()) 637 { 638 uno::Reference< chart::XStatisticDisplay > xStatDisp( mxChartDoc->getDiagram(), uno::UNO_QUERY ); 639 if( xStatDisp.is()) 640 return xStatDisp->getMinMaxLine(); 641 } 642 643 return uno::Reference< beans::XPropertySet >(); 644 } 645 646 // XServiceName 647 OUString SAL_CALL SampleAddIn::getServiceName() 648 { 649 return OUString::createFromAscii( "com.sun.star.chart.SampleAddIn" ); 650 } 651 652 // XServiceInfo 653 OUString SAL_CALL SampleAddIn::getImplementationName() 654 { 655 return getImplementationName_Static(); 656 } 657 658 sal_Bool SAL_CALL SampleAddIn::supportsService( const OUString& ServiceName ) 659 { 660 uno::Sequence< OUString > aServiceSeq = getSupportedServiceNames_Static(); 661 662 sal_Int32 nLength = aServiceSeq.getLength(); 663 for( sal_Int32 i=0; i < nLength; i++ ) 664 { 665 if( ServiceName.equals( aServiceSeq[ i ] )) 666 return sal_True; 667 } 668 669 return sal_False; 670 } 671 672 uno::Sequence< OUString > SAL_CALL SampleAddIn::getSupportedServiceNames() 673 { 674 return getSupportedServiceNames_Static(); 675 } 676 677 // XLocalizable 678 void SAL_CALL SampleAddIn::setLocale( const lang::Locale& eLocale ) 679 { 680 maLocale = eLocale; 681 } 682 683 lang::Locale SAL_CALL SampleAddIn::getLocale() 684 { 685 return maLocale; 686 } 687