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 <resources.hxx>
25 #include <WW8ResourceModelImpl.hxx>
26 
27 namespace writerfilter {
28 namespace doctok {
29 
initPayload()30 void WW8ListTable::initPayload()
31 {
32     sal_uInt32 nCount = getEntryCount();
33 
34     sal_uInt32 nOffset = 2;
35     sal_uInt32 nOffsetLevel = mnPlcfPayloadOffset;
36     for (sal_uInt32 n = 0; n < nCount; ++n)
37     {
38         WW8List aList(this, nOffset);
39 
40         entryOffsets.push_back(nOffset);
41         payloadIndices.push_back(payloadOffsets.size());
42         nOffset += WW8List::getSize();
43 
44         sal_uInt32 nLvlCount = aList.get_fSimpleList() ? 1 : 9;
45 
46         for (sal_uInt32 i = 0; i < nLvlCount; ++i)
47         {
48             WW8ListLevel aLevel(this, nOffsetLevel);
49 
50             payloadOffsets.push_back(nOffsetLevel);
51 
52             nOffsetLevel += aLevel.calcSize();
53         }
54 
55         if (nOffsetLevel > getCount())
56         {
57             nOffsetLevel = getCount();
58 
59             break;
60         }
61     }
62 
63     payloadOffsets.push_back(nOffsetLevel);
64     entryOffsets.push_back(nOffset);
65 }
66 
getEntryCount()67 sal_uInt32 WW8ListTable::getEntryCount()
68 {
69     return getU16(0);
70 }
71 
72 writerfilter::Reference<Properties>::Pointer_t
getEntry(sal_uInt32 nIndex)73 WW8ListTable::getEntry(sal_uInt32 nIndex)
74 {
75     WW8List * pList = new WW8List(this, entryOffsets[nIndex]);
76 
77     pList->setIndex(nIndex);
78 
79     return writerfilter::Reference<Properties>::Pointer_t
80         (pList);
81 }
82 
get_listlevel_count()83 sal_uInt32 WW8List::get_listlevel_count()
84 {
85     if (get_fSimpleList())
86         return 1;
87 
88     return 9;
89 }
90 
91 writerfilter::Reference<Properties>::Pointer_t
get_listlevel(sal_uInt32 nIndex)92 WW8List::get_listlevel(sal_uInt32 nIndex)
93 {
94     WW8ListTable * pListTable = dynamic_cast<WW8ListTable *>(mpParent);
95     sal_uInt32 nPayloadIndex = pListTable->getPayloadIndex(mnIndex) + nIndex;
96     sal_uInt32 nPayloadOffset = pListTable->getPayloadOffset(nPayloadIndex);
97     sal_uInt32 nPayloadSize = pListTable->getPayloadSize(nPayloadIndex);
98 
99     return writerfilter::Reference<Properties>::Pointer_t
100         (new WW8ListLevel(mpParent, nPayloadOffset, nPayloadSize));
101 }
102 
get_xst()103 ::rtl::OUString WW8ListLevel::get_xst()
104 {
105     sal_uInt32 nOffset = WW8ListLevel::getSize();
106 
107     nOffset += get_cbGrpprlPapx();
108     nOffset += get_cbGrpprlChpx();
109 
110     return getString(nOffset);
111 }
112 
resolveNoAuto(Properties & rHandler)113 void WW8ListLevel::resolveNoAuto(Properties & rHandler)
114 {
115     sal_uInt32 nOffset = getSize();
116 
117     {
118         WW8PropertySet::Pointer_t pSet
119             (new WW8PropertySetImpl(*this, nOffset, get_cbGrpprlPapx()));
120 
121         WW8PropertiesReference aRef(pSet);
122         aRef.resolve(rHandler);
123     }
124 
125     nOffset += get_cbGrpprlPapx();
126 
127     {
128         WW8PropertySet::Pointer_t pSet
129             (new WW8PropertySetImpl(*this, nOffset, get_cbGrpprlChpx()));
130 
131         WW8PropertiesReference aRef(pSet);
132         aRef.resolve(rHandler);
133     }
134 }
135 
calcSize()136 sal_uInt32 WW8ListLevel::calcSize()
137 {
138     sal_uInt32 nResult = WW8ListLevel::getSize();
139 
140     nResult += get_cbGrpprlPapx();
141     nResult += get_cbGrpprlChpx();
142     nResult += 2 + getU16(nResult) * 2;
143 
144     return nResult;
145 }
146 }}
147