xref: /trunk/main/sc/source/ui/inc/viewfunc.hxx (revision 52f1c2ee)
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 PasteOnDrawObjectLinked(
131         const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable,
132         SdrObject& rHitObj);
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 	void			InsertBookmark( const String& rDescription, const String& rURL,
154 									SCCOL nPosX, SCROW nPosY, const String* pTarget = NULL,
155 									sal_Bool bTryReplace = sal_False );
156 	sal_Bool			HasBookmarkAtCursor( SvxHyperlinkItem* pContent );
157 
158 	long			DropRequestHdl( Exchange* pExchange );
159 	sal_Bool			MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos,
160 									sal_Bool bCut, sal_Bool bRecord, sal_Bool bPaint, sal_Bool bApi );
161 
162 	sal_Bool			LinkBlock( const ScRange& rSource, const ScAddress& rDestPos, sal_Bool bApi );
163 
164 	void			CreateNames( sal_uInt16 nFlags );
165 	sal_uInt16			GetCreateNameFlags();
166 	void			InsertNameList();
167 	sal_Bool			InsertName( const String& rName, const String& rSymbol,
168 								const String& rType );
169 
170 	void			ApplyAttributes( const SfxItemSet* pDialogSet, const SfxItemSet* pOldSet,
171 										sal_Bool bRecord = sal_True );
172 	void			ApplyAttr( const SfxPoolItem& rAttrItem );
173 	void			ApplySelectionPattern( const ScPatternAttr& rAttr,
174 											sal_Bool bRecord = sal_True,
175 											sal_Bool bCursorOnly = sal_False );
176 	void			ApplyPatternLines( const ScPatternAttr& rAttr,
177 										const SvxBoxItem* pNewOuter,
178 										const SvxBoxInfoItem* pNewInner, sal_Bool bRecord = sal_True );
179 
180 	void			ApplyUserItemSet( const SfxItemSet& rItemSet );
181 
182 	const SfxStyleSheet*	GetStyleSheetFromMarked();
183 	void					SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet,
184 														sal_Bool bRecord = sal_True );
185     void                    RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet );
186     void                    UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet );
187 
188 	void			SetNumberFormat( short nFormatType, sal_uLong nAdd = 0 );
189 	void			SetNumFmtByStr( const String& rCode );
190 	void			ChangeNumFmtDecimals( sal_Bool bIncrement );
191 
192 	void			SetConditionalFormat( const ScConditionalFormat& rNew );
193 	void			SetValidation( const ScValidationData& rNew );
194 
195 	void			ChangeIndent( sal_Bool bIncrement );
196 
197 	void			ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect );
198 
199 	void			Protect( SCTAB nTab, const String& rPassword );
200 	sal_Bool			Unprotect( SCTAB nTab, const String& rPassword );
201 
202 	void			DeleteCells( DelCellCmd eCmd, sal_Bool bRecord = sal_True );
203 	sal_Bool			InsertCells( InsCellCmd eCmd, sal_Bool bRecord = sal_True, sal_Bool bPartOfPaste = sal_False );
204 	void			DeleteMulti( sal_Bool bRows, sal_Bool bRecord = sal_True );
205 
206 	void			DeleteContents( sal_uInt16 nFlags, sal_Bool bRecord = sal_True );
207 
208 	void			SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
209 										ScSizeMode eMode, sal_uInt16 nSizeTwips,
210 										sal_Bool bRecord = sal_True, sal_Bool bPaint = sal_True,
211 										ScMarkData* pMarkData = NULL );
212 	void			SetMarkedWidthOrHeight( sal_Bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips,
213 										sal_Bool bRecord = sal_True, sal_Bool bPaint = sal_True );
214 	void			ShowMarkedColumns( sal_Bool bShow, sal_Bool bRecord = sal_True );
215 	void			ShowMarkedRows( sal_Bool bShow, sal_Bool bRecord = sal_True );
216 
217 	sal_Bool			AdjustBlockHeight( sal_Bool bPaint = sal_True, ScMarkData* pMarkData = NULL );
218 	sal_Bool			AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, sal_Bool bPaint = sal_True );
219 
220 	void			ModifyCellSize( ScDirection eDir, sal_Bool bOptimal );
221 
222 	SC_DLLPUBLIC void			InsertPageBreak( sal_Bool bColumn, sal_Bool bRecord = sal_True,
223 										const ScAddress* pPos = NULL,
224 										sal_Bool bSetModified = sal_True );
225 	SC_DLLPUBLIC void			DeletePageBreak( sal_Bool bColumn, sal_Bool bRecord = sal_True,
226 										const ScAddress* pPos = NULL,
227 										sal_Bool bSetModified = sal_True );
228 
229 	void			RemoveManualBreaks();
230 
231 	void			SetPrintZoom(sal_uInt16 nScale, sal_uInt16 nPages);
232 	void			AdjustPrintZoom();
233 
234 	sal_Bool			TestMergeCells();
235 	sal_Bool			TestRemoveMerge();
236 
237 	sal_Bool			MergeCells( sal_Bool bApi, sal_Bool& rDoContents, sal_Bool bRecord = sal_True );
238 	sal_Bool			RemoveMerge( sal_Bool bRecord = sal_True );
239 
240 	void			FillSimple( FillDir eDir, sal_Bool bRecord = sal_True );
241 	void			FillSeries( FillDir	eDir, FillCmd eCmd, FillDateCmd	eDateCmd,
242 								double fStart, double fStep, double fMax, sal_Bool bRecord = sal_True );
243 	void			FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
244 								SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount, sal_Bool bRecord = sal_True );
245 	void			FillCrossDblClick();
246 
247 	void			TransliterateText( sal_Int32 nType );
248 
249 	ScAutoFormatData* CreateAutoFormatData();
250 	void			AutoFormat( sal_uInt16 nFormatNo, sal_Bool bRecord = sal_True );
251 
252 //	void			SearchAndReplace( const SvxSearchItem* pSearchItem,
253 	sal_Bool			SearchAndReplace( const SvxSearchItem* pSearchItem,
254 										sal_Bool bAddUndo, sal_Bool bIsApi );
255 
256 	void			Solve( const ScSolveParam& rParam );
257 	void			TabOp( const ScTabOpParam& rParam,  sal_Bool bRecord = sal_True );
258 
259 	sal_Bool			InsertTable( const String& rName, SCTAB nTabNr, sal_Bool bRecord = sal_True );
260 	sal_Bool			InsertTables(SvStrings *pNames, SCTAB nTab, SCTAB nCount, sal_Bool bRecord = sal_True);
261 
262 
263 	sal_Bool			AppendTable( const String& rName, sal_Bool bRecord = sal_True );
264 
265 	sal_Bool			DeleteTable( SCTAB nTabNr, sal_Bool bRecord = sal_True );
266 	sal_Bool			DeleteTables(const SvShorts &TheTabs, sal_Bool bRecord = sal_True );
267 
268 	sal_Bool			RenameTable( const String& rName, SCTAB nTabNr );
269 	void			MoveTable( sal_uInt16 nDestDocNo, SCTAB nDestTab, sal_Bool bCopy );
270 	void			ImportTables( ScDocShell* pSrcShell,
271 									SCTAB nCount, const SCTAB* pSrcTabs,
272 									sal_Bool bLink,SCTAB nTab);
273 
274     bool            SetTabBgColor( const Color& rColor, SCTAB nTabNr );
275     bool            SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList );
276 
277 	void			InsertTableLink( const String& rFile,
278 										const String& rFilter, const String& rOptions,
279 										const String& rTabName );
280 	void			InsertAreaLink( const String& rFile,
281 										const String& rFilter, const String& rOptions,
282 										const String& rSource, sal_uLong nRefresh );
283 
284 	void			ShowTable( const String& rName );
285 	void			HideTable( SCTAB nTabNr );
286 
287 	void			MakeScenario( const String& rName, const String& rComment,
288 									const Color& rColor, sal_uInt16 nFlags );
289 	void			ExtendScenario();
290 	void			UseScenario( const String& rName );
291 
292 	void			InsertSpecialChar( const String& rStr, const Font& rFont );
293 
294 	void			InsertDummyObject();
295 	void			InsertOleObject();
296 
297 	void			InsertDraw();
298 
299 	void			SetSelectionFrameLines( const SvxBorderLine* pLine,
300 											sal_Bool bColorOnly );
301 
302     void            SetNoteText( const ScAddress& rPos, const String& rNoteText );
303     void            ReplaceNote( const ScAddress& rPos, const String& rNoteText, const String* pAuthor, const String* pDate );
304     void            DoRefConversion( sal_Bool bRecord = sal_True );
305 
306 //UNUSED2008-05  void            DoSpellingChecker( sal_Bool bRecord = sal_True );
307     void            DoHangulHanjaConversion( sal_Bool bRecord = sal_True );
308 	void			DoThesaurus( sal_Bool bRecord = sal_True );
309 //UNUSED2008-05  DECL_LINK( SpellError, void * );
310 
311     /** Generic implementation of sheet conversion functions. */
312     void            DoSheetConversion( const ScConversionParam& rParam, sal_Bool bRecord = sal_True );
313 
314     void            SetPrintRanges( sal_Bool bEntireSheet,
315                                     const String* pPrint,
316 									const String* pRepCol, const String* pRepRow,
317 									sal_Bool bAddPrint );
318 
319 	void			DetectiveAddPred();
320 	void			DetectiveDelPred();
321 	void			DetectiveAddSucc();
322 	void			DetectiveDelSucc();
323 	void			DetectiveAddError();
324 	void			DetectiveMarkInvalid();
325 	void			DetectiveDelAll();
326 	void			DetectiveRefresh();
327 
328 	void			ShowNote( bool bShow = true );
HideNote()329 	inline void		HideNote() { ShowNote( false ); }
330 	void			EditNote();
331 
ForgetFormatArea()332 	void			ForgetFormatArea()		{ bFormatValid = sal_False; }
333 	sal_Bool			SelectionEditable( sal_Bool* pOnlyNotBecauseOfMatrix = NULL );
334 
335 												// interne Hilfsfunktionen
336 protected:
337 	void			UpdateLineAttrs( SvxBorderLine&		  rLine,
338 									 const SvxBorderLine* pDestLine,
339 									 const SvxBorderLine* pSrcLine,
340 									 sal_Bool 				  bColor );
341 
342 //UNUSED2008-05  void            PaintWidthHeight( sal_Bool bColumns, SCCOLROW nStart, SCCOLROW nEnd );
343 
344 
345 private:
346 	void			PasteRTF( SCCOL nCol, SCROW nStartRow,
347 								const ::com::sun::star::uno::Reference<
348 										::com::sun::star::datatransfer::XTransferable >& rxTransferable );
349     bool            PasteMultiRangesFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc, sal_uInt16 nFunction,
350                                               bool bSkipEmpty, bool bTranspos, bool bAsLink, bool bAllowDialogs,
351                                               InsCellCmd eMoveMode, sal_uInt16 nCondFlags, sal_uInt16 nUndoFlags );
352     void            PostPasteFromClip(const ScRange& rPasteRange, const ScMarkData& rMark);
353 
354 	sal_uInt16			GetOptimalColWidth( SCCOL nCol, SCTAB nTab, sal_Bool bFormula );
355 
356 	void			StartFormatArea();
357 	sal_Bool			TestFormatArea( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bAttrChanged );
358 	void			DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab,
359 										sal_Bool bAttrChanged, sal_Bool bAddUndo );
360 };
361 
362 
363 
364 #endif
365 
366