1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_FMTFTN_HXX
20 #define INCLUDED_SW_INC_FMTFTN_HXX
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>
31 namespace com::sun::star::text
{
43 /// SfxPoolItem subclass for footnotes and endnotes, stored in the anchor text node. The start node
44 /// for the footnote content is defined by m_pTextAttr.
45 class SW_DLLPUBLIC SwFormatFootnote final
47 , public sw::BroadcastingModify
49 friend class SwTextFootnote
;
50 SwTextFootnote
* m_pTextAttr
; ///< My TextAttribute.
51 OUString m_aNumber
; ///< User-defined 'Number'.
52 sal_uInt16 m_nNumber
; ///< automatic sequence number
53 sal_uInt16 m_nNumberRLHidden
; ///< automatic sequence number (hidden redlines)
54 bool m_bEndNote
; ///< Is it an End note?
56 unotools::WeakReference
<SwXFootnote
> m_wXFootnote
;
58 SwFormatFootnote
& operator=(const SwFormatFootnote
& rFootnote
) = delete;
59 SwFormatFootnote( const SwFormatFootnote
& ) = delete;
62 SwFormatFootnote( bool bEndNote
= false );
63 virtual ~SwFormatFootnote() override
;
65 /// "Pure virtual methods" of SfxPoolItem.
66 virtual bool operator==( const SfxPoolItem
& ) const override
;
67 virtual SwFormatFootnote
* Clone( SfxItemPool
* pPool
= nullptr ) const override
;
69 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
71 void InvalidateFootnote();
73 const OUString
& GetNumStr() const { return m_aNumber
; }
74 sal_uInt16
GetNumber() const { return m_nNumber
; }
75 sal_uInt16
GetNumberRLHidden() const { return m_nNumberRLHidden
; }
76 bool IsEndNote() const { return m_bEndNote
;}
78 void SetNumStr( const OUString
& rStr
) { m_aNumber
= rStr
; }
79 void SetEndNote( bool b
);
81 void SetNumber( const SwFormatFootnote
& rFootnote
)
83 m_nNumber
= rFootnote
.m_nNumber
;
84 m_nNumberRLHidden
= rFootnote
.m_nNumberRLHidden
;
85 m_aNumber
= rFootnote
.m_aNumber
;
88 const SwTextFootnote
*GetTextFootnote() const { return m_pTextAttr
; }
89 SwTextFootnote
*GetTextFootnote() { return m_pTextAttr
; }
91 OUString
GetFootnoteText(SwRootFrame
const& rLayout
) const;
93 /// Returns string to be displayed of footnote / endnote.
94 OUString
GetViewNumStr(const SwDoc
& rDoc
, SwRootFrame
const* pLayout
,
95 bool bInclStrings
= false) const;
97 rtl::Reference
<SwXTextRange
> getAnchor(SwDoc
& rDoc
) const;
99 unotools::WeakReference
<SwXFootnote
> const& GetXFootnote() const
100 { return m_wXFootnote
; }
101 void SetXFootnote(rtl::Reference
<SwXFootnote
> const& xNote
);
103 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */