LibreOffice Module svx (master) 1
unobtabl.cxx
Go to the documentation of this file.
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 <svx/xit.hxx>
21#include "UnoNameItemTable.hxx"
22
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>
28
29using namespace ::com::sun::star;
30using namespace ::cppu;
31
32namespace {
33
34class SvxUnoBitmapTable : public SvxUnoNameItemTable
35{
36public:
37 explicit SvxUnoBitmapTable( SdrModel* pModel ) noexcept;
38
39 virtual NameOrIndex* createItem() const override;
40 virtual bool isValid( const NameOrIndex* pItem ) const override;
41
42 // XServiceInfo
43 virtual OUString SAL_CALL getImplementationName( ) override;
44 virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
45
46 // XElementAccess
47 virtual uno::Type SAL_CALL getElementType( ) override;
48};
49
50}
51
52SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) noexcept
54{
55}
56
57bool SvxUnoBitmapTable::isValid( const NameOrIndex* pItem ) const
58{
59 if( SvxUnoNameItemTable::isValid( pItem ) )
60 {
61 const XFillBitmapItem* pBitmapItem = dynamic_cast< const XFillBitmapItem* >( pItem );
62 if( pBitmapItem )
63 {
64 const Graphic& rGraphic = pBitmapItem->GetGraphicObject().GetGraphic();
65
66 return rGraphic.GetSizeBytes() > 0;
67 }
68 }
69
70 return false;
71}
72
73OUString SAL_CALL SvxUnoBitmapTable::getImplementationName()
74{
75 return "SvxUnoBitmapTable";
76}
77
78uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames( )
79{
80 return { "com.sun.star.drawing.BitmapTable" };
81}
82
83NameOrIndex* SvxUnoBitmapTable::createItem() const
84{
85 return new XFillBitmapItem();
86}
87
88// XElementAccess
89uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( )
90{
91 return ::cppu::UnoType<awt::XBitmap>::get();
92}
93
97uno::Reference< uno::XInterface > SvxUnoBitmapTable_createInstance( SdrModel* pModel )
98{
99 return *new SvxUnoBitmapTable(pModel);
100}
101
102/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Graphic & GetGraphic() const
sal_uLong GetSizeBytes() const
virtual bool isValid(const NameOrIndex *pItem) const
virtual NameOrIndex * createItem() const =0
const GraphicObject & GetGraphicObject() const
Definition: xbtmpit.hxx:56
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
uno::Reference< uno::XInterface > SvxUnoBitmapTable_createInstance(SdrModel *pModel)
Create a bitmaptable.
Definition: unobtabl.cxx:97
#define MID_BITMAP
Definition: unomid.hxx:46
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)