xref: /aoo41x/main/svx/source/unodraw/unobtabl.cxx (revision f6e50924)
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 
62 SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw()
63 : SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_GRAFURL )
64 {
65 }
66 
67 SvxUnoBitmapTable::~SvxUnoBitmapTable() throw()
68 {
69 }
70 
71 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 GraphicObject& rGraphic = pBitmapItem->GetBitmapValue().GetGraphicObject();
79 			return rGraphic.GetSizeBytes() > 0;
80 		}
81 	}
82 
83 	return false;
84 }
85 
86 OUString SAL_CALL SvxUnoBitmapTable::getImplementationName() throw( uno::RuntimeException )
87 {
88 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoBitmapTable") );
89 }
90 
91 uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames(  )
92 	throw( uno::RuntimeException )
93 {
94     uno::Sequence< OUString > aSNS( 1 );
95     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable" ));
96     return aSNS;
97 }
98 
99 NameOrIndex* SvxUnoBitmapTable::createItem() const throw()
100 {
101 	return new XFillBitmapItem();
102 }
103 
104 // XElementAccess
105 uno::Type SAL_CALL SvxUnoBitmapTable::getElementType(  )
106 	throw( uno::RuntimeException )
107 {
108 	return ::getCppuType( (const ::rtl::OUString*)0 );
109 }
110 
111 /**
112  * Create a bitmaptable
113  */
114 uno::Reference< uno::XInterface > SAL_CALL SvxUnoBitmapTable_createInstance( SdrModel* pModel )
115 {
116 	return *new SvxUnoBitmapTable(pModel);
117 }
118 
119