1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 #include <svl/itempool.hxx> 31 #include <vcl/cvtgrf.hxx> 32 #include <svl/itemset.hxx> 33 #include <svx/xit.hxx> 34 #include "UnoNameItemTable.hxx" 35 36 #include <svx/xbtmpit.hxx> 37 #include <svx/svdmodel.hxx> 38 #include <svx/xflhtit.hxx> 39 #include "svx/unoapi.hxx" 40 #include <svx/unomid.hxx> 41 #include <editeng/unoprnms.hxx> 42 #include "svx/unofill.hxx" 43 #include <editeng/memberids.hrc> 44 45 using namespace ::com::sun::star; 46 using namespace ::rtl; 47 using namespace ::cppu; 48 49 class SvxUnoBitmapTable : public SvxUnoNameItemTable 50 { 51 public: 52 SvxUnoBitmapTable( SdrModel* pModel ) throw(); 53 virtual ~SvxUnoBitmapTable() throw(); 54 55 virtual NameOrIndex* createItem() const throw(); 56 virtual bool isValid( const NameOrIndex* pItem ) const; 57 58 // XServiceInfo 59 virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); 60 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); 61 62 // XElementAccess 63 virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); 64 }; 65 66 SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw() 67 : SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_GRAFURL ) 68 { 69 } 70 71 SvxUnoBitmapTable::~SvxUnoBitmapTable() throw() 72 { 73 } 74 75 bool SvxUnoBitmapTable::isValid( const NameOrIndex* pItem ) const 76 { 77 if( SvxUnoNameItemTable::isValid( pItem ) ) 78 { 79 const XFillBitmapItem* pBitmapItem = dynamic_cast< const XFillBitmapItem* >( pItem ); 80 if( pBitmapItem ) 81 { 82 const GraphicObject& rGraphic = pBitmapItem->GetBitmapValue().GetGraphicObject(); 83 return rGraphic.GetSizeBytes() > 0; 84 } 85 } 86 87 return false; 88 } 89 90 OUString SAL_CALL SvxUnoBitmapTable::getImplementationName() throw( uno::RuntimeException ) 91 { 92 return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoBitmapTable") ); 93 } 94 95 uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames( ) 96 throw( uno::RuntimeException ) 97 { 98 uno::Sequence< OUString > aSNS( 1 ); 99 aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable" )); 100 return aSNS; 101 } 102 103 NameOrIndex* SvxUnoBitmapTable::createItem() const throw() 104 { 105 return new XFillBitmapItem(); 106 } 107 108 // XElementAccess 109 uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( ) 110 throw( uno::RuntimeException ) 111 { 112 return ::getCppuType( (const ::rtl::OUString*)0 ); 113 } 114 115 /** 116 * Create a bitmaptable 117 */ 118 uno::Reference< uno::XInterface > SAL_CALL SvxUnoBitmapTable_createInstance( SdrModel* pModel ) 119 { 120 return *new SvxUnoBitmapTable(pModel); 121 } 122 123