STOFFList.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libstaroffice
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
#ifndef STOFF_LIST_H
# define STOFF_LIST_H
#include <iostream>
#include <vector>
#include <librevenge/librevenge.h>
#include "libstaroffice_internal.hxx"
class STOFFFont;
struct STOFFListLevel {
enum Type { DEFAULT, NONE, BULLET, NUMBER };
STOFFListLevel()
: m_type(NONE)
, m_propertyList()
, m_font()
, m_startValue(0)
{
}
STOFFListLevel(STOFFListLevel const &)=default;
STOFFListLevel(STOFFListLevel &&)=default;
STOFFListLevel &operator=(STOFFListLevel const &)=default;
STOFFListLevel &operator=(STOFFListLevel &&)=default;
~STOFFListLevel();
bool isDefault() const
{
return m_type==DEFAULT;
}
bool isNumeric() const
{
return m_type==NUMBER;
}
bool operator==(STOFFListLevel const &levl) const
{
return cmp(levl)==0;
}
bool operator!=(STOFFListLevel const &levl) const
{
return !operator==(levl);
}
void addTo(librevenge::RVNGPropertyList &propList) const;
int getStartValue() const
{
return m_startValue <= 0 ? 1 : m_startValue;
}
int cmp(STOFFListLevel const &levl) const;
Type m_type;
librevenge::RVNGPropertyList m_propertyList;
std::shared_ptr<STOFFFont> m_font;
int m_startValue;
};
class STOFFList
{
public:
explicit STOFFList(bool outline)
: m_outline(outline)
, m_name(""), m_levels()
, m_actLevel(-1)
, m_actualIndices()
, m_nextIndices()
, m_modifyMarker(1)
{
m_id[0] = m_id[1] = -1;
}
int getId() const
{
return m_id[0];
}
int getMarker() const
{
return m_modifyMarker;
}
void resize(int levl);
bool isCompatibleWith(int levl, STOFFListLevel const &level) const;
bool isCompatibleWith(STOFFList const &newList) const;
void updateIndicesFrom(STOFFList const &list);
void swapId() const
{
int tmp = m_id[0];
m_id[0] = m_id[1];
m_id[1] = tmp;
}
void setId(int newId) const;
STOFFListLevel getLevel(int levl) const
{
if (levl >= 0 && levl < int(m_levels.size()))
return m_levels[size_t(levl)];
STOFF_DEBUG_MSG(("STOFFList::getLevel: can not find level %d\n", levl));
return STOFFListLevel();
}
int numLevels() const
{
return int(m_levels.size());
}
void set(int levl, STOFFListLevel const &level);
void setLevel(int levl) const;
void openElement() const;
void closeElement() const {}
int getStartValueForNextElement() const;
void setStartValueForNextElement(int value);
bool isNumeric(int levl) const;
bool addTo(int level, librevenge::RVNGPropertyList &pList) const;
bool m_outline;
librevenge::RVNGString m_name;
protected:
std::vector<STOFFListLevel> m_levels;
mutable int m_actLevel;
mutable std::vector<int> m_actualIndices, m_nextIndices;
mutable int m_id[2];
mutable int m_modifyMarker;
};
class STOFFListManager
{
public:
STOFFListManager()
: m_listList()
, m_sendIdMarkerList() { }
~STOFFListManager() { }
bool needToSend(int index, std::vector<int> &idMarkerList) const;
std::shared_ptr<STOFFList> getList(int index) const;
std::shared_ptr<STOFFList> getNewList(std::shared_ptr<STOFFList> actList, int levl, STOFFListLevel const &level);
std::shared_ptr<STOFFList> addList(std::shared_ptr<STOFFList> actList);
protected:
std::vector<STOFFList> m_listList;
mutable std::vector<int> m_sendIdMarkerList;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFFont
Class to store font.
Definition STOFFFont.hxx:44
STOFFListManager::getNewList
std::shared_ptr< STOFFList > getNewList(std::shared_ptr< STOFFList > actList, int levl, STOFFListLevel const &level)
returns a new list corresponding to a list where we have a new level
Definition STOFFList.cxx:291
STOFFListManager::needToSend
bool needToSend(int index, std::vector< int > &idMarkerList) const
check if a list need to be send/resend to the interface
Definition STOFFList.cxx:243
STOFFListManager::addList
std::shared_ptr< STOFFList > addList(std::shared_ptr< STOFFList > actList)
add a new list
Definition STOFFList.cxx:274
STOFFListManager::~STOFFListManager
~STOFFListManager()
the destructor
Definition STOFFList.hxx:217
STOFFListManager::getList
std::shared_ptr< STOFFList > getList(int index) const
returns a list with given index ( if found )
Definition STOFFList.cxx:261
STOFFListManager::m_sendIdMarkerList
std::vector< int > m_sendIdMarkerList
the list of send list to interface
Definition STOFFList.hxx:230
STOFFListManager::m_listList
std::vector< STOFFList > m_listList
the list of created list
Definition STOFFList.hxx:228
STOFFListManager::STOFFListManager
STOFFListManager()
the constructor
Definition STOFFList.hxx:213
STOFFList
a small structure used to store the informations about a list
Definition STOFFList.hxx:110
STOFFList::STOFFList
STOFFList(bool outline)
default constructor
Definition STOFFList.hxx:113
STOFFList::getStartValueForNextElement
int getStartValueForNextElement() const
returns the startvalue corresponding to the actual level ( or -1 for an unknown/unordered list)
Definition STOFFList.cxx:209
STOFFList::m_id
int m_id[2]
the identificator ( actual and auxilliar )
Definition STOFFList.hxx:203
STOFFList::openElement
void openElement() const
open the list element
Definition STOFFList.cxx:220
STOFFList::updateIndicesFrom
void updateIndicesFrom(STOFFList const &list)
update the indices, the actual level from newList
Definition STOFFList.cxx:102
STOFFList::setLevel
void setLevel(int levl) const
set the list level
Definition STOFFList.cxx:183
STOFFList::getId
int getId() const
returns the list id
Definition STOFFList.hxx:125
STOFFList::set
void set(int levl, STOFFListLevel const &level)
sets a level
Definition STOFFList.cxx:164
STOFFList::m_name
librevenge::RVNGString m_name
the list name
Definition STOFFList.hxx:194
STOFFList::closeElement
void closeElement() const
close the list element
Definition STOFFList.hxx:179
STOFFList::isNumeric
bool isNumeric(int levl) const
returns true is a level is numeric
Definition STOFFList.cxx:230
STOFFList::swapId
void swapId() const
swap the list id
Definition STOFFList.hxx:148
STOFFList::numLevels
int numLevels() const
returns the number of level
Definition STOFFList.hxx:167
STOFFList::resize
void resize(int levl)
resize the number of level of the list (keeping only n level)
Definition STOFFList.cxx:86
STOFFList::getLevel
STOFFListLevel getLevel(int levl) const
returns a level if it exists
Definition STOFFList.hxx:159
STOFFList::getMarker
int getMarker() const
returns the actual modify marker
Definition STOFFList.hxx:131
STOFFList::addTo
bool addTo(int level, librevenge::RVNGPropertyList &pList) const
retrieve the list level property
Definition STOFFList.cxx:143
STOFFList::m_actLevel
int m_actLevel
the actual levels
Definition STOFFList.hxx:200
STOFFList::m_modifyMarker
int m_modifyMarker
a modification marker ( can be used to check if a list has been send to a interface )
Definition STOFFList.hxx:205
STOFFList::m_actualIndices
std::vector< int > m_actualIndices
Definition STOFFList.hxx:201
STOFFList::m_levels
std::vector< STOFFListLevel > m_levels
the different levels
Definition STOFFList.hxx:197
STOFFList::m_nextIndices
std::vector< int > m_nextIndices
Definition STOFFList.hxx:201
STOFFList::setStartValueForNextElement
void setStartValueForNextElement(int value)
set the startvalue corresponding to the actual level
Definition STOFFList.cxx:197
STOFFList::setId
void setId(int newId) const
set the list id
Definition STOFFList.cxx:137
STOFFList::m_outline
bool m_outline
flag to know if the list is a outline list
Definition STOFFList.hxx:192
STOFFList::isCompatibleWith
bool isCompatibleWith(int levl, STOFFListLevel const &level) const
returns true if we can add a new level in the list without changing is meaning
Definition STOFFList.cxx:114
libstaroffice_internal.hxx
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition libstaroffice_internal.hxx:129
STOFFListLevel
small structure to keep information about a list level
Definition STOFFList.hxx:48
STOFFListLevel::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
add the information of this level in the propList
Definition STOFFList.cxx:52
STOFFListLevel::isDefault
bool isDefault() const
returns true if the level type was not set
Definition STOFFList.hxx:68
STOFFListLevel::isNumeric
bool isNumeric() const
returns true if the list is decimal, alpha or roman
Definition STOFFList.hxx:73
STOFFListLevel::m_startValue
int m_startValue
the actual value (if this is an ordered level )
Definition STOFFList.hxx:105
STOFFListLevel::operator=
STOFFListLevel & operator=(STOFFListLevel const &)=default
STOFFListLevel::STOFFListLevel
STOFFListLevel()
basic constructor
Definition STOFFList.hxx:53
STOFFListLevel::m_propertyList
librevenge::RVNGPropertyList m_propertyList
the propertyList
Definition STOFFList.hxx:101
STOFFListLevel::~STOFFListLevel
~STOFFListLevel()
destructor
Definition STOFFList.cxx:48
STOFFListLevel::operator==
bool operator==(STOFFListLevel const &levl) const
operator==
Definition STOFFList.hxx:78
STOFFListLevel::m_type
Type m_type
the type of the level
Definition STOFFList.hxx:99
STOFFListLevel::operator=
STOFFListLevel & operator=(STOFFListLevel &&)=default
STOFFListLevel::cmp
int cmp(STOFFListLevel const &levl) const
comparison function ( compare all values excepted m_startValues
Definition STOFFList.cxx:67
STOFFListLevel::STOFFListLevel
STOFFListLevel(STOFFListLevel &&)=default
STOFFListLevel::m_font
std::shared_ptr< STOFFFont > m_font
the font
Definition STOFFList.hxx:103
STOFFListLevel::Type
Type
the type of the level
Definition STOFFList.hxx:50
STOFFListLevel::DEFAULT
@ DEFAULT
Definition STOFFList.hxx:50
STOFFListLevel::BULLET
@ BULLET
Definition STOFFList.hxx:50
STOFFListLevel::NUMBER
@ NUMBER
Definition STOFFList.hxx:50
STOFFListLevel::NONE
@ NONE
Definition STOFFList.hxx:50
STOFFListLevel::STOFFListLevel
STOFFListLevel(STOFFListLevel const &)=default
STOFFListLevel::operator!=
bool operator!=(STOFFListLevel const &levl) const
operator!=
Definition STOFFList.hxx:83
STOFFListLevel::getStartValue
int getStartValue() const
returns the start value (if set) or 1
Definition STOFFList.hxx:91