Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #include "clipcontext.hxx"
11 : #include "document.hxx"
12 : #include "mtvelements.hxx"
13 : #include <column.hxx>
14 : #include <scitems.hxx>
15 :
16 : #include <svl/intitem.hxx>
17 :
18 : namespace sc {
19 :
20 1106 : ClipContextBase::ClipContextBase(ScDocument& rDoc) :
21 1106 : mpSet(new ColumnBlockPositionSet(rDoc)) {}
22 :
23 1106 : ClipContextBase::~ClipContextBase() {}
24 :
25 113977 : ColumnBlockPosition* ClipContextBase::getBlockPosition(SCTAB nTab, SCCOL nCol)
26 : {
27 113977 : return mpSet->getBlockPosition(nTab, nCol);
28 : }
29 :
30 57 : CopyFromClipContext::CopyFromClipContext(ScDocument& rDoc,
31 : ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
32 : bool bAsLink, bool bSkipAttrForEmptyCells) :
33 : ClipContextBase(rDoc),
34 : mnDestCol1(-1), mnDestCol2(-1),
35 : mnDestRow1(-1), mnDestRow2(-1),
36 : mnTabStart(-1), mnTabEnd(-1),
37 : mpRefUndoDoc(pRefUndoDoc), mpClipDoc(pClipDoc),
38 : mnInsertFlag(nInsertFlag), mnDeleteFlag(IDF_NONE),
39 : mpCondFormatList(NULL), mpSinglePattern(NULL), mpSingleNote(NULL),
40 : mbAsLink(bAsLink), mbSkipAttrForEmptyCells(bSkipAttrForEmptyCells),
41 57 : mbCloneNotes (mnInsertFlag & (IDF_NOTE|IDF_ADDNOTES)),
42 114 : mbTableProtected(false)
43 : {
44 57 : }
45 :
46 57 : CopyFromClipContext::~CopyFromClipContext()
47 : {
48 57 : }
49 :
50 57 : void CopyFromClipContext::setTabRange(SCTAB nStart, SCTAB nEnd)
51 : {
52 57 : mnTabStart = nStart;
53 57 : mnTabEnd = nEnd;
54 57 : }
55 :
56 105 : SCTAB CopyFromClipContext::getTabStart() const
57 : {
58 105 : return mnTabStart;
59 : }
60 :
61 63 : SCTAB CopyFromClipContext::getTabEnd() const
62 : {
63 63 : return mnTabEnd;
64 : }
65 :
66 1 : void CopyFromClipContext::setDestRange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
67 : {
68 1 : mnDestCol1 = nCol1;
69 1 : mnDestRow1 = nRow1;
70 1 : mnDestCol2 = nCol2;
71 1 : mnDestRow2 = nRow2;
72 1 : }
73 :
74 2 : CopyFromClipContext::Range CopyFromClipContext::getDestRange() const
75 : {
76 : Range aRet;
77 2 : aRet.mnCol1 = mnDestCol1;
78 2 : aRet.mnCol2 = mnDestCol2;
79 2 : aRet.mnRow1 = mnDestRow1;
80 2 : aRet.mnRow2 = mnDestRow2;
81 2 : return aRet;
82 : }
83 :
84 40 : ScDocument* CopyFromClipContext::getUndoDoc()
85 : {
86 40 : return mpRefUndoDoc;
87 : }
88 :
89 385 : ScDocument* CopyFromClipContext::getClipDoc()
90 : {
91 385 : return mpClipDoc;
92 : }
93 :
94 780 : sal_uInt16 CopyFromClipContext::getInsertFlag() const
95 : {
96 780 : return mnInsertFlag;
97 : }
98 :
99 56 : void CopyFromClipContext::setDeleteFlag( sal_uInt16 nFlag )
100 : {
101 56 : mnDeleteFlag = nFlag;
102 56 : }
103 :
104 1 : sal_uInt16 CopyFromClipContext::getDeleteFlag() const
105 : {
106 1 : return mnDeleteFlag;
107 : }
108 :
109 4 : ScCellValue& CopyFromClipContext::getSingleCell()
110 : {
111 4 : return maSingleCell;
112 : }
113 :
114 1 : void CopyFromClipContext::setCondFormatList( ScConditionalFormatList* pCondFormatList )
115 : {
116 1 : mpCondFormatList = pCondFormatList;
117 1 : }
118 :
119 3 : ScConditionalFormatList* CopyFromClipContext::getCondFormatList()
120 : {
121 3 : return mpCondFormatList;
122 : }
123 :
124 2 : const ScPatternAttr* CopyFromClipContext::getSingleCellPattern() const
125 : {
126 2 : return mpSinglePattern;
127 : }
128 :
129 2 : void CopyFromClipContext::setSingleCellPattern( const ScPatternAttr* pAttr )
130 : {
131 2 : mpSinglePattern = pAttr;
132 2 : }
133 :
134 2 : const ScPostIt* CopyFromClipContext::getSingleCellNote() const
135 : {
136 2 : return mpSingleNote;
137 : }
138 :
139 2 : void CopyFromClipContext::setSingleCellNote( const ScPostIt* pNote )
140 : {
141 2 : mpSingleNote = pNote;
142 2 : }
143 :
144 1 : void CopyFromClipContext::setTableProtected( bool b )
145 : {
146 1 : mbTableProtected = b;
147 1 : }
148 :
149 3 : bool CopyFromClipContext::isTableProtected() const
150 : {
151 3 : return mbTableProtected;
152 : }
153 :
154 317 : bool CopyFromClipContext::isAsLink() const
155 : {
156 317 : return mbAsLink;
157 : }
158 :
159 121 : bool CopyFromClipContext::isSkipAttrForEmptyCells() const
160 : {
161 121 : return mbSkipAttrForEmptyCells;
162 : }
163 :
164 205 : bool CopyFromClipContext::isCloneNotes() const
165 : {
166 205 : return mbCloneNotes;
167 : }
168 :
169 130 : bool CopyFromClipContext::isDateCell( const ScColumn& rCol, SCROW nRow ) const
170 : {
171 130 : sal_uLong nNumIndex = static_cast<const SfxUInt32Item*>(rCol.GetAttr(nRow, ATTR_VALUE_FORMAT))->GetValue();
172 130 : short nType = mpClipDoc->GetFormatTable()->GetType(nNumIndex);
173 130 : return (nType == NUMBERFORMAT_DATE) || (nType == NUMBERFORMAT_TIME) || (nType == NUMBERFORMAT_DATETIME);
174 : }
175 :
176 38 : CopyToClipContext::CopyToClipContext(
177 : ScDocument& rDoc, bool bKeepScenarioFlags, bool bCloneNotes) :
178 38 : ClipContextBase(rDoc), mbKeepScenarioFlags(bKeepScenarioFlags), mbCloneNotes(bCloneNotes) {}
179 :
180 38 : CopyToClipContext::~CopyToClipContext() {}
181 :
182 59 : bool CopyToClipContext::isKeepScenarioFlags() const
183 : {
184 59 : return mbKeepScenarioFlags;
185 : }
186 :
187 59 : bool CopyToClipContext::isCloneNotes() const
188 : {
189 59 : return mbCloneNotes;
190 : }
191 :
192 1010 : CopyToDocContext::CopyToDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {}
193 1010 : CopyToDocContext::~CopyToDocContext() {}
194 :
195 1 : MixDocContext::MixDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {}
196 1 : MixDocContext::~MixDocContext() {}
197 :
198 102 : }
199 :
200 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|