Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/TableAutoFmt.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/itemprop.hxx>
22
#include <i18nlangtag/lang.h>
23
#include <svx/autoformathelper.hxx>
24
#include <bitset>
25
26
namespace Autoformat
27
{
28
enum PropertyIndex : sal_uInt8
29
{
30
    PROP_FONT = 0,
31
    PROP_HEIGHT,
32
    PROP_WEIGHT,
33
    PROP_POSTURE,
34
    PROP_CJK_FONT,
35
    PROP_CJK_HEIGHT,
36
    PROP_CJK_WEIGHT,
37
    PROP_CJK_POSTURE,
38
    PROP_CTL_FONT,
39
    PROP_CTL_HEIGHT,
40
    PROP_CTL_WEIGHT,
41
    PROP_CTL_POSTURE,
42
    PROP_UNDERLINE,
43
    PROP_COLOR,
44
    PROP_BOX,
45
    PROP_BACKGROUND,
46
    PROP_HOR_JUSTIFY,
47
    PROP_VER_JUSTIFY,
48
    PROP_PADDING,
49
    PROP_COUNT
50
};
51
52
enum Elements : sal_uInt8
53
{
54
    FIRST_ROW = 0,
55
    LAST_ROW,
56
    FIRST_COL,
57
    LAST_COL,
58
    BODY,
59
    EVEN_ROW,
60
    ODD_ROW,
61
    EVEN_COL,
62
    ODD_COL,
63
    BACKGROUND,
64
    FIRST_ROW_EVEN_COL,
65
    LAST_ROW_EVEN_COL,
66
    FIRST_ROW_END_COL,
67
    FIRST_ROW_START_COL,
68
    LAST_ROW_END_COL,
69
    LAST_ROW_START_COL,
70
    ELEMENT_COUNT
71
};
72
}
73
74
using namespace Autoformat;
75
76
class SVX_DLLPUBLIC SvxAutoFormatDataField : public AutoFormatBase
77
{
78
private:
79
    // number format
80
    rtl::OUString maNumFormatString;
81
    LanguageType meSysLanguage;
82
    LanguageType meNumFormatLanguage;
83
84
    std::bitset<Autoformat::PROP_COUNT> mSetProperties;
85
86
public:
87
    SvxAutoFormatDataField(const AutoFormatWhichIds& rIds);
88
    SvxAutoFormatDataField(const SvxAutoFormatDataField& rCopy);
89
90
4.17k
    virtual ~SvxAutoFormatDataField() = default;
91
92
    void GetValueFormat(OUString& rFormat, LanguageType& rLng, LanguageType& rSys) const;
93
2.08k
    const OUString& GetNumFormatString() const noexcept { return maNumFormatString; }
94
2.08k
    const LanguageType& GetSysLanguage() const noexcept { return meSysLanguage; }
95
2.08k
    const LanguageType& GetNumFormatLanguage() const noexcept { return meNumFormatLanguage; }
96
97
    void SetValueFormat(const OUString& rFormat, LanguageType eLng, LanguageType eSys);
98
2.08k
    void SetNumFormatString(const OUString& rNew) { maNumFormatString = rNew; }
99
4.17k
    void SetSysLanguage(const LanguageType& rNew) noexcept { meSysLanguage = rNew; }
100
4.17k
    void SetNumFormatLanguage(const LanguageType& rNew) noexcept { meNumFormatLanguage = rNew; }
101
102
    bool IsPropertySet(PropertyIndex prop) const noexcept
103
0
    {
104
0
        return prop < PROP_COUNT && mSetProperties[prop];
105
0
    }
106
    void SetPropertyFlag(PropertyIndex prop, bool set = true) noexcept
107
6.64k
    {
108
6.64k
        if (prop < PROP_COUNT)
109
6.64k
            mSetProperties[prop] = set;
110
6.64k
    }
111
0
    const std::bitset<PROP_COUNT>& GetPropertySet() const { return mSetProperties; }
112
0
    void SetPropertySet(std::bitset<PROP_COUNT> aSet) { mSetProperties = aSet; }
113
};
114
115
class SVX_DLLPUBLIC SvxAutoFormatData
116
{
117
private:
118
    OUString maName;
119
120
    // Common flags of Calc and Writer.
121
    bool mbInclFont : 1;
122
    bool mbInclJustify : 1;
123
    bool mbInclFrame : 1;
124
    bool mbInclBackground : 1;
125
    // Calc specific flags
126
    bool mbInclValueFormat : 1;
127
    bool mbInclWidthHeight : 1;
128
129
    bool mbUseFirstRowStyles : 1;
130
    bool mbUseLastRowStyles : 1;
131
    bool mbUseFirstColStyles : 1;
132
    bool mbUseLastColStyles : 1;
133
    bool mbUseBandedRowStyles : 1;
134
    bool mbUseBandedColStyles : 1;
135
136
    OUString maParent;
137
138
public:
139
    SvxAutoFormatData();
140
    SvxAutoFormatData(const SvxAutoFormatData& rData);
141
0
    virtual ~SvxAutoFormatData() = default;
142
143
0
    bool IsFont() const noexcept { return mbInclFont; }
144
0
    bool IsJustify() const noexcept { return mbInclJustify; }
145
0
    bool IsFrame() const noexcept { return mbInclFrame; }
146
0
    bool IsBackground() const noexcept { return mbInclBackground; }
147
0
    bool IsValueFormat() const noexcept { return mbInclValueFormat; }
148
0
    bool IsWidthHeight() const noexcept { return mbInclWidthHeight; }
149
150
0
    bool UseFirstRowStyles() const noexcept { return mbUseFirstRowStyles; }
151
0
    bool UseLastRowStyles() const noexcept { return mbUseLastRowStyles; }
152
0
    bool UseFirstColStyles() const noexcept { return mbUseFirstColStyles; }
153
0
    bool UseLastColStyles() const noexcept { return mbUseLastColStyles; }
154
0
    bool UseBandedRowStyles() const noexcept { return mbUseBandedRowStyles; }
155
0
    bool UseBandedColStyles() const noexcept { return mbUseBandedColStyles; }
156
157
0
    void SetFont(const bool bNew) noexcept { mbInclFont = bNew; }
158
0
    void SetJustify(const bool bNew) noexcept { mbInclJustify = bNew; }
159
0
    void SetFrame(const bool bNew) noexcept { mbInclFrame = bNew; }
160
0
    void SetBackground(const bool bNew) noexcept { mbInclBackground = bNew; }
161
0
    void SetValueFormat(const bool bNew) noexcept { mbInclValueFormat = bNew; }
162
0
    void SetWidthHeight(const bool bNew) noexcept { mbInclWidthHeight = bNew; }
163
0
    void SetParent(const OUString& rParentName) { maParent = rParentName; }
164
165
0
    void SetUseFirstRowStyles(const bool bNew) noexcept { mbUseFirstRowStyles = bNew; }
166
0
    void SetUseFirstColStyles(const bool bNew) noexcept { mbUseFirstColStyles = bNew; }
167
0
    void SetUseLastRowStyles(const bool bNew) noexcept { mbUseLastRowStyles = bNew; }
168
0
    void SetUseLastColStyles(const bool bNew) noexcept { mbUseLastColStyles = bNew; }
169
0
    void SetUseBandedRowStyles(const bool bNew) noexcept { mbUseBandedRowStyles = bNew; }
170
0
    void SetUseBandedColStyles(const bool bNew) noexcept { mbUseBandedColStyles = bNew; }
171
172
0
    const OUString& GetName() const noexcept { return maName; }
173
0
    const OUString& GetParent() const noexcept { return maParent; }
174
175
0
    virtual void SetName(const OUString& rName) { maName = rName; }
176
    virtual SvxAutoFormatDataField* GetField(size_t nIndex) = 0;
177
    virtual const SvxAutoFormatDataField* GetField(size_t nIndex) const = 0;
178
    virtual SvxAutoFormatDataField* GetDefaultField() const = 0;
179
    virtual bool SetField(size_t nIndex, const SvxAutoFormatDataField& aField) = 0;
180
    virtual SvxAutoFormatData* MakeCopy() const = 0;
181
182
    void FillToItemSet(size_t nIndex, SfxItemSet& rItemSet) const;
183
    void MergeStyle(const SvxAutoFormatData& pData);
184
    void ResetAutoFormat(SvxAutoFormatData& pOld);
185
186
    SvxAutoFormatData& operator=(const SvxAutoFormatData& rCopy);
187
};
188
189
class SVX_DLLPUBLIC SvxAutoFormat
190
{
191
public:
192
    virtual ~SvxAutoFormat();
193
194
    virtual const SvxAutoFormatData* GetData(size_t nIndex) const = 0;
195
    virtual SvxAutoFormatData* GetData(size_t nIndex) = 0;
196
    virtual bool InsertAutoFormat(SvxAutoFormatData* pFormat) = 0;
197
    virtual SvxAutoFormatData* ReleaseAutoFormat(const OUString& rName) = 0;
198
    virtual SvxAutoFormatData* FindAutoFormat(const OUString& rName) const = 0;
199
    virtual SvxAutoFormatData* GetDefaultData() = 0;
200
    virtual SvxAutoFormatDataField* GetDefaultField() = 0;
201
    virtual const SvxAutoFormatData* GetResolvedStyle(const SvxAutoFormatData* pData) const = 0;
202
    virtual size_t size() const = 0;
203
    void ResetParent(std::u16string_view rName);
204
205
    /** Translate built-in table style names between programmatic name and localized UI name. */
206
    static OUString MapProgToUIName(std::u16string_view rProgName);
207
    static OUString MapUIToProgName(std::u16string_view rUIName);
208
209
    static const SfxItemPropertySet& GetTablePropertySet();
210
211
    bool Load(bool bWriter);
212
    bool Save();
213
};
214
215
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */