Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svl/itempool.hxx>
21 : #include <vcl/cvtgrf.hxx>
22 : #include <svl/itemset.hxx>
23 : #include <svx/xit.hxx>
24 : #include "UnoNameItemTable.hxx"
25 :
26 : #include <svx/xbtmpit.hxx>
27 : #include <svx/svdmodel.hxx>
28 : #include <svx/xflhtit.hxx>
29 : #include "svx/unoapi.hxx"
30 : #include <svx/unomid.hxx>
31 : #include <editeng/unoprnms.hxx>
32 : #include "svx/unofill.hxx"
33 : #include <editeng/memberids.hrc>
34 :
35 : using namespace ::com::sun::star;
36 : using namespace ::rtl;
37 : using namespace ::cppu;
38 :
39 : class SvxUnoBitmapTable : public SvxUnoNameItemTable
40 : {
41 : public:
42 : SvxUnoBitmapTable( SdrModel* pModel ) throw();
43 : virtual ~SvxUnoBitmapTable() throw();
44 :
45 : virtual NameOrIndex* createItem() const throw() SAL_OVERRIDE;
46 : virtual bool isValid( const NameOrIndex* pItem ) const SAL_OVERRIDE;
47 :
48 : // XServiceInfo
49 : virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
50 : virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
51 :
52 : // XElementAccess
53 : virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException, std::exception) SAL_OVERRIDE;
54 : };
55 :
56 0 : SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw()
57 0 : : SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_GRAFURL )
58 : {
59 0 : }
60 :
61 0 : SvxUnoBitmapTable::~SvxUnoBitmapTable() throw()
62 : {
63 0 : }
64 :
65 0 : bool SvxUnoBitmapTable::isValid( const NameOrIndex* pItem ) const
66 : {
67 0 : if( SvxUnoNameItemTable::isValid( pItem ) )
68 : {
69 0 : const XFillBitmapItem* pBitmapItem = dynamic_cast< const XFillBitmapItem* >( pItem );
70 0 : if( pBitmapItem )
71 : {
72 0 : const Graphic& rGraphic = pBitmapItem->GetGraphicObject().GetGraphic();
73 :
74 0 : return rGraphic.GetSizeBytes() > 0;
75 : }
76 : }
77 :
78 0 : return false;
79 : }
80 :
81 0 : OUString SAL_CALL SvxUnoBitmapTable::getImplementationName() throw( uno::RuntimeException, std::exception )
82 : {
83 0 : return OUString("SvxUnoBitmapTable");
84 : }
85 :
86 0 : uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames( )
87 : throw( uno::RuntimeException, std::exception )
88 : {
89 0 : uno::Sequence< OUString > aSNS( 1 );
90 0 : aSNS[0] = "com.sun.star.drawing.BitmapTable";
91 0 : return aSNS;
92 : }
93 :
94 0 : NameOrIndex* SvxUnoBitmapTable::createItem() const throw()
95 : {
96 0 : return new XFillBitmapItem();
97 : }
98 :
99 : // XElementAccess
100 0 : uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( )
101 : throw( uno::RuntimeException, std::exception )
102 : {
103 0 : return ::getCppuType( (const OUString*)0 );
104 : }
105 :
106 : /**
107 : * Create a bitmaptable
108 : */
109 0 : uno::Reference< uno::XInterface > SAL_CALL SvxUnoBitmapTable_createInstance( SdrModel* pModel )
110 : {
111 0 : return *new SvxUnoBitmapTable(pModel);
112 : }
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|