StarFormatManager.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libstaroffice
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 /*
35 * FormatManager to read/parse StarOffice format
36 *
37 */
38 #ifndef STAR_FORMATMANAGER
39 # define STAR_FORMATMANAGER
40
41 #include <vector>
42
43 #include "STOFFDebug.hxx"
44 #include "STOFFEntry.hxx"
45 #include "STOFFInputStream.hxx"
46
47 #include "StarWriterStruct.hxx"
48
49 class StarState;
50 class StarObject;
51
52 namespace StarFormatManagerInternal
53 {
54 struct FormatDef {
56 FormatDef() : m_attributeList()
57 {
58 for (int &value : m_values) value=0;
59 m_values[2]=-1; // no objRef
60 }
62 ~FormatDef();
64 void updateState(StarState &state) const;
66 bool send(STOFFListenerPtr listener, StarState &state) const;
68 void printData(libstoff::DebugStream &o) const;
70 librevenge::RVNGString m_names[2];
72 std::vector<StarWriterStruct::Attribute> m_attributeList;
74 int m_values[3];
75 };
76
77 struct State;
78 }
79
80 class StarZone;
81 class StarObject;
82
83 class STOFFCell;
84
90 class StarFormatManager
91 {
92 public:
94 StarFormatManager();
96 virtual ~StarFormatManager();
97
99 bool readSWFormatDef(StarZone &zone, unsigned char kind, std::shared_ptr<StarFormatManagerInternal::FormatDef> &format, StarObject &doc);
101 void storeSWFormatDef(librevenge::RVNGString const &name, std::shared_ptr<StarFormatManagerInternal::FormatDef> &format);
103 std::shared_ptr<StarFormatManagerInternal::FormatDef> getSWFormatDef(librevenge::RVNGString const &name) const;
105 bool readSWNumberFormatterList(StarZone &zone);
107 bool readSWFlyFrameList(StarZone &zone, StarObject &doc, std::vector<std::shared_ptr<StarFormatManagerInternal::FormatDef> > &listFormats);
109 bool readSWPatternLCL(StarZone &zone);
110
112 bool readNumberFormat(StarZone &zone, long endPos, StarObject &doc);
114 bool readNumberFormatter(StarZone &zone);
115
117 void updateNumberingProperties(STOFFCell &cell) const;
118
119 //
120 // data
121 //
122 private:
124 std::shared_ptr<StarFormatManagerInternal::State> m_state;
125 };
126 #endif
127 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
StarFileManager.hxx
StarFormatManagerInternal::State
Internal: the state of a StarFormatManager.
Definition: StarFormatManager.cxx:553
STOFFCell::F_NUMBER
@ F_NUMBER
Definition: STOFFCell.hxx:57
StarLanguage.hxx
STOFFListenerPtr
std::shared_ptr< STOFFListener > STOFFListenerPtr
a smart pointer of STOFFListener
Definition: libstaroffice_internal.hxx:491
StarFormatManagerInternal::NumberFormatter::Format::operator<<
friend std::ostream & operator<<(std::ostream &o, Format const &form)
operator<<
Definition: StarFormatManager.cxx:179
StarLanguage::getLanguageId
bool getLanguageId(int id, std::string &lang, std::string &country)
returns the iso639-1 and iso3166 language code
Definition: StarLanguage.cxx:471
StarFileManager
the main class to read/.
Definition: StarFileManager.hxx:61
StarFormatManagerInternal::NumberFormatter::FormatItem::updateNumberingProperties
bool updateNumberingProperties(librevenge::RVNGPropertyListVector &vect) const
try to update the cell's formating
Definition: StarFormatManager.cxx:306
libstoff::getString
librevenge::RVNGString getString(std::vector< uint32_t > const &unicode)
transform a unicode string in a RNVGString
Definition: libstaroffice_internal.cxx:63
StarFormatManagerInternal::NumberFormatter::FormatItem::FormatItem
FormatItem()
constructor
Definition: StarFormatManager.cxx:122
StarZone::ascii
libstoff::DebugFile & ascii()
returns the ascii file
Definition: StarZone.hxx:254
StarZone::getPoolName
bool getPoolName(int poolId, librevenge::RVNGString &res) const
try to return a pool name
Definition: StarZone.hxx:235
STOFFEntry.hxx
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
StarFormatManager::StarFormatManager
StarFormatManager()
constructor
Definition: StarFormatManager.cxx:570
StarFormatManagerInternal::NumberFormatter::m_limitsOp
int m_limitsOp[2]
the limits operator
Definition: StarFormatManager.cxx:299
StarFormatManagerInternal::FormatDef::updateState
void updateState(StarState &state) const
try to update the state
Definition: StarFormatManager.cxx:67
StarFormatManagerInternal::State::State
State()
constructor
Definition: StarFormatManager.cxx:555
StarZone::isCompatibleWith
int isCompatibleWith(int vers) const
checks if the document is compatible with vers
Definition: StarZone.hxx:99
StarWriterStruct::Attribute::readList
static bool readList(StarZone &zone, std::vector< Attribute > &attributeList, StarObject &object)
try to read a list of attribute: 'S'
Definition: StarWriterStruct.cxx:107
StarFormatManagerInternal::NumberFormatter::Format::updateNumberingProperties
bool updateNumberingProperties(STOFFCell &cell, std::string const &language, std::string const &country) const
try to update the cell's formating
Definition: StarFormatManager.cxx:455
STOFFCell::getCellStyle
const STOFFCellStyle & getCellStyle() const
returns the cell style
Definition: STOFFCell.hxx:185
StarGraphicStruct.hxx
STOFFCell::F_NUMBER_CURRENCY
@ F_NUMBER_CURRENCY
Definition: STOFFCell.hxx:59
StarFormatManagerInternal::FormatDef::~FormatDef
~FormatDef()
destructor
Definition: StarFormatManager.cxx:63
StarState::m_content
bool m_content
flag to know if this is a content zone
Definition: StarState.hxx:184
StarFormatManagerInternal::NumberFormatter::Format::m_postfix
int m_postfix
the postfix digits
Definition: StarFormatManager.cxx:207
StarFormatManagerInternal::NumberFormatter::Format::Format
Format()
constructor
Definition: StarFormatManager.cxx:167
StarZone::openSWRecord
bool openSWRecord(unsigned char &type)
try to open a SW record: type + size (24 bytes)
Definition: StarZone.cxx:507
StarZone::readString
bool readString(std::vector< uint32_t > &string, int encoding=-1) const
try to read an unicode string
Definition: StarZone.hxx:220
StarFormatManagerInternal::FormatDef::m_attributeList
std::vector< StarWriterStruct::Attribute > m_attributeList
the attributes list
Definition: StarFormatManager.hxx:72
STOFFCell
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
StarFormatManager::readSWPatternLCL
bool readSWPatternLCL(StarZone &zone)
try to read a format pattern LCL : 'P' (list of 'D') (child of a TOXs)
Definition: StarFormatManager.cxx:1051
StarZone::closeFlagZone
void closeFlagZone()
close the cflag zone
Definition: StarZone.cxx:618
STOFFColor
the class to store a color
Definition: libstaroffice_internal.hxx:189
StarFormatManagerInternal::NumberFormatter::Format
struct use to store different local format
Definition: StarFormatManager.cxx:165
StarState
class to store an state: ie.
Definition: StarState.hxx:67
StarFormatManagerInternal::NumberFormatter::Format::m_exponential
int m_exponential
the exponential digits
Definition: StarFormatManager.cxx:209
StarFormatManagerInternal::NumberFormatter::FormatItem::operator<<
friend std::ostream & operator<<(std::ostream &o, FormatItem const &item)
operator<<
Definition: StarFormatManager.cxx:131
StarFormatManagerInternal
Internal: the structures of a StarFormatManager.
Definition: StarFormatManager.cxx:58
STOFFCell::getNumberingStyle
const librevenge::RVNGPropertyList & getNumberingStyle() const
returns the numbering style
Definition: STOFFCell.hxx:201
STOFFCell::F_NUMBER_PERCENT
@ F_NUMBER_PERCENT
Definition: STOFFCell.hxx:59
StarFormatManagerInternal::NumberFormatter::m_format
librevenge::RVNGString m_format
the format
Definition: StarFormatManager.cxx:287
StarFormatManagerInternal::NumberFormatter::Format::m_colorName
librevenge::RVNGString m_colorName
the color name
Definition: StarFormatManager.cxx:213
libstoff::DebugStream::str
static std::string str()
Definition: STOFFDebug.hxx:203
StarZone::closeSWRecord
bool closeSWRecord(unsigned char type, std::string const &debugName)
try to close a record
Definition: StarZone.hxx:177
StarFormatManagerInternal::NumberFormatter::FormatItem::m_text
librevenge::RVNGString m_text
the string
Definition: StarFormatManager.cxx:160
StarFormatManagerInternal::NumberFormatter::FormatItem
struct use to store small format item
Definition: StarFormatManager.cxx:120
STOFF_FALLTHROUGH
#define STOFF_FALLTHROUGH
fall through attributes
Definition: libstaroffice_internal.hxx:110
StarFormatManagerInternal::NumberFormatter::Format::m_type
int m_type
the format type
Definition: StarFormatManager.cxx:201
STOFFCell::F_BOOLEAN
@ F_BOOLEAN
Definition: STOFFCell.hxx:57
STOFFCell::getFormat
const Format & getFormat() const
returns the cell format
Definition: STOFFCell.hxx:163
STOFFCell::F_NUMBER_SCIENTIFIC
@ F_NUMBER_SCIENTIFIC
Definition: STOFFCell.hxx:59
StarFormatManagerInternal::NumberFormatter::Format::m_thousand
int m_thousand
the number of thousand digits
Definition: StarFormatManager.cxx:211
StarFormatManagerInternal::FormatDef::m_values
int m_values[3]
nDerived, nPoolId, nObjRef
Definition: StarFormatManager.hxx:74
StarFormatManagerInternal::NumberFormatter::m_extra
std::string m_extra
extra data
Definition: StarFormatManager.cxx:303
StarFormatManagerInternal::FormatDef::FormatDef
FormatDef()
constructor
Definition: StarFormatManager.hxx:56
STOFFCell::Format::m_format
FormatType m_format
the cell format : by default unknown
Definition: STOFFCell.hxx:83
STOFFInputStreamPtr
std::shared_ptr< STOFFInputStream > STOFFInputStreamPtr
a smart pointer of STOFFInputStream
Definition: libstaroffice_internal.hxx:489
StarFormatManagerInternal::FormatDef
Definition: StarFormatManager.hxx:54
StarGraphicStruct::StarBrush
Class to store a brush.
Definition: StarGraphicStruct.hxx:51
StarZone
a zone in a StarOffice file
Definition: StarZone.hxx:56
STOFFCellStyle.hxx
StarZone::getRecordLevel
int getRecordLevel() const
returns the record level
Definition: StarZone.hxx:195
StarObject
an object corresponding to an OLE directory
Definition: StarObject.hxx:64
StarFormatManagerInternal::NumberFormatter::Format::m_hasThousandSep
bool m_hasThousandSep
a flag to know if we need to add a thousand separator
Definition: StarFormatManager.cxx:203
StarFormatManagerInternal::NumberFormatter::Format::m_prefix
int m_prefix
the prefix digits
Definition: StarFormatManager.cxx:205
StarObjectModel.hxx
StarFormatManager::m_state
std::shared_ptr< StarFormatManagerInternal::State > m_state
the state
Definition: StarFormatManager.hxx:124
STOFFCell::F_NUMBER_DECIMAL
@ F_NUMBER_DECIMAL
Definition: STOFFCell.hxx:59
STOFFCell::F_TIME
@ F_TIME
Definition: STOFFCell.hxx:57
StarFormatManagerInternal::NumberFormatter::m_subFormats
Format m_subFormats[4]
the list of sub format
Definition: StarFormatManager.cxx:301
libstoff::DebugStream
Definition: STOFFDebug.hxx:194
StarFormatManager::readNumberFormat
bool readNumberFormat(StarZone &zone, long endPos, StarObject &doc)
try to read a number format (find in attribute)
Definition: StarFormatManager.cxx:709
STOFFCell::F_NUMBER_GENERIC
@ F_NUMBER_GENERIC
Definition: STOFFCell.hxx:59
STOFFCell::setFormat
void setFormat(Format const &format)
set the cell format
Definition: STOFFCell.hxx:168
StarFormatManagerInternal::NumberFormatter::m_isUsed
bool m_isUsed
a flag to know if this format is used
Definition: StarFormatManager.cxx:295
STOFFCell::F_DATETIME
@ F_DATETIME
Definition: STOFFCell.hxx:57
StarFormatManagerInternal::NumberFormatter::m_isStandart
bool m_isStandart
a flag to know if the format is standart
Definition: StarFormatManager.cxx:293
StarFormatManager::updateNumberingProperties
void updateNumberingProperties(STOFFCell &cell) const
try to update the cell's data
Definition: StarFormatManager.cxx:1149
StarFormatManager::readSWFlyFrameList
bool readSWFlyFrameList(StarZone &zone, StarObject &doc, std::vector< std::shared_ptr< StarFormatManagerInternal::FormatDef > > &listFormats)
try to read a fly frame list : 'F' (list of 'l' or 'o')
Definition: StarFormatManager.cxx:1019
StarFormatManagerInternal::State::m_idNumberFormatMap
std::map< unsigned, NumberFormatter > m_idNumberFormatMap
a map id to number format
Definition: StarFormatManager.cxx:561
StarFormatManager::~StarFormatManager
virtual ~StarFormatManager()
destructor
Definition: StarFormatManager.cxx:575
STOFFDebug.hxx
StarFormatManagerInternal::NumberFormatter::FormatItem::m_type
int m_type
the type
Definition: StarFormatManager.cxx:162
StarState.hxx
StarFormatManagerInternal::NumberFormatter::operator<<
friend std::ostream & operator<<(std::ostream &o, NumberFormatter const &form)
operator<<
Definition: StarFormatManager.cxx:248
StarFormatManagerInternal::NumberFormatter::NumberFormatter
NumberFormatter()
constructor
Definition: StarFormatManager.cxx:216
StarFormatManager::readSWNumberFormatterList
bool readSWNumberFormatterList(StarZone &zone)
try to read a number formatter type : 'q'
Definition: StarFormatManager.cxx:685
StarFormatManagerInternal::NumberFormatter::updateNumberingProperties
bool updateNumberingProperties(STOFFCell &cell) const
try to update the cell's formating
Definition: StarFormatManager.cxx:280
StarFormatManagerInternal::FormatDef::send
bool send(STOFFListenerPtr listener, StarState &state) const
try to send the data to a listener
Definition: StarFormatManager.cxx:76
StarFormatManager::getSWFormatDef
std::shared_ptr< StarFormatManagerInternal::FormatDef > getSWFormatDef(librevenge::RVNGString const &name) const
try to return a named format zone(if possible)
Definition: StarFormatManager.cxx:588
libstoff::DebugFile::addPos
static void addPos(long)
Definition: STOFFDebug.hxx:223
libstoff::DebugFile::addDelimiter
static void addDelimiter(long, char)
Definition: STOFFDebug.hxx:225
StarFormatManagerInternal::FormatDef::m_names
librevenge::RVNGString m_names[2]
the pool name, the read name
Definition: StarFormatManager.hxx:70
StarWriterStruct.hxx
STOFFCell::Format
a structure uses to define the format of a cell content
Definition: STOFFCell.hxx:61
StarObject.hxx
StarZone.hxx
StarFormatManagerInternal::NumberFormatter::m_type
uint16_t m_type
the format type
Definition: StarFormatManager.cxx:291
StarFormatManager::readNumberFormatter
bool readNumberFormatter(StarZone &zone)
try to read number formatter type
Definition: StarFormatManager.cxx:815
STOFFCell::F_TEXT
@ F_TEXT
Definition: STOFFCell.hxx:57
StarState::m_global
std::shared_ptr< GlobalState > m_global
global state
Definition: StarState.hxx:165
StarFormatManagerInternal::NumberFormatter::getTypeString
static std::string getTypeString(int typeId)
returns a string corresponding to a format type
Definition: StarFormatManager.cxx:230
libstoff::DebugFile
Definition: STOFFDebug.hxx:210
StarFormatManagerInternal::NumberFormatter::m_limits
double m_limits[2]
the limits
Definition: StarFormatManager.cxx:297
STOFFCell::Format::m_numberFormat
NumberType m_numberFormat
the numeric format
Definition: STOFFCell.hxx:85
STOFFCell::F_DATE
@ F_DATE
Definition: STOFFCell.hxx:57
StarGraphicStruct::StarBrush::read
bool read(StarZone &zone, int nVers, long endPos, StarObject &document)
try to read a brush
Definition: StarGraphicStruct.cxx:498
StarFileManager::readFont
static bool readFont(StarZone &zone)
try to read a font
Definition: StarFileManager.cxx:775
StarFormatManager.hxx
libstoff::DebugFile::addNote
static void addNote(char const *)
Definition: STOFFDebug.hxx:224
StarFormatManager
the main class to read/.
Definition: StarFormatManager.hxx:90
STOFFCell::F_NUMBER_FRACTION
@ F_NUMBER_FRACTION
Definition: STOFFCell.hxx:59
StarFormatManagerInternal::NumberFormatter
a struct use to store number formatter of a StarFormatManager
Definition: StarFormatManager.cxx:118
StarZone::input
STOFFInputStreamPtr input()
return the zone input
Definition: StarZone.hxx:247
StarFormatManagerInternal::State::m_nameToFormatDefMap
std::map< librevenge::RVNGString, std::shared_ptr< StarFormatManagerInternal::FormatDef > > m_nameToFormatDefMap
a map name to format definition
Definition: StarFormatManager.cxx:563
StarFormatManager::readSWFormatDef
bool readSWFormatDef(StarZone &zone, unsigned char kind, std::shared_ptr< StarFormatManagerInternal::FormatDef > &format, StarObject &doc)
try to read a format zone : 'f' or 'l' or 'o' or 'r' or 's'(in TOCX)
Definition: StarFormatManager.cxx:595
STOFFInputStream.hxx
StarFormatManagerInternal::FormatDef::printData
void printData(libstoff::DebugStream &o) const
debug function to print the data
Definition: StarFormatManager.cxx:105
StarFormatManagerInternal::NumberFormatter::Format::m_itemList
std::vector< FormatItem > m_itemList
the item list
Definition: StarFormatManager.cxx:199
StarZone::openFlagZone
unsigned char openFlagZone()
try to open a cflag zone
Definition: StarZone.cxx:611
StarFormatManagerInternal::NumberFormatter::m_language
int m_language
the format language
Definition: StarFormatManager.cxx:289
StarAttribute.hxx
StarZone::getRecordLastPosition
long getRecordLastPosition() const
returns the actual record last position
Definition: StarZone.hxx:200
StarFormatManager::storeSWFormatDef
void storeSWFormatDef(librevenge::RVNGString const &name, std::shared_ptr< StarFormatManagerInternal::FormatDef > &format)
store a named format zone
Definition: StarFormatManager.cxx:579
STOFFCell::F_UNKNOWN
@ F_UNKNOWN
Definition: STOFFCell.hxx:57
STOFFCell.hxx