Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "WW8FFData.hxx"
31 : : #include <tools/stream.hxx>
32 : : #include <doc.hxx>
33 : : #include "writerwordglue.hxx"
34 : : #include "wrtww8.hxx"
35 : :
36 : : namespace sw
37 : : {
38 : :
39 : : using sw::types::msword_cast;
40 : :
41 : 0 : WW8FFData::WW8FFData()
42 : : :
43 : : mnType(0),
44 : : mnResult(0),
45 : : mbOwnHelp(false),
46 : : mbOwnStat(false),
47 : : mbProtected(false),
48 : : mbSize(false),
49 : : mnTextType(0),
50 : : mbRecalc(false),
51 : : mbListBox(false),
52 : : mnMaxLen(0),
53 : : mnCheckboxHeight(0),
54 [ # # ]: 0 : mnDefault(0)
55 : : {
56 : 0 : }
57 : :
58 : 0 : WW8FFData::~WW8FFData()
59 : : {
60 : 0 : }
61 : :
62 : 0 : void WW8FFData::setHelp(const ::rtl::OUString & rHelp)
63 : : {
64 : 0 : msHelp = rHelp;
65 : 0 : mbOwnHelp = true;
66 : 0 : }
67 : :
68 : 0 : void WW8FFData::setStatus(const ::rtl::OUString & rStatus)
69 : : {
70 : 0 : msStatus = rStatus;
71 : 0 : mbOwnStat = true;
72 : 0 : }
73 : :
74 : 0 : void WW8FFData::addListboxEntry(const ::rtl::OUString & rEntry)
75 : : {
76 : 0 : mbListBox = true;
77 : 0 : msListEntries.push_back(rEntry);
78 : 0 : }
79 : :
80 : 0 : void WW8FFData::WriteOUString(SvStream * pDataStrm, const ::rtl::OUString & rStr,
81 : : bool bAddZero)
82 : : {
83 : 0 : sal_uInt16 nStrLen = msword_cast<sal_uInt16>(rStr.getLength());
84 : 0 : *pDataStrm << nStrLen;
85 [ # # ]: 0 : SwWW8Writer::WriteString16(*pDataStrm, rStr, bAddZero);
86 : 0 : }
87 : :
88 : 0 : void WW8FFData::Write(SvStream * pDataStrm)
89 : : {
90 : 0 : sal_uLong nDataStt = pDataStrm->Tell();
91 : :
92 : : static const sal_uInt8 aHeader[] =
93 : : {
94 : : 0,0,0,0, // len of struct
95 : : 0x44,0, // the start of "next" data
96 : : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // PIC
97 : : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
98 : : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
99 : : 0,0,0,0,0,0,0,0,0,0,0,0,0,0
100 : : };
101 : :
102 [ # # ]: 0 : pDataStrm->Write( aHeader, sizeof(aHeader) );
103 : :
104 : : sal_uInt8 aData[10] = {
105 : : 0xff, 0xff, 0xff, 0xff,
106 : : 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
107 : 0 : };
108 : :
109 : 0 : aData[4] = mnType | (mnResult << 2);
110 : :
111 [ # # ]: 0 : if (mbOwnHelp)
112 : 0 : aData[4] |= (1 << 7);
113 : :
114 : 0 : aData[5] = (mnTextType << 3);
115 : :
116 [ # # ]: 0 : if (mbOwnStat)
117 : 0 : aData[5] |= 1;
118 : :
119 [ # # ]: 0 : if (mbProtected)
120 : 0 : aData[5] |= (1 << 1);
121 : :
122 [ # # ]: 0 : if (mbSize)
123 : 0 : aData[5] |= (1 << 2);
124 : :
125 [ # # ]: 0 : if (mbRecalc)
126 : 0 : aData[5] |= (1 << 6);
127 : :
128 [ # # ]: 0 : if (mbListBox)
129 : 0 : aData[5] |= (1 << 7);
130 : :
131 : 0 : aData[6] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen & 0xffff);
132 : 0 : aData[7] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen >> 8);
133 : 0 : aData[8] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight & 0xffff);
134 : 0 : aData[9] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight >> 8);
135 : :
136 [ # # ]: 0 : pDataStrm->Write(aData, sizeof(aData));
137 : :
138 [ # # ]: 0 : WriteOUString(pDataStrm, msName, true);
139 : :
140 [ # # ]: 0 : if (mnType == 0)
141 [ # # ]: 0 : WriteOUString(pDataStrm, msDefault, true);
142 : : else
143 [ # # ]: 0 : *pDataStrm << mnDefault;
144 : :
145 [ # # ]: 0 : WriteOUString(pDataStrm, msFormat, true);
146 [ # # ]: 0 : WriteOUString(pDataStrm, msHelp, true);
147 [ # # ]: 0 : WriteOUString(pDataStrm, msStatus, true);
148 [ # # ]: 0 : WriteOUString(pDataStrm, msMacroEnter, true);
149 [ # # ]: 0 : WriteOUString(pDataStrm, msMacroExit, true);
150 : :
151 [ # # ]: 0 : if (mnType == 2)
152 : : {
153 : 0 : sal_uInt8 aData1[2] = { 0xff, 0xff };
154 [ # # ]: 0 : pDataStrm->Write(aData1, sizeof(aData1));
155 : :
156 : 0 : sal_uInt32 nListboxEntries = msListEntries.size();
157 [ # # ]: 0 : *pDataStrm << nListboxEntries;
158 : :
159 [ # # ]: 0 : ::std::vector< ::rtl::OUString >::const_iterator aIt = msListEntries.begin();
160 : :
161 [ # # ][ # # ]: 0 : while (aIt != msListEntries.end())
162 : : {
163 : 0 : const ::rtl::OUString & rEntry = *aIt;
164 [ # # ]: 0 : WriteOUString(pDataStrm, rEntry, false);
165 : :
166 : 0 : ++aIt;
167 : : }
168 : : }
169 : :
170 : : SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
171 [ # # ]: 0 : pDataStrm->Tell() - nDataStt );
172 : 0 : }
173 : :
174 : : }
175 : :
176 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|