Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "WW8FFData.hxx"
21 : #include <tools/stream.hxx>
22 : #include <doc.hxx>
23 : #include "writerwordglue.hxx"
24 : #include "wrtww8.hxx"
25 :
26 : namespace sw
27 : {
28 :
29 : using sw::types::msword_cast;
30 :
31 0 : WW8FFData::WW8FFData()
32 : :
33 : mnType(0),
34 : mnResult(0),
35 : mbOwnHelp(false),
36 : mbOwnStat(false),
37 : mbProtected(false),
38 : mbSize(false),
39 : mnTextType(0),
40 : mbRecalc(false),
41 : mbListBox(false),
42 : mnMaxLen(0),
43 : mnCheckboxHeight(0),
44 0 : mnDefault(0)
45 : {
46 0 : }
47 :
48 0 : WW8FFData::~WW8FFData()
49 : {
50 0 : }
51 :
52 0 : void WW8FFData::setHelp(const OUString & rHelp)
53 : {
54 0 : msHelp = rHelp;
55 0 : mbOwnHelp = true;
56 0 : }
57 :
58 0 : void WW8FFData::setStatus(const OUString & rStatus)
59 : {
60 0 : msStatus = rStatus;
61 0 : mbOwnStat = true;
62 0 : }
63 :
64 0 : void WW8FFData::addListboxEntry(const OUString & rEntry)
65 : {
66 0 : mbListBox = true;
67 0 : msListEntries.push_back(rEntry);
68 0 : }
69 :
70 0 : void WW8FFData::WriteOUString(SvStream * pDataStrm, const OUString & rStr,
71 : bool bAddZero)
72 : {
73 0 : sal_uInt16 nStrLen = msword_cast<sal_uInt16>(rStr.getLength());
74 0 : pDataStrm->WriteUInt16( nStrLen );
75 0 : SwWW8Writer::WriteString16(*pDataStrm, rStr, bAddZero);
76 0 : }
77 :
78 0 : void WW8FFData::Write(SvStream * pDataStrm)
79 : {
80 0 : sal_uLong nDataStt = pDataStrm->Tell();
81 :
82 : static const sal_uInt8 aHeader[] =
83 : {
84 : 0,0,0,0, // len of struct
85 : 0x44,0, // the start of "next" data
86 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // PIC
87 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
88 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89 : 0,0,0,0,0,0,0,0,0,0,0,0,0,0
90 : };
91 :
92 0 : pDataStrm->Write( aHeader, sizeof(aHeader) );
93 :
94 : sal_uInt8 aData[10] = {
95 : 0xff, 0xff, 0xff, 0xff,
96 : 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
97 0 : };
98 :
99 0 : aData[4] = mnType | (mnResult << 2);
100 :
101 0 : if (mbOwnHelp)
102 0 : aData[4] |= (1 << 7);
103 :
104 0 : aData[5] = (mnTextType << 3);
105 :
106 0 : if (mbOwnStat)
107 0 : aData[5] |= 1;
108 :
109 0 : if (mbProtected)
110 0 : aData[5] |= (1 << 1);
111 :
112 0 : if (mbSize)
113 0 : aData[5] |= (1 << 2);
114 :
115 0 : if (mbRecalc)
116 0 : aData[5] |= (1 << 6);
117 :
118 0 : if (mbListBox)
119 0 : aData[5] |= (1 << 7);
120 :
121 0 : aData[6] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen & 0xffff);
122 0 : aData[7] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen >> 8);
123 0 : aData[8] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight & 0xffff);
124 0 : aData[9] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight >> 8);
125 :
126 0 : pDataStrm->Write(aData, sizeof(aData));
127 :
128 0 : WriteOUString(pDataStrm, msName, true);
129 :
130 0 : if (mnType == 0)
131 0 : WriteOUString(pDataStrm, msDefault, true);
132 : else
133 0 : pDataStrm->WriteUInt16( mnDefault );
134 :
135 0 : WriteOUString(pDataStrm, msFormat, true);
136 0 : WriteOUString(pDataStrm, msHelp, true);
137 0 : WriteOUString(pDataStrm, msStatus, true);
138 0 : WriteOUString(pDataStrm, msMacroEnter, true);
139 0 : WriteOUString(pDataStrm, msMacroExit, true);
140 :
141 0 : if (mnType == 2)
142 : {
143 0 : sal_uInt8 aData1[2] = { 0xff, 0xff };
144 0 : pDataStrm->Write(aData1, sizeof(aData1));
145 :
146 0 : sal_uInt32 nListboxEntries = msListEntries.size();
147 0 : pDataStrm->WriteUInt32( nListboxEntries );
148 :
149 0 : ::std::vector< OUString >::const_iterator aIt = msListEntries.begin();
150 :
151 0 : while (aIt != msListEntries.end())
152 : {
153 0 : const OUString & rEntry = *aIt;
154 0 : WriteOUString(pDataStrm, rEntry, false);
155 :
156 0 : ++aIt;
157 : }
158 : }
159 :
160 : SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
161 0 : pDataStrm->Tell() - nDataStt );
162 0 : }
163 :
164 : }
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|