1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef SC_VIEWFUNC_HXX
20 #define SC_VIEWFUNC_HXX
22 #include "tabview.hxx"
24 #include "tabbgcolor.hxx"
26 #include <com/sun/star/embed/XEmbeddedObject.hpp>
27 #include <com/sun/star/embed/Aspects.hpp>
29 #include <boost/ptr_container/ptr_vector.hpp>
32 class ScAutoFormatData
;
37 class SfxStyleSheetBase
;
43 class ScValidationData
;
44 class ScConversionParam
;
49 class SvxHyperlinkItem
;
51 class ScTableProtection
;
53 namespace editeng
{ class SvxBorderLine
; }
55 namespace com
{ namespace sun
{ namespace star
{ namespace datatransfer
{ class XTransferable
; } } } }
57 //==================================================================
59 class ScViewFunc
: public ScTabView
62 ScAddress aFormatSource
; // for automatic extension of formatting
64 sal_Bool bFormatValid
;
67 ScViewFunc( Window
* pParent
, ScDocShell
& rDocSh
, ScTabViewShell
* pViewShell
);
70 const ScPatternAttr
* GetSelectionPattern ();
71 void GetSelectionFrame ( SvxBoxItem
& rLineOuter
,
72 SvxBoxInfoItem
& rLineInner
);
74 sal_uInt8
GetSelectionScriptType();
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 OUString
GetAutoSumFormula( const ScRangeList
& rRangeList
, bool bSubTotal
, const ScAddress
& rAddr
);
81 void EnterData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const OUString
& rString
,
82 const EditTextObject
* pData
= NULL
);
83 void EnterData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
84 const EditTextObject
& rData
, bool bTestSimple
= false );
85 void EnterValue( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const double& rValue
);
87 void EnterMatrix( const OUString
& rString
, ::formula::FormulaGrammar::Grammar eGram
);
90 * @param pData The caller must manage the life cycle of the object this
91 * pointer points to. NULL is allowed.
93 void EnterBlock( const OUString
& rString
, const EditTextObject
* pData
);
95 void EnterDataAtCursor( const OUString
& rString
); //! Not used?
97 SC_DLLPUBLIC
void CutToClip( ScDocument
* pClipDoc
= NULL
, sal_Bool bIncludeObjects
= false );
98 SC_DLLPUBLIC sal_Bool
CopyToClip( ScDocument
* pClipDoc
= NULL
, sal_Bool bCut
= false, sal_Bool bApi
= false,
99 sal_Bool bIncludeObjects
= false, sal_Bool bStopEdit
= true );
100 SC_DLLPUBLIC sal_Bool
CopyToClip( ScDocument
* pClipDoc
, const ScRangeList
& rRange
, sal_Bool bCut
= false,
101 sal_Bool bApi
= false, sal_Bool bIncludeObjects
= false, sal_Bool bStopEdit
= true, sal_Bool bUseRangeForVBA
= true );
102 ScTransferObj
* CopyToTransferable();
103 SC_DLLPUBLIC
bool PasteFromClip( sal_uInt16 nFlags
, ScDocument
* pClipDoc
,
104 sal_uInt16 nFunction
= PASTE_NOFUNC
, bool bSkipEmpty
= false,
105 bool bTranspose
= false, bool bAsLink
= false,
106 InsCellCmd eMoveMode
= INS_NONE
,
107 sal_uInt16 nUndoExtraFlags
= IDF_NONE
,
108 bool bAllowDialogs
= false );
110 void FillTab( sal_uInt16 nFlags
, sal_uInt16 nFunction
, sal_Bool bSkipEmpty
, sal_Bool bAsLink
);
112 SC_DLLPUBLIC
void PasteFromSystem();
113 SC_DLLPUBLIC sal_Bool
PasteFromSystem( sal_uLong nFormatId
, sal_Bool bApi
= false );
114 void PasteFromTransferable( const ::com::sun::star::uno::Reference
<
115 ::com::sun::star::datatransfer::XTransferable
>& rxTransferable
);
118 void PasteDraw( const Point
& rLogicPos
, SdrModel
* pModel
,
119 sal_Bool bGroup
= false, sal_Bool bSameDocClipboard
= false );
121 sal_Bool
PasteOnDrawObject( const ::com::sun::star::uno::Reference
<
122 ::com::sun::star::datatransfer::XTransferable
>& rxTransferable
,
123 SdrObject
* pHitObj
, sal_Bool bLink
);
125 sal_Bool
PasteDataFormat( sal_uLong nFormatId
,
126 const ::com::sun::star::uno::Reference
<
127 ::com::sun::star::datatransfer::XTransferable
>& rxTransferable
,
128 SCCOL nPosX
, SCROW nPosY
, Point
* pLogicPos
= NULL
,
129 sal_Bool bLink
= false, sal_Bool bAllowDialogs
= false );
131 sal_Bool
PasteFile( const Point
&, const OUString
&, sal_Bool bLink
=false );
132 sal_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
);
133 sal_Bool
PasteBitmapEx( const Point
&, const BitmapEx
& );
134 sal_Bool
PasteMetaFile( const Point
&, const GDIMetaFile
& );
135 sal_Bool
PasteGraphic( const Point
& rPos
, const Graphic
& rGraphic
,
136 const OUString
& rFile
, const OUString
& rFilter
);
137 sal_Bool
PasteBookmark( sal_uLong nFormatId
,
138 const ::com::sun::star::uno::Reference
<
139 ::com::sun::star::datatransfer::XTransferable
>& rxTransferable
,
140 SCCOL nPosX
, SCROW nPosY
);
141 bool PasteLink( const ::com::sun::star::uno::Reference
<
142 ::com::sun::star::datatransfer::XTransferable
>& rxTransferable
);
144 sal_Bool
ApplyGraphicToObject( SdrObject
* pObject
, const Graphic
& rGraphic
);
146 void InsertBookmark( const OUString
& rDescription
, const OUString
& rURL
,
147 SCCOL nPosX
, SCROW nPosY
, const OUString
* pTarget
= NULL
,
148 sal_Bool bTryReplace
= false );
149 bool HasBookmarkAtCursor( SvxHyperlinkItem
* pContent
);
151 long DropRequestHdl( Exchange
* pExchange
);
152 sal_Bool
MoveBlockTo( const ScRange
& rSource
, const ScAddress
& rDestPos
,
153 sal_Bool bCut
, sal_Bool bRecord
, sal_Bool bPaint
, sal_Bool bApi
);
155 sal_Bool
LinkBlock( const ScRange
& rSource
, const ScAddress
& rDestPos
, sal_Bool bApi
);
157 void CreateNames( sal_uInt16 nFlags
);
158 sal_uInt16
GetCreateNameFlags();
159 void InsertNameList();
160 bool InsertName( const OUString
& rName
, const OUString
& rSymbol
,
161 const OUString
& rType
);
163 void ApplyAttributes( const SfxItemSet
* pDialogSet
, const SfxItemSet
* pOldSet
,
164 bool bRecord
= true );
165 void ApplyAttr( const SfxPoolItem
& rAttrItem
);
166 void ApplySelectionPattern( const ScPatternAttr
& rAttr
,
168 bool bCursorOnly
= false );
169 void ApplyPatternLines( const ScPatternAttr
& rAttr
,
170 const SvxBoxItem
* pNewOuter
,
171 const SvxBoxInfoItem
* pNewInner
, bool bRecord
= true );
173 void ApplyUserItemSet( const SfxItemSet
& rItemSet
);
175 const SfxStyleSheet
* GetStyleSheetFromMarked();
176 void SetStyleSheetToMarked( SfxStyleSheet
* pStyleSheet
,
177 bool bRecord
= true );
178 void RemoveStyleSheetInUse( const SfxStyleSheetBase
* pStyleSheet
);
179 void UpdateStyleSheetInUse( const SfxStyleSheetBase
* pStyleSheet
);
181 void SetNumberFormat( short nFormatType
, sal_uLong nAdd
= 0 );
182 void SetNumFmtByStr( const OUString
& rCode
);
183 void ChangeNumFmtDecimals( bool bIncrement
);
185 void SetValidation( const ScValidationData
& rNew
);
187 void ChangeIndent( bool bIncrement
);
189 void ProtectSheet( SCTAB nTab
, const ScTableProtection
& rProtect
);
191 void Protect( SCTAB nTab
, const OUString
& rPassword
);
192 bool Unprotect( SCTAB nTab
, const OUString
& rPassword
);
194 void DeleteCells( DelCellCmd eCmd
, bool bRecord
= true );
195 bool InsertCells( InsCellCmd eCmd
, bool bRecord
= true, bool bPartOfPaste
= false );
196 void DeleteMulti( bool bRows
, bool bRecord
= true );
198 void DeleteContents( sal_uInt16 nFlags
, bool bRecord
= true );
200 void SetWidthOrHeight( bool bWidth
, SCCOLROW nRangeCnt
, SCCOLROW
* pRanges
,
201 ScSizeMode eMode
, sal_uInt16 nSizeTwips
,
202 bool bRecord
= true, bool bPaint
= true,
203 ScMarkData
* pMarkData
= NULL
);
204 void SetMarkedWidthOrHeight( bool bWidth
, ScSizeMode eMode
, sal_uInt16 nSizeTwips
,
205 bool bRecord
= true, bool bPaint
= true );
206 void ShowMarkedColumns( sal_Bool bShow
, sal_Bool bRecord
= sal_True
);
207 void ShowMarkedRows( sal_Bool bShow
, sal_Bool bRecord
= sal_True
);
209 sal_Bool
AdjustBlockHeight( sal_Bool bPaint
= sal_True
, ScMarkData
* pMarkData
= NULL
);
210 sal_Bool
AdjustRowHeight( SCROW nStartRow
, SCROW nEndRow
, sal_Bool bPaint
= sal_True
);
212 void ModifyCellSize( ScDirection eDir
, bool bOptimal
);
214 SC_DLLPUBLIC
void InsertPageBreak( sal_Bool bColumn
, sal_Bool bRecord
= sal_True
,
215 const ScAddress
* pPos
= NULL
,
216 sal_Bool bSetModified
= sal_True
);
217 SC_DLLPUBLIC
void DeletePageBreak( sal_Bool bColumn
, sal_Bool bRecord
= sal_True
,
218 const ScAddress
* pPos
= NULL
,
219 sal_Bool bSetModified
= sal_True
);
221 void RemoveManualBreaks();
223 void SetPrintZoom(sal_uInt16 nScale
, sal_uInt16 nPages
);
224 void AdjustPrintZoom();
226 sal_Bool
TestMergeCells();
227 sal_Bool
TestRemoveMerge();
229 sal_Bool
MergeCells( sal_Bool bApi
, sal_Bool
& rDoContents
, sal_Bool bRecord
= true, sal_Bool bCenter
= false );
230 sal_Bool
RemoveMerge( sal_Bool bRecord
= true );
232 void FillSimple( FillDir eDir
, bool bRecord
= true );
233 void FillSeries( FillDir eDir
, FillCmd eCmd
, FillDateCmd eDateCmd
,
234 double fStart
, double fStep
, double fMax
, sal_Bool bRecord
= sal_True
);
235 void FillAuto( FillDir eDir
, SCCOL nStartCol
, SCROW nStartRow
,
236 SCCOL nEndCol
, SCROW nEndRow
, sal_uLong nCount
, sal_Bool bRecord
= sal_True
);
237 void FillCrossDblClick();
239 void TransliterateText( sal_Int32 nType
);
241 ScAutoFormatData
* CreateAutoFormatData();
242 void AutoFormat( sal_uInt16 nFormatNo
, sal_Bool bRecord
= sal_True
);
244 void SearchAndReplace( const SvxSearchItem
* pSearchItem
,
245 sal_Bool bAddUndo
, sal_Bool bIsApi
);
247 void Solve( const ScSolveParam
& rParam
);
248 void TabOp( const ScTabOpParam
& rParam
, sal_Bool bRecord
= sal_True
);
250 sal_Bool
InsertTable( const OUString
& rName
, SCTAB nTabNr
, sal_Bool bRecord
= sal_True
);
251 sal_Bool
InsertTables(std::vector
<OUString
>& aNames
, SCTAB nTab
, SCTAB nCount
, sal_Bool bRecord
= sal_True
);
254 sal_Bool
AppendTable( const OUString
& rName
, sal_Bool bRecord
= sal_True
);
256 sal_Bool
DeleteTable( SCTAB nTabNr
, sal_Bool bRecord
= true );
257 sal_Bool
DeleteTables(const std::vector
<SCTAB
>& TheTabs
, sal_Bool bRecord
= true );
258 bool DeleteTables(SCTAB nTab
, SCTAB nSheets
);
260 sal_Bool
RenameTable( const OUString
& rName
, SCTAB nTabNr
);
261 void MoveTable( sal_uInt16 nDestDocNo
, SCTAB nDestTab
, bool bCopy
, const OUString
* pNewTabName
= NULL
);
262 void ImportTables( ScDocShell
* pSrcShell
,
263 SCTAB nCount
, const SCTAB
* pSrcTabs
,
264 sal_Bool bLink
,SCTAB nTab
);
266 bool SetTabBgColor( const Color
& rColor
, SCTAB nTabNr
);
267 bool SetTabBgColor( ScUndoTabColorInfo::List
& rUndoSetTabBgColorInfoList
);
269 void InsertTableLink( const OUString
& rFile
,
270 const OUString
& rFilter
, const OUString
& rOptions
,
271 const OUString
& rTabName
);
272 void InsertAreaLink( const OUString
& rFile
,
273 const OUString
& rFilter
, const OUString
& rOptions
,
274 const OUString
& rSource
, sal_uLong nRefresh
);
276 void ShowTable( const std::vector
<OUString
>& rNames
);
277 void HideTable( const ScMarkData
& rMark
);
279 void MakeScenario( const OUString
& rName
, const OUString
& rComment
,
280 const Color
& rColor
, sal_uInt16 nFlags
);
281 void ExtendScenario();
282 void UseScenario( const OUString
& rName
);
284 void InsertSpecialChar( const OUString
& rStr
, const Font
& rFont
);
286 void InsertDummyObject();
287 void InsertOleObject();
291 void SetSelectionFrameLines( const ::editeng::SvxBorderLine
* pLine
,
292 sal_Bool bColorOnly
);
294 void SetNoteText( const ScAddress
& rPos
, const OUString
& rNoteText
);
295 void ReplaceNote( const ScAddress
& rPos
, const OUString
& rNoteText
, const OUString
* pAuthor
, const OUString
* pDate
);
296 void DoRefConversion( sal_Bool bRecord
= sal_True
);
298 void DoHangulHanjaConversion( sal_Bool bRecord
= true );
299 void DoThesaurus( sal_Bool bRecord
= true );
301 /** Generic implementation of sheet conversion functions. */
302 void DoSheetConversion( const ScConversionParam
& rParam
, sal_Bool bRecord
= sal_True
);
304 void SetPrintRanges( sal_Bool bEntireSheet
,
305 const OUString
* pPrint
,
306 const OUString
* pRepCol
, const OUString
* pRepRow
,
307 sal_Bool bAddPrint
);
309 void DetectiveAddPred();
310 void DetectiveDelPred();
311 void DetectiveAddSucc();
312 void DetectiveDelSucc();
313 void DetectiveAddError();
314 void DetectiveMarkInvalid();
315 void DetectiveDelAll();
316 void DetectiveRefresh();
317 void DetectiveMarkPred();
318 void DetectiveMarkSucc();
320 void InsertCurrentTime(short nCellFmt
, const OUString
& rUndoStr
);
322 void ShowNote( bool bShow
= true );
323 inline void HideNote() { ShowNote( false ); }
326 void ForgetFormatArea() { bFormatValid
= false; }
327 bool SelectionEditable( bool* pOnlyNotBecauseOfMatrix
= NULL
);
329 SC_DLLPUBLIC
void DataFormPutData( SCROW nCurrentRow
,
330 SCROW nStartRow
, SCCOL nStartCol
,
331 SCROW nEndRow
, SCCOL nEndCol
,
332 boost::ptr_vector
<boost::nullable
<Edit
> >& aEdits
,
333 sal_uInt16 aColLength
);
334 void UpdateSelectionArea( const ScMarkData
& rSel
, ScPatternAttr
* pAttr
= NULL
);
335 // Internal helper functions
337 void UpdateLineAttrs( ::editeng::SvxBorderLine
& rLine
,
338 const ::editeng::SvxBorderLine
* pDestLine
,
339 const ::editeng::SvxBorderLine
* pSrcLine
,
344 void PasteRTF( SCCOL nCol
, SCROW nStartRow
,
345 const ::com::sun::star::uno::Reference
<
346 ::com::sun::star::datatransfer::XTransferable
>& rxTransferable
);
348 bool PasteMultiRangesFromClip( sal_uInt16 nFlags
, ScDocument
* pClipDoc
, sal_uInt16 nFunction
,
349 bool bSkipEmpty
, bool bTranspose
, bool bAsLink
, bool bAllowDialogs
,
350 InsCellCmd eMoveMode
, sal_uInt16 nUndoFlags
);
352 bool PasteFromClipToMultiRanges( sal_uInt16 nFlags
, ScDocument
* pClipDoc
, sal_uInt16 nFunction
,
353 bool bSkipEmpty
, bool bTranspose
, bool bAsLink
, bool bAllowDialogs
,
354 InsCellCmd eMoveMode
, sal_uInt16 nUndoFlags
);
356 void PostPasteFromClip(const ScRangeList
& rPasteRanges
, const ScMarkData
& rMark
);
358 sal_uInt16
GetOptimalColWidth( SCCOL nCol
, SCTAB nTab
, bool bFormula
);
360 void StartFormatArea();
361 bool TestFormatArea( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, bool bAttrChanged
);
362 void DoAutoAttributes( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
363 bool bAttrChanged
, bool bAddUndo
);
365 void MarkAndJumpToRanges(const ScRangeList
& rRanges
);
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */