Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sc/inc/docoptio.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
20
#pragma once
21
22
#include <unotools/textsearch.hxx>
23
#include <svl/poolitem.hxx>
24
#include "scdllapi.h"
25
#include "optutil.hxx"
26
27
class SC_DLLPUBLIC ScDocOptions
28
{
29
    double     fIterEps;                // epsilon value dazu
30
    sal_uInt16 nIterCount;              ///< number
31
    sal_uInt16 nPrecStandardFormat;     ///< precision for standard format
32
    sal_uInt16 nDay;                    ///< Null date:
33
    sal_uInt16 nMonth;
34
    sal_uInt16 nYear;
35
    sal_uInt16 nYear2000;               ///< earlier 19YY is assumed, 20YY otherwise (if only YY of year is given)
36
    sal_uInt16 nTabDistance;            ///< distance of standard tabs
37
    mutable utl::SearchParam::SearchType eFormulaSearchType; ///< wildcards or regular expressions or normal search
38
    bool       bIsIgnoreCase;           ///< ignore case for comparisons?
39
    bool       bIsIter;                 ///< iterations for circular refs
40
    bool       bCalcAsShown;            ///< calculate as shown (wrt precision)
41
    bool       bMatchWholeCell;         ///< search criteria must match the whole cell
42
    bool       bLookUpColRowNames;      ///< determine column-/row titles automagically
43
    mutable bool bFormulaRegexEnabled;    ///< regular expressions in formulas enabled, only when reading settings
44
    mutable bool bFormulaWildcardsEnabled;///< wildcards in formulas enabled, only when reading settings
45
    bool       bWriteCalcConfig;        ///< (subset of) Calc config will be written to user's profile
46
47
public:
48
                ScDocOptions();
49
50
1.91M
    bool   IsLookUpColRowNames() const       { return bLookUpColRowNames; }
51
165k
    void   SetLookUpColRowNames( bool bVal ) { bLookUpColRowNames = bVal; }
52
22.5k
    bool   IsMatchWholeCell() const         { return bMatchWholeCell; }
53
20.1k
    void   SetMatchWholeCell( bool bVal )   { bMatchWholeCell = bVal; }
54
344k
    bool   IsIgnoreCase() const             { return bIsIgnoreCase; }
55
39.9k
    void   SetIgnoreCase( bool bVal )       { bIsIgnoreCase = bVal; }
56
20.2k
    bool   IsIter() const                   { return bIsIter; }
57
30.0k
    void   SetIter( bool bVal )             { bIsIter = bVal; }
58
0
    sal_uInt16 GetIterCount() const         { return nIterCount; }
59
28.4k
    void   SetIterCount( sal_uInt16 nCount) { nIterCount = nCount; }
60
0
    double GetIterEps() const               { return fIterEps; }
61
32.4k
    void   SetIterEps( double fEps )        { fIterEps = fEps; }
62
63
    void   GetDate( sal_uInt16& rD, sal_uInt16& rM, sal_Int16& rY ) const
64
213k
                                        { rD = nDay; rM = nMonth; rY = nYear;}
65
    void   SetDate (sal_uInt16 nD, sal_uInt16 nM, sal_Int16 nY)
66
39.9k
                                        { nDay = nD; nMonth = nM; nYear = nY; }
67
21.4k
    sal_uInt16 GetTabDistance() const { return nTabDistance;}
68
2.87k
    void   SetTabDistance( sal_uInt16 nTabDist ) {nTabDistance = nTabDist;}
69
70
    void        ResetDocOptions();
71
72
    inline bool                 operator==( const ScDocOptions& rOpt ) const;
73
    inline bool                 operator!=( const ScDocOptions& rOpt ) const;
74
75
213k
    sal_uInt16  GetStdPrecision() const         { return nPrecStandardFormat; }
76
0
    void        SetStdPrecision( sal_uInt16 n ) { nPrecStandardFormat = n; }
77
78
1.71M
    bool    IsCalcAsShown() const           { return bCalcAsShown; }
79
27.2k
    void    SetCalcAsShown( bool bVal )     { bCalcAsShown = bVal; }
80
81
20.1k
    void    SetYear2000( sal_uInt16 nVal )  { nYear2000 = nVal; }
82
213k
    sal_uInt16  GetYear2000() const         { return nYear2000; }
83
84
    utl::SearchParam::SearchType GetFormulaSearchType() const
85
4.84k
    {
86
4.84k
        if (eFormulaSearchType == utl::SearchParam::SearchType::Unknown || (bFormulaRegexEnabled && bFormulaWildcardsEnabled))
87
0
            eFormulaSearchType = utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled, bFormulaRegexEnabled);
88
4.84k
        return eFormulaSearchType;
89
4.84k
    }
