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 INCLUDED_SC_SOURCE_UI_INC_DOCFUNC_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_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 1320 : ScDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {}
68 : public:
69 1289 : 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 DeleteContents(
89 : const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi );
90 :
91 : bool DeleteCell(
92 : const ScAddress& rPos, const ScMarkData& rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi );
93 :
94 : bool TransliterateText( const ScMarkData& rMark, sal_Int32 nType,
95 : bool bRecord, bool bApi );
96 :
97 : bool SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const OUString& rText, bool bApi );
98 : bool SetValueCell( const ScAddress& rPos, double fVal, bool bInteraction );
99 : bool SetValueCells( const ScAddress& rPos, const std::vector<double>& aVals, bool bInteraction );
100 : bool SetStringCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
101 : bool SetEditCell( const ScAddress& rPos, const EditTextObject& rStr, bool bInteraction );
102 :
103 : bool SetStringOrEditCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
104 :
105 : /**
106 : * This method takes ownership of the formula cell instance. The caller
107 : * must not delete it after passing it to this call.
108 : */
109 : bool SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction );
110 : bool PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, bool bApi );
111 : bool SetCellText(
112 : const ScAddress& rPos, const OUString& rText, bool bInterpret, bool bEnglish, bool bApi,
113 : const formula::FormulaGrammar::Grammar eGrammar );
114 :
115 : bool ShowNote( const ScAddress& rPos, bool bShow = true );
116 : inline bool HideNote( const ScAddress& rPos ) { return ShowNote( rPos, false ); }
117 :
118 : bool SetNoteText( const ScAddress& rPos, const OUString& rNoteText, bool bApi );
119 : bool ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, const OUString* pAuthor, const OUString* pDate, bool bApi );
120 :
121 : bool ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& rPattern,
122 : bool bRecord, bool bApi );
123 : bool ApplyStyle( const ScMarkData& rMark, const OUString& rStyleName,
124 : bool bRecord, bool bApi );
125 :
126 : bool InsertCells( const ScRange& rRange,const ScMarkData* pTabMark,
127 : InsCellCmd eCmd, bool bRecord, bool bApi, bool bPartOfPaste = false );
128 :
129 : bool DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
130 : DelCellCmd eCmd, bool bRecord, bool bApi );
131 :
132 : bool MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
133 : bool bCut, bool bRecord, bool bPaint, bool bApi );
134 :
135 : SC_DLLPUBLIC bool InsertTable( SCTAB nTab, const OUString& rName, bool bRecord, bool bApi );
136 : bool RenameTable( SCTAB nTab, const OUString& rName, bool bRecord, bool bApi );
137 : bool DeleteTable( SCTAB nTab, bool bRecord, bool bApi );
138 :
139 : bool SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi );
140 : bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoTabColorList, bool bRecord, bool bApi );
141 :
142 : bool SetTableVisible( SCTAB nTab, bool bVisible, bool bApi );
143 :
144 : bool SetLayoutRTL( SCTAB nTab, bool bRTL, bool bApi );
145 :
146 : SC_DLLPUBLIC bool SetWidthOrHeight(
147 : bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, SCTAB nTab,
148 : ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord, bool bApi );
149 :
150 : bool InsertPageBreak( bool bColumn, const ScAddress& rPos,
151 : bool bRecord, bool bSetModified, bool bApi );
152 : bool RemovePageBreak( bool bColumn, const ScAddress& rPos,
153 : bool bRecord, bool bSetModified, bool bApi );
154 :
155 : void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect );
156 :
157 : bool Protect( SCTAB nTab, const OUString& rPassword, bool bApi );
158 : bool Unprotect( SCTAB nTab, const OUString& rPassword, bool bApi );
159 :
160 : bool ClearItems( const ScMarkData& rMark, const sal_uInt16* pWhich, bool bApi );
161 : bool ChangeIndent( const ScMarkData& rMark, bool bIncrement, bool bApi );
162 : bool AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
163 : sal_uInt16 nFormatNo, bool bRecord, bool bApi );
164 :
165 : SC_DLLPUBLIC bool
166 : EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
167 : const ScTokenArray* pTokenArray,
168 : const OUString& rString, bool bApi, bool bEnglish,
169 : const OUString& rFormulaNmsp,
170 : const formula::FormulaGrammar::Grammar );
171 :
172 : bool TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
173 : const ScTabOpParam& rParam, bool bRecord, bool bApi );
174 :
175 : bool FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
176 : FillDir eDir, bool bRecord, bool bApi );
177 : bool FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
178 : FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
179 : double fStart, double fStep, double fMax,
180 : bool bRecord, bool bApi );
181 :
182 : // FillAuto: rRange wird von Source-Range auf Dest-Range angepasst
183 : SC_DLLPUBLIC bool
184 : FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, sal_uLong nCount, double fStep, double fMax, bool bRecord, bool bApi );
185 :
186 : bool FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
187 : FillDir eDir, sal_uLong nCount, bool bRecord, bool bApi );
188 :
189 : bool ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd, bool bApi );
190 :
191 : bool MergeCells( const ScCellMergeOption& rOption, bool bContents,
192 : bool bRecord, bool bApi );
193 : bool UnmergeCells( const ScRange& rRange, bool bRecord );
194 : bool UnmergeCells( const ScCellMergeOption& rOption, bool bRecord );
195 :
196 : void SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc = true, SCTAB nTab = -1 ); // takes ownership of pNewRanges //nTab = -1 for local range names
197 : void ModifyRangeNames( const ScRangeName& rNewRanges, SCTAB nTab = -1 );
198 : /**
199 : * Modify all range names, global scope names as well as sheet local ones,
200 : * in one go. Note that this method will <b>not</b> destroy the instances
201 : * passed as arguments (it creates copies); the caller is responsible for
202 : * destroying them.
203 : */
204 : void ModifyAllRangeNames( const boost::ptr_map<OUString, ScRangeName>& rRangeMap );
205 :
206 : bool CreateNames( const ScRange& rRange, sal_uInt16 nFlags, bool bApi, SCTAB nTab = -1 ); // -1 for global range names
207 : bool InsertNameList( const ScAddress& rStartPos, bool bApi );
208 :
209 : bool InsertAreaLink( const OUString& rFile, const OUString& rFilter,
210 : const OUString& rOptions, const OUString& rSource,
211 : const ScRange& rDestRange, sal_uLong nRefresh,
212 : bool bFitBlock, bool bApi );
213 :
214 : /**
215 : * @param nOldIndex If 0 don't delete an old format
216 : * @param pFormat if NULL only delete an old format
217 : */
218 : void ReplaceConditionalFormat( sal_uLong nOldIndex, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges );
219 :
220 : /**
221 : * Sets or replaces the conditional format list of a table
222 : *
223 : * @param pList the new ScConditionalFormatList, method takes ownership
224 : * @param nTab the tab to which the conditional format list belongs
225 : */
226 : void SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB nTab );
227 :
228 : void ConvertFormulaToValue( const ScRange& rRange, bool bRecord, bool bInteraction );
229 : };
230 :
231 : class ScDocFuncDirect : public ScDocFunc
232 : {
233 : public:
234 1320 : ScDocFuncDirect( ScDocShell& rDocSh ) : ScDocFunc( rDocSh ) {}
235 2578 : virtual ~ScDocFuncDirect() {}
236 : };
237 :
238 : void VBA_DeleteModule( ScDocShell& rDocSh, const OUString& sModuleName );
239 :
240 : #endif
241 :
242 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|