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 "listenercontext.hxx"
11 : #include "document.hxx"
12 : #include "mtvelements.hxx"
13 :
14 : namespace sc {
15 :
16 1933 : StartListeningContext::StartListeningContext(ScDocument& rDoc) :
17 1933 : mrDoc(rDoc), mpSet(new ColumnBlockPositionSet(rDoc)) {}
18 :
19 1064 : StartListeningContext::StartListeningContext(
20 : ScDocument& rDoc, const boost::shared_ptr<ColumnBlockPositionSet>& pSet) :
21 1064 : mrDoc(rDoc), mpSet(pSet) {}
22 :
23 13644 : ColumnBlockPosition* StartListeningContext::getBlockPosition(SCTAB nTab, SCCOL nCol)
24 : {
25 13644 : return mpSet->getBlockPosition(nTab, nCol);
26 : }
27 :
28 551 : EndListeningContext::EndListeningContext(ScDocument& rDoc, ScTokenArray* pOldCode) :
29 551 : mrDoc(rDoc), maSet(false), mpPosSet(new ColumnBlockPositionSet(rDoc)),
30 1102 : mpOldCode(pOldCode), maPosDelta(0,0,0) {}
31 :
32 1064 : EndListeningContext::EndListeningContext(
33 : ScDocument& rDoc, const boost::shared_ptr<ColumnBlockPositionSet>& pSet, ScTokenArray* pOldCode) :
34 : mrDoc(rDoc), maSet(false), mpPosSet(pSet),
35 1064 : mpOldCode(pOldCode), maPosDelta(0,0,0) {}
36 :
37 32 : void EndListeningContext::setPositionDelta( const ScAddress& rDelta )
38 : {
39 32 : maPosDelta = rDelta;
40 32 : }
41 :
42 521 : ScAddress EndListeningContext::getOldPosition( const ScAddress& rPos ) const
43 : {
44 521 : ScAddress aOldPos = rPos;
45 521 : aOldPos.IncCol(maPosDelta.Col());
46 521 : aOldPos.IncRow(maPosDelta.Row());
47 521 : aOldPos.IncTab(maPosDelta.Tab());
48 521 : return aOldPos;
49 : }
50 :
51 595 : ColumnBlockPosition* EndListeningContext::getBlockPosition(SCTAB nTab, SCCOL nCol)
52 : {
53 595 : return mpPosSet->getBlockPosition(nTab, nCol);
54 : }
55 :
56 348 : void EndListeningContext::addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow)
57 : {
58 348 : maSet.set(nTab, nCol, nRow, true);
59 348 : }
60 :
61 413 : void EndListeningContext::purgeEmptyBroadcasters()
62 : {
63 413 : PurgeListenerAction aAction(mrDoc);
64 413 : maSet.executeAction(aAction);
65 413 : }
66 :
67 420 : PurgeListenerAction::PurgeListenerAction(ScDocument& rDoc) :
68 420 : mrDoc(rDoc), mpBlockPos(new ColumnBlockPosition) {}
69 :
70 117 : void PurgeListenerAction::startColumn( SCTAB nTab, SCCOL nCol )
71 : {
72 117 : mrDoc.InitColumnBlockPosition(*mpBlockPos, nTab, nCol);
73 117 : }
74 :
75 346 : void PurgeListenerAction::execute( const ScAddress& rPos, SCROW nLength, bool bVal )
76 : {
77 346 : if (bVal)
78 : {
79 125 : mrDoc.DeleteBroadcasters(*mpBlockPos, rPos, nLength);
80 : }
81 346 : };
82 :
83 156 : }
84 :
85 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|