90
91
    void    SetFormulaRegexEnabled( bool bVal );
92
0
    bool    IsFormulaRegexEnabled() const       { return GetFormulaSearchType() == utl::SearchParam::SearchType::Regexp; }
93
94
    void    SetFormulaWildcardsEnabled( bool bVal );
95
0
    bool    IsFormulaWildcardsEnabled() const   { return GetFormulaSearchType() == utl::SearchParam::SearchType::Wildcard; }
96
97
0
    void    SetWriteCalcConfig( bool bVal ) { bWriteCalcConfig = bVal; }
98
0
    bool    IsWriteCalcConfig() const       { return bWriteCalcConfig; }
99
};
100
101
inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
102
272k
{
103
272k
    return (
104
272k
                rOpt.bIsIgnoreCase          == bIsIgnoreCase
105
272k
            &&  rOpt.bIsIter                == bIsIter
106
272k
            &&  rOpt.nIterCount             == nIterCount
107
272k
            &&  rOpt.fIterEps               == fIterEps
108
272k
            &&  rOpt.nPrecStandardFormat    == nPrecStandardFormat
109
272k
            &&  rOpt.nDay                   == nDay
110
272k
            &&  rOpt.nMonth                 == nMonth
111
272k
            &&  rOpt.nYear                  == nYear
112
272k
            &&  rOpt.nYear2000              == nYear2000
113
272k
            &&  rOpt.nTabDistance           == nTabDistance
114
272k
            &&  rOpt.bCalcAsShown           == bCalcAsShown
115
272k
            &&  rOpt.bMatchWholeCell        == bMatchWholeCell
116
272k
            &&  rOpt.bLookUpColRowNames     == bLookUpColRowNames
117
272k
            &&  rOpt.bFormulaRegexEnabled   == bFormulaRegexEnabled
118
272k
            &&  rOpt.bFormulaWildcardsEnabled == bFormulaWildcardsEnabled
119
272k
            &&  rOpt.eFormulaSearchType     == eFormulaSearchType
120
272k
            &&  rOpt.bWriteCalcConfig       == bWriteCalcConfig
121
272k
            );
122
272k
}
123
124
inline bool ScDocOptions::operator!=( const ScDocOptions& rOpt ) const
125
272k
{
126
272k
    return !(operator==(rOpt));
127
272k
}
128
129
// Item for preferences dialog - calculation
130
131
class SC_DLLPUBLIC ScTpCalcItem final : public SfxPoolItem
132
{
133
public:
134
                ScTpCalcItem( sal_uInt16 nWhich,
135
                              const ScDocOptions& rOpt );
136
                virtual ~ScTpCalcItem() override;
137
138
    DECLARE_ITEM_TYPE_FUNCTION(ScTpCalcItem)
139
0
    ScTpCalcItem(ScTpCalcItem const &) = default;
140
    ScTpCalcItem(ScTpCalcItem &&) = default;
141
    ScTpCalcItem & operator =(ScTpCalcItem const &) = delete; // due to SfxPoolItem
142
    ScTpCalcItem & operator =(ScTpCalcItem &&) = delete; // due to SfxPoolItem
143
144
    virtual bool            operator==( const SfxPoolItem& ) const override;
145
    virtual ScTpCalcItem*   Clone( SfxItemPool *pPool = nullptr ) const override;
146
147
0
    const ScDocOptions& GetDocOptions() const { return theOptions; }
148
149
private:
150
    ScDocOptions theOptions;
151
};
152
153
//  Config Item containing document options
154
155
class ScDocCfg : public ScDocOptions
156
{
157
    ScLinkConfigItem    aCalcItem;
158
    ScLinkConfigItem    aLayoutItem;
159
160
    DECL_LINK( CalcCommitHdl, ScLinkConfigItem&, void );
161
    DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void );
162
163
    static css::uno::Sequence<OUString> GetCalcPropertyNames();
164
    static css::uno::Sequence<OUString> GetLayoutPropertyNames();
165
166
public:
167
            ScDocCfg();
168
169
    void    SetOptions( const ScDocOptions& rNew );
170
};
171
172
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */