From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- svx/source/items/galleryitem.cxx | 140 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 svx/source/items/galleryitem.cxx (limited to 'svx/source/items/galleryitem.cxx') diff --git a/svx/source/items/galleryitem.cxx b/svx/source/items/galleryitem.cxx new file mode 100644 index 000000000..e5c1762c3 --- /dev/null +++ b/svx/source/items/galleryitem.cxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include + + +SfxPoolItem* SvxGalleryItem::CreateDefault() { return new SvxGalleryItem; } + +SvxGalleryItem::SvxGalleryItem() + : m_nType( css::gallery::GalleryItemType::EMPTY ) +{ +} + +SvxGalleryItem::SvxGalleryItem( const SvxGalleryItem &rItem ) + : SfxPoolItem( rItem ) + , m_nType( rItem.m_nType ) + , m_aURL( rItem.m_aURL ) + , m_xDrawing( rItem.m_xDrawing ) + , m_xGraphic( rItem.m_xGraphic ) +{ +} + +SvxGalleryItem::~SvxGalleryItem() +{ +} + +bool SvxGalleryItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /* nMemberId */ ) const +{ + css::uno::Sequence< css::beans::PropertyValue > aSeq( SVXGALLERYITEM_PARAMS ); + + aSeq[0].Name = SVXGALLERYITEM_TYPE; + aSeq[0].Value <<= m_nType; + aSeq[1].Name = SVXGALLERYITEM_URL; + aSeq[1].Value <<= m_aURL; + aSeq[2].Name = SVXGALLERYITEM_FILTER; + aSeq[2].Value <<= m_aURL; + aSeq[3].Name = SVXGALLERYITEM_DRAWING; + aSeq[3].Value <<= m_xDrawing; + aSeq[4].Name = SVXGALLERYITEM_GRAPHIC; + aSeq[4].Value <<= m_xGraphic; + + rVal <<= aSeq; + + return true; +} + +bool SvxGalleryItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /* nMemberId */) +{ + css::uno::Sequence< css::beans::PropertyValue > aSeq; + + if ( !( rVal >>= aSeq ) || ( aSeq.getLength() < SVXGALLERYITEM_PARAMS ) ) + return false; + + int nConverted(0); + bool bAllConverted( true ); + + sal_Int8 nType(0); + OUString aURL, aFilterName; + css::uno::Reference< css::lang::XComponent > xDrawing; + css::uno::Reference< css::graphic::XGraphic > xGraphic; + + for ( const css::beans::PropertyValue& rProp : std::as_const(aSeq) ) + { + if ( rProp.Name == SVXGALLERYITEM_TYPE ) + { + bAllConverted &= ( rProp.Value >>= nType ); + ++nConverted; + } + else if ( rProp.Name == SVXGALLERYITEM_URL ) + { + bAllConverted &= ( rProp.Value >>= aURL ); + ++nConverted; + } + else if ( rProp.Name == SVXGALLERYITEM_FILTER ) + { + bAllConverted &= ( rProp.Value >>= aFilterName ); + ++nConverted; + } + else if ( rProp.Name == SVXGALLERYITEM_DRAWING ) + { + bAllConverted &= ( rProp.Value >>= xDrawing ); + ++nConverted; + } + else if ( rProp.Name == SVXGALLERYITEM_GRAPHIC ) + { + bAllConverted &= ( rProp.Value >>= xGraphic ); + ++nConverted; + } + } + + if ( !bAllConverted || nConverted != SVXGALLERYITEM_PARAMS ) + return false; + + m_nType = nType; + m_aURL = aURL; + m_xDrawing = xDrawing; + m_xGraphic = xGraphic; + + return true; +} + +bool SvxGalleryItem::operator==( const SfxPoolItem& rAttr ) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SvxGalleryItem& rItem = static_cast(rAttr); + + return m_nType == rItem.m_nType && + m_aURL == rItem.m_aURL && + m_xDrawing == rItem.m_xDrawing && + m_xGraphic == rItem.m_xGraphic; +} + +SvxGalleryItem* SvxGalleryItem::Clone( SfxItemPool * ) const +{ + return new SvxGalleryItem( *this ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3