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 2492 : ClipContextBase::ClipContextBase(ScDocument& rDoc) :
21 2492 : mpSet(new ColumnBlockPositionSet(rDoc)) {}
22 :
23 2492 : ClipContextBase::~ClipContextBase() {}
24 :
25 363318 : ColumnBlockPosition* ClipContextBase::getBlockPosition(SCTAB nTab, SCCOL nCol)
26 : {
27 363318 : return mpSet->getBlockPosition(nTab, nCol);
28 : }
29 :
30 140 : CopyFromClipContext::CopyFromClipContext(ScDocument& rDoc,
31 : ScDocument* pRefUndoDoc, ScDocument* pClipDoc, InsertDeleteFlags 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 280 : mbCloneNotes (mnInsertFlag & (IDF_NOTE|IDF_ADDNOTES)),
42 420 : mbTableProtected(false)
43 : {
44 140 : }
45 :
46 140 : CopyFromClipContext::~CopyFromClipContext()
47 : {
48 140 : }
49 :
50 140 : void CopyFromClipContext::setTabRange(SCTAB nStart, SCTAB nEnd)
51 : {
52 140 : mnTabStart = nStart;
53 140 : mnTabEnd = nEnd;
54 140 : }
55 :
56 4 : void CopyFromClipContext::setDestRange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
57 : {
58 4 : mnDestCol1 = nCol1;
59 4 : mnDestRow1 = nRow1;
60 4 : mnDestCol2 = nCol2;
61 4 : mnDestRow2 = nRow2;
62 4 : }
63 :
64 12 : CopyFromClipContext::Range CopyFromClipContext::getDestRange() const
65 : {
66 : Range aRet;
67 12 : aRet.mnCol1 = mnDestCol1;
68 12 : aRet.mnCol2 = mnDestCol2;
69 12 : aRet.mnRow1 = mnDestRow1;
70 12 : aRet.mnRow2 = mnDestRow2;
71 12 : return aRet;
72 : }
73 :
74 138 : void CopyFromClipContext::setDeleteFlag( InsertDeleteFlags nFlag )
75 : {
76 138 : mnDeleteFlag = nFlag;
77 138 : }
78 :
79 4 : void CopyFromClipContext::setCondFormatList( ScConditionalFormatList* pCondFormatList )
80 : {
81 4 : mpCondFormatList = pCondFormatList;
82 4 : }
83 :
84 6 : void CopyFromClipContext::setSingleCellPattern( const ScPatternAttr* pAttr )
85 : {
86 6 : mpSinglePattern = pAttr;
87 6 : }
88 :
89 6 : void CopyFromClipContext::setSingleCellNote( const ScPostIt* pNote )
90 : {
91 6 : mpSingleNote = pNote;
92 6 : }
93 :
94 4 : void CopyFromClipContext::setTableProtected( bool b )
95 : {
96 4 : mbTableProtected = b;
97 4 : }
98 :
99 304 : bool CopyFromClipContext::isDateCell( const ScColumn& rCol, SCROW nRow ) const
100 : {
101 304 : sal_uLong nNumIndex = static_cast<const SfxUInt32Item*>(rCol.GetAttr(nRow, ATTR_VALUE_FORMAT))->GetValue();
102 304 : short nType = mpClipDoc->GetFormatTable()->GetType(nNumIndex);
103 304 : return (nType == NUMBERFORMAT_DATE) || (nType == NUMBERFORMAT_TIME) || (nType == NUMBERFORMAT_DATETIME);
104 : }
105 :
106 102 : CopyToClipContext::CopyToClipContext(
107 : ScDocument& rDoc, bool bKeepScenarioFlags, bool bCloneNotes) :
108 102 : ClipContextBase(rDoc), mbKeepScenarioFlags(bKeepScenarioFlags), mbCloneNotes(bCloneNotes) {}
109 :
110 102 : CopyToClipContext::~CopyToClipContext() {}
111 :
112 2246 : CopyToDocContext::CopyToDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {}
113 2246 : CopyToDocContext::~CopyToDocContext() {}
114 :
115 4 : MixDocContext::MixDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {}
116 4 : MixDocContext::~MixDocContext() {}
117 :
118 228 : }
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|