Bump version to 4.1-6
[LibreOffice.git] / writerfilter / source / doctok / WW8Sttbf.cxx
blob68b1c92cb4f5202b9d4b46778d7225d1ff4ff2d0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <WW8Sttbf.hxx>
21 #include <doctok/resources.hxx>
23 namespace writerfilter {
24 namespace doctok
27 WW8Sttbf::WW8Sttbf(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount)
28 : WW8StructBase(rStream, nOffset, nCount)
30 sal_uInt32 nComplexOffset = 0;
31 if (getU16(0) == 0xffff)
33 mbComplex = true;
34 nComplexOffset = 2;
37 mnCount = getU16(nComplexOffset);
38 mnExtraDataCount = getU16(nComplexOffset + 2);
40 nOffset = (mbComplex ? 2 : 0) + 4;
42 for (sal_uInt32 n = 0; n < mnCount; ++n)
44 mEntryOffsets.push_back(nOffset);
46 sal_uInt32 nStringLength = getU16(nOffset);
48 nOffset += 2 + nStringLength * (mbComplex ? 2 : 1);
50 mExtraOffsets.push_back(nOffset);
52 nOffset += mnExtraDataCount;
56 sal_uInt32 WW8Sttbf::getEntryOffset(sal_uInt32 nPos) const
58 return mEntryOffsets[nPos];
61 sal_uInt32 WW8Sttbf::getEntryCount() const
63 return mnCount;
66 OUString WW8Sttbf::getEntry(sal_uInt32 nPos) const
68 return getString(getEntryOffset(nPos));
71 WW8SttbTableResource::WW8SttbTableResource(WW8Sttbf::Pointer_t pSttbf)
72 : mpSttbf(pSttbf)
76 WW8SttbTableResource::~WW8SttbTableResource()
80 void WW8SttbTableResource::resolve(Table & rTable)
82 sal_uInt32 nCount = mpSttbf->getEntryCount();
84 for (sal_uInt32 n = 0; n < nCount; n++)
86 WW8StringValue::Pointer_t pVal(new WW8StringValue(mpSttbf->getEntry(n)));
87 ::writerfilter::Reference<Properties>::Pointer_t pProps(new WW8StringProperty(0, pVal));
89 rTable.entry(n, pProps);
93 string WW8SttbTableResource::getType() const
95 return "WW8SttbTableResource";
98 SAL_WNODEPRECATED_DECLARATIONS_PUSH
99 WW8StringProperty::WW8StringProperty(sal_uInt32 nId, WW8StringValue::Pointer_t pValue)
100 : mnId(nId), mpValue(pValue)
103 SAL_WNODEPRECATED_DECLARATIONS_POP
105 WW8StringProperty::~WW8StringProperty()
109 void WW8StringProperty::resolve(Properties & rProperties)
111 rProperties.attribute(mnId, *mpValue);
114 string WW8StringProperty::getType() const
116 return "WW8StringProperty";
119 sal_uInt32 WW8SttbRgtplc::getEntryCount()
121 return getU16(2);
124 ::writerfilter::Reference<Properties>::Pointer_t
125 WW8SttbRgtplc::getEntry(sal_uInt32 nIndex)
127 ::writerfilter::Reference<Properties>::Pointer_t pResult;
129 sal_uInt32 nOffset = 6;
131 for (sal_uInt32 i = 0; i < nIndex; ++i)
133 sal_uInt16 nCount = getU16(nOffset);
134 nOffset = nOffset + 2 + nCount;
137 sal_uInt16 nCount = getU16(nOffset);
139 if (nCount > 0)
141 WW8Tplc * pTplc = new WW8Tplc(*this, nOffset + 2, nCount);
143 pResult.reset(pTplc);
146 return pResult;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */