Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/fmtclds.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_INC_FMTCLDS_HXX
20
#define INCLUDED_SW_INC_FMTCLDS_HXX
21
22
#include <editeng/borderline.hxx>
23
#include <tools/color.hxx>
24
#include <tools/solar.h>
25
#include <svl/poolitem.hxx>
26
#include "swdllapi.h"
27
#include "hintids.hxx"
28
#include "format.hxx"
29
30
#include <vector>
31
32
/// ColumnDescriptor
33
class SwColumn
34
{
35
    sal_uInt16 m_nWish;   /**< Desired width, borders included.
36
                         It is inversely proportional to the ratio of
37
                         desired width environment / current width column. */
38
    sal_uInt16 m_nLeft;   ///< Left border.
39
    sal_uInt16 m_nRight;  ///< Right border.
40
41
public:
42
    SwColumn();
43
44
    bool operator==( const SwColumn & ) const;
45
46
383k
    void SetWishWidth( sal_uInt16 nNew ) { m_nWish  = nNew; }
47
209k
    void SetLeft ( sal_uInt16  nNew ) { m_nLeft  = nNew; }
48
209k
    void SetRight( sal_uInt16  nNew ) { m_nRight = nNew; }
49
50
325k
    sal_uInt16 GetWishWidth() const { return m_nWish;  }
51
300k
    sal_uInt16 GetLeft () const { return m_nLeft; }
52
300k
    sal_uInt16 GetRight() const { return m_nRight; }
53
54
    void dumpAsXml(xmlTextWriterPtr pWriter) const;
55
};
56
57
typedef std::vector<SwColumn> SwColumns;
58
59
enum SwColLineAdj
60
{
61
    COLADJ_NONE,
62
    COLADJ_TOP,
63
    COLADJ_CENTER,
64
    COLADJ_BOTTOM
65
};
66
67
/// This pool item subclass can appear in the item set of an SwPageDesc, and contains settings
68
/// visible on the UI via Format -> Page Style -> Columns tab.
69
/// It can also appear in the item set of an SwSectionFormat, and then contains settings visible on
70
/// the UI via Format -> Sections -> Options -> Columns tab.
71
class SW_DLLPUBLIC SwFormatCol final : public SfxPoolItem
72
{
73
    SvxBorderLineStyle m_eLineStyle;     ///< style of the separator line
74
    sal_uLong   m_nLineWidth;                 ///< Width of the separator line.
75
    Color   m_aLineColor;                     ///< Color of the separator line.
76
77
    sal_uInt16   m_nLineHeight;               /**< Percentile height of lines.
78
                                          (Based on height of columns including UL). */
79
80
    SwColLineAdj m_eAdj;                      ///< Line will be adjusted top, centered or bottom.
81
82
    SwColumns   m_aColumns;                   ///< Information concerning the columns.
83
    sal_uInt16  m_nWidth;                     ///< Total desired width of all columns.
84
    sal_Int16   m_aWidthAdjustValue;
85
86
    bool m_bOrtho;            /**< Only if this flag is set, the setting of GutterWidth will
87
                             be accompanied by a "visual rearrangement".
88
                             The flag must be reset if widths of columns or borders are changed.
89
                             When it is set (again) the visual arrangement is recalculated.
90
                             The flag is initially set. */
91
92
    SAL_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct );
93
94
public:
95
    DECLARE_ITEM_TYPE_FUNCTION(SwFormatCol)
96
    SwFormatCol();
97
    SwFormatCol( const SwFormatCol& );
98
    virtual ~SwFormatCol() override;
99
    //#i120133#
100
10.2k
    sal_Int16 GetAdjustValue() const { return m_aWidthAdjustValue; }
101
0
    void SetAdjustValue( sal_Int16 n ) { m_aWidthAdjustValue = n; }
102
103
    SwFormatCol& operator=( const SwFormatCol& );
104
105
    /// "pure virtual methods" of SfxPoolItem
106
    virtual bool            operator==( const SfxPoolItem& ) const override;
107
    virtual SwFormatCol*    Clone( SfxItemPool* pPool = nullptr ) const override;
108
    virtual bool GetPresentation( SfxItemPresentation ePres,
109
                                  MapUnit eCoreMetric,
110
                                  MapUnit ePresMetric,
111
                                  OUString &rText,
112
                                  const IntlWrapper& rIntl ) const override;
113
114
    virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
115
    virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
116
117
243k
    const SwColumns &GetColumns() const { return m_aColumns; }
118
36.0k
          SwColumns &GetColumns()       { return m_aColumns; }
119
403k
    sal_uInt16           GetNumCols() const { return m_aColumns.size(); }
120
121
138
    SvxBorderLineStyle     GetLineStyle() const  { return m_eLineStyle;}
122
186
    sal_uLong           GetLineWidth() const  { return m_nLineWidth;}
123
138
    const Color&    GetLineColor() const { return m_aLineColor;}
124
125
21.2k
    SwColLineAdj     GetLineAdj() const { return m_eAdj; }
126
19.7k
    bool             IsOrtho()    const { return m_bOrtho; }
127
194k
    sal_uInt16           GetWishWidth() const { return m_nWidth; }
128
21.0k
    sal_uInt8            GetLineHeight()const { return m_nLineHeight; }
129
130
    /** @return USHRT_MAX if ambiguous.
131
     @return smallest width if bMin is true. */
132
    sal_uInt16 GetGutterWidth( bool bMin = false ) const;
133
134
0
    void SetLineStyle(SvxBorderLineStyle eStyle)        { m_eLineStyle = eStyle;}
135
2.75k
    void SetLineWidth(sal_uLong nLWidth)        { m_nLineWidth = nLWidth;}
136
2.75k
    void SetLineColor(const Color& rCol )   { m_aLineColor = rCol;}
137
2.75k
    void SetLineHeight( sal_uInt8 nNew )     { m_nLineHeight = nNew; }
138
2.75k
    void SetLineAdj( SwColLineAdj eNew ){ m_eAdj = eNew; }
139
1.26k
    void SetWishWidth( sal_uInt16 nNew )    { m_nWidth = nNew; }
140
141
    /** This function allows to (repeatedly) initialize the columns.
142
     The Ortho flag is set automatically. */
143
    void Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
144
145
    /** Adjusts borders for columns in aColumns.
146
     If flag m_bOrtho is set, columns are visually re-arranged.
147
     If the flag is not set, columns widths are not changed and
148
     borders are adjusted. */
149
    void SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct );
150
151
    /** This too re-arranges columns automatically if flag is set.
152
     Only in this case the second parameter is needed and evaluated. */
153
    void SetOrtho( bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
154
155
    /// For the reader
156
1.26k
    void SetOrtho_( bool bNew ) { m_bOrtho = bNew; }
157
158
    /** Calculates current width of column nCol.
159
     The ratio of desired width of this column to return value is
160
     proportional to ratio of total desired value to nAct. */
161
    sal_uInt16 CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
162
163
    /** As above except that it @return the width of PrtArea -
164
     that corresponds to what constitutes the column for the user. */
165
    sal_uInt16 CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
166
167
    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
168
};
169
170
inline const SwFormatCol &SwAttrSet::GetCol(bool bInP) const
171
101k
    { return Get( RES_COL,bInP); }
172
173
inline const SwFormatCol &SwFormat::GetCol(bool bInP) const
174
101k
    { return m_aSet.GetCol(bInP); }
175
176
#endif
177
178
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */