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