StarObjectModel.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 * Parser to convert a SdrModel zone/OLE in a StarOffice document
36 *
37 */
38 #ifndef STAR_OBJECT_MODEL
39 # define STAR_OBJECT_MODEL
40
41 #include <ostream>
42 #include <set>
43 #include <vector>
44
45 #include "libstaroffice_internal.hxx"
46 #include "StarObject.hxx"
47
48 namespace StarObjectModelInternal
49 {
50 class Layer;
51 class LayerSet;
52 class Page;
53 struct State;
54 }
55
56 class StarState;
57 class StarZone;
58
64 class StarObjectModel : public StarObject
65 {
66 public:
68 StarObjectModel(StarObject const &orig, bool duplicateState);
70 ~StarObjectModel() override;
72 bool read(StarZone &zone);
77 void updateObjectIds(std::set<long> &unusedId);
79 bool updatePageSpans(std::vector<STOFFPageSpan> &pageSpan, int &numPages, bool usePage0=false) const;
81 bool sendMasterPages(STOFFGraphicListenerPtr listener);
83 bool sendPages(STOFFListenerPtr listener);
85 bool sendPage(int pageId, STOFFListenerPtr listener, bool masterPage=false);
87 bool sendObject(int id, STOFFListenerPtr listener, StarState const &state);
88
90 friend std::ostream &operator<<(std::ostream &o, StarObjectModel const &model);
91 protected:
92 //
93 // low level
94 //
96 bool readSdrLayer(StarZone &zone, StarObjectModelInternal::Layer &layer);
98 bool readSdrLayerSet(StarZone &zone, StarObjectModelInternal::LayerSet &layers);
100 std::shared_ptr<StarObjectModelInternal::Page> readSdrPage(StarZone &zone);
101 /* try to read a Master Page descriptor zone: "DrMP' and add it the master page descriptor */
102 bool readSdrMPageDesc(StarZone &zone, StarObjectModelInternal::Page &page);
103 /* try to read a list of Master Page zone: "DrML' and add them in the master page descriptors */
104 bool readSdrMPageDescList(StarZone &zone, StarObjectModelInternal::Page &page);
106 bool readSdrPageUnknownZone1(StarZone &zone, long lastPos);
107
108
109 protected:
110 //
111 // data
112 //
113
115 std::shared_ptr<StarObjectModelInternal::State> m_modelState;
116 private:
117 StarObjectModel &operator=(StarObjectModel const &orig) = delete;
118 };
119 #endif
120 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFListenerPtr
std::shared_ptr< STOFFListener > STOFFListenerPtr
a smart pointer of STOFFListener
Definition: libstaroffice_internal.hxx:491
StarObjectModel::sendObject
bool sendObject(int id, STOFFListenerPtr listener, StarState const &state)
try to send an object
Definition: StarObjectModel.cxx:412
STOFFVec2< int >
StarObjectModelInternal::State::m_layerSetList
std::vector< LayerSet > m_layerSetList
the list of layer set
Definition: StarObjectModel.cxx:326
libstoff::getString
librevenge::RVNGString getString(std::vector< uint32_t > const &unicode)
transform a unicode string in a RNVGString
Definition: libstaroffice_internal.cxx:63
StarObjectModelInternal::State::m_masterPageList
std::vector< std::shared_ptr< Page > > m_masterPageList
list of master pages
Definition: StarObjectModel.cxx:322
StarZone::ascii
libstoff::DebugFile & ascii()
returns the ascii file
Definition: StarZone.hxx:254
StarObjectModelInternal::State::m_previewMasterPage
int m_previewMasterPage
the default master page: -1 means not found, in general 1 in StarDrawDocument
Definition: StarObjectModel.cxx:306
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
StarZone::openRecord
bool openRecord()
try to open a classic record: size (32 bytes) + size-4 bytes
Definition: StarZone.cxx:455
STOFFFrameStyle.hxx
StarState::m_frame
STOFFFrameStyle m_frame
the frame style
Definition: StarState.hxx:175
StarZone::closeSDRHeader
bool closeSDRHeader(std::string const &debugName)
close a zone header
Definition: StarZone.cxx:436
StarObjectModel::readSdrLayerSet
bool readSdrLayerSet(StarZone &zone, StarObjectModelInternal::LayerSet &layers)
try to read a SdrLayerSet zone: "DrLS'
Definition: StarObjectModel.cxx:826
StarObjectModelInternal::Page
Internal: class used to store a page and its data.
Definition: StarObjectModel.cxx:138
STOFFFrameStyle
Class to store a frame style.
Definition: STOFFFrameStyle.hxx:45
STOFFPageSpan
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:75
StarObjectModelInternal::State::m_masterPageToSendSet
std::set< int > m_masterPageToSendSet
the list of master page to send
Definition: StarObjectModel.cxx:330
StarObjectModelInternal::Page::m_objectList
std::vector< std::shared_ptr< StarObjectSmallGraphic > > m_objectList
the list of object
Definition: StarObjectModel.cxx:247
StarObject::getNewItemPool
std::shared_ptr< StarItemPool > getNewItemPool(StarItemPool::Type type)
returns a new item pool for this document
Definition: StarObject.cxx:142
StarObjectModel::updatePageSpans
bool updatePageSpans(std::vector< STOFFPageSpan > &pageSpan, int &numPages, bool usePage0=false) const
try to update the page span (to create draw document)
Definition: StarObjectModel.cxx:360
StarObjectModel::readSdrLayer
bool readSdrLayer(StarZone &zone, StarObjectModelInternal::Layer &layer)
try to read a SdrLayer zone: "DrLy'
Definition: StarObjectModel.cxx:774
StarZone::readString
bool readString(std::vector< uint32_t > &string, int encoding=-1) const
try to read an unicode string
Definition: StarZone.hxx:220
StarObjectModelInternal::Page::m_background
std::shared_ptr< StarObjectSmallGraphic > m_background
the background object
Definition: StarObjectModel.cxx:249
StarObjectModel::~StarObjectModel
~StarObjectModel() override
destructor
Definition: StarObjectModel.cxx:347
StarObjectModelInternal::Page::m_borders
int m_borders[4]
the border size: left, up, right, bottom
Definition: StarObjectModel.cxx:239
StarObjectModelInternal::LayerSet::m_memberList
std::vector< bool > m_memberList
the list of member
Definition: StarObjectModel.cxx:131
StarObjectModelInternal::Page::m_masterPage
bool m_masterPage
a flag to know if the page is a master page
Definition: StarObjectModel.cxx:233
StarObjectModelInternal::Page::m_layerSet
LayerSet m_layerSet
the layer set
Definition: StarObjectModel.cxx:245
StarObjectModelInternal::Layer::Layer
Layer()
constructor
Definition: StarObjectModel.cxx:79
StarState
class to store an state: ie.
Definition: StarState.hxx:67
StarObjectModel::m_modelState
std::shared_ptr< StarObjectModelInternal::State > m_modelState
the state
Definition: StarObjectModel.hxx:115
StarObjectModelInternal::State::m_idToLayerMap
std::map< int, Layer > m_idToLayerMap
a map layerId to layer
Definition: StarObjectModel.cxx:324
StarObjectModelInternal::Page::updatePageSpan
void updatePageSpan(STOFFPageSpan &page, double relUnit) const
update pagespan properties
Definition: StarObjectModel.cxx:187
STOFFOLEParser.hxx
StarObjectModel
the main class to read a SdrModel zone
Definition: StarObjectModel.hxx:64
StarEncoding::E_DONTKNOW
@ E_DONTKNOW
Definition: StarEncoding.hxx:55
libstaroffice_internal.hxx
StarObjectModelInternal::Page::m_name
librevenge::RVNGString m_name
the page name
Definition: StarObjectModel.cxx:235
STOFFPageSpan::m_propertiesList
librevenge::RVNGPropertyList m_propertiesList[3]
the document, header and footer property list
Definition: STOFFPageSpan.hxx:110
StarObjectModelInternal::Page::Descriptor::operator<<
friend std::ostream & operator<<(std::ostream &o, Descriptor const &desc)
operator<<
Definition: StarObjectModel.cxx:151
libstoff::DebugStream::str
static std::string str()
Definition: STOFFDebug.hxx:203
StarObjectModelInternal::LayerSet::LayerSet
LayerSet()
constructor
Definition: StarObjectModel.cxx:106
STOFFPageSpan.hxx
StarZone::openSDRHeader
bool openSDRHeader(std::string &magic)
open a zone header present in a SDR file
Definition: StarZone.cxx:403
StarObjectModel::readSdrPageUnknownZone1
bool readSdrPageUnknownZone1(StarZone &zone, long lastPos)
try to read a zone which appear at end of a zone: "DrPg'
Definition: StarObjectModel.cxx:1151
StarObjectModelInternal::convertUint8ListToBoolList
static bool convertUint8ListToBoolList(std::vector< int > const &orig, std::vector< bool > &res)
small function used to convert a list of uint8_t to a bool vector
Definition: StarObjectModel.cxx:62
StarObjectModelInternal::Layer
Internal: class used to store a layer and its data.
Definition: StarObjectModel.cxx:75
StarObjectModelInternal::Page::Descriptor::Descriptor
Descriptor()
constructor
Definition: StarObjectModel.cxx:145
STOFFListener.hxx
StarObjectModel::readSdrMPageDesc
bool readSdrMPageDesc(StarZone &zone, StarObjectModelInternal::Page &page)
Definition: StarObjectModel.cxx:1217
StarObjectModelInternal::LayerSet::m_excludeList
std::vector< bool > m_excludeList
the list of exclude
Definition: StarObjectModel.cxx:133
STOFFInputStreamPtr
std::shared_ptr< STOFFInputStream > STOFFInputStreamPtr
a smart pointer of STOFFInputStream
Definition: libstaroffice_internal.hxx:489
StarObjectModel::sendMasterPages
bool sendMasterPages(STOFFGraphicListenerPtr listener)
try to send the master pages
Definition: StarObjectModel.cxx:439
StarObjectModelInternal
Internal: the structures of a StarObjectModel.
Definition: StarObjectModel.cxx:59
StarObjectModelInternal::State::m_pageToSendList
std::vector< int > m_pageToSendList
the list of page to send
Definition: StarObjectModel.cxx:328
StarZone
a zone in a StarOffice file
Definition: StarZone.hxx:56
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
StarObjectModel::operator=
StarObjectModel & operator=(StarObjectModel const &orig)=delete
StarObjectModel.hxx
StarObjectModelInternal::LayerSet::m_name
librevenge::RVNGString m_name
the layer name
Definition: StarObjectModel.cxx:129
StarEncoding::getEncodingForId
static Encoding getEncodingForId(int id)
return an encoding corresponding to an id
Definition: StarEncoding.cxx:73
StarObjectModel::readSdrPage
std::shared_ptr< StarObjectModelInternal::Page > readSdrPage(StarZone &zone)
try to read a Page/MasterPage zone: "DrPg'
Definition: StarObjectModel.cxx:881
libstoff::DebugStream
Definition: STOFFDebug.hxx:194
StarObjectModel::StarObjectModel
StarObjectModel(StarObject const &orig, bool duplicateState)
constructor
Definition: StarObjectModel.cxx:341
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
STOFFPosition::m_propertyList
librevenge::RVNGPropertyList m_propertyList
the property list
Definition: STOFFPosition.hxx:153
StarObjectModelInternal::Page::Descriptor::m_masterId
int m_masterId
the page number
Definition: StarObjectModel.cxx:163
STOFFFrameStyle::m_position
STOFFPosition m_position
the position
Definition: STOFFFrameStyle.hxx:73
StarObjectModelInternal::LayerSet
Internal: class used to store a layer set and its data.
Definition: StarObjectModel.cxx:102
StarObjectModel::readSdrMPageDescList
bool readSdrMPageDescList(StarZone &zone, StarObjectModelInternal::Page &page)
Definition: StarObjectModel.cxx:1255
StarObjectModelInternal::State::operator<<
friend std::ostream & operator<<(std::ostream &o, State const &state)
small operator<< to print the content of the state
Definition: StarObjectModel.cxx:268
StarObjectModel::sendPages
bool sendPages(STOFFListenerPtr listener)
try to send the different page
Definition: StarObjectModel.cxx:422
STOFFGraphicListenerPtr
std::shared_ptr< STOFFGraphicListener > STOFFGraphicListenerPtr
a smart pointer of STOFFGraphicListener
Definition: libstaroffice_internal.hxx:485
StarObjectModelInternal::State::m_idToObjectMap
std::map< int, std::shared_ptr< StarObjectSmallGraphic > > m_idToObjectMap
a map objectId to object
Definition: StarObjectModel.cxx:332
STOFFGraphicListener.hxx
StarObjectModelInternal::Page::operator<<
friend std::ostream & operator<<(std::ostream &o, Page const &page)
operator<<
Definition: StarObjectModel.cxx:204
StarObjectModelInternal::Page::m_masterPageDescList
std::vector< Descriptor > m_masterPageDescList
the list of master page descriptor
Definition: StarObjectModel.cxx:241
StarObjectModelInternal::State::m_pageList
std::vector< std::shared_ptr< Page > > m_pageList
list of pages
Definition: StarObjectModel.cxx:314
StarObjectModelInternal::State::State
State()
constructor
Definition: StarObjectModel.cxx:256
StarObjectModelInternal::State
Internal: the state of a StarObjectModel.
Definition: StarObjectModel.cxx:254
operator<<
std::ostream & operator<<(std::ostream &o, StarObjectModel const &model)
Definition: StarObjectModel.cxx:351
STOFFPosition::Page
@ Page
Definition: STOFFPosition.hxx:51
StarState.hxx
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
StarObjectModelInternal::Layer::m_type
int m_type
the layer type
Definition: StarObjectModel.cxx:98
STOFFListener::PageBreak
@ PageBreak
Definition: STOFFListener.hxx:59
StarObjectModelInternal::Page::getMasterPageId
int getMasterPageId() const
returns the master page id
Definition: StarObjectModel.cxx:181
libstoff::DebugFile
Definition: STOFFDebug.hxx:210
STOFFPosition::m_anchorTo
AnchorTo m_anchorTo
anchor position
Definition: STOFFPosition.hxx:145
StarObjectModelInternal::Page::m_size
STOFFVec2i m_size
the page size
Definition: StarObjectModel.cxx:237
StarZone::closeRecord
bool closeRecord(std::string const &debugName)
try to close a record
Definition: StarZone.hxx:147
StarObjectModelInternal::Layer::m_id
int m_id
the layer id
Definition: StarObjectModel.cxx:96
StarObjectModel::read
bool read(StarZone &zone)
try to read a SdrModel zone: "DrMd"
Definition: StarObjectModel.cxx:494
StarZone::setEncoding
void setEncoding(StarEncoding::Encoding encod)
sets the zone encoding
Definition: StarZone.hxx:126
libstoff::DebugFile::addNote
static void addNote(char const *)
Definition: STOFFDebug.hxx:224
StarObjectSmallGraphic.hxx
StarZone::input
STOFFInputStreamPtr input()
return the zone input
Definition: StarZone.hxx:247
StarItemPool::T_VCControlPool
@ T_VCControlPool
Definition: StarItemPool.hxx:75
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:767
StarObjectModelInternal::Page::Descriptor::m_layerList
std::vector< bool > m_layerList
a list of layer
Definition: StarObjectModel.cxx:165
StarObjectModelInternal::Page::m_layer
Layer m_layer
the layer
Definition: StarObjectModel.cxx:243
StarObjectModelInternal::Layer::operator<<
friend std::ostream & operator<<(std::ostream &o, Layer const &layer)
operator<<
Definition: StarObjectModel.cxx:86
StarObjectModelInternal::Page::Descriptor
Internal: class used to store a page descriptor.
Definition: StarObjectModel.cxx:143
StarItemPool.hxx
StarItemPool::T_XOutdevPool
@ T_XOutdevPool
Definition: StarItemPool.hxx:75
StarObjectSmallGraphic
the main class to read a small StarOffice graphic zone
Definition: StarObjectSmallGraphic.hxx:81
StarAttribute.hxx
StarZone::getRecordLastPosition
long getRecordLastPosition() const
returns the actual record last position
Definition: StarZone.hxx:200
StarObjectModelInternal::Layer::m_name
librevenge::RVNGString m_name
the layer name
Definition: StarObjectModel.cxx:94
StarObjectModel::sendPage
bool sendPage(int pageId, STOFFListenerPtr listener, bool masterPage=false)
try to send a page content
Definition: StarObjectModel.cxx:466
StarObjectModel::updateObjectIds
void updateObjectIds(std::set< long > &unusedId)
try to update the object id of page 0
Definition: StarObjectModel.cxx:398
StarObjectModelInternal::Page::Page
Page()
constructor
Definition: StarObjectModel.cxx:168
StarObjectModelInternal::LayerSet::operator<<
friend std::ostream & operator<<(std::ostream &o, LayerSet const &layer)
operator<<
Definition: StarObjectModel.cxx:113
StarObjectModel::operator<<
friend std::ostream & operator<<(std::ostream &o, StarObjectModel const &model)
small operator<< to print the content of the model
Definition: StarObjectModel.cxx:351
StarZone::getHeaderVersion
int getHeaderVersion() const
returns the StarOffice header version (if set)
Definition: StarZone.hxx:94