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_STTBF_HXX
25 #define INCLUDED_WW8_STTBF_HXX
26 
27 #include <WW8StructBase.hxx>
28 #include <WW8ResourceModelImpl.hxx>
29 
30 #include <boost/shared_ptr.hpp>
31 #include <vector>
32 
33 namespace writerfilter {
34 namespace doctok
35 {
36 
37 using namespace ::std;
38 
39 /**
40    A string table in file.
41 
42    The string table contains strings that each can have extra data.
43  */
44 class WW8Sttbf : public WW8StructBase
45 {
46     /// true if strings contain two-byte characters
47     bool mbComplex;
48 
49     /// the number of entries
50     sal_uInt32 mnCount;
51 
52     /// the size of the extra data (per string)
53     sal_uInt32 mnExtraDataCount;
54 
55     /// offsets for the strings
56     vector<sal_uInt32> mEntryOffsets;
57 
58     /// offsets for the extra data
59     vector<sal_uInt32> mExtraOffsets;
60 
61     /**
62        Return offset of an entry.
63 
64        @param nPos    the index of the entry
65     */
66     sal_uInt32 getEntryOffset(sal_uInt32 nPos) const;
67 
68     /**
69        Return offset of extra data of an entry.
70 
71        @param nPos    the index of the entry
72      */
73     sal_uInt32 getExtraOffset(sal_uInt32 nPos) const;
74 
75 public:
76     typedef boost::shared_ptr<WW8Sttbf> Pointer_t;
77 
78     WW8Sttbf(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount);
79 
80     /**
81        Return the number of entries.
82     */
83     sal_uInt32 getEntryCount() const;
84 
85     /**
86        Return the string of an entry.
87 
88        @param nPos     the index of the entry
89      */
90     rtl::OUString getEntry(sal_uInt32 nPos) const;
91 
92     /**
93        Return the extra data of an entry.
94 
95        @param nPos     the index of the entry
96     */
97     WW8StructBase::Pointer_t getExtraData(sal_uInt32 nPos);
98 };
99 
100 class WW8SttbTableResource : public ::writerfilter::Reference<Table>
101 {
102     WW8Sttbf::Pointer_t mpSttbf;
103 
104 public:
105     WW8SttbTableResource(WW8Sttbf::Pointer_t pSttbf);
106     virtual ~WW8SttbTableResource();
107 
108     void resolve(Table & rTable);
109 
110     string getType() const;
111 };
112 
113 class WW8StringProperty : public ::writerfilter::Reference<Properties>
114 {
115     sal_uInt32 mnId;
116     WW8StringValue::Pointer_t mpValue;
117 
118 public:
119     WW8StringProperty(sal_uInt32 nId, WW8StringValue::Pointer_t pValue);
120     virtual ~WW8StringProperty();
121 
122     void resolve(Properties & rProperties);
123 
124     string getType() const;
125 };
126 
127 }}
128 #endif // INCLUDED_WW8_STTBF
129