merge the formfield patch from ooo-build
[ooovba.git] / sw / source / filter / ww8 / WW8FFData.cxx
blobbafeab2afd5637e4fde9c0ed72a02f90df54495f
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: WW8FFData.cxx,v $
10 * $Revision: 1.2 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include "WW8FFData.hxx"
35 #include <tools/stream.hxx>
36 #include <doc.hxx>
37 #include "writerwordglue.hxx"
38 #include "wrtww8.hxx"
40 namespace sw
43 using sw::types::msword_cast;
45 WW8FFData::WW8FFData()
47 mnType(0),
48 mnResult(0),
49 mbOwnHelp(false),
50 mbOwnStat(false),
51 mbProtected(false),
52 mbSize(false),
53 mnTextType(0),
54 mbRecalc(false),
55 mbListBox(false),
56 mnMaxLen(0),
57 mnCheckboxHeight(0),
58 mnDefault(0)
62 WW8FFData::~WW8FFData()
66 void WW8FFData::setHelp(const ::rtl::OUString & rHelp)
68 msHelp = rHelp;
69 mbOwnHelp = true;
72 void WW8FFData::setStatus(const ::rtl::OUString & rStatus)
74 msStatus = rStatus;
75 mbOwnStat = true;
78 void WW8FFData::addListboxEntry(const ::rtl::OUString & rEntry)
80 mbListBox = true;
81 msListEntries.push_back(rEntry);
84 void WW8FFData::WriteOUString(SvStream * pDataStrm, const ::rtl::OUString & rStr,
85 bool bAddZero)
87 sal_uInt16 nStrLen = msword_cast<sal_uInt16>(rStr.getLength());
88 *pDataStrm << nStrLen;
89 SwWW8Writer::WriteString16(*pDataStrm, rStr, bAddZero);
92 void WW8FFData::Write(SvStream * pDataStrm)
94 ULONG nDataStt = pDataStrm->Tell();
96 static const sal_uInt8 aHeader[] =
98 0,0,0,0, // len of struct
99 0x44,0, // the start of "next" data
100 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // PIC
101 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
102 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
103 0,0,0,0,0,0,0,0,0,0,0,0,0,0
106 pDataStrm->Write( aHeader, sizeof(aHeader) );
108 sal_uInt8 aData[10] = {
109 0xff, 0xff, 0xff, 0xff,
110 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
113 aData[4] = mnType | (mnResult << 2);
115 if (mbOwnHelp)
116 aData[4] |= (1 << 7);
118 aData[5] = (mnTextType << 3);
120 if (mbOwnStat)
121 aData[5] |= 1;
123 if (mbProtected)
124 aData[5] |= (1 << 1);
126 if (mbSize)
127 aData[5] |= (1 << 2);
129 if (mbRecalc)
130 aData[5] |= (1 << 6);
132 if (mbListBox)
133 aData[5] |= (1 << 7);
135 aData[6] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen & 0xffff);
136 aData[7] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen >> 8);
137 aData[8] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight & 0xffff);
138 aData[9] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight >> 8);
140 pDataStrm->Write(aData, sizeof(aData));
142 WriteOUString(pDataStrm, msName, true);
144 if (mnType == 0)
145 WriteOUString(pDataStrm, msDefault, true);
146 else
147 *pDataStrm << mnDefault;
149 WriteOUString(pDataStrm, msFormat, true);
150 WriteOUString(pDataStrm, msHelp, true);
151 WriteOUString(pDataStrm, msStatus, true);
152 WriteOUString(pDataStrm, msMacroEnter, true);
153 WriteOUString(pDataStrm, msMacroExit, true);
155 if (mnType == 2)
157 sal_uInt8 aData1[2] = { 0xff, 0xff };
158 pDataStrm->Write(aData1, sizeof(aData1));
160 sal_uInt32 nListboxEntries = msListEntries.size();
161 *pDataStrm << nListboxEntries;
163 ::std::vector< ::rtl::OUString >::const_iterator aIt = msListEntries.begin();
165 while (aIt != msListEntries.end())
167 const ::rtl::OUString & rEntry = *aIt;
168 WriteOUString(pDataStrm, rEntry, false);
170 aIt++;
174 SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
175 pDataStrm->Tell() - nDataStt );