Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/cellatr.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
20
#pragma once
21
22
#include <svl/intitem.hxx>
23
#include <svl/zforlist.hxx>
24
#include "swdllapi.h"
25
#include "format.hxx"
26
#include "hintids.hxx"
27
#include "cellfml.hxx"
28
#include "node.hxx"
29
30
class SwHistory;
31
32
/** The number formatter's default locale's @ Text format.
33
    Not necessarily system locale, but the locale the formatter was constructed
34
    with. For this SvNumberFormatter::IsTextFormat() always returns true.
35
 */
36
1.01M
constexpr sal_uInt32 getSwDefaultTextFormat() { return NF_STANDARD_FORMAT_TEXT; }
37
38
class SW_DLLPUBLIC SwTableBoxNumFormat final : public SfxUInt32Item
39
{
40
public:
41
    DECLARE_ITEM_TYPE_FUNCTION(SwTableBoxNumFormat)
42
    SwTableBoxNumFormat( sal_uInt32 nFormat = getSwDefaultTextFormat() );
43
44
    // "pure virtual methods" of SfxPoolItem
45
    virtual bool            operator==( const SfxPoolItem& ) const override;
46
    virtual SwTableBoxNumFormat* Clone( SfxItemPool* pPool = nullptr ) const override;
47
48
    SwTableBoxNumFormat& operator=( const SwTableBoxNumFormat& rAttr )
49
0
    {
50
0
        SetValue( rAttr.GetValue() );
51
0
        return *this;
52
0
    }
53
};
54
55
class SW_DLLPUBLIC SwTableBoxFormula final : public SfxPoolItem, public SwTableFormula
56
{
57
    sw::BroadcastingModify* m_pDefinedIn;   // Modify object where the formula is located
58
                            // can only be TableBoxFormat
59
60
public:
61
    DECLARE_ITEM_TYPE_FUNCTION(SwTableBoxFormula)
62
    SwTableBoxFormula( const OUString& rFormula );
63
64
    // "pure virtual methods" of SfxPoolItem
65
    virtual bool            operator==( const SfxPoolItem& ) const override;
66
    virtual SwTableBoxFormula* Clone( SfxItemPool* pPool = nullptr ) const override;
67
68
801
    const sw::BroadcastingModify* GetDefinedIn() const { return m_pDefinedIn; }
69
    void ChgDefinedIn( const sw::BroadcastingModify* pNew )
70
399
                                            { m_pDefinedIn = const_cast<sw::BroadcastingModify*>(pNew); }
71
    //  BoxAttribute -> BoxStartNode
72
    virtual const SwNode* GetNodeOfFormula() const override;
73
74
          SwTableBox* GetTableBox();
75
    const SwTableBox* GetTableBox() const
76
0
        { return const_cast<SwTableBoxFormula*>(this)->GetTableBox(); }
77
78
    void TryBoxNmToPtr();
79
    void TryRelBoxNm();
80
    void ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& rUpdate, SwHistory* pHistory);
81
    void ChangeState()
82
0
    {
83
0
        if(!m_pDefinedIn)
84
0
            return;
85
        // detect table that contains this attribute
86
0
        const SwNode* pNd = GetNodeOfFormula();
87
0
        if(!pNd) // || &pNd->GetNodes() != &pNd->GetDoc().GetNodes())
88
0
            return;
89
0
        const SwTableNode* pTableNd = pNd->FindTableNode();
90
0
        if(pTableNd == nullptr)
91
0
            return;
92
0
        ChgValid(false);
93
0
    }
94
    void Calc( SwTableCalcPara& rCalcPara, double& rValue );
95
96
    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
97
};
98
99
class SW_DLLPUBLIC SwTableBoxValue final : public SfxPoolItem
100
{
101
    double m_nValue;
102
public:
103
    DECLARE_ITEM_TYPE_FUNCTION(SwTableBoxValue)
104
    SwTableBoxValue();
105
    SwTableBoxValue( const double aVal );
106
107
    // "pure virtual methods" of SfxPoolItem
108
    virtual bool            operator==( const SfxPoolItem& ) const override;
109
    virtual SwTableBoxValue* Clone( SfxItemPool* pPool = nullptr ) const override;
110
111
    SwTableBoxValue& operator=( const SwTableBoxValue& rCmp )
112
0
    {
113
0
        m_nValue = rCmp.m_nValue;
114
0
        return *this;
115
0
    }
116
117
31.6k
    double GetValue() const                     { return m_nValue; }
118
119
    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
120
};
121
122
inline const SwTableBoxNumFormat      &SwAttrSet::GetTableBoxNumFormat(bool bInP) const
123
5.56k
    {   return Get( RES_BOXATR_FORMAT,bInP); }
124
inline const SwTableBoxFormula        &SwAttrSet::GetTableBoxFormula(bool bInP) const
125
0
    {   return Get( RES_BOXATR_FORMULA,bInP); }
126
inline const SwTableBoxValue          &SwAttrSet::GetTableBoxValue(bool bInP) const
127
0
    {   return Get( RES_BOXATR_VALUE, bInP); }
128
129
inline const SwTableBoxNumFormat      &SwFormat::GetTableBoxNumFormat(bool bInP) const
130
5.56k
    {   return m_aSet.GetTableBoxNumFormat(bInP); }
131
inline const SwTableBoxFormula        &SwFormat::GetTableBoxFormula(bool bInP) const
132
0
    {   return m_aSet.GetTableBoxFormula(bInP); }
133
inline const SwTableBoxValue          &SwFormat::GetTableBoxValue(bool bInP) const
134
0
    {   return m_aSet.GetTableBoxValue(bInP); }
135
136
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */