Updated core
[LibreOffice.git] / writerfilter / source / doctok / WW8StyleSheet.cxx
blob3b7c298e784767fe07d8b1ef03fea505c35800ed
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 <doctok/resources.hxx>
22 namespace writerfilter {
23 namespace doctok {
25 void WW8StyleSheet::initPayload()
27 sal_uInt32 nCount = getEntryCount();
29 sal_uInt32 nOffset = get_size() + 2;
30 for (sal_uInt32 n = 0; n < nCount; ++n)
32 entryOffsets.push_back(nOffset);
34 sal_uInt32 cbStd = getU16(nOffset);
35 nOffset += cbStd + 2;
38 entryOffsets.push_back(nOffset);
41 sal_uInt32 WW8StyleSheet::getEntryCount()
43 return get_cstd();
46 writerfilter::Reference<Properties>::Pointer_t
47 WW8StyleSheet::getEntry(sal_uInt32 nIndex)
49 writerfilter::Reference<Properties>::Pointer_t pResult;
51 sal_uInt32 nCount = entryOffsets[nIndex + 1] - entryOffsets[nIndex];
53 if (nCount > get_cbSTDBaseInFile() + 2U)
55 WW8Style * pStyle = new WW8Style(this, entryOffsets[nIndex], nCount);
57 pStyle->setIndex(nIndex);
59 pResult = writerfilter::Reference<Properties>::Pointer_t(pStyle);
62 return pResult;
65 OUString WW8Style::get_xstzName()
67 sal_uInt32 nCount = getU8(0xc);
69 if (nCount > 0)
71 Sequence aSeq(mSequence, 0xe, nCount * 2);
73 rtl_uString * pNew = 0;
74 rtl_uString_newFromStr
75 (&pNew, reinterpret_cast<const sal_Unicode *>(&aSeq[0]));
77 return OUString(pNew);
81 return get_xstzName1();
84 OUString WW8Style::get_xstzName1()
86 WW8StyleSheet * pParentStyleSheet = dynamic_cast<WW8StyleSheet *>(mpParent);
88 if (mpParent != NULL)
90 sal_uInt32 nOffset = pParentStyleSheet->get_cbSTDBaseInFile() + 2;
92 if (nOffset < getCount())
94 sal_uInt32 nCount = getU16(nOffset);
96 if (nCount > 0)
98 Sequence aSeq(mSequence, nOffset + 2, nCount * 2);
100 rtl_uString * pNew = 0;
101 rtl_uString_newFromStr
102 (&pNew, reinterpret_cast<const sal_Unicode *>(&aSeq[0]));
104 return OUString(pNew);
110 return OUString();
113 sal_uInt32 WW8Style::get_upxstart()
115 sal_uInt32 nResult = 0;
116 sal_uInt32 nCount = getU8(0xc);
118 if (nCount > 0)
120 nResult = 0xc + 1 + nCount * 2;
122 nResult += nResult % 2;
124 else
126 WW8StyleSheet * pParentStyleSheet =
127 dynamic_cast<WW8StyleSheet *>(mpParent);
129 nResult = pParentStyleSheet->get_cbSTDBaseInFile() + 2;
131 if (nResult < getCount())
133 sal_uInt32 nCountTmp = getU16(nResult);
135 nResult += 4 + nCountTmp * 2;
139 return nResult;
142 sal_uInt32 WW8Style::get_upx_count()
144 return get_cupx();
147 writerfilter::Reference<Properties>::Pointer_t WW8Style::get_upx
148 (sal_uInt32 nIndex)
150 writerfilter::Reference<Properties>::Pointer_t pResult;
152 WW8StructBaseTmpOffset aOffset(this);
154 aOffset.set(get_upxstart());
156 if (aOffset.get() > 0 )
158 sal_uInt32 nCount;
160 for (sal_uInt32 n = 0; n < nIndex; ++n)
162 nCount = getU16(aOffset);
164 aOffset.inc(nCount + 2);
165 aOffset.inc(aOffset.get() % 2);
168 nCount = getU16(aOffset);
170 if (nCount > 0)
172 aOffset.inc(2);
174 bool bIsPap = get_cupx() == 2 && nIndex == 0;
175 WW8PropertySet::Pointer_t
176 pProps(new WW8PropertySetImpl(*this, aOffset.get(), nCount,
177 bIsPap));
179 WW8PropertiesReference * pRef =
180 new WW8PropertiesReference(pProps);
182 pResult = writerfilter::Reference<Properties>::Pointer_t(pRef);
186 return pResult;
189 void WW8Style::resolveNoAuto(Properties & /*rHandler*/)
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */