Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/inc/docfunc.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 <tools/solar.h>
23
#include <global.hxx>
24
#include <formula/grammar.hxx>
25
#include <tabbgcolor.hxx>
26
#include <unotools/resmgr.hxx>
27
#include <SheetViewTypes.hxx>
28
29
#include <memory>
30
#include <utility>
31
#include <vector>
32
#include <map>
33
34
class GenerateNoteCaption;
35
class ScEditEngineDefaulter;
36
class SdrUndoAction;
37
class ScAddress;
38
class ScDocShell;
39
class ScMarkData;
40
class ScPatternAttr;
41
class ScRange;
42
class ScRangeList;
43
class ScFormulaCell;
44
class ScTokenArray;
45
struct ScTabOpParam;
46
class ScTableProtection;
47
class ScDocProtection;
48
struct ScCellMergeOption;
49
class ScConditionalFormat;
50
class ScConditionalFormatList;
51
class ScUndoRemoveMerge;
52
class ScRangeName;
53
class ScViewData;
54
55
enum class TransliterationFlags;
56
enum class CreateNameFlags;
57
namespace sc
58
{
59
    struct ColRowSpan;
60
    class SparklineAttributes;
61
    class SparklineGroup;
62
    class Sparkline;
63
    enum class OperationType;
64
}
65
namespace tools
66
{
67
    class Rectangle;
68
}
69
70
class ScDocFunc
71
{
72
    ScDocShell&     rDocShell;
73
74
protected:
75
    void            CreateOneName( ScRangeName& rList,
76
                                    SCCOL nPosX, SCROW nPosY, SCTAB nTab,
77
                                    SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
78
                                    bool& rCancel, bool bApi );
79
80
28.2k
                    ScDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {}
81
public:
82
28.2k
    virtual         ~ScDocFunc() {}
83
84
    bool            AdjustRowHeight( const ScRange& rRange, bool bPaint, bool bApi );
85
    void            NotifyInputHandler( const ScAddress& rPos );
86
87
    void            NotifyDrawUndo(std::unique_ptr<SdrUndoAction>);
88
89
    // for grouping multiple operations into one with a new name
90
    void            EnterListAction(TranslateId pNameResId);
91
    void            EndListAction();
92
93
    bool            DetectiveAddPred(const ScAddress& rPos);
94
    bool            DetectiveDelPred(const ScAddress& rPos);
95
    bool            DetectiveAddSucc(const ScAddress& rPos);
96
    bool            DetectiveDelSucc(const ScAddress& rPos);
97
    bool            DetectiveAddError(const ScAddress& rPos);
98
    bool            DetectiveMarkInvalid(SCTAB nTab);
99
    bool            DetectiveDelAll(SCTAB nTab);
100
    bool            DetectiveRefresh(bool bAutomatic = false);
101
    void            DetectiveCollectAllPreds(const ScRangeList& rSrcRanges, ::std::vector<ScTokenRef>& rRefTokens);
102
    void            DetectiveCollectAllSuccs(const ScRangeList& rSrcRanges, ::std::vector<ScTokenRef>& rRefTokens);
103
104
    SC_DLLPUBLIC bool DeleteContents(
105
        const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi );
106
107
    bool DeleteCell(
108
        const ScAddress& rPos, const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi );
109
110
    SC_DLLPUBLIC bool TransliterateText( const ScMarkData& rMark, TransliterationFlags nType,
111
                                               bool bApi );
112
113
    bool            SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const OUString& rText, bool bApi );
114
    SC_DLLPUBLIC bool SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
115
    void SetValueCells( const ScAddress& rPos, const std::vector<double>& aVals, bool bInteraction );
116
    SC_DLLPUBLIC bool SetStringCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
117
    SC_DLLPUBLIC bool SetEditCell( const ScAddress& rPos, const EditTextObject& rStr, bool bInteraction );
118
119
    bool SetStringOrEditCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
120
121
    /**
122
     * Below two methods take ownership of the formula cell instance(s). The caller
123
     * must not delete it after passing it to this call.
124
     */
125
    SC_DLLPUBLIC bool SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction );
126
    bool SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells, bool bInteraction );
127
    void PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi );
128
    bool SetCellText(
129
        const ScAddress& rPos, const OUString& rText, bool bInterpret, bool bEnglish, bool bApi,
130
        const formula::FormulaGrammar::Grammar eGrammar );
