Coverage Report

Created: 2026-03-12 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwps/src/lib/WPS8TextStyle.h
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* libwps
3
 * Version: MPL 2.0 / LGPLv2.1+
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * Major Contributor(s):
10
 * Copyright (C) 2006, 2007 Andrew Ziem
11
 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
12
 * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
13
 *
14
 * For minor contributions see the git repository.
15
 *
16
 * Alternatively, the contents of this file may be used under the terms
17
 * of the GNU Lesser General Public License Version 2.1 or later
18
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
19
 * applicable instead of those above.
20
 */
21
22
#ifndef WPS8_TEXTSTYLE_H
23
#define WPS8_TEXTSTYLE_H
24
25
#include <ostream>
26
#include <string>
27
#include <vector>
28
29
#include "libwps_internal.h"
30
31
#include "WPSDebug.h"
32
33
namespace WPS8TextStyleInternal
34
{
35
struct State;
36
}
37
38
class WPS8Text;
39
40
class WPS8TextStyle
41
{
42
  friend class WPS8Text;
43
public:
44
  struct FontData;
45
46
  explicit WPS8TextStyle(WPS8Text &parser);
47
  ~WPS8TextStyle();
48
49
  //! sets the listener
50
  void setListener(WPSContentListenerPtr &listen)
51
5.58k
  {
52
5.58k
    m_listener = listen;
53
5.58k
  }
54
55
  //! finds all entries which correspond to the styles, parses them and stores data
56
  bool readStructures();
57
58
protected:
59
  //! reads the font names
60
  bool readFontNames(WPSEntry const &entry);
61
  //! reads a font properties
62
  bool readFont(long endPos, int &id, std::string &mess);
63
64
  void sendFont(int fId, FontData &data);
65
66
  //! the paragraph
67
  bool readParagraph(long endPos, int &id, std::string &mess);
68
69
  void sendParagraph(int pId);
70
71
  /** \brief reads a style sheet zone
72
    \warning the read data are NOT used*/
73
  bool readSTSH(WPSEntry const &entry);
74
75
  /** \brief parses a SGP zone: style general property ?*/
76
  bool readSGP(WPSEntry const &entry);
77
78
  //----------------------------------------
79
  // FDP parsing
80
  //----------------------------------------
81
82
  /** finds the FDPC/FDPP structure using the BTEC/BTEP entries
83
    which == 0 means FDPP, 1 means FDPC */
84
  bool findFDPStructures(int which, std::vector<WPSEntry> &result);
85
  /** finds the FDPC/FDPP structure by searching after the text zone
86
    which == 0 means FDPP, 1 means FDPC */
87
  bool findFDPStructuresByHand(int which, std::vector<WPSEntry> &result);
88
89
protected:
90
  //! a DebugFile used to write what we recognize when we parse the document
91
  libwps::DebugFile &ascii()
92
21.2k
  {
93
21.2k
    return m_asciiFile;
94
21.2k
  }
95
96
private:
97
  //! private copy constructor: forbidden
98
  WPS8TextStyle(WPS8TextStyle const &orig) = delete;
99
  //! private copy operator: forbidden
100
  WPS8TextStyle &operator=(WPS8TextStyle const &orig) = delete;
101
102
protected:
103
  //! the main parser
104
  WPS8Text &m_mainParser;
105
  //! the main input
106
  RVNGInputStreamPtr m_input;
107
  //! the listener
108
  WPSContentListenerPtr m_listener;
109
  //! the internal state
110
  mutable std::shared_ptr<WPS8TextStyleInternal::State> m_state;
111
  //! the ascii file
112
  libwps::DebugFile &m_asciiFile;
113
public:
114
  struct FontData
115
  {
116
    FontData()
117
215k
      : m_type(T_None)
118
215k
      , m_fieldType(F_None)
119
215k
      , m_fieldFormat(0) {}
120
    //! operator <<
121
    friend std::ostream &operator<<(std::ostream &o, FontData const &fData);
122
    //! returns a format to used with strftime
123
    std::string format() const;
124
125
    enum { T_None=0, T_Object=2, T_Footnote=3, T_Endnote=4, T_Field=5, T_Comment=6 };
126
    /** the main type: footnote, ... */
127
    int m_type;
128
    enum { F_None=0, F_PageNumber=-1, F_Date=-4, F_Time=-5 };
129
    /** the field type: pagenumber, data, time, ... */
130
    int m_fieldType;
131
    /** the field format */
132
    int m_fieldFormat;
133
  };
134
protected:
135
};
136
137
138
#endif /* WPS8_TEXT_H */
139
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */