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/.
12 #include "address.hxx"
13 #include "cellvalue.hxx"
14 #include "celltextattr.hxx"
15 #include "columnspanset.hxx"
16 #include "Sparkline.hxx"
25 class ScConditionalFormatList
;
29 struct ColumnBlockPosition
;
30 class ColumnBlockPositionSet
;
34 std::unique_ptr
<ColumnBlockPositionSet
> mpSet
;
37 ClipContextBase() = delete;
38 ClipContextBase(const ClipContextBase
&) = delete;
39 const ClipContextBase
& operator=(const ClipContextBase
&) = delete;
40 ClipContextBase(ScDocument
& rDoc
);
41 virtual ~ClipContextBase();
43 ColumnBlockPosition
* getBlockPosition(SCTAB nTab
, SCCOL nCol
);
44 ColumnBlockPositionSet
* getBlockPositionSet() { return mpSet
.get(); }
47 class SC_DLLPUBLIC CopyFromClipContext final
: public ClipContextBase
49 /** Tracks modified formula group spans. */
50 sc::ColumnSpanSet maListeningFormulaSpans
;
58 ScDocument
& mrDestDoc
;
59 ScDocument
* mpRefUndoDoc
;
60 ScDocument
* mpClipDoc
;
61 InsertDeleteFlags mnInsertFlag
;
62 InsertDeleteFlags mnDeleteFlag
;
64 std::vector
<ScCellValue
> maSingleCells
;
65 std::vector
<sc::CellTextAttr
> maSingleCellAttrs
;
66 std::vector
<const ScPatternAttr
*> maSinglePatterns
;
67 std::vector
<const ScPostIt
*> maSingleNotes
;
68 std::vector
<std::shared_ptr
<sc::Sparkline
>> maSingleSparkline
;
70 ScConditionalFormatList
* mpCondFormatList
;
72 bool mbSkipEmptyCells
:1;
73 bool mbTableProtected
:1;
85 CopyFromClipContext() = delete;
86 CopyFromClipContext(ScDocument
& rDoc
,
87 ScDocument
* pRefUndoDoc
, ScDocument
* pClipDoc
, InsertDeleteFlags nInsertFlag
,
88 bool bAsLink
, bool bSkipAttrForEmptyCells
);
90 virtual ~CopyFromClipContext() override
;
92 void setTabRange(SCTAB nStart
, SCTAB nEnd
);
94 SCTAB
getTabStart() const;
95 SCTAB
getTabEnd() const;
97 void setDestRange( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
98 Range
getDestRange() const;
100 ScDocument
* getUndoDoc();
101 ScDocument
* getClipDoc();
102 ScDocument
* getDestDoc() { return &mrDestDoc
; }
103 InsertDeleteFlags
getInsertFlag() const;
105 void setDeleteFlag( InsertDeleteFlags nFlag
);
106 InsertDeleteFlags
getDeleteFlag() const;
109 * Record a range of formula cells that need to start listening after the
110 * copy-from-clip is complete.
112 void setListeningFormulaSpans( SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
115 * Have the formula cells in the recorded ranges start listening.
117 void startListeningFormulas();
120 * Set the column size of a "single cell" row, which is used when copying
121 * a single row of cells in a clip doc and pasting it into multiple
122 * rows by replicating it.
124 void setSingleCellColumnSize( size_t nSize
);
126 ScCellValue
& getSingleCell( size_t nColOffset
);
127 sc::CellTextAttr
& getSingleCellAttr( size_t nColOffset
);
129 void setSingleCell( const ScAddress
& rSrcPos
, const ScColumn
& rSrcCol
);
132 const ScPatternAttr
* getSingleCellPattern( size_t nColOffset
) const;
133 void setSingleCellPattern( size_t nColOffset
, const ScPatternAttr
* pAttr
);
135 const ScPostIt
* getSingleCellNote( size_t nColOffset
) const;
136 void setSingleCellNote( size_t nColOffset
, const ScPostIt
* pNote
);
138 std::shared_ptr
<sc::Sparkline
> const& getSingleSparkline(size_t nColOffset
) const;
139 void setSingleSparkline(size_t nColOffset
, std::shared_ptr
<sc::Sparkline
> const& pSparkline
);
141 void setCondFormatList( ScConditionalFormatList
* pCondFormatList
);
142 ScConditionalFormatList
* getCondFormatList();
144 void setTableProtected( bool b
);
145 bool isTableProtected() const;
147 bool isAsLink() const;
150 * Get the flag that indicates whether the "skip empty cells" paste option
151 * is selected. When this option is selected, empty cells in the clipboard
152 * document will not overwrite the corresponding non-empty cells in the
155 bool isSkipEmptyCells() const;
156 bool isCloneNotes() const;
157 bool isCloneSparklines() const;
158 bool isDateCell( const ScColumn
& rCol
, SCROW nRow
) const;
161 class CopyToClipContext final
: public ClipContextBase
163 bool mbKeepScenarioFlags
:1;
164 bool mbCopyChartRanges
: 1 = false; // Copying ranges not included in selection:
165 // only copy data, not cell attributes
168 CopyToClipContext(ScDocument
& rDoc
, bool bKeepScenarioFlags
, bool bCopyChartRanges
= false);
169 virtual ~CopyToClipContext() override
;
171 bool isKeepScenarioFlags() const;
172 bool isCopyChartRanges() const { return mbCopyChartRanges
; }
175 class CopyToDocContext final
: public ClipContextBase
177 bool mbStartListening
;
180 CopyToDocContext(ScDocument
& rDoc
);
181 virtual ~CopyToDocContext() override
;
183 void setStartListening( bool b
);
184 bool isStartListening() const;
187 class MixDocContext final
: public ClipContextBase
190 MixDocContext(ScDocument
& rDoc
);
191 virtual ~MixDocContext() override
;
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */