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 : #include <WW8Sttbf.hxx>
21 : #include <doctok/resources.hxx>
22 :
23 : namespace writerfilter {
24 : namespace doctok
25 : {
26 :
27 0 : WW8Sttbf::WW8Sttbf(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount)
28 0 : : WW8StructBase(rStream, nOffset, nCount)
29 : {
30 0 : sal_uInt32 nComplexOffset = 0;
31 0 : if (getU16(0) == 0xffff)
32 : {
33 0 : mbComplex = true;
34 0 : nComplexOffset = 2;
35 : }
36 :
37 0 : mnCount = getU16(nComplexOffset);
38 0 : mnExtraDataCount = getU16(nComplexOffset + 2);
39 :
40 0 : nOffset = (mbComplex ? 2 : 0) + 4;
41 :
42 0 : for (sal_uInt32 n = 0; n < mnCount; ++n)
43 : {
44 0 : mEntryOffsets.push_back(nOffset);
45 :
46 0 : sal_uInt32 nStringLength = getU16(nOffset);
47 :
48 0 : nOffset += 2 + nStringLength * (mbComplex ? 2 : 1);
49 :
50 0 : mExtraOffsets.push_back(nOffset);
51 :
52 0 : nOffset += mnExtraDataCount;
53 : }
54 0 : }
55 :
56 0 : sal_uInt32 WW8Sttbf::getEntryOffset(sal_uInt32 nPos) const
57 : {
58 0 : return mEntryOffsets[nPos];
59 : }
60 :
61 0 : sal_uInt32 WW8Sttbf::getEntryCount() const
62 : {
63 0 : return mnCount;
64 : }
65 :
66 0 : OUString WW8Sttbf::getEntry(sal_uInt32 nPos) const
67 : {
68 0 : return getString(getEntryOffset(nPos));
69 : }
70 :
71 0 : WW8SttbTableResource::WW8SttbTableResource(WW8Sttbf::Pointer_t pSttbf)
72 0 : : mpSttbf(pSttbf)
73 : {
74 0 : }
75 :
76 0 : WW8SttbTableResource::~WW8SttbTableResource()
77 : {
78 0 : }
79 :
80 0 : void WW8SttbTableResource::resolve(Table & rTable)
81 : {
82 0 : sal_uInt32 nCount = mpSttbf->getEntryCount();
83 :
84 0 : for (sal_uInt32 n = 0; n < nCount; n++)
85 : {
86 0 : WW8StringValue::Pointer_t pVal(new WW8StringValue(mpSttbf->getEntry(n)));
87 0 : ::writerfilter::Reference<Properties>::Pointer_t pProps(new WW8StringProperty(0, pVal));
88 :
89 0 : rTable.entry(n, pProps);
90 0 : }
91 0 : }
92 :
93 0 : string WW8SttbTableResource::getType() const
94 : {
95 0 : return "WW8SttbTableResource";
96 : }
97 :
98 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
99 0 : WW8StringProperty::WW8StringProperty(sal_uInt32 nId, WW8StringValue::Pointer_t pValue)
100 0 : : mnId(nId), mpValue(pValue)
101 : {
102 0 : }
103 : SAL_WNODEPRECATED_DECLARATIONS_POP
104 :
105 0 : WW8StringProperty::~WW8StringProperty()
106 : {
107 0 : }
108 :
109 0 : void WW8StringProperty::resolve(Properties & rProperties)
110 : {
111 0 : rProperties.attribute(mnId, *mpValue);
112 0 : }
113 :
114 0 : string WW8StringProperty::getType() const
115 : {
116 0 : return "WW8StringProperty";
117 : }
118 :
119 0 : sal_uInt32 WW8SttbRgtplc::getEntryCount()
120 : {
121 0 : return getU16(2);
122 : }
123 :
124 : ::writerfilter::Reference<Properties>::Pointer_t
125 0 : WW8SttbRgtplc::getEntry(sal_uInt32 nIndex)
126 : {
127 0 : ::writerfilter::Reference<Properties>::Pointer_t pResult;
128 :
129 0 : sal_uInt32 nOffset = 6;
130 :
131 0 : while (nIndex > 0)
132 : {
133 0 : sal_uInt16 nCount = getU16(nOffset);
134 :
135 0 : nOffset = nOffset + 2 + nCount;
136 0 : ++nIndex;
137 : }
138 :
139 0 : sal_uInt16 nCount = getU16(nOffset);
140 :
141 0 : if (nCount > 0)
142 : {
143 0 : WW8Tplc * pTplc = new WW8Tplc(*this, nOffset + 2, nCount);
144 :
145 0 : pResult.reset(pTplc);
146 : }
147 :
148 0 : return pResult;
149 : }
150 :
151 15 : }}
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|