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 0 : StartListeningContext::StartListeningContext(ScDocument& rDoc) :
17 0 : mrDoc(rDoc), mpSet(new ColumnBlockPositionSet(rDoc)) {}
18 :
19 0 : ScDocument& StartListeningContext::getDoc()
20 : {
21 0 : return mrDoc;
22 : }
23 :
24 0 : ColumnBlockPosition* StartListeningContext::getBlockPosition(SCTAB nTab, SCCOL nCol)
25 : {
26 0 : return mpSet->getBlockPosition(nTab, nCol);
27 : }
28 :
29 0 : EndListeningContext::EndListeningContext(ScDocument& rDoc, ScTokenArray* pOldCode) :
30 0 : mrDoc(rDoc), maSet(false), mpPosSet(new ColumnBlockPositionSet(rDoc)),
31 0 : mpOldCode(pOldCode), maPosDelta(0,0,0) {}
32 :
33 0 : void EndListeningContext::setPositionDelta( const ScAddress& rDelta )
34 : {
35 0 : maPosDelta = rDelta;
36 0 : }
37 :
38 0 : ScDocument& EndListeningContext::getDoc()
39 : {
40 0 : return mrDoc;
41 : }
42 :
43 0 : ScTokenArray* EndListeningContext::getOldCode()
44 : {
45 0 : return mpOldCode;
46 : }
47 :
48 0 : ScAddress EndListeningContext::getOldPosition( const ScAddress& rPos ) const
49 : {
50 0 : ScAddress aOldPos = rPos;
51 0 : aOldPos.IncCol(maPosDelta.Col());
52 0 : aOldPos.IncRow(maPosDelta.Row());
53 0 : aOldPos.IncTab(maPosDelta.Tab());
54 0 : return aOldPos;
55 : }
56 :
57 0 : ColumnBlockPosition* EndListeningContext::getBlockPosition(SCTAB nTab, SCCOL nCol)
58 : {
59 0 : return mpPosSet->getBlockPosition(nTab, nCol);
60 : }
61 :
62 0 : void EndListeningContext::addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow)
63 : {
64 0 : maSet.set(nTab, nCol, nRow, true);
65 0 : }
66 :
67 0 : void EndListeningContext::purgeEmptyBroadcasters()
68 : {
69 0 : PurgeListenerAction aAction(mrDoc);
70 0 : maSet.executeAction(aAction);
71 0 : }
72 :
73 0 : PurgeListenerAction::PurgeListenerAction(ScDocument& rDoc) :
74 0 : mrDoc(rDoc), mpBlockPos(new ColumnBlockPosition) {}
75 :
76 0 : void PurgeListenerAction::startColumn( SCTAB nTab, SCCOL nCol )
77 : {
78 0 : mrDoc.InitColumnBlockPosition(*mpBlockPos, nTab, nCol);
79 0 : }
80 :
81 0 : void PurgeListenerAction::execute( const ScAddress& rPos, SCROW nLength, bool bVal )
82 : {
83 0 : if (bVal)
84 : {
85 0 : mrDoc.DeleteBroadcasters(*mpBlockPos, rPos, nLength);
86 : }
87 0 : };
88 :
89 0 : }
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|