LibreOffice Module svl (master) 1
globalnameitem.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 <com/sun/star/uno/Any.hxx>
21#include <com/sun/star/uno/Sequence.hxx>
22#include <com/sun/star/script/Converter.hpp>
23
24#include <osl/diagnose.h>
25
27
29
31
32
34{
35}
36
37
39: SfxPoolItem( nW ),
40 m_aName( rName )
41{
42}
43
45{
46}
47
49{
50 return SfxPoolItem::operator==(rItem) &&
51 static_cast<const SfxGlobalNameItem&>(rItem).m_aName == m_aName;
52}
53
55{
56 return new SfxGlobalNameItem( *this );
57}
58
59// virtual
60bool SfxGlobalNameItem::PutValue( const css::uno::Any& rVal, sal_uInt8 )
61{
62 css::uno::Reference < css::script::XTypeConverter > xConverter
63 ( css::script::Converter::create( ::comphelper::getProcessComponentContext() ));
64 css::uno::Sequence< sal_Int8 > aSeq;
65 css::uno::Any aNew;
66
67 try { aNew = xConverter->convertTo( rVal, cppu::UnoType<css::uno::Sequence < sal_Int8 >>::get() ); }
68 catch (css::uno::Exception&) {}
69 aNew >>= aSeq;
70 if ( aSeq.getLength() == 16 )
71 {
72 m_aName.MakeFromMemory( aSeq.getConstArray() );
73 return true;
74 }
75
76 OSL_FAIL( "SfxGlobalNameItem::PutValue - Wrong type!" );
77 return true;
78}
79
80// virtual
81bool SfxGlobalNameItem::QueryValue( css::uno::Any& rVal, sal_uInt8 ) const
82{
83 css::uno::Sequence< sal_Int8 > aSeq( 16 );
84 void const * pData = &m_aName.GetCLSID();
85 memcpy( aSeq.getArray(), pData, 16 );
86 rVal <<= aSeq;
87 return true;
88}
89
90/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SfxGlobalNameItem() override
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
static SfxPoolItem * CreateDefault()
virtual SfxGlobalNameItem * Clone(SfxItemPool *pPool=nullptr) const override
virtual bool operator==(const SfxPoolItem &) const override
SvGlobalName m_aName
Base class for providers of defaults of SfxPoolItems.
Definition: itempool.hxx:51
virtual bool operator==(const SfxPoolItem &) const =0
Definition: poolitem.cxx:478
const SvGUID & GetCLSID() const
void MakeFromMemory(void const *pData)
Reference< XTypeConverter > xConverter
Sequence< sal_Int8 > aSeq
std::unique_ptr< sal_Int32[]> pData
OUString m_aName
unsigned char sal_uInt8