1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_WW8_FKP_HXX
25 #define INCLUDED_WW8_FKP_HXX
26 
27 #ifndef INCLUDES_WW8_CP_AND_FC_HXX
28 #include <WW8CpAndFc.hxx>
29 #endif
30 #ifndef INCLUDE_WW8_STRUCT_BASE_HXX
31 #include <WW8StructBase.hxx>
32 #endif
33 
34 namespace writerfilter {
35 namespace doctok
36 {
37 
38 /**
39    A formated diskpage (FKP).
40 
41    Formatted diskpages are used by Word to store runs of SPRMs (single
42    property modifier). A FKP contains a list of file character
43    positions (FC). For each FC there is an entry containing the run of
44    SPRMs stored for that FC.
45  */
46 class WW8FKP : public WW8StructBase
47 {
48 public:
49     /**
50        Shared pointer to an FKP.
51      */
52     typedef boost::shared_ptr<WW8FKP> Pointer_t;
53 
54     /**
55        Create FKP from stream.
56 
57        @param rStream    stream to create FKP from
58        @param nOffset    offset in stream where the FKP starts.
59      */
WW8FKP(WW8Stream & rStream,sal_uInt32 nOffset)60     WW8FKP(WW8Stream & rStream, sal_uInt32 nOffset)
61     : WW8StructBase(rStream, nOffset, 512)
62     {
63     }
64 
65     /**
66        Return count of entries.
67     */
68     virtual sal_uInt32 getEntryCount() const = 0;
69 
70     /**
71        Return an FC.
72 
73        @param nIndex   index of the FC to return
74      */
75     virtual Fc getFc(sal_uInt32 nIndex) const = 0;
76 
77     /**
78        Returns the first FC of the FKP.
79     */
80     virtual Fc getFirstFc() const = 0;
81 
82     /**
83        Returns the last FC of the FKP.
84      */
85     virtual Fc getLastFc() const = 0;
86 
87     /**
88        Check if an FKP contains an FC.
89 
90        @param rFc   FC to look for
91 
92        @retval true    FKP contains FC
93        @retval false   else
94      */
95     virtual bool contains(const Fc & rFc) const = 0;
96 
97     /**
98        Return properties stored in an FKP for a FC.
99 
100        @param rFc   FC to look for
101      */
102     virtual writerfilter::Reference<Properties>::Pointer_t
103     getProperties(const Fc & rFc)
104         const = 0;
105 };
106 
107 /**
108    Cache providing FKPs.
109  */
110 class WW8FKPCache
111 {
112 public:
113     /**
114        Shared pointer to cache.
115      */
116     typedef boost::shared_ptr<WW8FKPCache> Pointer_t;
117 
118     virtual ~WW8FKPCache();
119 
120     /**
121        Return FKP.
122 
123        @param nPageNumber    number of page to return
124      */
125     virtual WW8FKP::Pointer_t get(sal_uInt32 nPageNumber, bool bComplex) = 0;
126 };
127 }}
128 
129 #endif // INCLUDED_WW8_FKP_HXX
130