Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / unodraw / unobtabl.cxx
blob0b3dae21f2d40586dd1ef61f53c5838c19f4f918
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/xit.hxx>
21 #include "UnoNameItemTable.hxx"
23 #include <svx/xbtmpit.hxx>
24 #include <svx/svdmodel.hxx>
25 #include <svx/unomid.hxx>
26 #include <svx/unofill.hxx>
27 #include <com/sun/star/awt/XBitmap.hpp>
29 using namespace ::com::sun::star;
30 using namespace ::cppu;
32 namespace {
34 class SvxUnoBitmapTable : public SvxUnoNameItemTable
36 public:
37 explicit SvxUnoBitmapTable( SdrModel* pModel ) throw();
39 virtual NameOrIndex* createItem() const override;
40 virtual bool isValid( const NameOrIndex* pItem ) const override;
42 // XServiceInfo
43 virtual OUString SAL_CALL getImplementationName( ) override;
44 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
46 // XElementAccess
47 virtual uno::Type SAL_CALL getElementType( ) override;
52 SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw()
53 : SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_BITMAP )
57 bool SvxUnoBitmapTable::isValid( const NameOrIndex* pItem ) const
59 if( SvxUnoNameItemTable::isValid( pItem ) )
61 const XFillBitmapItem* pBitmapItem = dynamic_cast< const XFillBitmapItem* >( pItem );
62 if( pBitmapItem )
64 const Graphic& rGraphic = pBitmapItem->GetGraphicObject().GetGraphic();
66 return rGraphic.GetSizeBytes() > 0;
70 return false;
73 OUString SAL_CALL SvxUnoBitmapTable::getImplementationName()
75 return "SvxUnoBitmapTable";
78 uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames( )
80 return { "com.sun.star.drawing.BitmapTable" };
83 NameOrIndex* SvxUnoBitmapTable::createItem() const
85 return new XFillBitmapItem();
88 // XElementAccess
89 uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( )
91 return ::cppu::UnoType<awt::XBitmap>::get();
94 /**
95 * Create a bitmaptable
97 uno::Reference< uno::XInterface > SvxUnoBitmapTable_createInstance( SdrModel* pModel )
99 return *new SvxUnoBitmapTable(pModel);
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */