src/lib/VSDLayerList.cpp | 24 ++++++++++++++++++++++++ src/lib/VSDLayerList.h | 14 ++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-)
New commits: commit e51525145ebd369093a60ecb902a2739518dca31 Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Fri Dec 11 10:05:57 2015 +0100 Some useful functions for the VSDLayerList Change-Id: Icf8e1535adaa8fda02bd1cc89c8d4c42a2d0045c diff --git a/src/lib/VSDLayerList.cpp b/src/lib/VSDLayerList.cpp index 3ca5037..73fd233 100644 --- a/src/lib/VSDLayerList.cpp +++ b/src/lib/VSDLayerList.cpp @@ -62,4 +62,28 @@ void libvisio::VSDLayerList::clear() m_elements.clear(); } +void libvisio::VSDLayerList::addLayer(unsigned id, const libvisio::VSDLayer &layer) +{ + m_elements[id] = layer; +} + +unsigned libvisio::VSDLayerList::getColourId(const std::vector<unsigned> &ids) +{ + unsigned colourId = MINUS_ONE; + for (std::vector<unsigned>::const_iterator iter = ids.begin(); iter != ids.end(); ++iter) + { + std::map<unsigned, libvisio::VSDLayer>::const_iterator iterMap = m_elements.find(*iter); + // It is enough that one layer does not override colour and the original colour is used + if (iterMap->second.m_colourId == MINUS_ONE) + return MINUS_ONE; + // This means we are reading the first layer and it overrides colour + else if (colourId == MINUS_ONE) + colourId = iterMap->second.m_colourId; + // If two layers override colour to two different values, the original colour is used + else if (colourId != iterMap->second.m_colourId) + return MINUS_ONE; + } + return colourId; +} + /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDLayerList.h b/src/lib/VSDLayerList.h index bc5154b..7267c2a 100644 --- a/src/lib/VSDLayerList.h +++ b/src/lib/VSDLayerList.h @@ -11,6 +11,7 @@ #define __VSDLAYERLIST_H__ #include <map> +#include <vector> #include "VSDTypes.h" namespace libvisio @@ -36,14 +37,11 @@ public: VSDLayerList &operator=(const VSDLayerList &layerList); void clear(); - unsigned long size() const - { - return (unsigned long)m_elements.size(); - } - bool empty() const - { - return (m_elements.empty()); - } + + void addLayer(unsigned id, const VSDLayer &layer); + + unsigned getColourId(const std::vector<unsigned> &ids); + private: std::map<unsigned, VSDLayer> m_elements; };
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits