Coverage Report

Created: 2026-07-20 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libstaroffice/src/lib/StarItemPool.hxx
Line
Count
Source
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
 * StarPool to read/parse some StarOffice pools
36
 *
37
 */
38
#ifndef STAR_ITEM_POOL_HXX
39
#  define STAR_ITEM_POOL_HXX
40
41
#include <map>
42
#include <set>
43
#include <vector>
44
45
#include <libstaroffice/STOFFDocument.hxx>
46
47
#include "STOFFDebug.hxx"
48
#include "STOFFEntry.hxx"
49
#include "STOFFInputStream.hxx"
50
51
class StarAttribute;
52
class StarItem;
53
class StarItemSet;
54
class StarItemStyle;
55
56
namespace StarItemPoolInternal
57
{
58
struct State;
59
}
60
61
class StarAttribute;
62
class StarObject;
63
class StarZone;
64
65
/** \brief the main class to read/.. some basic StarOffice SfxItemItemPool itemPools
66
 *
67
 *
68
 *
69
 */
70
class StarItemPool
71
{
72
public:
73
  friend struct StarItemPoolInternal::State;
74
  //! the known item pool
75
  enum Type { T_ChartPool, T_EditEnginePool, T_SpreadsheetPool, T_VCControlPool, T_WriterPool, T_XOutdevPool, T_Unknown };
76
  //! constructor
77
  StarItemPool(StarObject &document, Type type);
78
  //! destructor
79
  virtual ~StarItemPool();
80
81
  //! clean the pool's list of attributes, ...
82
  void clean();
83
  //! add a secondary pool
84
  void addSecondaryPool(std::shared_ptr<StarItemPool> secondary);
85
  //! returns true if a pool is a secondary pool
86
  bool isSecondaryPool() const;
87
  //! try to read a "ItemPool" zone
88
  bool read(StarZone &zone);
89
  //! returns the pool version
90
  int getVersion() const;
91
  //! returns the pool type
92
  Type getType() const;
93
  //! returns true if we are reading the pool
94
  bool isInside() const
95
1.42M
  {
96
1.42M
    return m_isInside;
97
1.42M
  }
98
  //! try to read the styles, ie a "StyleItemPool" zone
99
  bool readStyles(StarZone &zone, StarObject &doc);
100
  /** try to update the style
101
102
   \note must be called after all styles have been updated */
103
  void updateStyles();
104
  /** update a itemset by adding attribute corresponding to its styles*/
105
  void updateUsingStyles(StarItemSet &itemSet) const;
106
  /** define a graphic style */
107
  void defineGraphicStyle(STOFFListenerPtr &listener, librevenge::RVNGString const &styleName, StarObject &object) const
108
12.5k
  {
109
12.5k
    std::set<librevenge::RVNGString> done;
110
12.5k
    defineGraphicStyle(listener, styleName, object, done);
111
12.5k
  }
112
  /** define a paragraph style */
113
  void defineParagraphStyle(STOFFListenerPtr &listener, librevenge::RVNGString const &styleName, StarObject &object) const
114
0
  {
115
0
    std::set<librevenge::RVNGString> done;
116
0
    defineParagraphStyle(listener, styleName, object, done);
117
0
  }
118
  /** try to find a style with a name and a family style */
119
  StarItemStyle const *findStyleWithFamily(librevenge::RVNGString const &style, int family) const;
120
  //! try to read an attribute
121
  std::shared_ptr<StarAttribute> readAttribute(StarZone &zone, int which, int vers, long endPos);
122
  //! read a item
123
  std::shared_ptr<StarItem> readItem(StarZone &zone, bool isDirect, long endPos);
124
  //! try to load a surrogate
125
  std::shared_ptr<StarItem> loadSurrogate(StarZone &zone, uint16_t &nWhich, bool localId, libstoff::DebugStream &f);
126
  //! try to load a surrogate
127
  bool loadSurrogate(StarItem &item);
128
  //! set the item pool relative unit (if this is different to the default one)
129
  void setRelativeUnit(double relUnit);
130
  //! returns the set relative unit if this is set, or the default unit corresponding to this pool
131
  double getRelativeUnit() const;
132
protected:
133
  /** define a graphic style */
134
  void defineGraphicStyle(STOFFListenerPtr listener, librevenge::RVNGString const &styleName, StarObject &object, std::set<librevenge::RVNGString> &done) const;
135
  /** define a paragraph style */
136
  void defineParagraphStyle(STOFFListenerPtr listener, librevenge::RVNGString const &styleName, StarObject &object, std::set<librevenge::RVNGString> &done) const;
137
  //! try to read a "ItemPool" zone (version 1)
138
  bool readV1(StarZone &zone, StarItemPool *master);
139
  //! try to read a "ItemPool" zone (version 2)
140
  bool readV2(StarZone &zone, StarItemPool *master);
141
142
  //! create an item for futher reading
143
  std::shared_ptr<StarItem> createItem(int which, int surrogateId, bool localId);
144
145
  //
146
  // data
147
  //
148
private:
149
  //! true if the pool is open
150
  bool m_isInside;
151
  //! the state
152
  std::shared_ptr<StarItemPoolInternal::State> m_state;
153
};
154
#endif
155
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: