StarObject.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 * class to parse/store an object corresponding to an OLE directory
36 *
37 */
38 #ifndef STAR_OBJECT
39 # define STAR_OBJECT
40
41 #include <vector>
42 #include <stack>
43 #include <libstaroffice/STOFFDocument.hxx>
44
45 #include "STOFFDebug.hxx"
46 #include "STOFFOLEParser.hxx"
47
48 #include "StarItemPool.hxx"
49
50 namespace StarObjectInternal
51 {
52 struct State;
53 }
54
55 class StarAttributeManager;
56 class StarFormatManager;
57 class StarItemSet;
58
64 class StarObject
65 {
66 public:
68 StarObject(char const *passwd, std::shared_ptr<STOFFOLEParser> &oleParser, std::shared_ptr<STOFFOLEParser::OleDirectory> &directory);
70 virtual ~StarObject();
71
72 //
73 // basic
74 //
75
77 bool parse();
79 STOFFDocument::Kind getDocumentKind() const;
81 char const *getPassword() const
82 {
83 return m_password;
84 }
86 std::shared_ptr<STOFFOLEParser::OleDirectory> getOLEDirectory()
87 {
88 return m_directory;
89 }
91 std::shared_ptr<StarAttributeManager> getAttributeManager();
93 std::shared_ptr<StarFormatManager> getFormatManager();
95 librevenge::RVNGPropertyList const &getMetaData() const
96 {
97 return m_metaData;
98 }
100 librevenge::RVNGString getUserNameMetaData(int i) const;
101 // the document pool
103 void cleanPools();
105 std::shared_ptr<StarItemPool> getNewItemPool(StarItemPool::Type type);
109 std::shared_ptr<StarItemPool> findItemPool(StarItemPool::Type type, bool isInside);
111 std::shared_ptr<StarItemPool> getCurrentPool(bool onlyInside=true);
112
114 bool readPersistData(StarZone &zone, long endPos);
116 bool readSfxStyleSheets(STOFFInputStreamPtr input, std::string const &name);
118 bool readItemSet(StarZone &zone, std::vector<STOFFVec2i> const &limits, long endPos,
119 StarItemSet &itemSet, StarItemPool *pool=nullptr, bool isDirect=false);
120 protected:
122 bool readPersistElements(STOFFInputStreamPtr input, std::string const &name);
124 bool readSfxDocumentInformation(STOFFInputStreamPtr input, std::string const &name);
126 bool readSfxPreview(STOFFInputStreamPtr input, std::string const &name);
128 bool readSfxWindows(STOFFInputStreamPtr input, libstoff::DebugFile &ascii);
130 bool readStarFrameworkConfigFile(STOFFInputStreamPtr input, libstoff::DebugFile &ascii);
132 bool readStarFrameworkConfigItem(STOFFEntry &entry, STOFFInputStreamPtr input, libstoff::DebugFile &ascii);
133
134 //
135 // data
136 //
137 protected:
139 StarObject(StarObject const &orig, bool duplicateState);
141 char const *m_password;
143 std::shared_ptr<STOFFOLEParser> m_oleParser;
145 std::shared_ptr<STOFFOLEParser::OleDirectory> m_directory;
146
148 std::shared_ptr<StarObjectInternal::State> m_state;
150 librevenge::RVNGPropertyList m_metaData;
151
152 private:
153 StarObject(StarObject const &orig) = delete;
154 StarObject &operator=(StarObject const &orig) = delete;
155 };
156
157 #endif
158 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
StarFileManager.hxx
StarItemSet::add
bool add(std::shared_ptr< StarItem > item)
try to add a item
Definition: StarItem.cxx:42
StarFileManager
the main class to read/.
Definition: StarFileManager.hxx:61
STOFFDocument::STOFF_K_DRAW
@ STOFF_K_DRAW
vectorized graphic: .sda
Definition: STOFFDocument.hxx:71
STOFFEntry::end
long end() const
returns the end offset
Definition: STOFFEntry.hxx:83
StarObjectInternal::State::m_attributeManager
std::shared_ptr< StarAttributeManager > m_attributeManager
the attribute manager
Definition: StarObject.cxx:67
STOFFEntry
basic class to store an entry in a file This contained :
Definition: STOFFEntry.hxx:46
libstoff::getString
librevenge::RVNGString getString(std::vector< uint32_t > const &unicode)
transform a unicode string in a RNVGString
Definition: libstaroffice_internal.cxx:63
StarObject::readPersistData
bool readPersistData(StarZone &zone, long endPos)
try to read persist data
Definition: StarObject.cxx:363
StarZone::ascii
libstoff::DebugFile & ascii()
returns the ascii file
Definition: StarZone.hxx:254
StarAttributeManager
the main class to read/.
Definition: StarAttribute.hxx:1080
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
StarItemPool::Type
Type
the known item pool
Definition: StarItemPool.hxx:75
StarObject::m_directory
std::shared_ptr< STOFFOLEParser::OleDirectory > m_directory
the directory
Definition: StarObject.hxx:145
STOFFDocument::Kind
Kind
an enum to define the kind of document
Definition: STOFFDocument.hxx:66
StarObject::readSfxPreview
bool readSfxPreview(STOFFInputStreamPtr input, std::string const &name)
try to read the preview : "SfxPreview"
Definition: StarObject.cxx:800
StarObject::readSfxWindows
bool readSfxWindows(STOFFInputStreamPtr input, libstoff::DebugFile &ascii)
try to read the windows information : "SfxWindows"
Definition: StarObject.cxx:824
StarObjectInternal
Internal: the structures of a StarObject.
Definition: StarObject.cxx:51
StarObject::m_password
const char * m_password
the document password
Definition: StarObject.hxx:141
StarObject::cleanPools
void cleanPools()
clean each pool
Definition: StarObject.cxx:106
STOFFBox2i
STOFFBox2< int > STOFFBox2i
STOFFBox2 of int.
Definition: libstaroffice_internal.hxx:1133
StarObject::getNewItemPool
std::shared_ptr< StarItemPool > getNewItemPool(StarItemPool::Type type)
returns a new item pool for this document
Definition: StarObject.cxx:142
StarZone::readString
bool readString(std::vector< uint32_t > &string, int encoding=-1) const
try to read an unicode string
Definition: StarZone.hxx:220
StarObject::readStarFrameworkConfigFile
bool readStarFrameworkConfigFile(STOFFInputStreamPtr input, libstoff::DebugFile &ascii)
try to read the "Star Framework Config File"
Definition: StarObject.cxx:687
StarObject::StarObject
StarObject(char const *passwd, std::shared_ptr< STOFFOLEParser > &oleParser, std::shared_ptr< STOFFOLEParser::OleDirectory > &directory)
constructor
Definition: StarObject.cxx:80
STOFFDocument::STOFF_K_UNKNOWN
@ STOFF_K_UNKNOWN
unknown
Definition: STOFFDocument.hxx:67
StarObjectInternal::State::m_poolList
std::vector< std::shared_ptr< StarItemPool > > m_poolList
the list of pool
Definition: StarObject.cxx:65
StarObject::m_state
std::shared_ptr< StarObjectInternal::State > m_state
the state
Definition: StarObject.hxx:148
StarObject::getUserNameMetaData
librevenge::RVNGString getUserNameMetaData(int i) const
returns the ith user meta data
Definition: StarObject.cxx:130
StarObject::~StarObject
virtual ~StarObject()
destructor
Definition: StarObject.cxx:102
STOFFOLEParser.hxx
StarObject::readSfxDocumentInformation
bool readSfxDocumentInformation(STOFFInputStreamPtr input, std::string const &name)
try to read the document information : "SfxDocumentInformation"
Definition: StarObject.cxx:488
libstoff::DebugStream::str
static std::string str()
Definition: STOFFDebug.hxx:203
StarItemPool
the main class to read/.
Definition: StarItemPool.hxx:70
StarObject::readPersistElements
bool readPersistElements(STOFFInputStreamPtr input, std::string const &name)
the "persist elements" small ole: the list of object
Definition: StarObject.cxx:287
StarZone::openSCRecord
bool openSCRecord()
try to open a SC record: size (32 bytes) + size bytes
Definition: StarZone.cxx:483
StarEncoding::convert
static bool convert(std::vector< uint8_t > const &src, Encoding encoding, std::vector< uint32_t > &dest, std::vector< size_t > &srcPositions)
try to convert a list of character and transforms it a unicode's list
Definition: StarEncoding.cxx:61
StarObject::readItemSet
bool readItemSet(StarZone &zone, std::vector< STOFFVec2i > const &limits, long endPos, StarItemSet &itemSet, StarItemPool *pool=nullptr, bool isDirect=false)
try to read a list of item
Definition: StarObject.cxx:229
StarObject::operator=
StarObject & operator=(StarObject const &orig)=delete
StarObject::readSfxStyleSheets
bool readSfxStyleSheets(STOFFInputStreamPtr input, std::string const &name)
try to read a spreadshet style zone: SfxStyleSheets
Definition: StarObject.cxx:638
STOFFInputStreamPtr
std::shared_ptr< STOFFInputStream > STOFFInputStreamPtr
a smart pointer of STOFFInputStream
Definition: libstaroffice_internal.hxx:489
StarObject::getFormatManager
std::shared_ptr< StarFormatManager > getFormatManager()
returns the format manager
Definition: StarObject.cxx:125
StarZone
a zone in a StarOffice file
Definition: StarZone.hxx:56
StarItemPool::T_EditEnginePool
@ T_EditEnginePool
Definition: StarItemPool.hxx:75
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
StarObject::m_metaData
librevenge::RVNGPropertyList m_metaData
the meta data
Definition: StarObject.hxx:150
StarEncoding::getEncodingForId
static Encoding getEncodingForId(int id)
return an encoding corresponding to an id
Definition: StarEncoding.cxx:73
libstoff::DebugStream
Definition: STOFFDebug.hxx:194
StarObject::findItemPool
std::shared_ptr< StarItemPool > findItemPool(StarItemPool::Type type, bool isInside)
check if a pool corresponding to a given type is opened if so returned it.
Definition: StarObject.cxx:159
StarZone::closeSCRecord
bool closeSCRecord(std::string const &debugName)
try to close a record
Definition: StarZone.hxx:165
StarObject::getPassword
const char * getPassword() const
returns the document password (the password given by the user)
Definition: StarObject.hxx:81
StarItemPool::T_Unknown
@ T_Unknown
Definition: StarItemPool.hxx:75
STOFFDocument.hxx
StarObject::getMetaData
const librevenge::RVNGPropertyList & getMetaData() const
returns the meta data (filled by readSfxDocumentInformation)
Definition: StarObject.hxx:95
STOFFDocument::STOFF_K_PRESENTATION
@ STOFF_K_PRESENTATION
presentation
Definition: STOFFDocument.hxx:73
STOFFDebug.hxx
StarObject::getDocumentKind
STOFFDocument::Kind getDocumentKind() const
returns the document kind
Definition: StarObject.cxx:115
StarObject::parse
bool parse()
try to parse data
Definition: StarObject.cxx:170
StarObjectInternal::State::State
State()
constructor
Definition: StarObject.cxx:56
StarObject::m_oleParser
std::shared_ptr< STOFFOLEParser > m_oleParser
the ole parser
Definition: StarObject.hxx:143
libstoff::DebugFile::addPos
static void addPos(long)
Definition: STOFFDebug.hxx:223
libstoff::DebugFile::addDelimiter
static void addDelimiter(long, char)
Definition: STOFFDebug.hxx:225
StarObject.hxx
StarZone.hxx
libstoff::convertToDateTime
bool convertToDateTime(uint32_t date, uint32_t time, std::string &dateTime)
convert a date/time in a date time format
Definition: libstaroffice_internal.cxx:389
STOFFEntry::setId
void setId(int newId)
sets the id
Definition: STOFFEntry.hxx:164
STOFFEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: STOFFEntry.hxx:62
libstoff::DebugFile
Definition: STOFFDebug.hxx:210
STOFFEntry::id
int id() const
returns the id
Definition: STOFFEntry.hxx:159
StarObject::getOLEDirectory
std::shared_ptr< STOFFOLEParser::OleDirectory > getOLEDirectory()
returns the object directory
Definition: StarObject.hxx:86
StarObjectInternal::State
the state of a StarObject
Definition: StarObject.cxx:54
StarItemSet::m_whichToItemMap
std::map< int, std::shared_ptr< StarItem > > m_whichToItemMap
the list of item
Definition: StarItem.hxx:111
StarItemSet
class to store a list of item
Definition: StarItem.hxx:87
StarFormatManager.hxx
libstoff::DebugFile::addNote
static void addNote(char const *)
Definition: STOFFDebug.hxx:224
StarFormatManager
the main class to read/.
Definition: StarFormatManager.hxx:90
StarObject::getCurrentPool
std::shared_ptr< StarItemPool > getCurrentPool(bool onlyInside=true)
returns the current all/inside pool
Definition: StarObject.cxx:149
StarObjectInternal::State::m_formatManager
std::shared_ptr< StarFormatManager > m_formatManager
the format manager
Definition: StarObject.cxx:69
StarObject::getAttributeManager
std::shared_ptr< StarAttributeManager > getAttributeManager()
returns the attribute manager
Definition: StarObject.cxx:120
StarObjectInternal::State::operator=
State operator=(State const &)=delete
StarZone::input
STOFFInputStreamPtr input()
return the zone input
Definition: StarZone.hxx:247
StarItemPool::T_VCControlPool
@ T_VCControlPool
Definition: StarItemPool.hxx:75
STOFFEntry::setLength
void setLength(long l)
sets the zone size
Definition: STOFFEntry.hxx:67
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:767
libstoff::DebugFile::open
static bool open(std::string const &)
Definition: STOFFDebug.hxx:218
StarObject::readStarFrameworkConfigItem
bool readStarFrameworkConfigItem(STOFFEntry &entry, STOFFInputStreamPtr input, libstoff::DebugFile &ascii)
try to read an item in a "Star Framework Config File"
Definition: StarObject.cxx:764
STOFFEntry::length
long length() const
returns the length of the zone
Definition: STOFFEntry.hxx:88
StarItemPool.hxx
StarItemPool::T_XOutdevPool
@ T_XOutdevPool
Definition: StarItemPool.hxx:75
StarAttribute.hxx
StarZone::getRecordLastPosition
long getRecordLastPosition() const
returns the actual record last position
Definition: StarZone.hxx:200
StarItemPool::readItem
std::shared_ptr< StarItem > readItem(StarZone &zone, bool isDirect, long endPos)
read a item
Definition: StarItemPool.cxx:1041
StarFileManager::readSVGDI
static bool readSVGDI(StarZone &zone)
try to read a SVGDI object
Definition: StarFileManager.cxx:958
STOFFEntry::begin
long begin() const
returns the begin offset
Definition: STOFFEntry.hxx:78
STOFFEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: STOFFEntry.hxx:94
StarObjectInternal::State::m_userMetaNames
librevenge::RVNGString m_userMetaNames[4]
the list of user name
Definition: StarObject.cxx:71