xref: /trunk/main/svx/source/unodraw/unobtabl.cxx (revision 70d3707a)
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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <svl/itempool.hxx>
27 #include <vcl/cvtgrf.hxx>
28 #include <svl/itemset.hxx>
29 #include <svx/xit.hxx>
30 #include "UnoNameItemTable.hxx"
31 
32 #include <svx/xbtmpit.hxx>
33 #include <svx/svdmodel.hxx>
34 #include <svx/xflhtit.hxx>
35 #include "svx/unoapi.hxx"
36 #include <svx/unomid.hxx>
37 #include <editeng/unoprnms.hxx>
38 #include "svx/unofill.hxx"
39 #include <editeng/memberids.hrc>
40 
41 using namespace ::com::sun::star;
42 using namespace ::rtl;
43 using namespace ::cppu;
44 
45 class SvxUnoBitmapTable : public SvxUnoNameItemTable
46 {
47 public:
48 	SvxUnoBitmapTable( SdrModel* pModel ) throw();
49 	virtual	~SvxUnoBitmapTable() throw();
50 
51 	virtual NameOrIndex* createItem() const throw();
52 	virtual bool isValid( const NameOrIndex* pItem ) const;
53 
54     // XServiceInfo
55     virtual OUString SAL_CALL getImplementationName(  ) throw( uno::RuntimeException );
56     virtual uno::Sequence<  OUString > SAL_CALL getSupportedServiceNames(  ) throw( uno::RuntimeException);
57 
58 	// XElementAccess
59     virtual uno::Type SAL_CALL getElementType(  ) throw( uno::RuntimeException);
60 };
61 
SvxUnoBitmapTable(SdrModel * pModel)62 SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw()
63 : SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_GRAFURL )
64 {
65 }
66 
~SvxUnoBitmapTable()67 SvxUnoBitmapTable::~SvxUnoBitmapTable() throw()
68 {
69 }
70 
isValid(const NameOrIndex * pItem) const71 bool SvxUnoBitmapTable::isValid( const NameOrIndex* pItem ) const
72 {
73 	if( SvxUnoNameItemTable::isValid( pItem ) )
74 	{
75 		const XFillBitmapItem* pBitmapItem = dynamic_cast< const XFillBitmapItem* >( pItem );
76 		if( pBitmapItem )
77 		{
78 			const Graphic& rGraphic = pBitmapItem->GetGraphicObject().GetGraphic();
79 
80             return rGraphic.GetSizeBytes() > 0;
81 		}
82 	}
83 
84 	return false;
85 }
86 
getImplementationName()87 OUString SAL_CALL SvxUnoBitmapTable::getImplementationName() throw( uno::RuntimeException )
88 {
89 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoBitmapTable") );
90 }
91 
getSupportedServiceNames()92 uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames(  )
93 	throw( uno::RuntimeException )
94 {
95     uno::Sequence< OUString > aSNS( 1 );
96     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable" ));
97     return aSNS;
98 }
99 
createItem() const100 NameOrIndex* SvxUnoBitmapTable::createItem() const throw()
101 {
102 	return new XFillBitmapItem();
103 }
104 
105 // XElementAccess
getElementType()106 uno::Type SAL_CALL SvxUnoBitmapTable::getElementType(  )
107 	throw( uno::RuntimeException )
108 {
109 	return ::getCppuType( (const ::rtl::OUString*)0 );
110 }
111 
112 /**
113  * Create a bitmaptable
114  */
SvxUnoBitmapTable_createInstance(SdrModel * pModel)115 uno::Reference< uno::XInterface > SAL_CALL SvxUnoBitmapTable_createInstance( SdrModel* pModel )
116 {
117 	return *new SvxUnoBitmapTable(pModel);
118 }
119 
120