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: WW8LFOTable.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "resources.hxx"
34 namespace writerfilter
{
37 void WW8LFOTable::initPayload()
39 sal_uInt32 nCount
= getEntryCount();
41 sal_uInt32 nOffset
= 4;
42 sal_uInt32 nOffsetLevel
= mnPlcfPayloadOffset
;
44 for (sal_uInt32 n
= 0; n
< nCount
; ++n
)
46 WW8LFO
aLFO(this, nOffset
);
48 entryOffsets
.push_back(nOffset
);
49 payloadIndices
.push_back(payloadOffsets
.size());
50 nOffset
+= WW8LFO::getSize();
52 sal_uInt32 nLvlCount
= aLFO
.get_lfolevel_count();
54 for (sal_uInt32 i
= 0; i
< nLvlCount
; ++i
)
56 WW8LFOLevel
aLevel(this, nOffsetLevel
);
58 payloadOffsets
.push_back(nOffsetLevel
);
60 nOffsetLevel
+= aLevel
.calcSize();
64 entryOffsets
.push_back(nOffset
);
65 payloadOffsets
.push_back(nOffsetLevel
);
68 sal_uInt32
WW8LFOTable::calcPayloadOffset()
70 sal_uInt32 nResult
= 4 + getEntryCount() * WW8LFO::getSize();
72 while (getU32(nResult
) == 0xffffffff)
78 sal_uInt32
WW8LFOTable::getEntryCount()
83 writerfilter::Reference
<Properties
>::Pointer_t
84 WW8LFOTable::getEntry(sal_uInt32 nIndex
)
86 WW8LFO
* pLFO
= new WW8LFO(this, entryOffsets
[nIndex
]);
88 pLFO
->setIndex(nIndex
);
90 return writerfilter::Reference
<Properties
>::Pointer_t(pLFO
);
93 sal_uInt32
WW8LFO::get_lfolevel_count()
98 writerfilter::Reference
<Properties
>::Pointer_t
99 WW8LFO::get_lfolevel(sal_uInt32 nIndex
)
101 WW8LFOTable
* pLFOTable
= dynamic_cast<WW8LFOTable
*>(mpParent
);
102 sal_uInt32 nPayloadIndex
= pLFOTable
->getPayloadIndex(mnIndex
) + nIndex
;
103 sal_uInt32 nPayloadOffset
= pLFOTable
->getPayloadOffset(nPayloadIndex
);
104 sal_uInt32 nPayloadSize
= pLFOTable
->getPayloadSize(nPayloadIndex
);
106 return writerfilter::Reference
<Properties
>::Pointer_t
107 (new WW8LFOLevel(mpParent
, nPayloadOffset
, nPayloadSize
));
110 void WW8LFOLevel::resolveNoAuto(Properties
& /*rHandler*/)
115 sal_uInt32
WW8LFOLevel::calcSize()
117 sal_uInt32 nResult
= WW8LFOLevel::getSize();
119 if (get_fFormatting())
121 WW8ListLevel
aLevel(mpParent
, mnOffsetInParent
+ nResult
);
123 nResult
+= aLevel
.calcSize();
125 sal_uInt32 nXstSize
= mpParent
->getU16(mnOffsetInParent
+ nResult
);
127 nResult
+= (nXstSize
+ 1) * 2;