Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svl/source/items/globalnameitem.cxx
Line
Count
Source
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
26
#include <comphelper/processfactory.hxx>
27
28
#include <svl/globalnameitem.hxx>
29
30
0
SfxPoolItem* SfxGlobalNameItem::CreateDefault() { return new SfxGlobalNameItem; }
31
32
33
SfxGlobalNameItem::SfxGlobalNameItem() :
34
0
    SfxPoolItem(0)
35
0
{
36
0
}
37
38
39
SfxGlobalNameItem::SfxGlobalNameItem( sal_uInt16 nW, const SvGlobalName& rName )
40
0
:   SfxPoolItem( nW ),
41
0
    m_aName( rName )
42
0
{
43
0
}
44
45
SfxGlobalNameItem::~SfxGlobalNameItem()
46
0
{
47
0
}
48
49
bool SfxGlobalNameItem::operator==( const SfxPoolItem& rItem ) const
50
0
{
51
0
    return SfxPoolItem::operator==(rItem) &&
52
0
        static_cast<const SfxGlobalNameItem&>(rItem).m_aName == m_aName;
53
0
}
54
55
SfxGlobalNameItem* SfxGlobalNameItem::Clone(SfxItemPool *) const
56
0
{
57
0
    return new SfxGlobalNameItem( *this );
58
0
}
59
60
// virtual
61
bool SfxGlobalNameItem::PutValue( const css::uno::Any& rVal, sal_uInt8 )
62
0
{
63
0
    css::uno::Reference < css::script::XTypeConverter > xConverter
64
0
            ( css::script::Converter::create( ::comphelper::getProcessComponentContext() ));
65
0
    css::uno::Sequence< sal_Int8 > aSeq;
66
0
    css::uno::Any aNew;
67
68
0
    try { aNew = xConverter->convertTo( rVal, cppu::UnoType<css::uno::Sequence < sal_Int8 >>::get() ); }
69
0
    catch (css::uno::Exception&) {}
70
0
    aNew >>= aSeq;
71
0
    if ( aSeq.getLength() == 16 )
72
0
    {
73
0
        m_aName.MakeFromMemory( aSeq.getConstArray() );
74
0
        return true;
75
0
    }
76
77
0
    OSL_FAIL( "SfxGlobalNameItem::PutValue - Wrong type!" );
78
0
    return true;
79
0
}
80
81
// virtual
82
bool SfxGlobalNameItem::QueryValue( css::uno::Any& rVal, sal_uInt8 ) const
83
0
{
84
0
    css::uno::Sequence< sal_Int8 > aSeq( 16 );
85
0
    void const * pData = &m_aName.GetCLSID();
86
0
    memcpy( aSeq.getArray(), pData, 16 );
87
0
    rVal <<= aSeq;
88
0
    return true;
89
0
}
90
91
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */