/src/libwpd/src/lib/WP3FootnoteEndnoteGroup.cpp
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ |
2 | | /* libwpd |
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) 2005 Fridrich Strba (fridrich.strba@bluewin.ch) |
11 | | * |
12 | | * For minor contributions see the git repository. |
13 | | * |
14 | | * Alternatively, the contents of this file may be used under the terms |
15 | | * of the GNU Lesser General Public License Version 2.1 or later |
16 | | * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are |
17 | | * applicable instead of those above. |
18 | | * |
19 | | * For further information visit http://libwpd.sourceforge.net |
20 | | */ |
21 | | |
22 | | /* "This product is not manufactured, approved, or supported by |
23 | | * Corel Corporation or Corel Corporation Limited." |
24 | | */ |
25 | | |
26 | | #include <math.h> |
27 | | #include "WP3FootnoteEndnoteGroup.h" |
28 | | #include "WP3FileStructure.h" |
29 | | #include "WP3Parser.h" |
30 | | |
31 | | WP3FootnoteEndnoteGroup::WP3FootnoteEndnoteGroup(librevenge::RVNGInputStream *input, WPXEncryption *encryption) : |
32 | 7.32k | WP3VariableLengthGroup(), |
33 | 7.32k | m_subDocument() |
34 | 7.32k | { |
35 | 7.32k | _read(input, encryption); |
36 | 7.32k | } |
37 | | |
38 | | WP3FootnoteEndnoteGroup::~WP3FootnoteEndnoteGroup() |
39 | 7.31k | { |
40 | 7.31k | } |
41 | | |
42 | | void WP3FootnoteEndnoteGroup::_readContents(librevenge::RVNGInputStream *input, WPXEncryption *encryption) |
43 | 7.32k | { |
44 | 7.32k | int tmpSizeOfNote = getSize() - 8; |
45 | 7.32k | input->seek(25, librevenge::RVNG_SEEK_CUR); |
46 | 7.32k | tmpSizeOfNote -= 25; |
47 | 7.32k | unsigned tmpNumOfPages = readU16(input, encryption, true); |
48 | 7.32k | tmpSizeOfNote -= 2; |
49 | 7.32k | input->seek(4*tmpNumOfPages, librevenge::RVNG_SEEK_CUR); |
50 | 7.32k | tmpSizeOfNote -= 4*tmpNumOfPages; |
51 | 7.32k | unsigned tmpNumBreakTableEntries = readU16(input, encryption, true); |
52 | 7.32k | tmpSizeOfNote -= 2; |
53 | 7.32k | input->seek(6*tmpNumBreakTableEntries, librevenge::RVNG_SEEK_CUR); |
54 | 7.32k | tmpSizeOfNote -= 6*tmpNumBreakTableEntries; |
55 | | |
56 | | // here we skipped all the useless junk and we are at the beginning of the |
57 | | // actual subdocument. tmpSizeOfNote should give the size in bytes of the |
58 | | // subdocument |
59 | | |
60 | 7.32k | if (tmpSizeOfNote > 0) |
61 | 304 | m_subDocument.reset(new WP3SubDocument(input, encryption, (unsigned)tmpSizeOfNote)); |
62 | 7.32k | } |
63 | | |
64 | | void WP3FootnoteEndnoteGroup::parse(WP3Listener *listener) |
65 | 7.31k | { |
66 | 7.31k | WPD_DEBUG_MSG(("WordPerfect: handling a Footnote/Endnote group\n")); |
67 | 7.31k | switch (getSubGroup()) |
68 | 7.31k | { |
69 | 5.91k | case WP3_FOOTNOTE_ENDNOTE_GROUP_FOOTNOTE_FUNCTION: |
70 | 5.91k | listener->insertNote(FOOTNOTE, m_subDocument.get()); |
71 | 5.91k | break; |
72 | 958 | case WP3_FOOTNOTE_ENDNOTE_GROUP_ENDNOTE_FUNCTION: |
73 | 958 | listener->insertNote(ENDNOTE, m_subDocument.get()); |
74 | 958 | break; |
75 | 438 | default: // something else we don't support, since it isn't in the docs |
76 | 438 | break; |
77 | 7.31k | } |
78 | 7.31k | } |
79 | | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |