merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / source / doctok / WW8FKPImpl.hxx
blob51a27e036ee0b2124e24aab53a5e33a2ec20fbb1
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: WW8FKPImpl.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_FKP_IMPL_HXX
32 #define INCLUDED_WW8_FKP_IMPL_HXX
34 #include <set>
35 #include <deque>
36 #include <WW8FKP.hxx>
38 #ifndef INCLUDED_OUTPUT_WITH_DEPTH_HXX
39 #include <resourcemodel/OutputWithDepth.hxx>
40 #endif
42 namespace writerfilter {
43 namespace doctok
45 /**
46 Implementation class for formatted disk pages.
48 class WW8FKPImpl : public WW8FKP
50 sal_uInt32 mnPageNumber;
51 bool mbComplex;
53 public:
54 WW8FKPImpl(WW8Stream & rStream, sal_uInt32 nPageNumber, bool bComplex)
55 : WW8FKP(rStream, nPageNumber * 512), mnPageNumber(nPageNumber),
56 mbComplex(bComplex)
60 virtual sal_uInt32 getPageNumber() const { return mnPageNumber; }
62 virtual sal_uInt32 getEntryCount() const { return getU8(511); }
63 virtual sal_uInt32 getRgb() const { return 4 * (getEntryCount() + 1); }
64 virtual Fc getFc(sal_uInt32 nIndex) const
65 { return Fc(getU32(nIndex * 4), mbComplex); }
66 virtual Fc getFirstFc() const { return getFc(0); }
67 virtual Fc getLastFc() const { return getFc(getEntryCount()); }
69 virtual bool contains(const Fc & rFc) const
70 { return getFirstFc() <= rFc && rFc < getLastFc(); }
72 virtual sal_uInt32 getIndex(const Fc & rFc) const;
74 friend bool operator < (const WW8FKPImpl & rA,
75 const WW8FKPImpl & rB);
78 /**
79 Implementation class for formatted disk pages containing character
80 properties.
82 class WW8CHPFKPImpl : public WW8FKPImpl
84 public:
85 WW8CHPFKPImpl(WW8Stream & rStream, sal_uInt32 nPageNumber,
86 bool bComplex)
87 : WW8FKPImpl(rStream, nPageNumber, bComplex)
91 virtual writerfilter::Reference<Properties>::Pointer_t
92 getProperties(const Fc & rFc) const;
94 virtual void dump(OutputWithDepth<string> & o) const;
97 /**
98 Implementation class for formatted disk pages containing paragraph
99 properties.
101 class WW8PAPFKPImpl : public WW8FKPImpl
103 public:
104 WW8PAPFKPImpl(WW8Stream & rStream, sal_uInt32 nPageNumber,
105 bool bComplex)
106 : WW8FKPImpl(rStream, nPageNumber, bComplex)
110 virtual writerfilter::Reference<Properties>::Pointer_t
111 getProperties(const Fc & rFc) const;
113 virtual void dump(OutputWithDepth<string> & o) const;
117 Tuple of page number and formattet disk page.
119 class PageNumberAndFKP
121 /// page number
122 sal_uInt32 mnPageNumber;
124 /// pointer to formatted disk page
125 WW8FKP::Pointer_t mpFKP;
127 public:
128 PageNumberAndFKP(sal_uInt32 nPageNumber, WW8FKP::Pointer_t pFKP)
129 : mnPageNumber(nPageNumber), mpFKP(pFKP)
134 Return page number.
136 sal_uInt32 getPageNumber() const { return mnPageNumber; }
139 Return formatted disk page.
141 const WW8FKP::Pointer_t getFKP() const { return mpFKP; }
143 friend bool operator < (const PageNumberAndFKP & rA,
144 const PageNumberAndFKP & rB);
148 Cache for formatted disk pages.
150 class WW8FKPCacheImpl : public WW8FKPCache
152 /// size of the cache
153 sal_uInt32 mnCacheSize;
155 /// set of tuples of page number and FKP
156 typedef set<PageNumberAndFKP> PageNumbersAndFKPs;
158 ///
159 typedef deque<sal_uInt32> PageNumbers;
161 PageNumbers mPageNumbers;
162 PageNumbersAndFKPs mPageNumbersAndFKPs;
164 protected:
165 WW8Stream::Pointer_t mpStream;
166 virtual WW8FKP::Pointer_t createFKP(sal_uInt32 nPageNumber,
167 bool bComplex) = 0;
169 public:
170 WW8FKPCacheImpl(WW8Stream::Pointer_t rpStream, sal_uInt32 nCacheSize)
171 : mnCacheSize(nCacheSize), mpStream(rpStream)
175 virtual ~WW8FKPCacheImpl()
179 WW8FKP::Pointer_t get(sal_uInt32 nPageNumber, bool bComplex);
182 class WW8CHPFKPCacheImpl : public WW8FKPCacheImpl
184 virtual WW8FKP::Pointer_t createFKP(sal_uInt32 nPageNumber,
185 bool bComplex);
187 public:
188 WW8CHPFKPCacheImpl(WW8Stream::Pointer_t rpStream,
189 sal_uInt32 nCacheSize)
190 : WW8FKPCacheImpl(rpStream, nCacheSize)
194 virtual ~WW8CHPFKPCacheImpl()
199 class WW8PAPFKPCacheImpl : public WW8FKPCacheImpl
201 virtual WW8FKP::Pointer_t createFKP(sal_uInt32 nPageNumber,
202 bool bComplex);
204 public:
205 WW8PAPFKPCacheImpl(WW8Stream::Pointer_t rpStream,
206 sal_uInt32 nCacheSize)
207 : WW8FKPCacheImpl(rpStream, nCacheSize)
211 virtual ~WW8PAPFKPCacheImpl()
217 #endif // INCLUDED_WW8_FKP_IMPL_HXX