diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-30 08:51:50 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-08-31 18:29:42 +0200 |
commit | 1cdaec1931e0012506726c773373e46fa6ef81c0 (patch) | |
tree | 864587764cd3d3c5f6e06e4f0c9c6273c610363a /sc/inc | |
parent | 0aad6244eb1a894fc399769b7dc52e23888b6982 (diff) |
make the ScColumnsRange iterator return SCCOL
since we don't want to expose internal details like the ScColumn to most
of the code, make the ScColumnsRange iterators return SCCOL instead of
ScColumn*
Change-Id: I67a58df90959170105255d18e7dd38ef0d6e3c11
Reviewed-on: https://gerrit.libreoffice.org/41719
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/document.hxx | 5 | ||||
-rw-r--r-- | sc/inc/table.hxx | 32 |
2 files changed, 27 insertions, 10 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index bc1f4ea2f5cf..45f450e59462 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -296,7 +296,6 @@ friend class sc::ColumnSpanSet; friend class sc::EditTextIterator; friend class sc::FormulaGroupAreaListener; friend class sc::TableColumnBlockPositionSet; -friend class ScDrawLayer; typedef std::vector<ScTable*> TableContainer; @@ -2323,6 +2322,8 @@ public: void SwapNonEmpty( sc::TableValues& rValues ); void finalizeOutlineImport(); + ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const; + private: /** @@ -2385,8 +2386,6 @@ private: void EndListeningGroups( const std::vector<ScAddress>& rPosArray ); void SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArray ); - - ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const; }; #endif diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index d41d67d10a1c..3113ef6d8cd0 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -119,13 +119,31 @@ class ScHint; class ScColumnsRange final { - typedef std::vector<ScColumn*>::const_iterator const_iterator; - const const_iterator maBegin; - const const_iterator maEnd; -public: - ScColumnsRange(const_iterator nBegin, const_iterator nEnd) : maBegin(nBegin), maEnd(nEnd) {} - const const_iterator & begin() { return maBegin; } - const const_iterator & end() { return maEnd; } + public: + class Iterator final : public std::iterator< + std::input_iterator_tag, // iterator_category + SCCOL, // value_type + SCCOL, // difference_type + const SCCOL*, // pointer + SCCOL> // reference + { + std::vector<ScColumn*>::const_iterator maColIter; + public: + explicit Iterator(std::vector<ScColumn*>::const_iterator colIter) : maColIter(colIter) {} + + Iterator& operator++() { maColIter++; return *this;} + + bool operator==(Iterator other) const {return maColIter == other.maColIter;} + bool operator!=(Iterator other) const {return !(*this == other);} + reference operator*() const {return (*maColIter)->GetCol();} + }; + + ScColumnsRange(Iterator nBegin, Iterator nEnd) : maBegin(nBegin), maEnd(nEnd) {} + const Iterator & begin() { return maBegin; } + const Iterator & end() { return maEnd; } +private: + const Iterator maBegin; + const Iterator maEnd; }; class ScTable |