Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / inc / clipcontext.hxx
blobb09e1be787613dea41b8cedad626fc326204f350
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 "Sparkline.hxx"
17 #include <memory>
18 #include <vector>
20 class ScDocument;
21 class ScColumn;
22 class ScPatternAttr;
23 class ScPostIt;
24 class ScConditionalFormatList;
26 namespace sc {
28 struct ColumnBlockPosition;
29 class ColumnBlockPositionSet;
31 class ClipContextBase
33 std::unique_ptr<ColumnBlockPositionSet> mpSet;
35 public:
36 ClipContextBase() = delete;
37 ClipContextBase(const ClipContextBase&) = delete;
38 const ClipContextBase& operator=(const ClipContextBase&) = delete;
39 ClipContextBase(ScDocument& rDoc);
40 virtual ~ClipContextBase();
42 ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
43 ColumnBlockPositionSet* getBlockPositionSet() { return mpSet.get(); }
46 class SC_DLLPUBLIC CopyFromClipContext final : public ClipContextBase
48 SCCOL mnDestCol1;
49 SCCOL mnDestCol2;
50 SCROW mnDestRow1;
51 SCROW mnDestRow2;
52 SCTAB mnTabStart;
53 SCTAB mnTabEnd;
54 ScDocument& mrDestDoc;
55 ScDocument* mpRefUndoDoc;
56 ScDocument* mpClipDoc;
57 InsertDeleteFlags mnInsertFlag;
58 InsertDeleteFlags mnDeleteFlag;
60 std::vector<ScCellValue> maSingleCells;
61 std::vector<sc::CellTextAttr> maSingleCellAttrs;
62 std::vector<const ScPatternAttr*> maSinglePatterns;
63 std::vector<const ScPostIt*> maSingleNotes;
64 std::vector<std::shared_ptr<sc::Sparkline>> maSingleSparkline;
66 ScConditionalFormatList* mpCondFormatList;
67 bool mbAsLink:1;
68 bool mbSkipEmptyCells:1;
69 bool mbTableProtected:1;
71 public:
73 struct Range
75 SCCOL mnCol1;
76 SCCOL mnCol2;
77 SCROW mnRow1;
78 SCROW mnRow2;
81 CopyFromClipContext() = delete;
82 CopyFromClipContext(ScDocument& rDoc,
83 ScDocument* pRefUndoDoc, ScDocument* pClipDoc, InsertDeleteFlags nInsertFlag,
84 bool bAsLink, bool bSkipAttrForEmptyCells);
86 virtual ~CopyFromClipContext() override;
88 void setTabRange(SCTAB nStart, SCTAB nEnd);
90 SCTAB getTabStart() const;
91 SCTAB getTabEnd() const;
93 void setDestRange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
94 Range getDestRange() const;
96 ScDocument* getUndoDoc();
97 ScDocument* getClipDoc();
98 ScDocument* getDestDoc() { return &mrDestDoc; }
99 InsertDeleteFlags getInsertFlag() const;
101 void setDeleteFlag( InsertDeleteFlags nFlag );
102 InsertDeleteFlags getDeleteFlag() const;
105 * Set the column size of a "single cell" row, which is used when copying
106 * a single row of cells in a clip doc and pasting it into multiple
107 * rows by replicating it.
109 void setSingleCellColumnSize( size_t nSize );
111 ScCellValue& getSingleCell( size_t nColOffset );
112 sc::CellTextAttr& getSingleCellAttr( size_t nColOffset );
114 void setSingleCell( const ScAddress& rSrcPos, const ScColumn& rSrcCol );
117 const ScPatternAttr* getSingleCellPattern( size_t nColOffset ) const;
118 void setSingleCellPattern( size_t nColOffset, const ScPatternAttr* pAttr );
120 const ScPostIt* getSingleCellNote( size_t nColOffset ) const;
121 void setSingleCellNote( size_t nColOffset, const ScPostIt* pNote );
123 std::shared_ptr<sc::Sparkline> const& getSingleSparkline(size_t nColOffset) const;
124 void setSingleSparkline(size_t nColOffset, std::shared_ptr<sc::Sparkline> const& pSparkline);
126 void setCondFormatList( ScConditionalFormatList* pCondFormatList );
127 ScConditionalFormatList* getCondFormatList();
129 void setTableProtected( bool b );
130 bool isTableProtected() const;
132 bool isAsLink() const;
135 * Get the flag that indicates whether the "skip empty cells" paste option
136 * is selected. When this option is selected, empty cells in the clipboard
137 * document will not overwrite the corresponding non-empty cells in the
138 * destination range.
140 bool isSkipEmptyCells() const;
141 bool isCloneNotes() const;
142 bool isCloneSparklines() const;
143 bool isDateCell( const ScColumn& rCol, SCROW nRow ) const;
146 class CopyToClipContext final : public ClipContextBase
148 bool mbKeepScenarioFlags:1;
150 public:
151 CopyToClipContext(ScDocument& rDoc, bool bKeepScenarioFlags);
152 virtual ~CopyToClipContext() override;
154 bool isKeepScenarioFlags() const;
157 class CopyToDocContext final : public ClipContextBase
159 bool mbStartListening;
161 public:
162 CopyToDocContext(ScDocument& rDoc);
163 virtual ~CopyToDocContext() override;
165 void setStartListening( bool b );
166 bool isStartListening() const;
169 class MixDocContext final : public ClipContextBase
171 public:
172 MixDocContext(ScDocument& rDoc);
173 virtual ~MixDocContext() override;
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */