Update ooo320-m1
[ooovba.git] / writerfilter / source / doctok / WW8PieceTable.hxx
blob59b5612767d1573bac9424087fd58b62bc558c7b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WW8PieceTable.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_WW8_PIECE_TABLE_HXX
32 #define INCLUDED_WW8_PIECE_TABLE_HXX
34 #include <sal/types.h>
35 #include <doctok/WW8Document.hxx>
37 #include <boost/shared_ptr.hpp>
38 #include <iostream>
40 namespace writerfilter {
41 namespace doctok {
43 using namespace ::std;
45 struct Cp;
46 struct Fc;
47 class CpAndFc;
49 /**
50 The piece table of a Word document.
52 The piece table associates character positions (CP) and File
53 character positions (FC). In a FC based view the piece table
54 defines intervals of FCs that contain consecutive text.
56 CPs and FCs can be complex, i.e. the associated text is stored in
57 bytes. Otherwise the text encoding is UTF-16.
59 class WW8PieceTable
61 public:
62 virtual ~WW8PieceTable() {}
63 /**
64 Shared pointer to piece table
66 typedef boost::shared_ptr<WW8PieceTable> Pointer_t;
68 /**
69 Convert CP to FC.
71 @param aCpIn CP to convert
73 @return FC associated with CP
75 virtual Fc cp2fc(const Cp & aCpIn) const = 0;
77 /**
78 Convert FC to CP.
80 @param aFcIn FC to convert
82 @return CP associated with FC
84 virtual Cp fc2cp(const Fc & aFcIn) const = 0;
86 /**
87 Check if CP is complex.
89 @param aCp CP to check
90 @retval true CP is complex
91 @retval false else
93 virtual bool isComplex(const Cp & aCp) const = 0;
95 /**
96 Check if FC is complex.
98 @param aFc FC to check
99 @retval true FC is complex
100 @retval false else
102 virtual bool isComplex(const Fc & aFc) const = 0;
105 Return number of entries.
107 virtual sal_uInt32 getCount() const = 0;
110 Return first CP.
112 virtual Cp getFirstCp() const = 0;
115 Return first FC.
117 virtual Fc getFirstFc() const = 0;
120 Return last CP.
122 virtual Cp getLastCp() const = 0;
124 /**
125 Return last FC.
127 virtual Fc getLastFc() const = 0;
130 Return CP at index.
132 @param nIndex index of CP to return
134 virtual Cp getCp(sal_uInt32 nIndex) const = 0;
137 Return FC at index.
139 @param nIndex index of FC to return
141 virtual Fc getFc(sal_uInt32 nIndex) const = 0;
143 /**
144 Create CpAndFc from Cp.
146 @param rCp the Cp
148 @return CpAndFc containing rCp and corresponding Fc
150 virtual CpAndFc createCpAndFc(const Cp & rCp, PropertyType eType) const = 0;
152 /**
153 Create CpAndFc from Fc.
155 @param rFc the Fc
157 @return CpAndFc containing rFc and corresponding Cp
159 virtual CpAndFc createCpAndFc(const Fc & rFc, PropertyType eType) const = 0;
162 Dump piece table.
164 @param o stream to dump to
166 virtual void dump(ostream & o) const = 0;
170 Dump piece table.
172 @param o stream to dump to
173 @param rPieceTable piece table to dump
175 ostream & operator << (ostream & o, const WW8PieceTable & rPieceTable);
178 #endif // INCLUDED_WW8_PIECE_TABLE_HXX