131
132
    SC_DLLPUBLIC bool ShowNote( const ScAddress& rPos, bool bShow );
133
134
    SC_DLLPUBLIC void SetNoteText( const ScAddress& rPos, const OUString& rNoteText, bool bApi );
135
    SC_DLLPUBLIC void ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, const OUString* pAuthor, const OUString* pDate, bool bApi );
136
    SC_DLLPUBLIC void InsertThreadedComment( const ScAddress& rPos, const OUString& rText, const OUString* pAuthor, bool bApi );
137
    SC_DLLPUBLIC void ImportNote( const ScAddress& rPos,
138
                                  std::unique_ptr<GenerateNoteCaption> xGenerator,
139
                                  const tools::Rectangle& rCaptionRect, bool bShown );
140
141
    bool            ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& rPattern,
142
                                           bool bApi );
143
    bool            ApplyStyle( const ScMarkData& rMark, const OUString& rStyleName,
144
                                        bool bApi );
145
146
    bool            InsertCells( const ScRange& rRange,const ScMarkData* pTabMark,
147
                              InsCellCmd eCmd, bool bRecord, bool bApi, bool bPartOfPaste = false, size_t nInsertCount = 0 );
148
149
    bool            DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
150
                              DelCellCmd eCmd, bool bApi );
151
152
    SC_DLLPUBLIC bool MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
153
                                       bool bCut, bool bRecord, bool bPaint, bool bApi );
154
155
    SC_DLLPUBLIC bool InsertTable( SCTAB nTab, const OUString& rName, bool bRecord, bool bApi );
156
    std::pair<sc::SheetViewID, SCTAB> InsertSheetView( SCTAB nTab, bool bRecord );
157
    SC_DLLPUBLIC bool RenameTable( SCTAB nTab, const OUString& rName, bool bRecord, bool bApi );
158
    bool            DeleteTable( SCTAB nTab, bool bRecord );
159
160
    bool            SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi );
161
    bool            SetTabBgColor( ScUndoTabColorInfo::List& rUndoTabColorList, bool bApi );
162
163
    void            SetTableVisible( SCTAB nTab, bool bVisible, bool bApi );
164
165
    bool            SetLayoutRTL( SCTAB nTab, bool bRTL );
166
167
    SC_DLLPUBLIC bool SetWidthOrHeight(
168
        bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, SCTAB nTab,
169
        ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord, bool bApi );
170
171
    bool            InsertPageBreak( bool bColumn, const ScAddress& rPos,
172
                                             bool bRecord, bool bSetModified );
173
    bool            RemovePageBreak( bool bColumn, const ScAddress& rPos,
174
                                             bool bRecord, bool bSetModified );
175
176
    void            ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect );
177
178
    bool            Protect( SCTAB nTab, const OUString& rPassword );
179
    bool            Unprotect( SCTAB nTab, std::u16string_view rPassword, bool bApi );
180
181
    SC_DLLPUBLIC void ClearItems( const ScMarkData& rMark, const sal_uInt16* pWhich, bool bApi );
182
    SC_DLLPUBLIC bool ChangeIndent( const ScMarkData& rMark, bool bIncrement, bool bApi );
183
    SC_DLLPUBLIC bool AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
184
                                        sal_uInt16 nFormatNo, bool bApi );
185
186
    SC_DLLPUBLIC bool
187
                    EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
188
                                         const ScTokenArray* pTokenArray,
189
                                         const OUString& rString, bool bApi, bool bEnglish,
190
                                         const OUString& rFormulaNmsp,
191
                                         const formula::FormulaGrammar::Grammar,
192
                                         bool bDynamicArrayMaster = false);
193
194
    SC_DLLPUBLIC bool TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
195
                                   const ScTabOpParam& rParam, bool bRecord, bool bApi );
196
197
    SC_DLLPUBLIC bool FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
198
                                        FillDir eDir, bool bApi );
199
    SC_DLLPUBLIC bool FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
200
                                        FillDir    eDir, FillCmd eCmd, FillDateCmd    eDateCmd,
201
                                        double fStart, double fStep, double fMax,
202
                                        bool bApi );
203
204
    // FillAuto: rRange is change from Source-Range to Dest-Range
205
    SC_DLLPUBLIC bool
