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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27 #include "WW8FFData.hxx"
28 #include <tools/stream.hxx>
29 #include <doc.hxx>
30 #include "writerwordglue.hxx"
31 #include "wrtww8.hxx"
32
33 namespace sw
34 {
35
36 using sw::types::msword_cast;
37
WW8FFData()38 WW8FFData::WW8FFData()
39 :
40 mnType(0),
41 mnResult(0),
42 mbOwnHelp(false),
43 mbOwnStat(false),
44 mbProtected(false),
45 mbSize(false),
46 mnTextType(0),
47 mbRecalc(false),
48 mbListBox(false),
49 mnMaxLen(0),
50 mnCheckboxHeight(0),
51 mnDefault(0)
52 {
53 }
54
~WW8FFData()55 WW8FFData::~WW8FFData()
56 {
57 }
58
setHelp(const::rtl::OUString & rHelp)59 void WW8FFData::setHelp(const ::rtl::OUString & rHelp)
60 {
61 msHelp = rHelp;
62 mbOwnHelp = true;
63 }
64
setStatus(const::rtl::OUString & rStatus)65 void WW8FFData::setStatus(const ::rtl::OUString & rStatus)
66 {
67 msStatus = rStatus;
68 mbOwnStat = true;
69 }
70
addListboxEntry(const::rtl::OUString & rEntry)71 void WW8FFData::addListboxEntry(const ::rtl::OUString & rEntry)
72 {
73 mbListBox = true;
74 msListEntries.push_back(rEntry);
75 }
76
WriteOUString(SvStream * pDataStrm,const::rtl::OUString & rStr,bool bAddZero)77 void WW8FFData::WriteOUString(SvStream * pDataStrm, const ::rtl::OUString & rStr,
78 bool bAddZero)
79 {
80 sal_uInt16 nStrLen = msword_cast<sal_uInt16>(rStr.getLength());
81 *pDataStrm << nStrLen;
82 SwWW8Writer::WriteString16(*pDataStrm, rStr, bAddZero);
83 }
84
Write(SvStream * pDataStrm)85 void WW8FFData::Write(SvStream * pDataStrm)
86 {
87 sal_uLong nDataStt = pDataStrm->Tell();
88
89 static const sal_uInt8 aHeader[] =
90 {
91 0,0,0,0, // len of struct
92 0x44,0, // the start of "next" data
93 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // PIC
94 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
95 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
96 0,0,0,0,0,0,0,0,0,0,0,0,0,0
97 };
98
99 pDataStrm->Write( aHeader, sizeof(aHeader) );
100
101 sal_uInt8 aData[10] = {
102 0xff, 0xff, 0xff, 0xff,
103 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
104 };
105
106 aData[4] = mnType | (mnResult << 2);
107
108 if (mbOwnHelp)
109 aData[4] |= (1 << 7);
110
111 aData[5] = (mnTextType << 3);
112
113 if (mbOwnStat)
114 aData[5] |= 1;
115
116 if (mbProtected)
117 aData[5] |= (1 << 1);
118
119 if (mbSize)
120 aData[5] |= (1 << 2);
121
122 if (mbRecalc)
123 aData[5] |= (1 << 6);
124
125 if (mbListBox)
126 aData[5] |= (1 << 7);
127
128 aData[6] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen & 0xffff);
129 aData[7] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen >> 8);
130 aData[8] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight & 0xffff);
131 aData[9] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight >> 8);
132
133 pDataStrm->Write(aData, sizeof(aData));
134
135 WriteOUString(pDataStrm, msName, true);
136
137 if (mnType == 0)
138 WriteOUString(pDataStrm, msDefault, true);
139 else
140 *pDataStrm << mnDefault;
141
142 WriteOUString(pDataStrm, msFormat, true);
143 WriteOUString(pDataStrm, msHelp, true);
144 WriteOUString(pDataStrm, msStatus, true);
145 WriteOUString(pDataStrm, msMacroEnter, true);
146 WriteOUString(pDataStrm, msMacroExit, true);
147
148 if (mnType == 2)
149 {
150 sal_uInt8 aData1[2] = { 0xff, 0xff };
151 pDataStrm->Write(aData1, sizeof(aData1));
152
153 sal_uInt32 nListboxEntries = msListEntries.size();
154 *pDataStrm << nListboxEntries;
155
156 ::std::vector< ::rtl::OUString >::const_iterator aIt = msListEntries.begin();
157
158 while (aIt != msListEntries.end())
159 {
160 const ::rtl::OUString & rEntry = *aIt;
161 WriteOUString(pDataStrm, rEntry, false);
162
163 aIt++;
164 }
165 }
166
167 SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
168 pDataStrm->Tell() - nDataStt );
169 }
170
171 }
172
173