ofz: Use-of-uninitialized-value
[LibreOffice.git] / sc / inc / clipcontext.hxx
blob32e2dd97767a3f2358bcd4a8031df5c555b0cfc3
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"
16 #include <memory>
17 #include <vector>
19 class ScDocument;
20 class ScColumn;
21 class ScPatternAttr;
22 class ScPostIt;
23 class ScConditionalFormatList;
25 namespace sc {
27 struct ColumnBlockPosition;
28 class ColumnBlockPositionSet;
30 class ClipContextBase
32 std::unique_ptr<ColumnBlockPositionSet> mpSet;
34 public:
35 ClipContextBase() = delete;
36 ClipContextBase(const ClipContextBase&) = delete;
37 const ClipContextBase& operator=(const ClipContextBase&) = delete;
38 ClipContextBase(ScDocument& rDoc);
39 virtual ~ClipContextBase();
41 ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
42 ColumnBlockPositionSet* getBlockPositionSet() { return mpSet.get(); }
45 class SC_DLLPUBLIC CopyFromClipContext final : public ClipContextBase
47 SCCOL mnDestCol1;
48 SCCOL mnDestCol2;
49 SCROW mnDestRow1;
50 SCROW mnDestRow2;
51 SCTAB mnTabStart;
52 SCTAB mnTabEnd;
53 ScDocument& mrDestDoc;
54 ScDocument* mpRefUndoDoc;
55 ScDocument* mpClipDoc;
56 InsertDeleteFlags mnInsertFlag;
57 InsertDeleteFlags mnDeleteFlag;
59 std::vector<ScCellValue> maSingleCells;
60 std::vector<sc::CellTextAttr> maSingleCellAttrs;
61 std::vector<const ScPatternAttr*> maSinglePatterns;
62 std::vector<const ScPostIt*> maSingleNotes;
64 ScConditionalFormatList* mpCondFormatList;
65 bool mbAsLink:1;
66 bool mbSkipEmptyCells:1;
67 bool mbCloneNotes:1;
68 bool mbTableProtected:1;
70 public:
72 struct Range
74 SCCOL mnCol1;
75 SCCOL mnCol2;
76 SCROW mnRow1;
77 SCROW mnRow2;
80 CopyFromClipContext() = delete;
81 CopyFromClipContext(ScDocument& rDoc,
82 ScDocument* pRefUndoDoc, ScDocument* pClipDoc, InsertDeleteFlags nInsertFlag,
83 bool bAsLink, bool bSkipAttrForEmptyCells);
85 virtual ~CopyFromClipContext() override;
87 void setTabRange(SCTAB nStart, SCTAB nEnd);
89 SCTAB getTabStart() const;
90 SCTAB getTabEnd() const;
92 void setDestRange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
93 Range getDestRange() const;
95 ScDocument* getUndoDoc();
96 ScDocument* getClipDoc();
97 ScDocument* getDestDoc() { return &mrDestDoc; }
98 InsertDeleteFlags getInsertFlag() const;
100 void setDeleteFlag( InsertDeleteFlags nFlag );
101 InsertDeleteFlags getDeleteFlag() const;
104 * Set the column size of a "single cell" row, which is used when copying
105 * a single row of cells in a clip doc and pasting it into multiple
106 * rows by replicating it.
108 void setSingleCellColumnSize( size_t nSize );
110 ScCellValue& getSingleCell( size_t nColOffset );
111 sc::CellTextAttr& getSingleCellAttr( size_t nColOffset );
113 void setSingleCell( const ScAddress& rSrcPos, const ScColumn& rSrcCol );
116 const ScPatternAttr* getSingleCellPattern( size_t nColOffset ) const;
117 void setSingleCellPattern( size_t nColOffset, const ScPatternAttr* pAttr );
119 const ScPostIt* getSingleCellNote( size_t nColOffset ) const;
120 void setSingleCellNote( size_t nColOffset, const ScPostIt* pNote );
122 void setCondFormatList( ScConditionalFormatList* pCondFormatList );
123 ScConditionalFormatList* getCondFormatList();
125 void setTableProtected( bool b );
126 bool isTableProtected() const;
128 bool isAsLink() const;
131 * Get the flag that indicates whether the "skip empty cells" paste option
132 * is selected. When this option is selected, empty cells in the clipboard
133 * document will not overwrite the corresponding non-empty cells in the
134 * destination range.
136 bool isSkipEmptyCells() const;
137 bool isCloneNotes() const;
138 bool isDateCell( const ScColumn& rCol, SCROW nRow ) const;
141 class CopyToClipContext final : public ClipContextBase
143 bool mbKeepScenarioFlags:1;
145 public:
146 CopyToClipContext(ScDocument& rDoc, bool bKeepScenarioFlags);
147 virtual ~CopyToClipContext() override;
149 bool isKeepScenarioFlags() const;
152 class CopyToDocContext final : public ClipContextBase
154 bool mbStartListening;
156 public:
157 CopyToDocContext(ScDocument& rDoc);
158 virtual ~CopyToDocContext() override;
160 void setStartListening( bool b );
161 bool isStartListening() const;
164 class MixDocContext final : public ClipContextBase
166 public:
167 MixDocContext(ScDocument& rDoc);
168 virtual ~MixDocContext() override;
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */