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