206
                    FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd  eDateCmd, sal_uLong nCount, double fStep, double fMax, bool bRecord, bool bApi );
207
208
    bool            FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
209
                                      FillDir eDir, sal_uLong nCount, bool bApi );
210
211
    void            ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd );
212
213
    SC_DLLPUBLIC bool
214
                    MergeCells( const ScCellMergeOption& rOption, bool bContents,
215
                                        bool bRecord, bool bApi, bool bEmptyMergedCells = false );
216
    bool            UnmergeCells( const ScRange& rRange, bool bRecord, ScUndoRemoveMerge* pUndoRemoveMerge );
217
    SC_DLLPUBLIC bool
218
                    UnmergeCells( const ScCellMergeOption& rOption, bool bRecord, ScUndoRemoveMerge* pUndoRemoveMerge );
219
220
    // takes ownership of pNewRanges, nTab = -1 for local range names
221
    void            SetNewRangeNames( std::unique_ptr<ScRangeName> pNewRanges, bool bModifyDoc, SCTAB nTab );
222
    void            ModifyRangeNames( const ScRangeName& rNewRanges, SCTAB nTab = -1 );
223
    /**
224
     * Modify all range names, global scope names as well as sheet local ones,
225
     * in one go.  Note that this method will <b>not</b> destroy the instances
226
     * passed as arguments (it creates copies); the caller is responsible for
227
     * destroying them.
228
     */
229
    void            ModifyAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap);
230
231
    bool            CreateNames( const ScRange& rRange, CreateNameFlags nFlags, bool bApi, SCTAB nTab = -1 ); // -1 for global range names
232
    SC_DLLPUBLIC bool InsertNameList(const ScAddress& rStartPos, bool bApi);
233
234
    void            InsertAreaLink( const OUString& rFile, const OUString& rFilter,
235
                                            const OUString& rOptions, const OUString& rSource,
236
                                            const ScRange& rDestRange, sal_Int32 nRefreshDelaySeconds,
237
                                            bool bFitBlock, bool bApi );
238
239
    /**
240
     * @param nOldIndex If 0 don't delete an old format
241
     * @param pFormat if NULL only delete an old format
242
     */
243
    void ReplaceConditionalFormat( sal_uLong nOldIndex, std::unique_ptr<ScConditionalFormat> pFormat, SCTAB nTab, const ScRangeList& rRanges );
244
245
    /**
246
     * Sets or replaces the conditional format list of a table
247
     *
248
     * @param pList the new ScConditionalFormatList, method takes ownership
249
     * @param nTab the tab to which the conditional format list belongs
250
     */
251
    void SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB nTab );
252
253
    SC_DLLPUBLIC void ConvertFormulaToValue( const ScRange& rRange, bool bInteraction );
254
255
    SC_DLLPUBLIC bool InsertSparklines(ScRange const& rDataRange, ScRange const& rSparklineRange,
256
                                       const std::shared_ptr<sc::SparklineGroup>& pSparklineGroup);
257
258
    SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rAddress);
259
    SC_DLLPUBLIC bool DeleteSparklineGroup(std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup, SCTAB nTab);
260
    SC_DLLPUBLIC bool ChangeSparklineGroupAttributes(std::shared_ptr<sc::SparklineGroup> const& pExistingSparklineGroup,
261
                                                     sc::SparklineAttributes const& rNewAttributes);
262
    SC_DLLPUBLIC bool GroupSparklines(ScRange const& rRange, std::shared_ptr<sc::SparklineGroup> const& rpGroup);
263
    SC_DLLPUBLIC bool UngroupSparklines(ScRange const& rRange);
264
    SC_DLLPUBLIC bool ChangeSparkline(std::shared_ptr<sc::Sparkline> const& rpSparkline, SCTAB nTab, ScRangeList const& rDataRange);
265
266
    static void PaintAbove(ScDocShell& rDocShell, const ScRange& rRange);
267
268
private:
269
    void ProtectDocument(const ScDocProtection& rProtect);
270
};
271
272
class ScDocFuncDirect final : public ScDocFunc
273
{
274
public:
275
28.2k
            ScDocFuncDirect( ScDocShell& rDocSh ) : ScDocFunc( rDocSh ) {}
276
};
277
278
void VBA_DeleteModule( ScDocShell& rDocSh, const OUString& sModuleName );
279
280
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */