xref: /aoo42x/main/sc/source/ui/inc/viewfunc.hxx (revision 4d7c9de0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef SC_VIEWFUNC_HXX
24 #define SC_VIEWFUNC_HXX
25 
26 #include "tabview.hxx"
27 
28 #include "tabbgcolor.hxx"
29 
30 #ifndef _SVSTDARR_SHORTS
31 #define _SVSTDARR_SHORTS
32 #include <svl/svstdarr.hxx>
33 
34 #endif
35 
36 #ifndef _SVSTDARR_STRINGS
37 
38 #define _SVSTDARR_STRINGS
39 #include <svl/svstdarr.hxx>
40 
41 #endif
42 #include <com/sun/star/embed/XEmbeddedObject.hpp>
43 #include <com/sun/star/embed/Aspects.hpp>
44 
45 class ScPatternAttr;
46 class ScAutoFormatData;
47 class SvxSearchItem;
48 class SfxItemSet;
49 class SvxBorderLine;
50 class SvxBoxItem;
51 class SvxBoxInfoItem;
52 class SfxStyleSheetBase;
53 class SfxStyleSheet;
54 class SfxPoolItem;
55 class EditTextObject;
56 struct ScSolveParam;
57 struct ScTabOpParam;
58 class ScPostIt;
59 class ScConditionalFormat;
60 class ScValidationData;
61 class ScConversionParam;
62 class SdrModel;
63 class Graphic;
64 class Exchange;
65 class ScRangeList;
66 class SvxHyperlinkItem;
67 class ScTransferObj;
68 class ScTableProtection;
69 
70 namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
71 
72 //==================================================================
73 
74 class ScViewFunc : public ScTabView
75 {
76 private:
77 	ScAddress	aFormatSource;		// fuer automatisches Erweitern von Formatierung
78 	ScRange		aFormatArea;
79 	sal_Bool		bFormatValid;
80 
81 public:
82 					ScViewFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
83 //UNUSED2008-05     ScViewFunc( Window* pParent, const ScViewFunc& rViewFunc, ScTabViewShell* pViewShell );
84 					~ScViewFunc();
85 
86 	const ScPatternAttr*    GetSelectionPattern	();
87 	void					GetSelectionFrame	( SvxBoxItem&		rLineOuter,
88 												  SvxBoxInfoItem&	rLineInner );
89 
90 	sal_uInt8			GetSelectionScriptType();
91 
92 	sal_Bool			GetAutoSumArea(ScRangeList& rRangeList);
93 	void			EnterAutoSum(const ScRangeList& rRangeList, sal_Bool bSubTotal);
94     bool            AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor, bool bContinue );
95     String          GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal );
96 
97 	void			EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
98                                sal_Bool bRecord = sal_True, const EditTextObject* pData = NULL );
99 	void			EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rValue );
100 	void			EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextObject* pData,
101 								sal_Bool bRecord = sal_True, sal_Bool bTestSimple = sal_False );
102 
103 	void			EnterMatrix( const String& rString );
104 	void			EnterBlock( const String& rString, const EditTextObject* pData );
105 
106 	void			EnterDataAtCursor( const String& rString );			//! nicht benutzt ?
107 
108 	SC_DLLPUBLIC void			CutToClip( ScDocument* pClipDoc = NULL, sal_Bool bIncludeObjects = sal_False );
109 	SC_DLLPUBLIC sal_Bool			CopyToClip( ScDocument* pClipDoc = NULL, sal_Bool bCut = sal_False, sal_Bool bApi = sal_False,
110 								sal_Bool bIncludeObjects = sal_False, sal_Bool bStopEdit = sal_True );
111     ScTransferObj*              CopyToTransferable();
112 	SC_DLLPUBLIC sal_Bool			PasteFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc,
113 									sal_uInt16 nFunction = PASTE_NOFUNC, sal_Bool bSkipEmpty = sal_False,
114 									sal_Bool bTranspose = sal_False, sal_Bool bAsLink = sal_False,
115 									InsCellCmd eMoveMode = INS_NONE,
116 									sal_uInt16 nUndoExtraFlags = IDF_NONE,
117 									sal_Bool bAllowDialogs = sal_False );
118 
119 	void			FillTab( sal_uInt16 nFlags, sal_uInt16 nFunction, sal_Bool bSkipEmpty, sal_Bool bAsLink );
120 
121 	SC_DLLPUBLIC void			PasteFromSystem();
122 	SC_DLLPUBLIC sal_Bool			PasteFromSystem( sal_uLong nFormatId, sal_Bool bApi = sal_False );
123     void                        PasteFromTransferable( const ::com::sun::star::uno::Reference<
124                                                        ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
125 
126 	void			PasteDraw();
127 	void			PasteDraw( const Point& rLogicPos, SdrModel* pModel,
128                                 sal_Bool bGroup = sal_False, sal_Bool bSameDocClipboard = sal_False );
129 
130 	sal_Bool			PasteOnDrawObject( const ::com::sun::star::uno::Reference<
131 											::com::sun::star::datatransfer::XTransferable >& rxTransferable,
132 										SdrObject* pHitObj, sal_Bool bLink );
133 
134 	sal_Bool			PasteDataFormat( sal_uLong nFormatId,
135 										const ::com::sun::star::uno::Reference<
136 											::com::sun::star::datatransfer::XTransferable >& rxTransferable,
137 										SCCOL nPosX, SCROW nPosY, Point* pLogicPos = NULL,
138 										sal_Bool bLink = sal_False, sal_Bool bAllowDialogs = sal_False );
139 
140 	sal_Bool			PasteFile( const Point&, const String&, sal_Bool bLink=sal_False );
141     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 );
142 	sal_Bool			PasteBitmapEx( const Point&, const BitmapEx& );
143 	sal_Bool			PasteMetaFile( const Point&, const GDIMetaFile& );
144 	sal_Bool			PasteGraphic( const Point& rPos, const Graphic& rGraphic,
145 									const String& rFile, const String& rFilter );
146 	sal_Bool			PasteBookmark( sal_uLong nFormatId,
147 								const ::com::sun::star::uno::Reference<
148 									::com::sun::star::datatransfer::XTransferable >& rxTransferable,
149 								SCCOL nPosX, SCROW nPosY );
150 	sal_Bool			PasteDDE( const ::com::sun::star::uno::Reference<
151 								::com::sun::star::datatransfer::XTransferable >& rxTransferable );
152 
153 	sal_Bool			ApplyGraphicToObject( SdrObject* pObject, const Graphic& rGraphic );
154 
155 	void			InsertBookmark( const String& rDescription, const String& rURL,
156 									SCCOL nPosX, SCROW nPosY, const String* pTarget = NULL,
157 									sal_Bool bTryReplace = sal_False );
158 	sal_Bool			HasBookmarkAtCursor( SvxHyperlinkItem* pContent );
159 
160 	long			DropRequestHdl( Exchange* pExchange );
161 	sal_Bool			MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos,
162 									sal_Bool bCut, sal_Bool bRecord, sal_Bool bPaint, sal_Bool bApi );
163 
164 	sal_Bool			LinkBlock( const ScRange& rSource, const ScAddress& rDestPos, sal_Bool bApi );
165 
166 	void			CreateNames( sal_uInt16 nFlags );
167 	sal_uInt16			GetCreateNameFlags();
168 	void			InsertNameList();
169 	sal_Bool			InsertName( const String& rName, const String& rSymbol,
170 								const String& rType );
171 
172 	void			ApplyAttributes( const SfxItemSet* pDialogSet, const SfxItemSet* pOldSet,
173 										sal_Bool bRecord = sal_True );
174 	void			ApplyAttr( const SfxPoolItem& rAttrItem );
175 	void			ApplySelectionPattern( const ScPatternAttr& rAttr,
176 											sal_Bool bRecord = sal_True,
177 											sal_Bool bCursorOnly = sal_False );
178 	void			ApplyPatternLines( const ScPatternAttr& rAttr,
179 										const SvxBoxItem* pNewOuter,
180 										const SvxBoxInfoItem* pNewInner, sal_Bool bRecord = sal_True );
181 
182 	void			ApplyUserItemSet( const SfxItemSet& rItemSet );
183 
184 	const SfxStyleSheet*	GetStyleSheetFromMarked();
185 	void					SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet,
186 														sal_Bool bRecord = sal_True );
187     void                    RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet );
188     void                    UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet );
189 
190 	void			SetNumberFormat( short nFormatType, sal_uLong nAdd = 0 );
191 	void			SetNumFmtByStr( const String& rCode );
192 	void			ChangeNumFmtDecimals( sal_Bool bIncrement );
193 
194 	void			SetConditionalFormat( const ScConditionalFormat& rNew );
195 	void			SetValidation( const ScValidationData& rNew );
196 
197 	void			ChangeIndent( sal_Bool bIncrement );
198 
199 	void			ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect );
200 
201 	void			Protect( SCTAB nTab, const String& rPassword );
202 	sal_Bool			Unprotect( SCTAB nTab, const String& rPassword );
203 
204 	void			DeleteCells( DelCellCmd eCmd, sal_Bool bRecord = sal_True );
205 	sal_Bool			InsertCells( InsCellCmd eCmd, sal_Bool bRecord = sal_True, sal_Bool bPartOfPaste = sal_False );
206 	void			DeleteMulti( sal_Bool bRows, sal_Bool bRecord = sal_True );
207 
208 	void			DeleteContents( sal_uInt16 nFlags, sal_Bool bRecord = sal_True );
209 
210 	void			SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
211 										ScSizeMode eMode, sal_uInt16 nSizeTwips,
212 										sal_Bool bRecord = sal_True, sal_Bool bPaint = sal_True,
213 										ScMarkData* pMarkData = NULL );
214 	void			SetMarkedWidthOrHeight( sal_Bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips,
215 										sal_Bool bRecord = sal_True, sal_Bool bPaint = sal_True );
216 	void			ShowMarkedColumns( sal_Bool bShow, sal_Bool bRecord = sal_True );
217 	void			ShowMarkedRows( sal_Bool bShow, sal_Bool bRecord = sal_True );
218 
219 	sal_Bool			AdjustBlockHeight( sal_Bool bPaint = sal_True, ScMarkData* pMarkData = NULL );
220 	sal_Bool			AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, sal_Bool bPaint = sal_True );
221 
222 	void			ModifyCellSize( ScDirection eDir, sal_Bool bOptimal );
223 
224 	SC_DLLPUBLIC void			InsertPageBreak( sal_Bool bColumn, sal_Bool bRecord = sal_True,
225 										const ScAddress* pPos = NULL,
226 										sal_Bool bSetModified = sal_True );
227 	SC_DLLPUBLIC void			DeletePageBreak( sal_Bool bColumn, sal_Bool bRecord = sal_True,
228 										const ScAddress* pPos = NULL,
229 										sal_Bool bSetModified = sal_True );
230 
231 	void			RemoveManualBreaks();
232 
233 	void			SetPrintZoom(sal_uInt16 nScale, sal_uInt16 nPages);
234 	void			AdjustPrintZoom();
235 
236 	sal_Bool			TestMergeCells();
237 	sal_Bool			TestRemoveMerge();
238 
239 	sal_Bool			MergeCells( sal_Bool bApi, sal_Bool& rDoContents, sal_Bool bRecord = sal_True );
240 	sal_Bool			RemoveMerge( sal_Bool bRecord = sal_True );
241 
242 	void			FillSimple( FillDir eDir, sal_Bool bRecord = sal_True );
243 	void			FillSeries( FillDir	eDir, FillCmd eCmd, FillDateCmd	eDateCmd,
244 								double fStart, double fStep, double fMax, sal_Bool bRecord = sal_True );
245 	void			FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
246 								SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount, sal_Bool bRecord = sal_True );
247 	void			FillCrossDblClick();
248 
249 	void			TransliterateText( sal_Int32 nType );
250 
251 	ScAutoFormatData* CreateAutoFormatData();
252 	void			AutoFormat( sal_uInt16 nFormatNo, sal_Bool bRecord = sal_True );
253 
254 //	void			SearchAndReplace( const SvxSearchItem* pSearchItem,
255 	sal_Bool			SearchAndReplace( const SvxSearchItem* pSearchItem,
256 										sal_Bool bAddUndo, sal_Bool bIsApi );
257 
258 	void			Solve( const ScSolveParam& rParam );
259 	void			TabOp( const ScTabOpParam& rParam,  sal_Bool bRecord = sal_True );
260 
261 	sal_Bool			InsertTable( const String& rName, SCTAB nTabNr, sal_Bool bRecord = sal_True );
262 	sal_Bool			InsertTables(SvStrings *pNames, SCTAB nTab, SCTAB nCount, sal_Bool bRecord = sal_True);
263 
264 
265 	sal_Bool			AppendTable( const String& rName, sal_Bool bRecord = sal_True );
266 
267 	sal_Bool			DeleteTable( SCTAB nTabNr, sal_Bool bRecord = sal_True );
268 	sal_Bool			DeleteTables(const SvShorts &TheTabs, sal_Bool bRecord = sal_True );
269 
270 	sal_Bool			RenameTable( const String& rName, SCTAB nTabNr );
271 	void			MoveTable( sal_uInt16 nDestDocNo, SCTAB nDestTab, sal_Bool bCopy );
272 	void			ImportTables( ScDocShell* pSrcShell,
273 									SCTAB nCount, const SCTAB* pSrcTabs,
274 									sal_Bool bLink,SCTAB nTab);
275 
276     bool            SetTabBgColor( const Color& rColor, SCTAB nTabNr );
277     bool            SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList );
278 
279 	void			InsertTableLink( const String& rFile,
280 										const String& rFilter, const String& rOptions,
281 										const String& rTabName );
282 	void			InsertAreaLink( const String& rFile,
283 										const String& rFilter, const String& rOptions,
284 										const String& rSource, sal_uLong nRefresh );
285 
286 	void			ShowTable( const String& rName );
287 	void			HideTable( SCTAB nTabNr );
288 
289 	void			MakeScenario( const String& rName, const String& rComment,
290 									const Color& rColor, sal_uInt16 nFlags );
291 	void			ExtendScenario();
292 	void			UseScenario( const String& rName );
293 
294 	void			InsertSpecialChar( const String& rStr, const Font& rFont );
295 
296 	void			InsertDummyObject();
297 	void			InsertOleObject();
298 
299 	void			InsertDraw();
300 
301 	void			SetSelectionFrameLines( const SvxBorderLine* pLine,
302 											sal_Bool bColorOnly );
303 
304     void            SetNoteText( const ScAddress& rPos, const String& rNoteText );
305     void            ReplaceNote( const ScAddress& rPos, const String& rNoteText, const String* pAuthor, const String* pDate );
306     void            DoRefConversion( sal_Bool bRecord = sal_True );
307 
308 //UNUSED2008-05  void            DoSpellingChecker( sal_Bool bRecord = sal_True );
309     void            DoHangulHanjaConversion( sal_Bool bRecord = sal_True );
310 	void			DoThesaurus( sal_Bool bRecord = sal_True );
311 //UNUSED2008-05  DECL_LINK( SpellError, void * );
312 
313     /** Generic implementation of sheet conversion functions. */
314     void            DoSheetConversion( const ScConversionParam& rParam, sal_Bool bRecord = sal_True );
315 
316     void            SetPrintRanges( sal_Bool bEntireSheet,
317                                     const String* pPrint,
318 									const String* pRepCol, const String* pRepRow,
319 									sal_Bool bAddPrint );
320 
321 	void			DetectiveAddPred();
322 	void			DetectiveDelPred();
323 	void			DetectiveAddSucc();
324 	void			DetectiveDelSucc();
325 	void			DetectiveAddError();
326 	void			DetectiveMarkInvalid();
327 	void			DetectiveDelAll();
328 	void			DetectiveRefresh();
329 
330 	void			ShowNote( bool bShow = true );
331 	inline void		HideNote() { ShowNote( false ); }
332 	void			EditNote();
333 
334 	void			ForgetFormatArea()		{ bFormatValid = sal_False; }
335 	sal_Bool			SelectionEditable( sal_Bool* pOnlyNotBecauseOfMatrix = NULL );
336 
337 												// interne Hilfsfunktionen
338 protected:
339 	void			UpdateLineAttrs( SvxBorderLine&		  rLine,
340 									 const SvxBorderLine* pDestLine,
341 									 const SvxBorderLine* pSrcLine,
342 									 sal_Bool 				  bColor );
343 
344 //UNUSED2008-05  void            PaintWidthHeight( sal_Bool bColumns, SCCOLROW nStart, SCCOLROW nEnd );
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     bool            PasteMultiRangesFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc, sal_uInt16 nFunction,
352                                               bool bSkipEmpty, bool bTranspos, bool bAsLink, bool bAllowDialogs,
353                                               InsCellCmd eMoveMode, sal_uInt16 nCondFlags, sal_uInt16 nUndoFlags );
354     void            PostPasteFromClip(const ScRange& rPasteRange, const ScMarkData& rMark);
355 
356 	sal_uInt16			GetOptimalColWidth( SCCOL nCol, SCTAB nTab, sal_Bool bFormula );
357 
358 	void			StartFormatArea();
359 	sal_Bool			TestFormatArea( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bAttrChanged );
360 	void			DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab,
361 										sal_Bool bAttrChanged, sal_Bool bAddUndo );
362 };
363 
364 
365 
366 #endif
367 
368