Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/inc/uinums.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
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_UINUMS_HXX
20
#define INCLUDED_SW_SOURCE_UIBASE_INC_UINUMS_HXX
21
22
#include <numrule.hxx>
23
#include <swdllapi.h>
24
25
#include <memory>
26
#include <vector>
27
28
class SfxPoolItem;
29
class SwWrtShell;
30
class SvStream;
31
32
namespace sw { class StoredChapterNumberingRules; }
33
34
#define MAX_NUM_RULES 9
35
36
class SW_DLLPUBLIC SwNumRulesWithName final
37
{
38
    UIName maName;
39
    // the NumRule's formats _have_ to be independent of a document
40
    // (They should always be there!)
41
    class SAL_DLLPRIVATE SwNumFormatGlobal
42
    {
43
        friend class SwNumRulesWithName;
44
        SwNumFormat m_aFormat;
45
        UIName m_sCharFormatName;
46
        sal_uInt16 m_nCharPoolId;
47
        std::vector<std::unique_ptr<SfxPoolItem>> m_Items;
48
49
        SwNumFormatGlobal& operator=( const SwNumFormatGlobal& ) = delete;
50
51
    public:
52
        SwNumFormatGlobal( const SwNumFormat& rFormat );
53
        SwNumFormatGlobal( const SwNumFormatGlobal& );
54
        ~SwNumFormatGlobal();
55
56
        SwNumFormat MakeNumFormat(SwWrtShell& rSh) const;
57
    };
58
59
    std::unique_ptr<SwNumFormatGlobal> m_aFormats[ MAXLEVEL ];
60
61
    friend class sw::StoredChapterNumberingRules;
62
    friend class SwChapterNumRules;
63
0
    void SetName(const UIName& rSet) {maName = rSet;}
64
    void SetNumFormat(size_t, SwNumFormat const&, UIName const&);
65
0
    SwNumRulesWithName() = default;
66
67
public:
68
    SwNumRulesWithName(const SwNumRule &, OUString );
69
    SwNumRulesWithName( const SwNumRulesWithName & );
70
    ~SwNumRulesWithName();
71
72
    SwNumRulesWithName &operator=(const SwNumRulesWithName &);
73
74
0
    const UIName& GetName() const               { return maName; }
75
    void ResetNumRule(SwWrtShell& rSh, SwNumRule& ) const;
76
77
    void GetNumFormat(size_t, SwNumFormat const*&, UIName const*&) const;
78
};
79
80
class SW_DLLPUBLIC SwChapterNumRules final
81
{
82
public:
83
    enum { nMaxRules = MAX_NUM_RULES };         // currently 9 defined forms
84
private:
85
    std::unique_ptr<SwNumRulesWithName> m_pNumRules[ MAX_NUM_RULES ];
86
87
    void Init();
88
    void Save();
89
90
public:
91
    SwChapterNumRules();
92
    ~SwChapterNumRules();
93
94
    inline const SwNumRulesWithName*    GetRules(sal_uInt16 nIdx) const;
95
    void CreateEmptyNumRule(sal_uInt16 nIdx); // for import
96
    void ApplyNumRules( const SwNumRulesWithName &rCopy,
97
                        sal_uInt16 nIdx);
98
};
99
100
inline const SwNumRulesWithName *SwChapterNumRules::GetRules(sal_uInt16 nIdx) const
101
0
{
102
    assert(nIdx < nMaxRules);
103
0
    return m_pNumRules[nIdx].get();
104
0
}
105
106
107
namespace sw
108
{
109
110
void ExportStoredChapterNumberingRules(
111
        SwChapterNumRules & rRules, SvStream & rStream, OUString const&);
112
void ImportStoredChapterNumberingRules(
113
        SwChapterNumRules & rRules, SvStream & rStream, OUString const&);
114
115
} // namespace sw
116
117
#endif
118
119
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */