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) 2002 William Lachance (wrlach@gmail.com)
11  * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
12  * Copyright (C) 2004 Fridrich Strba (fridrich.strba@bluewin.ch)
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  * For further information visit http://libwpd.sourceforge.net
22  */
23 
24 /* "This product is not manufactured, approved, or supported by
25  * Corel Corporation or Corel Corporation Limited."
26  */
27 
28 #include "WP3SingleByteFunction.h"
29 #include "libwpd_internal.h"
30 #include "WP3Listener.h"
31 
constructSingleByteFunction(librevenge::RVNGInputStream *,WPXEncryption *,unsigned char groupID)32 WP3SingleByteFunction *WP3SingleByteFunction::constructSingleByteFunction(librevenge::RVNGInputStream * /* input */, WPXEncryption * /* encryption */, unsigned char groupID)
33 {
34 
35 	switch (groupID)
36 	{
37 	case 0x80: // condensed hard return
38 		return new WP3EOLFunction();
39 
40 	case 0x81: // condensed hard page
41 		return new WP3EOPFunction();
42 
43 	case 0x82: // condensed tab
44 		return new WP3CondensedTabFunction();
45 
46 	case 0x83: // condensed back-tab
47 		return new WP3CondensedBackTabFunction();
48 
49 	case 0x84: // condensed indent
50 		return new WP3CondensedIndentFunction();
51 
52 	case 0x85: // condensed left-right indent
53 		return new WP3CondensedLRIndentFunction();
54 
55 	case 0x96: // hard hyphen in line
56 		return new WP3HyphenFunction();
57 
58 	case 0x97: // soft hyphen in line
59 		return new WP3SoftHyphenFunction();
60 
61 	case 0xa0: // hard space
62 		return new WP3HardSpaceFunction();
63 
64 	default:
65 		// should not happen
66 		return nullptr;
67 	}
68 }
69 
parse(WP3Listener * listener)70 void WP3HardSpaceFunction::parse(WP3Listener *listener)
71 {
72 	listener->insertCharacter((unsigned) 0xa0);
73 }
74 
parse(WP3Listener * listener)75 void WP3HyphenFunction::parse(WP3Listener *listener)
76 {
77 	listener->insertCharacter((unsigned) '-');
78 }
79 
parse(WP3Listener * listener)80 void WP3SoftHyphenFunction::parse(WP3Listener *listener)
81 {
82 	listener->insertCharacter((unsigned) 0xad);
83 }
84 
parse(WP3Listener * listener)85 void WP3EOLFunction::parse(WP3Listener *listener)
86 {
87 	listener->insertEOL();
88 }
89 
parse(WP3Listener * listener)90 void WP3EOPFunction::parse(WP3Listener *listener)
91 {
92 	listener->insertBreak(WPX_PAGE_BREAK);
93 }
94 
parse(WP3Listener * listener)95 void WP3CondensedTabFunction::parse(WP3Listener *listener)
96 {
97 	listener->insertTab();
98 }
99 
parse(WP3Listener * listener)100 void WP3CondensedBackTabFunction::parse(WP3Listener *listener)
101 {
102 	listener->backTab();
103 }
104 
parse(WP3Listener * listener)105 void WP3CondensedIndentFunction::parse(WP3Listener *listener)
106 {
107 	listener->leftIndent();
108 }
109 
parse(WP3Listener * listener)110 void WP3CondensedLRIndentFunction::parse(WP3Listener *listener)
111 {
112 	listener->leftRightIndent();
113 }
114 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
115