merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / source / doctok / WW8FontTable.cxx
blobe808c22689b18fd5ba6564add0a34db365ff8f25
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: WW8FontTable.cxx,v $
10 * $Revision: 1.4 $
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 WW8FontTable::initPayload()
38 sal_uInt32 nCount = getU8(0);
40 sal_uInt32 nOffset = 1;
42 while (nCount > 0)
44 entryOffsets.push_back(nOffset);
46 sal_uInt32 nFFNSize = getU8(nOffset) + 1;
48 if (nFFNSize > 1)
49 nCount--;
51 nOffset += nFFNSize;
54 entryOffsets.push_back(nOffset);
55 mnPlcfPayloadOffset = nOffset;
58 sal_uInt32 WW8FontTable::calcPayloadOffset()
60 return 0;
63 sal_uInt32 WW8FontTable::getEntryCount()
65 return entryOffsets.size() - 1;
68 writerfilter::Reference<Properties>::Pointer_t
69 WW8FontTable::getEntry(sal_uInt32 nIndex)
71 writerfilter::Reference<Properties>::Pointer_t pResult;
73 sal_uInt32 nCount = entryOffsets[nIndex + 1] - entryOffsets[nIndex];
75 if (nCount > 1)
77 WW8Font * pFont = new WW8Font(this,
78 entryOffsets[nIndex], nCount);
80 pFont->setIndex(nIndex);
82 pResult = writerfilter::Reference<Properties>::Pointer_t(pFont);
85 return pResult;
88 sal_uInt32 WW8Font::get_f()
90 return mnIndex;
93 rtl::OUString WW8Font::get_xszFfn()
95 sal_uInt32 nOffset = 0x28;
96 sal_uInt32 nCount = get_cbFfnM1() - nOffset;
98 Sequence aSeq(mSequence, nOffset, nCount);
100 rtl_uString * pNew = 0;
101 rtl_uString_newFromStr
102 (&pNew, reinterpret_cast<const sal_Unicode *>(&aSeq[0]));
104 return rtl::OUString(pNew);
107 rtl::OUString WW8Font::get_altName()
109 sal_uInt32 nOffset = 0x28 + get_ixchSzAlt();
110 sal_uInt32 nCount = get_cbFfnM1() - nOffset;
112 Sequence aSeq(mSequence, nOffset, nCount);
114 rtl_uString * pNew = 0;
115 rtl_uString_newFromStr
116 (&pNew, reinterpret_cast<const sal_Unicode *>(&aSeq[0]));
118 return rtl::OUString(pNew);