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