Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/fchrfmt.hxx
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
#pragma once
20
21
#include <svl/poolitem.hxx>
22
#include <svl/listener.hxx>
23
#include "format.hxx"
24
#include "charfmt.hxx"
25
26
class SwTextCharFormat;
27
28
/// This pool item subclass can appear in the hint array of a text node. It refers to a character
29
/// style. It's owned by SwTextCharFormat.
30
class SW_DLLPUBLIC SwFormatCharFormat final : public SfxPoolItem, public SvtListener
31
{
32
    friend class SwTextCharFormat;
33
    SwTextCharFormat* m_pTextAttribute;     ///< My text attribute.
34
    SwCharFormat* m_pCharFormat;
35
36
public:
37
    /// single argument ctors shall be explicit.
38
    DECLARE_ITEM_TYPE_FUNCTION(SwFormatCharFormat)
39
    explicit SwFormatCharFormat( SwCharFormat *pFormat );
40
    virtual ~SwFormatCharFormat() override;
41
42
    /// @@@ public copy ctor, but no copy assignment?
43
    SwFormatCharFormat( const SwFormatCharFormat& rAttr );
44
45
private:
46
    virtual void Notify(const SfxHint&) override;
47
48
    /// @@@ public copy ctor, but no copy assignment?
49
    SwFormatCharFormat & operator= (const SwFormatCharFormat &) = delete;
50
public:
51
52
53
    /// "pure virtual methods" of SfxPoolItem
54
    virtual bool            operator==( const SfxPoolItem& ) const override;
55
    virtual SwFormatCharFormat* Clone( SfxItemPool* pPool = nullptr ) const override;
56
    virtual bool GetPresentation( SfxItemPresentation ePres,
57
                                  MapUnit eCoreMetric,
58
                                  MapUnit ePresMetric,
59
                                  OUString &rText,
60
                                  const IntlWrapper&    rIntl ) const override;
61
62
    virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
63
    virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
64
65
    void SetCharFormat( SwCharFormat* pFormat )
66
3.67k
    {
67
3.67k
        assert(!pFormat->IsDefault()); // expose cases that lead to use-after-free
68
3.67k
        EndListeningAll();
69
3.67k
        StartListening(pFormat->GetNotifier());
70
3.67k
        m_pCharFormat = pFormat;
71
3.67k
    }
72
22.8M
    SwCharFormat* GetCharFormat() const { return m_pCharFormat; }
73
74
    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
75
};
76
77
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */