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 #include <com/sun/star/io/XSeekable.hpp>
25 #include <WW8Clx.hxx>
26 #include <resources.hxx>
27 
28 namespace writerfilter {
29 namespace doctok
30 {
WW8Clx(WW8Stream & rStream,sal_uInt32 nOffset,sal_uInt32 nCount)31 WW8Clx::WW8Clx(WW8Stream & rStream,
32                sal_uInt32 nOffset, sal_uInt32 nCount)
33 : WW8StructBase(rStream, nOffset, nCount), nOffsetPieceTable(0)
34 {
35     while (getU8(nOffsetPieceTable) != 2)
36     {
37         nOffsetPieceTable += getU16(nOffsetPieceTable + 1) + 3;
38     }
39 }
40 
getPieceCount() const41 sal_uInt32 WW8Clx::getPieceCount() const
42 {
43     return (getU32(nOffsetPieceTable + 1) - 4) / 12;
44 }
45 
getCp(sal_uInt32 nIndex) const46 sal_uInt32 WW8Clx::getCp(sal_uInt32 nIndex) const
47 {
48     return getU32(nOffsetPieceTable + 5 + nIndex * 4);
49 }
50 
getFc(sal_uInt32 nIndex) const51 sal_uInt32 WW8Clx::getFc(sal_uInt32 nIndex) const
52 {
53     sal_uInt32 nResult = getU32(nOffsetPieceTable + 5 +
54                                 (getPieceCount() + 1) * 4 +
55                                 nIndex * 8 + 2);
56 
57     if (nResult & 0x40000000)
58         nResult = (nResult & ~0x40000000) / 2;
59 
60     return nResult;
61 }
62 
isComplexFc(sal_uInt32 nIndex) const63 sal_Bool WW8Clx::isComplexFc(sal_uInt32 nIndex) const
64 {
65     sal_Bool bResult = sal_False;
66     sal_uInt32 nTmp = getU32(nOffsetPieceTable + 5 +
67                              (getPieceCount() + 1) * 4 +
68                              nIndex * 8 + 2);
69     if (nTmp & 0x40000000)
70         bResult = sal_True;
71 
72     return bResult;
73 }
74 
dump(OutputWithDepth<string> & o) const75 void WW8Clx::dump(OutputWithDepth<string> & o) const
76 {
77     WW8StructBase::dump(o);
78 }
79 
80 }}
81