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 : #ifndef SC_VIEWFUNC_HXX
20 : #define SC_VIEWFUNC_HXX
21 :
22 : #include "tabview.hxx"
23 :
24 : #include "tabbgcolor.hxx"
25 :
26 : #include <com/sun/star/embed/XEmbeddedObject.hpp>
27 : #include <com/sun/star/embed/Aspects.hpp>
28 : #include <vector>
29 : #include <boost/ptr_container/ptr_vector.hpp>
30 :
31 : class ScPatternAttr;
32 : class ScAutoFormatData;
33 : class SvxSearchItem;
34 : class SfxItemSet;
35 : class SvxBoxItem;
36 : class SvxBoxInfoItem;
37 : class SfxStyleSheetBase;
38 : class SfxStyleSheet;
39 : class SfxPoolItem;
40 : class EditTextObject;
41 : struct ScSolveParam;
42 : struct ScTabOpParam;
43 : class ScValidationData;
44 : class ScConversionParam;
45 : class SdrModel;
46 : class Graphic;
47 : class Exchange;
48 : class ScRangeList;
49 : class SvxHyperlinkItem;
50 : class ScTransferObj;
51 : class ScTableProtection;
52 :
53 : namespace editeng { class SvxBorderLine; }
54 :
55 : namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
56 :
57 : //==================================================================
58 :
59 : class ScViewFunc : public ScTabView
60 : {
61 : private:
62 : ScAddress aFormatSource; // for automatic extension of formatting
63 : ScRange aFormatArea;
64 : sal_Bool bFormatValid;
65 :
66 : public:
67 : ScViewFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
68 : ~ScViewFunc();
69 :
70 : const ScPatternAttr* GetSelectionPattern ();
71 : void GetSelectionFrame ( SvxBoxItem& rLineOuter,
72 : SvxBoxInfoItem& rLineInner );
73 :
74 : sal_uInt8 GetSelectionScriptType();
75 :
76 : sal_Bool GetAutoSumArea(ScRangeList& rRangeList);
77 : void EnterAutoSum(const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr);
78 : bool AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor, bool bContinue );
79 : String GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr );
80 :
81 : void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
82 : const EditTextObject* pData = NULL );
83 : void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
84 : const EditTextObject& rData, bool bTestSimple = false );
85 : void EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rValue );
86 :
87 : void EnterMatrix( const String& rString, ::formula::FormulaGrammar::Grammar eGram );
88 :
89 : /**
90 : * @param pData The caller must manage the life cycle of the object this
91 : * pointer points to. NULL is allowed.
92 : */
93 : void EnterBlock( const String& rString, const EditTextObject* pData );
94 :
95 : void EnterDataAtCursor( const String& rString ); //! Not used?
96 :
97 : SC_DLLPUBLIC void CutToClip( ScDocument* pClipDoc = NULL, sal_Bool bIncludeObjects = false );
98 : SC_DLLPUBLIC sal_Bool CopyToClip( ScDocument* pClipDoc = NULL, sal_Bool bCut = false, sal_Bool bApi = false,
99 : sal_Bool bIncludeObjects = false, sal_Bool bStopEdit = true );
100 : SC_DLLPUBLIC sal_Bool CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRange, sal_Bool bCut = false,
101 : sal_Bool bApi = false, sal_Bool bIncludeObjects = false, sal_Bool bStopEdit = true, sal_Bool bUseRangeForVBA = true );
102 : ScTransferObj* CopyToTransferable();
103 : SC_DLLPUBLIC bool PasteFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc,
104 : sal_uInt16 nFunction = PASTE_NOFUNC, bool bSkipEmpty = false,
105 : bool bTranspose = false, bool bAsLink = false,
106 : InsCellCmd eMoveMode = INS_NONE,
107 : sal_uInt16 nUndoExtraFlags = IDF_NONE,
108 : bool bAllowDialogs = false );
109 :
110 : void FillTab( sal_uInt16 nFlags, sal_uInt16 nFunction, sal_Bool bSkipEmpty, sal_Bool bAsLink );
111 :
112 : SC_DLLPUBLIC void PasteFromSystem();
113 : SC_DLLPUBLIC sal_Bool PasteFromSystem( sal_uLong nFormatId, sal_Bool bApi = false );
114 : void PasteFromTransferable( const ::com::sun::star::uno::Reference<
115 : ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
116 :
117 : void PasteDraw();
118 : void PasteDraw( const Point& rLogicPos, SdrModel* pModel,
119 : sal_Bool bGroup = false, sal_Bool bSameDocClipboard = false );
120 :
121 : sal_Bool PasteOnDrawObject( const ::com::sun::star::uno::Reference<
122 : ::com::sun::star::datatransfer::XTransferable >& rxTransferable,
123 : SdrObject* pHitObj, sal_Bool bLink );
124 :
125 : sal_Bool PasteDataFormat( sal_uLong nFormatId,
126 : const ::com::sun::star::uno::Reference<
127 : ::com::sun::star::datatransfer::XTransferable >& rxTransferable,
128 : SCCOL nPosX, SCROW nPosY, Point* pLogicPos = NULL,
129 : sal_Bool bLink = false, sal_Bool bAllowDialogs = false );
130 :
131 : sal_Bool PasteFile( const Point&, const String&, sal_Bool bLink=false );
132 : sal_Bool PasteObject( const Point&, const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >&, const Size* = NULL, const Graphic* = NULL, const OUString& = OUString(), sal_Int64 nAspect = ::com::sun::star::embed::Aspects::MSOLE_CONTENT );
133 : sal_Bool PasteBitmapEx( const Point&, const BitmapEx& );
134 : sal_Bool PasteMetaFile( const Point&, const GDIMetaFile& );
135 : sal_Bool PasteGraphic( const Point& rPos, const Graphic& rGraphic,
136 : const String& rFile, const String& rFilter );
137 : sal_Bool PasteBookmark( sal_uLong nFormatId,
138 : const ::com::sun::star::uno::Reference<
139 : ::com::sun::star::datatransfer::XTransferable >& rxTransferable,
140 : SCCOL nPosX, SCROW nPosY );
141 : bool PasteLink( const ::com::sun::star::uno::Reference<
142 : ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
143 :
144 : sal_Bool ApplyGraphicToObject( SdrObject* pObject, const Graphic& rGraphic );
145 :
146 : void InsertBookmark( const String& rDescription, const String& rURL,
147 : SCCOL nPosX, SCROW nPosY, const String* pTarget = NULL,
148 : sal_Bool bTryReplace = false );
149 : bool HasBookmarkAtCursor( SvxHyperlinkItem* pContent );
150 :
151 : long DropRequestHdl( Exchange* pExchange );
152 : sal_Bool MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos,
153 : sal_Bool bCut, sal_Bool bRecord, sal_Bool bPaint, sal_Bool bApi );
154 :
155 : sal_Bool LinkBlock( const ScRange& rSource, const ScAddress& rDestPos, sal_Bool bApi );
156 :
157 : void CreateNames( sal_uInt16 nFlags );
158 : sal_uInt16 GetCreateNameFlags();
159 : void InsertNameList();
160 : sal_Bool InsertName( const String& rName, const String& rSymbol,
161 : const String& rType );
162 :
163 : void ApplyAttributes( const SfxItemSet* pDialogSet, const SfxItemSet* pOldSet,
164 : sal_Bool bRecord = sal_True );
165 : void ApplyAttr( const SfxPoolItem& rAttrItem );
166 : void ApplySelectionPattern( const ScPatternAttr& rAttr,
167 : sal_Bool bRecord = sal_True,
168 : sal_Bool bCursorOnly = false );
169 : void ApplyPatternLines( const ScPatternAttr& rAttr,
170 : const SvxBoxItem* pNewOuter,
171 : const SvxBoxInfoItem* pNewInner, sal_Bool bRecord = sal_True );
172 :
173 : void ApplyUserItemSet( const SfxItemSet& rItemSet );
174 :
175 : const SfxStyleSheet* GetStyleSheetFromMarked();
176 : void SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet,
177 : sal_Bool bRecord = sal_True );
178 : void RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet );
179 : void UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet );
180 :
181 : void SetNumberFormat( short nFormatType, sal_uLong nAdd = 0 );
182 : void SetNumFmtByStr( const String& rCode );
183 : void ChangeNumFmtDecimals( sal_Bool bIncrement );
184 :
185 : void SetValidation( const ScValidationData& rNew );
186 :
187 : void ChangeIndent( sal_Bool bIncrement );
188 :
189 : void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect );
190 :
191 : void Protect( SCTAB nTab, const String& rPassword );
192 : sal_Bool Unprotect( SCTAB nTab, const String& rPassword );
193 :
194 : void DeleteCells( DelCellCmd eCmd, sal_Bool bRecord = sal_True );
195 : sal_Bool InsertCells( InsCellCmd eCmd, sal_Bool bRecord = sal_True, sal_Bool bPartOfPaste = false );
196 : void DeleteMulti( sal_Bool bRows, sal_Bool bRecord = sal_True );
197 :
198 : void DeleteContents( sal_uInt16 nFlags, sal_Bool bRecord = sal_True );
199 :
200 : void SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
201 : ScSizeMode eMode, sal_uInt16 nSizeTwips,
202 : sal_Bool bRecord = sal_True, sal_Bool bPaint = sal_True,
203 : ScMarkData* pMarkData = NULL );
204 : void SetMarkedWidthOrHeight( sal_Bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips,
205 : sal_Bool bRecord = sal_True, sal_Bool bPaint = sal_True );
206 : void ShowMarkedColumns( sal_Bool bShow, sal_Bool bRecord = sal_True );
207 : void ShowMarkedRows( sal_Bool bShow, sal_Bool bRecord = sal_True );
208 :
209 : sal_Bool AdjustBlockHeight( sal_Bool bPaint = sal_True, ScMarkData* pMarkData = NULL );
210 : sal_Bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, sal_Bool bPaint = sal_True );
211 :
212 : void ModifyCellSize( ScDirection eDir, sal_Bool bOptimal );
213 :
214 : SC_DLLPUBLIC void InsertPageBreak( sal_Bool bColumn, sal_Bool bRecord = sal_True,
215 : const ScAddress* pPos = NULL,
216 : sal_Bool bSetModified = sal_True );
217 : SC_DLLPUBLIC void DeletePageBreak( sal_Bool bColumn, sal_Bool bRecord = sal_True,
218 : const ScAddress* pPos = NULL,
219 : sal_Bool bSetModified = sal_True );
220 :
221 : void RemoveManualBreaks();
222 :
223 : void SetPrintZoom(sal_uInt16 nScale, sal_uInt16 nPages);
224 : void AdjustPrintZoom();
225 :
226 : sal_Bool TestMergeCells();
227 : sal_Bool TestRemoveMerge();
228 :
229 : sal_Bool MergeCells( sal_Bool bApi, sal_Bool& rDoContents, sal_Bool bRecord = true, sal_Bool bCenter = false );
230 : sal_Bool RemoveMerge( sal_Bool bRecord = true );
231 :
232 : void FillSimple( FillDir eDir, bool bRecord = true );
233 : void FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
234 : double fStart, double fStep, double fMax, sal_Bool bRecord = sal_True );
235 : void FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
236 : SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount, sal_Bool bRecord = sal_True );
237 : void FillCrossDblClick();
238 :
239 : void TransliterateText( sal_Int32 nType );
240 :
241 : ScAutoFormatData* CreateAutoFormatData();
242 : void AutoFormat( sal_uInt16 nFormatNo, sal_Bool bRecord = sal_True );
243 :
244 : void SearchAndReplace( const SvxSearchItem* pSearchItem,
245 : sal_Bool bAddUndo, sal_Bool bIsApi );
246 :
247 : void Solve( const ScSolveParam& rParam );
248 : void TabOp( const ScTabOpParam& rParam, sal_Bool bRecord = sal_True );
249 :
250 : sal_Bool InsertTable( const String& rName, SCTAB nTabNr, sal_Bool bRecord = sal_True );
251 : sal_Bool InsertTables(std::vector<OUString>& aNames, SCTAB nTab, SCTAB nCount, sal_Bool bRecord = sal_True);
252 :
253 :
254 : sal_Bool AppendTable( const String& rName, sal_Bool bRecord = sal_True );
255 :
256 : sal_Bool DeleteTable( SCTAB nTabNr, sal_Bool bRecord = true );
257 : sal_Bool DeleteTables(const std::vector<SCTAB>& TheTabs, sal_Bool bRecord = true );
258 : bool DeleteTables(SCTAB nTab, SCTAB nSheets);
259 :
260 : sal_Bool RenameTable( const String& rName, SCTAB nTabNr );
261 : void MoveTable( sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy, const OUString* pNewTabName = NULL );
262 : void ImportTables( ScDocShell* pSrcShell,
263 : SCTAB nCount, const SCTAB* pSrcTabs,
264 : sal_Bool bLink,SCTAB nTab);
265 :
266 : bool SetTabBgColor( const Color& rColor, SCTAB nTabNr );
267 : bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList );
268 :
269 : void InsertTableLink( const String& rFile,
270 : const String& rFilter, const String& rOptions,
271 : const String& rTabName );
272 : void InsertAreaLink( const String& rFile,
273 : const String& rFilter, const String& rOptions,
274 : const String& rSource, sal_uLong nRefresh );
275 :
276 : void ShowTable( const std::vector<String>& rNames );
277 : void HideTable( const ScMarkData& rMark );
278 :
279 : void MakeScenario( const String& rName, const String& rComment,
280 : const Color& rColor, sal_uInt16 nFlags );
281 : void ExtendScenario();
282 : void UseScenario( const String& rName );
283 :
284 : void InsertSpecialChar( const String& rStr, const Font& rFont );
285 :
286 : void InsertDummyObject();
287 : void InsertOleObject();
288 :
289 : void InsertDraw();
290 :
291 : void SetSelectionFrameLines( const ::editeng::SvxBorderLine* pLine,
292 : sal_Bool bColorOnly );
293 :
294 : void SetNoteText( const ScAddress& rPos, const String& rNoteText );
295 : void ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, const OUString* pAuthor, const OUString* pDate );
296 : void DoRefConversion( sal_Bool bRecord = sal_True );
297 :
298 : void DoHangulHanjaConversion( sal_Bool bRecord = true );
299 : void DoThesaurus( sal_Bool bRecord = true );
300 :
301 : /** Generic implementation of sheet conversion functions. */
302 : void DoSheetConversion( const ScConversionParam& rParam, sal_Bool bRecord = sal_True );
303 :
304 : void SetPrintRanges( sal_Bool bEntireSheet,
305 : const String* pPrint,
306 : const String* pRepCol, const String* pRepRow,
307 : sal_Bool bAddPrint );
308 :
309 : void DetectiveAddPred();
310 : void DetectiveDelPred();
311 : void DetectiveAddSucc();
312 : void DetectiveDelSucc();
313 : void DetectiveAddError();
314 : void DetectiveMarkInvalid();
315 : void DetectiveDelAll();
316 : void DetectiveRefresh();
317 : void DetectiveMarkPred();
318 : void DetectiveMarkSucc();
319 :
320 : void InsertCurrentTime(short nCellFmt, const OUString& rUndoStr);
321 :
322 : void ShowNote( bool bShow = true );
323 : inline void HideNote() { ShowNote( false ); }
324 : void EditNote();
325 :
326 0 : void ForgetFormatArea() { bFormatValid = false; }
327 : sal_Bool SelectionEditable( bool* pOnlyNotBecauseOfMatrix = NULL );
328 :
329 : SC_DLLPUBLIC void DataFormPutData( SCROW nCurrentRow ,
330 : SCROW nStartRow , SCCOL nStartCol ,
331 : SCROW nEndRow , SCCOL nEndCol ,
332 : boost::ptr_vector<boost::nullable<Edit> >& aEdits,
333 : sal_uInt16 aColLength );
334 : void UpdateSelectionArea( const ScMarkData& rSel, ScPatternAttr* pAttr = NULL );
335 : // Internal helper functions
336 : protected:
337 : void UpdateLineAttrs( ::editeng::SvxBorderLine& rLine,
338 : const ::editeng::SvxBorderLine* pDestLine,
339 : const ::editeng::SvxBorderLine* pSrcLine,
340 : sal_Bool bColor );
341 :
342 :
343 : private:
344 : void PasteRTF( SCCOL nCol, SCROW nStartRow,
345 : const ::com::sun::star::uno::Reference<
346 : ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
347 :
348 : bool PasteMultiRangesFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc, sal_uInt16 nFunction,
349 : bool bSkipEmpty, bool bTranspose, bool bAsLink, bool bAllowDialogs,
350 : InsCellCmd eMoveMode, sal_uInt16 nUndoFlags );
351 :
352 : bool PasteFromClipToMultiRanges( sal_uInt16 nFlags, ScDocument* pClipDoc, sal_uInt16 nFunction,
353 : bool bSkipEmpty, bool bTranspose, bool bAsLink, bool bAllowDialogs,
354 : InsCellCmd eMoveMode, sal_uInt16 nUndoFlags );
355 :
356 : void PostPasteFromClip(const ScRangeList& rPasteRanges, const ScMarkData& rMark);
357 :
358 : sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, sal_Bool bFormula );
359 :
360 : void StartFormatArea();
361 : sal_Bool TestFormatArea( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bAttrChanged );
362 : void DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab,
363 : sal_Bool bAttrChanged, sal_Bool bAddUndo );
364 :
365 : void MarkAndJumpToRanges(const ScRangeList& rRanges);
366 : };
367 :
368 :
369 :
370 : #endif
371 :
372 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|