bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / filter / ww8 / WW8FFData.cxx
blob73732b8306641b03546917deaf32b3965e872a53
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "WW8FFData.hxx"
22 #include <tools/stream.hxx>
23 #include <doc.hxx>
24 #include "writerwordglue.hxx"
25 #include "wrtww8.hxx"
27 namespace sw
30 using sw::types::msword_cast;
32 WW8FFData::WW8FFData()
34 mnType(0),
35 mnResult(0),
36 mbOwnHelp(false),
37 mbOwnStat(false),
38 mbProtected(false),
39 mbSize(false),
40 mnTextType(0),
41 mbRecalc(false),
42 mbListBox(false),
43 mnMaxLen(0),
44 mnCheckboxHeight(0),
45 mnDefault(0)
49 WW8FFData::~WW8FFData()
53 void WW8FFData::setHelp(const OUString & rHelp)
55 msHelp = rHelp;
56 mbOwnHelp = true;
59 void WW8FFData::setStatus(const OUString & rStatus)
61 msStatus = rStatus;
62 mbOwnStat = true;
65 void WW8FFData::addListboxEntry(const OUString & rEntry)
67 mbListBox = true;
68 msListEntries.push_back(rEntry);
71 void WW8FFData::WriteOUString(SvStream * pDataStrm, const OUString & rStr,
72 bool bAddZero)
74 sal_uInt16 nStrLen = msword_cast<sal_uInt16>(rStr.getLength());
75 *pDataStrm << nStrLen;
76 SwWW8Writer::WriteString16(*pDataStrm, rStr, bAddZero);
79 void WW8FFData::Write(SvStream * pDataStrm)
81 sal_uLong nDataStt = pDataStrm->Tell();
83 static const sal_uInt8 aHeader[] =
85 0,0,0,0, // len of struct
86 0x44,0, // the start of "next" data
87 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // PIC
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,0,0,
90 0,0,0,0,0,0,0,0,0,0,0,0,0,0
93 pDataStrm->Write( aHeader, sizeof(aHeader) );
95 sal_uInt8 aData[10] = {
96 0xff, 0xff, 0xff, 0xff,
97 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
100 aData[4] = mnType | (mnResult << 2);
102 if (mbOwnHelp)
103 aData[4] |= (1 << 7);
105 aData[5] = (mnTextType << 3);
107 if (mbOwnStat)
108 aData[5] |= 1;
110 if (mbProtected)
111 aData[5] |= (1 << 1);
113 if (mbSize)
114 aData[5] |= (1 << 2);
116 if (mbRecalc)
117 aData[5] |= (1 << 6);
119 if (mbListBox)
120 aData[5] |= (1 << 7);
122 aData[6] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen & 0xffff);
123 aData[7] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen >> 8);
124 aData[8] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight & 0xffff);
125 aData[9] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight >> 8);
127 pDataStrm->Write(aData, sizeof(aData));
129 WriteOUString(pDataStrm, msName, true);
131 if (mnType == 0)
132 WriteOUString(pDataStrm, msDefault, true);
133 else
134 *pDataStrm << mnDefault;
136 WriteOUString(pDataStrm, msFormat, true);
137 WriteOUString(pDataStrm, msHelp, true);
138 WriteOUString(pDataStrm, msStatus, true);
139 WriteOUString(pDataStrm, msMacroEnter, true);
140 WriteOUString(pDataStrm, msMacroExit, true);
142 if (mnType == 2)
144 sal_uInt8 aData1[2] = { 0xff, 0xff };
145 pDataStrm->Write(aData1, sizeof(aData1));
147 sal_uInt32 nListboxEntries = msListEntries.size();
148 *pDataStrm << nListboxEntries;
150 ::std::vector< OUString >::const_iterator aIt = msListEntries.begin();
152 while (aIt != msListEntries.end())
154 const OUString & rEntry = *aIt;
155 WriteOUString(pDataStrm, rEntry, false);
157 ++aIt;
161 SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
162 pDataStrm->Tell() - nDataStt );
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */