merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / source / doctok / WW8StyleSheet.cxx
blobadf890563d0a766f1c948303e22ea8b493efcaed
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WW8StyleSheet.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <resources.hxx>
33 namespace writerfilter {
34 namespace doctok {
36 void WW8StyleSheet::initPayload()
38 sal_uInt32 nCount = getEntryCount();
40 sal_uInt32 nOffset = get_size() + 2;
41 for (sal_uInt32 n = 0; n < nCount; ++n)
43 entryOffsets.push_back(nOffset);
45 sal_uInt32 cbStd = getU16(nOffset);
46 nOffset += cbStd + 2;
49 entryOffsets.push_back(nOffset);
52 sal_uInt32 WW8StyleSheet::calcPayloadOffset()
54 return 0;
57 sal_uInt32 WW8StyleSheet::calcSize()
59 return getCount();
62 sal_uInt32 WW8StyleSheet::getEntryCount()
64 return get_cstd();
67 writerfilter::Reference<Properties>::Pointer_t
68 WW8StyleSheet::getEntry(sal_uInt32 nIndex)
70 writerfilter::Reference<Properties>::Pointer_t pResult;
72 sal_uInt32 nCount = entryOffsets[nIndex + 1] - entryOffsets[nIndex];
74 if (nCount > get_cbSTDBaseInFile() + 2U)
76 WW8Style * pStyle = new WW8Style(this, entryOffsets[nIndex], nCount);
78 pStyle->setIndex(nIndex);
80 pResult = writerfilter::Reference<Properties>::Pointer_t(pStyle);
83 return pResult;
86 rtl::OUString WW8Style::get_xstzName()
88 sal_uInt32 nCount = getU8(0xc);
90 if (nCount > 0)
92 Sequence aSeq(mSequence, 0xe, nCount * 2);
94 rtl_uString * pNew = 0;
95 rtl_uString_newFromStr
96 (&pNew, reinterpret_cast<const sal_Unicode *>(&aSeq[0]));
98 return rtl::OUString(pNew);
102 return get_xstzName1();
105 rtl::OUString WW8Style::get_xstzName1()
107 WW8StyleSheet * pParentStyleSheet = dynamic_cast<WW8StyleSheet *>(mpParent);
109 if (mpParent != NULL)
111 sal_uInt32 nOffset = pParentStyleSheet->get_cbSTDBaseInFile() + 2;
113 if (nOffset < getCount())
115 sal_uInt32 nCount = getU16(nOffset);
117 if (nCount > 0)
119 Sequence aSeq(mSequence, nOffset + 2, nCount * 2);
121 rtl_uString * pNew = 0;
122 rtl_uString_newFromStr
123 (&pNew, reinterpret_cast<const sal_Unicode *>(&aSeq[0]));
125 return rtl::OUString(pNew);
131 return rtl::OUString();
134 sal_uInt32 WW8Style::get_upxstart()
136 sal_uInt32 nResult = 0;
137 sal_uInt32 nCount = getU8(0xc);
139 if (nCount > 0)
141 nResult = 0xc + 1 + nCount * 2;
143 nResult += nResult % 2;
145 else
147 WW8StyleSheet * pParentStyleSheet =
148 dynamic_cast<WW8StyleSheet *>(mpParent);
150 nResult = pParentStyleSheet->get_cbSTDBaseInFile() + 2;
152 if (nResult < getCount())
154 sal_uInt32 nCountTmp = getU16(nResult);
156 nResult += 4 + nCountTmp * 2;
160 return nResult;
163 sal_uInt32 WW8Style::get_upx_count()
165 return get_cupx();
168 writerfilter::Reference<Properties>::Pointer_t WW8Style::get_upx
169 (sal_uInt32 nIndex)
171 writerfilter::Reference<Properties>::Pointer_t pResult;
173 WW8StructBaseTmpOffset aOffset(this);
175 aOffset.set(get_upxstart());
177 if (aOffset.get() > 0 )
179 sal_uInt32 nCount;
181 for (sal_uInt32 n = 0; n < nIndex; ++n)
183 nCount = getU16(aOffset);
185 aOffset.inc(nCount + 2);
186 aOffset.inc(aOffset.get() % 2);
189 nCount = getU16(aOffset);
191 if (nCount > 0)
193 aOffset.inc(2);
195 bool bIsPap = get_cupx() == 2 && nIndex == 0;
196 WW8PropertySet::Pointer_t
197 pProps(new WW8PropertySetImpl(*this, aOffset.get(), nCount,
198 bIsPap));
200 WW8PropertiesReference * pRef =
201 new WW8PropertiesReference(pProps);
203 pResult = writerfilter::Reference<Properties>::Pointer_t(pRef);
207 return pResult;
210 void WW8Style::resolveNoAuto(Properties & /*rHandler*/)