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_BIN_TABLE_IMPL_HXX
21 : #define INCLUDED_WW8_BIN_TABLE_IMPL_HXX
22 :
23 : #include <istream>
24 : #include <WW8BinTable.hxx>
25 : #include <PLCF.hxx>
26 :
27 : #include <boost/unordered_map.hpp>
28 :
29 : namespace writerfilter {
30 : namespace doctok
31 : {
32 : using namespace ::std;
33 :
34 : /**
35 : A number of a FKP.
36 : */
37 : class PageNumber
38 : {
39 : /// the page number
40 : sal_uInt32 mnPageNumber;
41 :
42 : public:
43 : /// Pointer to a page number
44 : typedef boost::shared_ptr<PageNumber> Pointer_t;
45 :
46 : /// get size of a page number
47 0 : static size_t getSize() { return 4; }
48 :
49 0 : PageNumber(WW8StructBase::Sequence & rSeq, sal_uInt32 nOffset,
50 : sal_uInt32 /*nCount*/)
51 0 : : mnPageNumber(getU32(rSeq, nOffset))
52 : {
53 0 : }
54 :
55 0 : virtual ~PageNumber()
56 0 : {
57 0 : }
58 :
59 : /// Return the page number
60 0 : sal_uInt32 get() const { return mnPageNumber; }
61 :
62 : virtual void dump(OutputWithDepth<string> & out) const;
63 : };
64 :
65 : /**
66 : Implementation class for a binary table
67 : */
68 0 : class WW8BinTableImpl : public WW8BinTable
69 : {
70 : /// PLCF containing the numbers of the FKPs of the binary table
71 : PLCF<PageNumber> mData;
72 : mutable boost::unordered_map<Fc, sal_uInt32, FcHash> mPageMap;
73 :
74 : public:
75 0 : WW8BinTableImpl(WW8Stream & rStream, sal_uInt32 nOffset,
76 : sal_uInt32 nCount)
77 0 : : mData(rStream, nOffset, nCount)
78 :
79 : {
80 0 : }
81 :
82 0 : virtual sal_uInt32 getEntryCount() const
83 0 : { return mData.getEntryCount(); }
84 0 : virtual Fc getFc(sal_uInt32 nIndex) const
85 0 : { return mData.getFc(nIndex); }
86 0 : virtual sal_uInt32 getPageNumber(sal_uInt32 nIndex) const
87 0 : { return mData.getEntry(nIndex)->get(); }
88 : virtual sal_uInt32 getPageNumber(const Fc & rFc) const;
89 : virtual string toString() const;
90 : };
91 :
92 : }}
93 :
94 : #endif // INCLUDED_WW8_BIN_TABLE_IMPL_HXX
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|