1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WW8StyleSheet.cxx,v $
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
{
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
);
49 entryOffsets
.push_back(nOffset
);
52 sal_uInt32
WW8StyleSheet::calcPayloadOffset()
57 sal_uInt32
WW8StyleSheet::calcSize()
62 sal_uInt32
WW8StyleSheet::getEntryCount()
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
);
86 rtl::OUString
WW8Style::get_xstzName()
88 sal_uInt32 nCount
= getU8(0xc);
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
);
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);
141 nResult
= 0xc + 1 + nCount
* 2;
143 nResult
+= nResult
% 2;
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;
163 sal_uInt32
WW8Style::get_upx_count()
168 writerfilter::Reference
<Properties
>::Pointer_t
WW8Style::get_upx
171 writerfilter::Reference
<Properties
>::Pointer_t pResult
;
173 WW8StructBaseTmpOffset
aOffset(this);
175 aOffset
.set(get_upxstart());
177 if (aOffset
.get() > 0 )
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
);
195 bool bIsPap
= get_cupx() == 2 && nIndex
== 0;
196 WW8PropertySet::Pointer_t
197 pProps(new WW8PropertySetImpl(*this, aOffset
.get(), nCount
,
200 WW8PropertiesReference
* pRef
=
201 new WW8PropertiesReference(pProps
);
203 pResult
= writerfilter::Reference
<Properties
>::Pointer_t(pRef
);
210 void WW8Style::resolveNoAuto(Properties
& /*rHandler*/)