LibreOffice Module sc (master)  1
listenercontext.cxx
Go to the documentation of this file.
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 
17  mrDoc(rDoc), mpSet(std::make_shared<ColumnBlockPositionSet>(rDoc)) {}
18 
20  ScDocument& rDoc, const std::shared_ptr<ColumnBlockPositionSet>& pSet) :
21  mrDoc(rDoc), mpSet(pSet) {}
22 
23 void StartListeningContext::setColumnSet( const std::shared_ptr<const ColumnSet>& rpColSet )
24 {
25  mpColSet = rpColSet;
26 }
27 
28 const std::shared_ptr<const ColumnSet>& StartListeningContext::getColumnSet() const
29 {
30  return mpColSet;
31 }
32 
34 {
35  return mpSet->getBlockPosition(nTab, nCol);
36 }
37 
39  mrDoc(rDoc), maSet(), mpPosSet(std::make_shared<ColumnBlockPositionSet>(rDoc)),
40  mpOldCode(pOldCode), maPosDelta(0,0,0) {}
41 
43  ScDocument& rDoc, const std::shared_ptr<ColumnBlockPositionSet>& pSet, ScTokenArray* pOldCode) :
44  mrDoc(rDoc), maSet(), mpPosSet(pSet),
45  mpOldCode(pOldCode), maPosDelta(0,0,0) {}
46 
48 {
49  maPosDelta = rDelta;
50 }
51 
53 {
54  ScAddress aOldPos = rPos;
55  aOldPos.IncCol(maPosDelta.Col());
56  aOldPos.IncRow(maPosDelta.Row());
57  aOldPos.IncTab(maPosDelta.Tab());
58  return aOldPos;
59 }
60 
62 {
63  return mpPosSet->getBlockPosition(nTab, nCol);
64 }
65 
67 {
68  maSet.set(mrDoc, nTab, nCol, nRow, true);
69 }
70 
72 {
73  PurgeListenerAction aAction(mrDoc);
74  maSet.executeAction(aAction);
75 }
76 
78  mrDoc(rDoc), mpBlockPos(new ColumnBlockPosition) {}
79 
81 {
83 }
84 
85 void PurgeListenerAction::execute( const ScAddress& rPos, SCROW nLength, bool bVal )
86 {
87  if (bVal)
88  {
89  mrDoc.DeleteBroadcasters(*mpBlockPos, rPos, nLength);
90  }
91 };
92 
93 }
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setPositionDelta(const ScAddress &rDelta)
std::shared_ptr< ColumnBlockPositionSet > mpSet
void IncTab(SCTAB nDelta=1)
Definition: address.hxx:308
SCROW Row() const
Definition: address.hxx:262
PurgeListenerAction(const PurgeListenerAction &)=delete
SC_DLLPUBLIC bool InitColumnBlockPosition(sc::ColumnBlockPosition &rBlockPos, SCTAB nTab, SCCOL nCol)
Definition: document.cxx:2614
Store position data for column array storage.
void addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow)
std::shared_ptr< T > make_shared(Args &&...args)
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
virtual void startColumn(SCTAB nTab, SCCOL nCol) override
const std::shared_ptr< const ColumnSet > & getColumnSet() const
ScAddress getOldPosition(const ScAddress &rPos) const
void set(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal)
SCTAB Tab() const
Definition: address.hxx:271
EndListeningContext(const EndListeningContext &)=delete
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
void DeleteBroadcasters(sc::ColumnBlockPosition &rBlockPos, const ScAddress &rTopPos, SCROW nLength)
Definition: document.cxx:2475
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:304
sal_Int16 SCCOL
Definition: types.hxx:22
StartListeningContext(const StartListeningContext &)=delete
std::shared_ptr< ColumnBlockPositionSet > mpPosSet
void IncRow(SCROW nDelta=1)
Definition: address.hxx:300
SCCOL Col() const
Definition: address.hxx:267
std::shared_ptr< const ColumnSet > mpColSet
virtual void execute(const ScAddress &rPos, SCROW nLength, bool bVal) override
sal_Int32 SCROW
Definition: types.hxx:18
std::unique_ptr< ColumnBlockPosition > mpBlockPos
void setColumnSet(const std::shared_ptr< const ColumnSet > &pColSet)
void executeAction(Action &ac) const
sal_Int16 SCTAB
Definition: types.hxx:23