Coverage Report

Created: 2026-07-20 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libstaroffice/src/lib/StarItem.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 store some StarOffice items
36
 *
37
 */
38
#ifndef STAR_ITEM_HXX
39
#  define STAR_ITEM_HXX
40
41
#include <map>
42
#include <vector>
43
44
#include <libstaroffice/STOFFDocument.hxx>
45
46
#include "STOFFDebug.hxx"
47
48
class StarAttribute;
49
50
/** \brief class to store an item: ie. an attribute whose reading is
51
    potentially retarded
52
 */
53
class StarItem
54
{
55
public:
56
  //! constructor
57
  explicit StarItem(int which)
58
4.28M
    : m_attribute()
59
4.28M
    , m_which(which)
60
4.28M
    , m_surrogateId(0)
61
4.28M
    , m_localId(false)
62
4.28M
  {
63
4.28M
  }
64
  //! constructor from attribute
65
  StarItem(std::shared_ptr<StarAttribute> attribute, int which)
66
7.52M
    : m_attribute(attribute)
67
7.52M
    , m_which(which)
68
7.52M
    , m_surrogateId(0)
69
7.52M
    , m_localId(false)
70
7.52M
  {
71
7.52M
  }
72
  /** the attribute if loaded */
73
  std::shared_ptr<StarAttribute> m_attribute;
74
  //! the which id
75
  int m_which;
76
  //! the surrogate id
77
  int m_surrogateId;
78
  //! true if which is local
79
  bool m_localId;
80
private:
81
  StarItem(StarItem const &);
82
  StarItem &operator=(StarItem const &);
83
};
84
85
/** \brief class to store a list of item
86
 */
87
class StarItemSet
88
{
89
public:
90
  //! constructor
91
  StarItemSet()
92
3.98M
    : m_style("")
93
3.98M
    , m_family(0)
94
3.98M
    , m_whichToItemMap()
95
3.98M
  {
96
3.98M
  }
97
  //! return true if the set is empty
98
  bool empty() const
99
0
  {
100
0
    return m_whichToItemMap.empty();
101
0
  }
102
  //! try to add a item
103
  bool add(std::shared_ptr<StarItem> item);
104
  //! debug function to print the child field
105
  std::string printChild() const;
106
  //! item set name
107
  librevenge::RVNGString m_style;
108
  //! the family
109
  int m_family;
110
  //! the list of item
111
  std::map<int, std::shared_ptr<StarItem> > m_whichToItemMap;
112
};
113
114
//! brief class used to stored the style
115
class StarItemStyle
116
{
117
public:
118
  //! the different family style
119
  enum FamilyStyle {
120
    F_Char=1, F_Paragraph=2, F_Frame=4, F_Page=8, F_Pseudo=0x10, F_ALL=0xFE
121
  };
122
  //! constructor
123
  StarItemStyle()
124
364k
    : m_family(0)
125
364k
    , m_mask(0)
126
364k
    , m_itemSet()
127
364k
    , m_helpId(0)
128
364k
    , m_outlineLevel(-1)
129
364k
  {
130
364k
  }
131
  //! operator<<
132
  friend std::ostream &operator<<(std::ostream &o, StarItemStyle const &style);
133
  //! the name, the parent name, the follow name, the help names
134
  librevenge::RVNGString m_names[4];
135
  //! the family
136
  int m_family;
137
  //! the mask
138
  int m_mask;
139
  //! the item list
140
  StarItemSet m_itemSet;
141
  //! the help id
142
  unsigned m_helpId;
143
  //! the outline level
144
  int m_outlineLevel;
145
};
146
147
#endif
148
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: