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