Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sw/inc/fmtftn.hxx
Line
Count
Source (jump to first uncovered line)
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
#ifndef INCLUDED_SW_INC_FMTFTN_HXX
20
#define INCLUDED_SW_INC_FMTFTN_HXX
21
22
#include <rtl/ustring.hxx>
23
#include <cppuhelper/weakref.hxx>
24
#include <svl/poolitem.hxx>
25
#include <unotools/weakref.hxx>
26
#include <com/sun/star/text/XFootnote.hpp>
27
28
#include "swdllapi.h"
29
#include "calbck.hxx"
30
31
class SwDoc;
32
class SwTextFootnote;
33
class SwRootFrame;
34
class SwXFootnote;
35
class SwXTextRange;
36
37
// ATT_FTN
38
39
/// SfxPoolItem subclass for footnotes and endnotes, stored in the anchor text node. The start node
40
/// for the footnote content is defined by m_pTextAttr.
41
class SW_DLLPUBLIC SwFormatFootnote final
42
    : public SfxPoolItem
43
    , public sw::BroadcasterMixin
44
{
45
    friend class SwTextFootnote;
46
    SwTextFootnote* m_pTextAttr;   ///< My TextAttribute.
47
    OUString m_aNumber;     ///< User-defined 'Number'.
48
    sal_uInt16 m_nNumber;   ///< automatic sequence number
49
    sal_uInt16 m_nNumberRLHidden; ///< automatic sequence number (hidden redlines)
50
    bool    m_bEndNote;     ///< Is it an End note?
51
52
    unotools::WeakReference<SwXFootnote> m_wXFootnote;
53
54
    SwFormatFootnote& operator=(const SwFormatFootnote& rFootnote) = delete;
55
    SwFormatFootnote( const SwFormatFootnote& ) = delete;
56
57
public:
58
    DECLARE_ITEM_TYPE_FUNCTION(SwFormatFootnote)
59
    SwFormatFootnote( bool bEndNote = false );
60
    virtual ~SwFormatFootnote() override;
61
62
    /// "Pure virtual methods" of SfxPoolItem.
63
    virtual bool            operator==( const SfxPoolItem& ) const override;
64
    virtual SwFormatFootnote* Clone( SfxItemPool* pPool = nullptr ) const override;
65
66
    void InvalidateFootnote();
67
68
22.3k
    const OUString& GetNumStr() const { return m_aNumber; }
69
3.44k
    sal_uInt16 GetNumber() const { return m_nNumber; }
70
143
    sal_uInt16 GetNumberRLHidden() const { return m_nNumberRLHidden; }
71
77.5k
    bool       IsEndNote() const { return m_bEndNote;}
72
73
0
    void SetNumStr( const OUString& rStr ) { m_aNumber = rStr; }
74
    void SetEndNote( bool b );
75
76
    void SetNumber( const SwFormatFootnote& rFootnote )
77
0
    {
78
0
        m_nNumber = rFootnote.m_nNumber;
79
0
        m_nNumberRLHidden = rFootnote.m_nNumberRLHidden;
80
0
        m_aNumber = rFootnote.m_aNumber;
81
0
    }
82
83
6.19k
    const SwTextFootnote *GetTextFootnote() const   { return m_pTextAttr; }
84
21.9k
          SwTextFootnote *GetTextFootnote()         { return m_pTextAttr; }
85
86
    OUString GetFootnoteText(SwRootFrame const& rLayout) const;
87
88
    /// Returns string to be displayed of footnote / endnote.
89
    OUString GetViewNumStr(const SwDoc& rDoc, SwRootFrame const* pLayout,
90
            bool bInclStrings = false) const;
91
92
    rtl::Reference<SwXTextRange> getAnchor(SwDoc& rDoc) const;
93
94
    unotools::WeakReference<SwXFootnote> const& GetXFootnote() const
95
1.15k
        { return m_wXFootnote; }
96
    void SetXFootnote(rtl::Reference<SwXFootnote> const& xNote);
97
98
    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
99
};
100
101
#endif
102
103
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */