1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include <resources.hxx>
25 
26 namespace writerfilter {
27 namespace doctok {
28 
initPayload()29 void WW8FontTable::initPayload()
30 {
31     sal_uInt32 nCount = getU8(0);
32 
33     sal_uInt32 nOffset = 1;
34 
35     while (nCount > 0)
36     {
37         entryOffsets.push_back(nOffset);
38 
39         sal_uInt32 nFFNSize = getU8(nOffset) + 1;
40 
41         if (nFFNSize > 1)
42             nCount--;
43 
44         nOffset += nFFNSize;
45     }
46 
47     entryOffsets.push_back(nOffset);
48     mnPlcfPayloadOffset = nOffset;
49 }
50 
getEntryCount()51 sal_uInt32 WW8FontTable::getEntryCount()
52 {
53     return entryOffsets.size() - 1;
54 }
55 
56 writerfilter::Reference<Properties>::Pointer_t
getEntry(sal_uInt32 nIndex)57 WW8FontTable::getEntry(sal_uInt32 nIndex)
58 {
59     writerfilter::Reference<Properties>::Pointer_t pResult;
60 
61     sal_uInt32 nCount = entryOffsets[nIndex + 1] - entryOffsets[nIndex];
62 
63     if (nCount > 1)
64     {
65         WW8Font * pFont = new WW8Font(this,
66                                       entryOffsets[nIndex], nCount);
67 
68         pFont->setIndex(nIndex);
69 
70         pResult = writerfilter::Reference<Properties>::Pointer_t(pFont);
71     }
72 
73     return pResult;
74 }
75 
get_f()76 sal_uInt32 WW8Font::get_f()
77 {
78     return mnIndex;
79 }
80 
get_xszFfn()81 rtl::OUString WW8Font::get_xszFfn()
82 {
83     sal_uInt32 nOffset = 0x28;
84     sal_uInt32 nCount = get_cbFfnM1() - nOffset;
85 
86     Sequence aSeq(mSequence, nOffset, nCount);
87 
88     rtl_uString * pNew = 0;
89     rtl_uString_newFromStr
90         (&pNew, reinterpret_cast<const sal_Unicode *>(&aSeq[0]));
91 
92     return rtl::OUString(pNew);
93 }
94 
get_altName()95 rtl::OUString WW8Font::get_altName()
96 {
97     sal_uInt32 nOffset = 0x28 + get_ixchSzAlt();
98     sal_uInt32 nCount = get_cbFfnM1() - nOffset;
99 
100     Sequence aSeq(mSequence, nOffset, nCount);
101 
102     rtl_uString * pNew = 0;
103     rtl_uString_newFromStr
104         (&pNew, reinterpret_cast<const sal_Unicode *>(&aSeq[0]));
105 
106     return rtl::OUString(pNew);
107 }
108 
109 }}
110