Line data Source code
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 : #ifndef SC_DOCFUNC_HXX
21 : #define SC_DOCFUNC_HXX
22 :
23 : #include <tools/link.hxx>
24 : #include "global.hxx"
25 : #include "formula/grammar.hxx"
26 : #include "tabbgcolor.hxx"
27 : #include "token.hxx"
28 : #include "rangenam.hxx"
29 :
30 : #include <vector>
31 : #include <map>
32 :
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 : struct ScCellMergeOption;
46 : class ScConditionalFormat;
47 : class ScConditionalFormatList;
48 :
49 : namespace sc {
50 :
51 : struct ColRowSpan;
52 :
53 : }
54 :
55 : class ScDocFunc
56 : {
57 : protected:
58 : ScDocShell& rDocShell;
59 :
60 : bool AdjustRowHeight( const ScRange& rRange, bool bPaint = true );
61 : void CreateOneName( ScRangeName& rList,
62 : SCCOL nPosX, SCROW nPosY, SCTAB nTab,
63 : SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
64 : bool& rCancel, bool bApi );
65 : void NotifyInputHandler( const ScAddress& rPos );
66 :
67 0 : ScDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {}
68 : public:
69 0 : virtual ~ScDocFunc() {}
70 :
71 : DECL_LINK( NotifyDrawUndo, SdrUndoAction* );
72 :
73 : // for grouping multiple operations into one with a new name
74 : void EnterListAction( sal_uInt16 nNameResId );
75 : void EndListAction();
76 :
77 : bool DetectiveAddPred(const ScAddress& rPos);
78 : bool DetectiveDelPred(const ScAddress& rPos);
79 : bool DetectiveAddSucc(const ScAddress& rPos);
80 : bool DetectiveDelSucc(const ScAddress& rPos);
81 : bool DetectiveAddError(const ScAddress& rPos);
82 : bool DetectiveMarkInvalid(SCTAB nTab);
83 : bool DetectiveDelAll(SCTAB nTab);
84 : bool DetectiveRefresh(bool bAutomatic = false);
85 : void DetectiveCollectAllPreds(const ScRangeList& rSrcRanges, ::std::vector<ScTokenRef>& rRefTokens);
86 : void DetectiveCollectAllSuccs(const ScRangeList& rSrcRanges, ::std::vector<ScTokenRef>& rRefTokens);
87 :
88 : SC_DLLPUBLIC bool
89 : DeleteContents( const ScMarkData& rMark, sal_uInt16 nFlags,
90 : bool bRecord, bool bApi );
91 :
92 : bool TransliterateText( const ScMarkData& rMark, sal_Int32 nType,
93 : bool bRecord, bool bApi );
94 :
95 : bool SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const OUString& rText, bool bApi );
96 : bool SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
97 : bool SetValueCells( const ScAddress& rPos, const std::vector<double>& aVals, bool bInteraction );
98 : bool SetStringCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
99 : bool SetEditCell( const ScAddress& rPos, const EditTextObject& rStr, bool bInteraction );
100 :
101 : bool SetStringOrEditCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
102 :
103 : /**
104 : * This method takes ownership of the formula cell instance. The caller
105 : * must not delete it after passing it to this call.
106 : */
107 : bool SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction );
108 : bool PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi );
109 : bool SetCellText(
110 : const ScAddress& rPos, const OUString& rText, bool bInterpret, bool bEnglish, bool bApi,
111 : const formula::FormulaGrammar::Grammar eGrammar );
112 :
113 : bool ShowNote( const ScAddress& rPos, bool bShow = true );
114 : inline bool HideNote( const ScAddress& rPos ) { return ShowNote( rPos, false ); }
115 :
116 : bool SetNoteText( const ScAddress& rPos, const OUString& rNoteText, bool bApi );
117 : bool ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, const OUString* pAuthor, const OUString* pDate, bool bApi );
118 :
119 : bool ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& rPattern,
120 : bool bRecord, bool bApi );
121 : bool ApplyStyle( const ScMarkData& rMark, const OUString& rStyleName,
122 : bool bRecord, bool bApi );
123 :
124 : bool InsertCells( const ScRange& rRange,const ScMarkData* pTabMark,
125 : InsCellCmd eCmd, bool bRecord, bool bApi, bool bPartOfPaste = false );
126 :
127 : bool DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
128 : DelCellCmd eCmd, bool bRecord, bool bApi );
129 :
130 : bool MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
131 : bool bCut, bool bRecord, bool bPaint, bool bApi );
132 :
133 : bool InsertTable( SCTAB nTab, const OUString& rName, bool bRecord, bool bApi );
134 : bool RenameTable( SCTAB nTab, const OUString& rName, bool bRecord, bool bApi );
135 : bool DeleteTable( SCTAB nTab, bool bRecord, bool bApi );
136 :
137 : bool SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi );
138 : bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoTabColorList, bool bRecord, bool bApi );
139 :
140 : bool SetTableVisible( SCTAB nTab, bool bVisible, bool bApi );
141 :
142 : bool SetLayoutRTL( SCTAB nTab, bool bRTL, bool bApi );
143 :
144 : SC_DLLPUBLIC bool SetWidthOrHeight(
145 : bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, SCTAB nTab,
146 : ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord, bool bApi );
147 :
148 : bool InsertPageBreak( bool bColumn, const ScAddress& rPos,
149 : bool bRecord, bool bSetModified, bool bApi );
150 : bool RemovePageBreak( bool bColumn, const ScAddress& rPos,
151 : bool bRecord, bool bSetModified, bool bApi );
152 :
153 : void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect );
154 :
155 : bool Protect( SCTAB nTab, const OUString& rPassword, bool bApi );
156 : bool Unprotect( SCTAB nTab, const OUString& rPassword, bool bApi );
157 :
158 : bool ClearItems( const ScMarkData& rMark, const sal_uInt16* pWhich, bool bApi );
159 : bool ChangeIndent( const ScMarkData& rMark, bool bIncrement, bool bApi );
160 : bool AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
161 : sal_uInt16 nFormatNo, bool bRecord, bool bApi );
162 :
163 : SC_DLLPUBLIC bool
164 : EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
165 : const ScTokenArray* pTokenArray,
166 : const OUString& rString, bool bApi, bool bEnglish,
167 : const OUString& rFormulaNmsp,
168 : const formula::FormulaGrammar::Grammar );
169 :
170 : bool TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
171 : const ScTabOpParam& rParam, bool bRecord, bool bApi );
172 :
173 : bool FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
174 : FillDir eDir, bool bRecord, bool bApi );
175 : bool FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
176 : FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
177 : double fStart, double fStep, double fMax,
178 : bool bRecord, bool bApi );
179 :
180 : // FillAuto: rRange wird von Source-Range auf Dest-Range angepasst
181 : SC_DLLPUBLIC bool
182 : FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, sal_uLong nCount, double fStep, double fMax, bool bRecord, bool bApi );
183 :
184 : bool FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
185 : FillDir eDir, sal_uLong nCount, bool bRecord, bool bApi );
186 :
187 : bool ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd, bool bApi );
188 :
189 : bool MergeCells( const ScCellMergeOption& rOption, bool bContents,
190 : bool bRecord, bool bApi );
191 : bool UnmergeCells( const ScRange& rRange, bool bRecord );
192 : bool UnmergeCells( const ScCellMergeOption& rOption, bool bRecord );
193 :
194 : bool SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc = true, SCTAB nTab = -1 ); // takes ownership of pNewRanges //nTab = -1 for local range names
195 : bool ModifyRangeNames( const ScRangeName& rNewRanges, SCTAB nTab = -1 );
196 : /**
197 : * Modify all range names, global scope names as well as sheet local ones,
198 : * in one go. Note that this method will <b>not</b> destroy the instances
199 : * passed as arguments (it creates copies); the caller is responsible for
200 : * destroying them.
201 : */
202 : void ModifyAllRangeNames( const boost::ptr_map<OUString, ScRangeName>& rRangeMap );
203 :
204 : bool CreateNames( const ScRange& rRange, sal_uInt16 nFlags, bool bApi, SCTAB nTab = -1 ); // -1 for global range names
205 : bool InsertNameList( const ScAddress& rStartPos, bool bApi );
206 :
207 : bool InsertAreaLink( const OUString& rFile, const OUString& rFilter,
208 : const OUString& rOptions, const OUString& rSource,
209 : const ScRange& rDestRange, sal_uLong nRefresh,
210 : bool bFitBlock, bool bApi );
211 :
212 : /**
213 : * @param nOldIndex If 0 don't delete an old format
214 : * @param pFormat if NULL only delete an old format
215 : */
216 : void ReplaceConditionalFormat( sal_uLong nOldIndex, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges );
217 :
218 : /**
219 : * Sets or replaces the conditional format list of a table
220 : *
221 : * @param pList the new ScConditionalFormatList, method takes ownership
222 : * @param nTab the tab to which the conditional format list belongs
223 : */
224 : void SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB nTab );
225 : };
226 :
227 : class ScDocFuncDirect : public ScDocFunc
228 : {
229 : public:
230 0 : ScDocFuncDirect( ScDocShell& rDocSh ) : ScDocFunc( rDocSh ) {}
231 0 : virtual ~ScDocFuncDirect() {}
232 : };
233 :
234 :
235 : #endif
236 :
237 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|