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 .
21 #include "tabview.hxx"
23 #include <tabbgcolor.hxx>
25 #include <com/sun/star/embed/Aspects.hpp>
29 class ScAutoFormatData
;
34 class SfxStyleSheetBase
;
40 class ScValidationData
;
41 class ScConversionParam
;
45 class SvxHyperlinkItem
;
47 class ScTableProtection
;
48 enum class CreateNameFlags
;
50 namespace editeng
{ class SvxBorderLine
; }
51 namespace com::sun::star::embed
{ class XEmbeddedObject
; }
59 namespace com::sun::star::datatransfer
{ class XTransferable
; }
61 struct ScDataFormFragment
63 std::unique_ptr
<weld::Builder
> m_xBuilder
;
64 std::unique_ptr
<weld::Label
> m_xLabel
;
65 std::unique_ptr
<weld::Entry
> m_xEdit
;
67 ScDataFormFragment(weld::Container
* pGrid
, int nLine
);
70 class ScViewFunc
: public ScTabView
73 ScAddress aFormatSource
; // for automatic extension of formatting
78 ScViewFunc( vcl::Window
* pParent
, ScDocShell
& rDocSh
, ScTabViewShell
* pViewShell
);
81 SC_DLLPUBLIC
const ScPatternAttr
* GetSelectionPattern ();
82 void GetSelectionFrame(
83 std::shared_ptr
<SvxBoxItem
>& rLineOuter
,
84 std::shared_ptr
<SvxBoxInfoItem
>& rLineInner
);
86 SvtScriptType
GetSelectionScriptType();
88 bool GetAutoSumArea( ScRangeList
& rRangeList
);
89 void EnterAutoSum( const ScRangeList
& rRangeList
, bool bSubTotal
, const ScAddress
& rAddr
, const OpCode eCode
);
90 bool AutoSum( const ScRange
& rRange
, bool bSubTotal
, bool bSetCursor
, bool bContinue
, const OpCode eCode
);
91 OUString
GetAutoSumFormula( const ScRangeList
& rRangeList
, bool bSubTotal
, const ScAddress
& rAddr
, const OpCode eCode
);
93 SC_DLLPUBLIC
void EnterData(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const OUString
& rString
,
94 const EditTextObject
* pData
= nullptr, bool bMatrixExpand
= false);
95 void EnterData( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
96 const EditTextObject
& rData
, bool bTestSimple
= false );
97 void EnterValue( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, const double& rValue
);
99 void EnterMatrix( const OUString
& rString
, ::formula::FormulaGrammar::Grammar eGram
);
102 * @param pData The caller must manage the life cycle of the object this
103 * pointer points to. NULL is allowed.
105 void EnterBlock( const OUString
& rString
, const EditTextObject
* pData
);
107 void EnterDataAtCursor( const OUString
& rString
);
109 SC_DLLPUBLIC
void CutToClip();
110 SC_DLLPUBLIC
bool CopyToClip( ScDocument
* pClipDoc
, bool bCut
, bool bApi
= false,
111 bool bIncludeObjects
= false, bool bStopEdit
= true );
112 SC_DLLPUBLIC
bool CopyToClip( ScDocument
* pClipDoc
, const ScRangeList
& rRange
, bool bCut
,
113 bool bApi
= false, bool bIncludeObjects
= false, bool bStopEdit
= true );
114 bool CopyToClipSingleRange( ScDocument
* pClipDoc
, const ScRangeList
& rRanges
, bool bCut
,
115 bool bIncludeObjects
);
116 bool CopyToClipMultiRange( const ScDocument
* pClipDoc
, const ScRangeList
& rRanges
, bool bCut
,
117 bool bApi
, bool bIncludeObjects
);
118 rtl::Reference
<ScTransferObj
> CopyToTransferable();
120 SC_DLLPUBLIC
bool PasteFromClip(
121 InsertDeleteFlags nFlags
, ScDocument
* pClipDoc
,
122 ScPasteFunc nFunction
= ScPasteFunc::NONE
, bool bSkipEmptyCells
= false,
123 bool bTranspose
= false, bool bAsLink
= false,
124 InsCellCmd eMoveMode
= INS_NONE
,
125 InsertDeleteFlags nUndoExtraFlags
= InsertDeleteFlags::NONE
,
126 bool bAllowDialogs
= false );
128 void FillTab( InsertDeleteFlags nFlags
, ScPasteFunc nFunction
, bool bSkipEmpty
, bool bAsLink
);
130 SC_DLLPUBLIC
void PasteFromSystem();
131 SC_DLLPUBLIC
bool PasteFromSystem( SotClipboardFormatId nFormatId
, bool bApi
= false );
132 void PasteFromTransferable( const css::uno::Reference
<
133 css::datatransfer::XTransferable
>& rxTransferable
);
136 void PasteDraw( const Point
& rLogicPos
, SdrModel
* pModel
, bool bGroup
,
137 std::u16string_view rSrcShellID
, std::u16string_view rDestShellID
);
139 bool PasteOnDrawObjectLinked(
140 const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
,
143 bool PasteDataFormat( SotClipboardFormatId nFormatId
,
144 const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
,
145 SCCOL nPosX
, SCROW nPosY
, const Point
* pLogicPos
,
146 bool bLink
= false, bool bAllowDialogs
= false );
148 bool PasteFile( const Point
&, const OUString
&, bool bLink
);
149 bool PasteObject( const Point
&, const css::uno::Reference
< css::embed::XEmbeddedObject
>&, const Size
*, const Graphic
* = nullptr, const OUString
& = OUString(), sal_Int64 nAspect
= css::embed::Aspects::MSOLE_CONTENT
);
150 bool PasteBitmapEx( const Point
&, const BitmapEx
& );
151 bool PasteMetaFile( const Point
&, const GDIMetaFile
& );
152 bool PasteGraphic( const Point
& rPos
, const Graphic
& rGraphic
,
153 const OUString
& rFile
);
154 bool PasteBookmark( SotClipboardFormatId nFormatId
,
155 const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
,
156 SCCOL nPosX
, SCROW nPosY
);
157 bool PasteLink( const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
);
159 void InsertBookmark( const OUString
& rDescription
, const OUString
& rURL
,
160 SCCOL nPosX
, SCROW nPosY
, const OUString
* pTarget
= nullptr,
161 bool bTryReplace
= false );
162 bool HasBookmarkAtCursor( SvxHyperlinkItem
* pContent
);
164 bool MoveBlockTo( const ScRange
& rSource
, const ScAddress
& rDestPos
,
167 bool LinkBlock( const ScRange
& rSource
, const ScAddress
& rDestPos
);
169 void CreateNames( CreateNameFlags nFlags
);
170 CreateNameFlags
GetCreateNameFlags();
171 void InsertNameList();
172 bool InsertName( const OUString
& rName
, const OUString
& rSymbol
,
173 const OUString
& rType
);
175 void ApplyAttributes( const SfxItemSet
& rDialogSet
, const SfxItemSet
& rOldSet
, bool bAdjustBlockHeight
= true );
176 void ApplyAttr( const SfxPoolItem
& rAttrItem
, bool bAdjustBlockHeight
= true );
178 void ApplySelectionPattern( const ScPatternAttr
& rAttr
,
179 bool bCursorOnly
= false);
180 void ApplyPatternLines(const ScPatternAttr
& rAttr
,
181 const SvxBoxItem
& rNewOuter
,
182 const SvxBoxInfoItem
* pNewInner
);
184 void ApplyUserItemSet( const SfxItemSet
& rItemSet
);
187 GetStyleSheetFromMarked();
188 void SetStyleSheetToMarked( const SfxStyleSheet
* pStyleSheet
);
189 void RemoveStyleSheetInUse( const SfxStyleSheetBase
* pStyleSheet
);
190 void UpdateStyleSheetInUse( const SfxStyleSheetBase
* pStyleSheet
);
192 void SetNumberFormat( SvNumFormatType nFormatType
, sal_uLong nAdd
= 0 );
193 void SetNumFmtByStr( const OUString
& rCode
);
194 void ChangeNumFmtDecimals( bool bIncrement
);
196 void SetValidation( const ScValidationData
& rNew
);
198 void ChangeIndent( bool bIncrement
);
200 void ProtectSheet( SCTAB nTab
, const ScTableProtection
& rProtect
);
202 void ProtectDoc( const OUString
& rPassword
);
203 bool Unprotect( SCTAB nTab
, const OUString
& rPassword
);
205 void DeleteCells( DelCellCmd eCmd
);
206 bool InsertCells( InsCellCmd eCmd
, bool bRecord
= true, bool bPartOfPaste
= false, size_t nCount
= 0);
207 void DeleteMulti( bool bRows
);
209 void DeleteContents( InsertDeleteFlags nFlags
);
211 void SetWidthOrHeight(
212 bool bWidth
, const std::vector
<sc::ColRowSpan
>& rRanges
, ScSizeMode eMode
,
213 sal_uInt16 nSizeTwips
, bool bRecord
= true, const ScMarkData
* pMarkData
= nullptr );
215 void SetMarkedWidthOrHeight( bool bWidth
, ScSizeMode eMode
, sal_uInt16 nSizeTwips
);
217 bool AdjustBlockHeight( bool bPaint
= true, ScMarkData
* pMarkData
= nullptr );
218 bool AdjustRowHeight( SCROW nStartRow
, SCROW nEndRow
, bool bApi
);
220 void ModifyCellSize( ScDirection eDir
, bool bOptimal
);
223 InsertPageBreak( bool bColumn
, bool bRecord
= true,
224 const ScAddress
* pPos
= nullptr,
225 bool bSetModified
= true );
227 DeletePageBreak( bool bColumn
, bool bRecord
= true,
228 const ScAddress
* pPos
= nullptr,
229 bool bSetModified
= true );
231 void RemoveManualBreaks();
233 void SetPrintZoom(sal_uInt16 nScale
);
234 void AdjustPrintZoom();
236 bool TestMergeCells();
237 bool TestRemoveMerge();
239 void MergeCells( bool bApi
, bool bDoContents
, bool bCenter
,
240 const sal_uInt16 nSlot
);
244 FillSimple( FillDir eDir
);
245 void FillSeries( FillDir eDir
, FillCmd eCmd
, FillDateCmd eDateCmd
,
246 double fStart
, double fStep
, double fMax
);
248 FillAuto( FillDir eDir
, SCCOL nStartCol
, SCROW nStartRow
,
249 SCCOL nEndCol
, SCROW nEndRow
, sal_uLong nCount
);
250 void FillCrossDblClick();
251 void ConvertFormulaToValue();
253 void TransliterateText( TransliterationFlags nType
);
255 ScAutoFormatData
* CreateAutoFormatData();
256 void AutoFormat( sal_uInt16 nFormatNo
);
258 bool SearchAndReplace( const SvxSearchItem
* pSearchItem
,
259 bool bAddUndo
, bool bIsApi
);
261 void Solve( const ScSolveParam
& rParam
);
262 void TabOp( const ScTabOpParam
& rParam
, bool bRecord
= true );
264 bool InsertTable( const OUString
& rName
, SCTAB nTabNr
, bool bRecord
= true );
265 void InsertTables(std::vector
<OUString
>& aNames
, SCTAB nTab
, SCTAB nCount
, bool bRecord
= true);
267 bool AppendTable( const OUString
& rName
, bool bRecord
= true );
269 void DeleteTable( SCTAB nTabNr
, bool bRecord
= true );
270 bool DeleteTables(const std::vector
<SCTAB
>& TheTabs
, bool bRecord
= true );
271 void DeleteTables(SCTAB nTab
, SCTAB nSheets
);
273 bool RenameTable( const OUString
& rName
, SCTAB nTabNr
);
274 void MoveTable( sal_uInt16 nDestDocNo
, SCTAB nDestTab
, bool bCopy
, const OUString
* pNewTabName
= nullptr,
275 bool bContextMenu
= false, SCTAB nContextMenuSourceTab
= -1 );
276 void ImportTables( ScDocShell
* pSrcShell
,
277 SCTAB nCount
, const SCTAB
* pSrcTabs
,
278 bool bLink
,SCTAB nTab
);
280 bool SetTabBgColor( const Color
& rColor
, SCTAB nTabNr
);
281 bool SetTabBgColor( ScUndoTabColorInfo::List
& rUndoSetTabBgColorInfoList
);
283 void InsertTableLink( const OUString
& rFile
,
284 const OUString
& rFilter
, const OUString
& rOptions
,
285 std::u16string_view rTabName
);
286 void InsertAreaLink( const OUString
& rFile
,
287 const OUString
& rFilter
, const OUString
& rOptions
,
288 const OUString
& rSource
);
290 void ShowTable( const std::vector
<OUString
>& rNames
);
291 void HideTable( const ScMarkData
& rMark
, SCTAB nTabToSelect
= -1);
293 void MakeScenario(const OUString
& rName
, const OUString
& rComment
,
294 const Color
& rColor
, ScScenarioFlags nFlags
);
295 void ExtendScenario();
296 void UseScenario( const OUString
& rName
);
298 void InsertSpecialChar( const OUString
& rStr
, const vcl::Font
& rFont
);
300 void SetSelectionFrameLines( const ::editeng::SvxBorderLine
* pLine
,
303 void SetNoteText( const ScAddress
& rPos
, const OUString
& rNoteText
);
304 void ReplaceNote( const ScAddress
& rPos
, const OUString
& rNoteText
, const OUString
* pAuthor
, const OUString
* pDate
);
305 void DoRefConversion();
307 void DoHangulHanjaConversion();
310 /** Generic implementation of sheet conversion functions. */
311 void DoSheetConversion( const ScConversionParam
& rParam
);
313 void SetPrintRanges( bool bEntireSheet
,
314 const OUString
* pPrint
,
315 const OUString
* pRepCol
, const OUString
* pRepRow
,
318 void DetectiveAddPred();
319 void DetectiveDelPred();
320 void DetectiveAddSucc();
321 void DetectiveDelSucc();
322 void DetectiveAddError();
323 void DetectiveMarkInvalid();
324 void DetectiveDelAll();
325 void DetectiveRefresh();
326 void DetectiveMarkPred();
327 void DetectiveMarkSucc();
329 void InsertCurrentTime(SvNumFormatType nCellFmt
, const OUString
& rUndoStr
);
331 void ShowNote( bool bShow
);
334 bool SelectionEditable( bool* pOnlyNotBecauseOfMatrix
= nullptr );
337 DataFormPutData(SCROW nCurrentRow
,
338 SCROW nStartRow
, SCCOL nStartCol
,
339 SCROW nEndRow
, SCCOL nEndCol
,
340 std::vector
<std::unique_ptr
<ScDataFormFragment
>>& rEdits
,
341 sal_uInt16 aColLength
);
342 void UpdateSelectionArea( const ScMarkData
& rSel
, ScPatternAttr
* pAttr
= nullptr );
344 void OnLOKInsertDeleteColumn(SCCOL nStartCol
, tools::Long nOffset
);
345 void OnLOKInsertDeleteRow(SCROW nStartRow
, tools::Long nOffset
);
346 void OnLOKSetWidthOrHeight(SCCOLROW nStart
, bool bWidth
);
348 bool TestFormatArea( SCCOL nCol
, SCROW nRow
, SCTAB nTab
, bool bAttrChanged
);
349 void DoAutoAttributes( SCCOL nCol
, SCROW nRow
, SCTAB nTab
,
352 // Internal helper functions
354 static void UpdateLineAttrs( ::editeng::SvxBorderLine
& rLine
,
355 const ::editeng::SvxBorderLine
* pDestLine
,
356 const ::editeng::SvxBorderLine
* pSrcLine
,
360 void PasteRTF( SCCOL nCol
, SCROW nStartRow
,
361 const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
);
363 bool PasteMultiRangesFromClip(
364 InsertDeleteFlags nFlags
, ScDocument
* pClipDoc
,
365 ScPasteFunc nFunction
, bool bSkipEmptyCells
,
366 bool bTranspose
, bool bAsLink
, bool bAllowDialogs
,
367 InsCellCmd eMoveMode
, InsertDeleteFlags nUndoFlags
);
369 bool PasteFromClipToMultiRanges(
370 InsertDeleteFlags nFlags
, ScDocument
* pClipDoc
, ScPasteFunc nFunction
,
371 bool bSkipEmptyCells
, bool bTranspose
, bool bAsLink
, bool bAllowDialogs
,
372 InsCellCmd eMoveMode
, InsertDeleteFlags nUndoFlags
);
374 void PostPasteFromClip(const ScRangeList
& rPasteRanges
, const ScMarkData
& rMark
);
376 bool PasteDataFormatSource( SotClipboardFormatId nFormatId
,
377 SCCOL nPosX
, SCROW nPosY
,
379 TransferableDataHelper
& rDataHelper
, Point
& rPos
);
380 bool PasteDataFormatFormattedText( SotClipboardFormatId nFormatId
,
381 const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
,
382 SCCOL nPosX
, SCROW nPosY
,
383 bool bAllowDialogs
, TransferableDataHelper
& rDataHelper
);
385 sal_uInt16
GetOptimalColWidth( SCCOL nCol
, SCTAB nTab
, bool bFormula
);
387 void StartFormatArea();
389 void MarkAndJumpToRanges(const ScRangeList
& rRanges
);
390 void CopyAutoSpellData( FillDir eDir
, SCCOL nStartCol
, SCROW nStartRow
,
391 SCCOL nEndCol
, SCROW nEndRow
, sal_uLong nCount
);
394 extern bool bPasteIsMove
;
396 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */