Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
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 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef INCLUDED_WW8_PIECE_TABLE_HXX
21 : : #define INCLUDED_WW8_PIECE_TABLE_HXX
22 : :
23 : : #include <sal/types.h>
24 : : #include <doctok/WW8Document.hxx>
25 : :
26 : : #include <boost/shared_ptr.hpp>
27 : : #include <iostream>
28 : :
29 : : namespace writerfilter {
30 : : namespace doctok {
31 : :
32 : : using namespace ::std;
33 : :
34 : : struct Cp;
35 : : struct Fc;
36 : : class CpAndFc;
37 : :
38 : : /**
39 : : The piece table of a Word document.
40 : :
41 : : The piece table associates character positions (CP) and File
42 : : character positions (FC). In a FC based view the piece table
43 : : defines intervals of FCs that contain consecutive text.
44 : :
45 : : CPs and FCs can be complex, i.e. the associated text is stored in
46 : : bytes. Otherwise the text encoding is UTF-16.
47 : : */
48 : 0 : class WW8PieceTable
49 : : {
50 : : public:
51 [ # # ]: 0 : virtual ~WW8PieceTable() {}
52 : : /**
53 : : Shared pointer to piece table
54 : : */
55 : : typedef boost::shared_ptr<WW8PieceTable> Pointer_t;
56 : :
57 : : /**
58 : : Convert CP to FC.
59 : :
60 : : @param aCpIn CP to convert
61 : :
62 : : @return FC associated with CP
63 : : */
64 : : virtual Fc cp2fc(const Cp & aCpIn) const = 0;
65 : :
66 : : /**
67 : : Convert FC to CP.
68 : :
69 : : @param aFcIn FC to convert
70 : :
71 : : @return CP associated with FC
72 : : */
73 : : virtual Cp fc2cp(const Fc & aFcIn) const = 0;
74 : :
75 : : /**
76 : : Check if CP is complex.
77 : :
78 : : @param aCp CP to check
79 : : @retval true CP is complex
80 : : @retval false else
81 : : */
82 : : virtual bool isComplex(const Cp & aCp) const = 0;
83 : :
84 : : /**
85 : : Check if FC is complex.
86 : :
87 : : @param aFc FC to check
88 : : @retval true FC is complex
89 : : @retval false else
90 : : */
91 : : virtual bool isComplex(const Fc & aFc) const = 0;
92 : :
93 : : /**
94 : : Return number of entries.
95 : : */
96 : : virtual sal_uInt32 getCount() const = 0;
97 : :
98 : : /**
99 : : Return first CP.
100 : : */
101 : : virtual Cp getFirstCp() const = 0;
102 : :
103 : : /**
104 : : Return first FC.
105 : : */
106 : : virtual Fc getFirstFc() const = 0;
107 : :
108 : : /**
109 : : Return last CP.
110 : : */
111 : : virtual Cp getLastCp() const = 0;
112 : :
113 : : /**
114 : : Return last FC.
115 : : */
116 : : virtual Fc getLastFc() const = 0;
117 : :
118 : : /**
119 : : Return CP at index.
120 : :
121 : : @param nIndex index of CP to return
122 : : */
123 : : virtual Cp getCp(sal_uInt32 nIndex) const = 0;
124 : :
125 : : /**
126 : : Return FC at index.
127 : :
128 : : @param nIndex index of FC to return
129 : : */
130 : : virtual Fc getFc(sal_uInt32 nIndex) const = 0;
131 : :
132 : : /**
133 : : Create CpAndFc from Cp.
134 : :
135 : : @param rCp the Cp
136 : :
137 : : @return CpAndFc containing rCp and corresponding Fc
138 : : */
139 : : virtual CpAndFc createCpAndFc(const Cp & rCp, PropertyType eType) const = 0;
140 : :
141 : : /**
142 : : Create CpAndFc from Fc.
143 : :
144 : : @param rFc the Fc
145 : :
146 : : @return CpAndFc containing rFc and corresponding Cp
147 : : */
148 : : virtual CpAndFc createCpAndFc(const Fc & rFc, PropertyType eType) const = 0;
149 : :
150 : : /**
151 : : Dump piece table.
152 : :
153 : : @param o stream to dump to
154 : : */
155 : : virtual void dump(ostream & o) const = 0;
156 : : };
157 : :
158 : : /**
159 : : Dump piece table.
160 : :
161 : : @param o stream to dump to
162 : : @param rPieceTable piece table to dump
163 : : */
164 : : ostream & operator << (ostream & o, const WW8PieceTable & rPieceTable);
165 : : }}
166 : :
167 : : #endif // INCLUDED_WW8_PIECE_TABLE_HXX
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|