Branch libreoffice-24-8-3
[LibreOffice.git] / sc / inc / clipcontext.hxx
blob8c3bc1730af104dee1ddff7675a8b7d529d3e5ba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #pragma once
12 #include "address.hxx"
13 #include "cellvalue.hxx"
14 #include "celltextattr.hxx"
15 #include "columnspanset.hxx"
16 #include "Sparkline.hxx"
18 #include <memory>
19 #include <vector>
21 class ScDocument;
22 class ScColumn;
23 class ScPatternAttr;
24 class ScPostIt;
25 class ScConditionalFormatList;
27 namespace sc {
29 struct ColumnBlockPosition;
30 class ColumnBlockPositionSet;
32 class ClipContextBase
34 std::unique_ptr<ColumnBlockPositionSet> mpSet;
36 public:
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 SAL_DLLPUBLIC_RTTI CopyFromClipContext final : public ClipContextBase
49 /** Tracks modified formula group spans. */
50 sc::ColumnSpanSet maListeningFormulaSpans;
52 SCCOL mnDestCol1;
53 SCCOL mnDestCol2;
54 SCROW mnDestRow1;
55 SCROW mnDestRow2;
56 SCTAB mnTabStart;
57 SCTAB mnTabEnd;
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;
71 bool mbAsLink:1;
72 bool mbSkipEmptyCells:1;
73 bool mbTableProtected:1;
75 public:
77 struct Range
79 SCCOL mnCol1;
80 SCCOL mnCol2;
81 SCROW mnRow1;
82 SCROW mnRow2;
85 CopyFromClipContext() = delete;
86 SC_DLLPUBLIC CopyFromClipContext(ScDocument& rDoc,
87 ScDocument* pRefUndoDoc, ScDocument* pClipDoc, InsertDeleteFlags nInsertFlag,
88 bool bAsLink, bool bSkipAttrForEmptyCells);
90 SC_DLLPUBLIC virtual ~CopyFromClipContext() override;
92 SC_DLLPUBLIC void setTabRange(SCTAB nStart, SCTAB nEnd);
94 SCTAB getTabStart() const;
95 SCTAB getTabEnd() const;
97 SC_DLLPUBLIC 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
153 * destination range.
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
167 public:
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;
179 public:
180 CopyToDocContext(ScDocument& rDoc);
181 virtual ~CopyToDocContext() override;
183 void setStartListening( bool b );
184 bool isStartListening() const;
187 class MixDocContext final : public ClipContextBase
189 public:
190 MixDocContext(ScDocument& rDoc);
191 virtual ~MixDocContext() override;
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */