LibreOffice Module sw (master)  1
WW8FFData.cxx
Go to the documentation of this file.
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 
30 
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  mnDefault(0)
45 {
46 }
47 
49 {
50 }
51 
52 void WW8FFData::setHelp(const OUString & rHelp)
53 {
54  msHelp = rHelp;
55  mbOwnHelp = true;
56 }
57 
58 void WW8FFData::setStatus(const OUString & rStatus)
59 {
60  msStatus = rStatus;
61  mbOwnStat = true;
62 }
63 
64 void WW8FFData::addListboxEntry(const OUString & rEntry)
65 {
66  mbListBox = true;
67  msListEntries.push_back(rEntry);
68 }
69 
70 void WW8FFData::WriteOUString(SvStream * pDataStrm, const OUString & rStr,
71  bool bAddZero)
72 {
73  sal_uInt16 nStrLen = msword_cast<sal_uInt16>(rStr.getLength());
74  pDataStrm->WriteUInt16( nStrLen );
75  SwWW8Writer::WriteString16(*pDataStrm, rStr, bAddZero);
76 }
77 
78 void WW8FFData::Write(SvStream * pDataStrm)
79 {
80  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  pDataStrm->WriteBytes(aHeader, sizeof(aHeader));
93 
94  sal_uInt8 aData[10] = {
95  0xff, 0xff, 0xff, 0xff,
96  0x0, 0x0, 0x0, 0x0, 0x0, 0x0
97  };
98 
99  aData[4] = mnType | (mnResult << 2);
100 
101  if (mbOwnHelp)
102  aData[4] |= (1 << 7);
103 
104  aData[5] = (mnTextType << 3);
105 
106  if (mbOwnStat)
107  aData[5] |= 1;
108 
109  if (mbProtected)
110  aData[5] |= (1 << 1);
111 
112  if (mbSize)
113  aData[5] |= (1 << 2);
114 
115  if (mbRecalc)
116  aData[5] |= (1 << 6);
117 
118  if (mbListBox)
119  aData[5] |= (1 << 7);
120 
121  aData[6] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen & 0xffff);
122  aData[7] = ::sal::static_int_cast<sal_uInt8>(mnMaxLen >> 8);
123  aData[8] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight & 0xffff);
124  aData[9] = ::sal::static_int_cast<sal_uInt8>(mnCheckboxHeight >> 8);
125 
126  pDataStrm->WriteBytes(aData, sizeof(aData));
127 
128  WriteOUString(pDataStrm, msName, true);
129 
130  if (mnType == 0)
131  WriteOUString(pDataStrm, msDefault, true);
132  else
133  pDataStrm->WriteUInt16( mnDefault );
134 
135  WriteOUString(pDataStrm, msFormat, true);
136  WriteOUString(pDataStrm, msHelp, true);
137  WriteOUString(pDataStrm, msStatus, true);
138  WriteOUString(pDataStrm, msMacroEnter, true);
139  WriteOUString(pDataStrm, msMacroExit, true);
140 
141  if (mnType == 2)
142  {
143  sal_uInt8 aData1[2] = { 0xff, 0xff };
144  pDataStrm->WriteBytes(aData1, sizeof(aData1));
145 
146  sal_uInt32 nListboxEntries = msListEntries.size();
147  pDataStrm->WriteUInt32( nListboxEntries );
148 
149  for (const OUString & rEntry : msListEntries)
150  WriteOUString(pDataStrm, rEntry, false);
151  }
152 
153  SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
154  pDataStrm->Tell() - nDataStt );
155 }
156 
157 }
158 
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString msName
Definition: WW8FFData.hxx:54
std::vector< OUString > msListEntries
Definition: WW8FFData.hxx:63
SvStream & WriteUInt16(sal_uInt16 nUInt16)
sal_uIntPtr sal_uLong
OUString msStatus
Definition: WW8FFData.hxx:59
void addListboxEntry(const OUString &rEntry)
Definition: WW8FFData.cxx:64
Dialog to specify the properties of date form field.
bool mbProtected
Definition: WW8FFData.hxx:41
sal_uInt16 mnCheckboxHeight
Definition: WW8FFData.hxx:51
sal_uInt8 mnResult
Definition: WW8FFData.hxx:36
SvStream & WriteUInt32(sal_uInt32 nUInt32)
Ret msword_cast(Param in)
A static_cast style cast for conversion of writer types to word's.
OUString msMacroEnter
Definition: WW8FFData.hxx:60
static void WriteString16(SvStream &rStrm, const OUString &rStr, bool bAddZero)
Definition: wrtww8.cxx:1768
sal_Int32 mnType
OUString msFormat
Definition: WW8FFData.hxx:57
static void WriteOUString(SvStream *pStream, const OUString &rStr, bool bAddZero)
Definition: WW8FFData.cxx:70
std::size_t WriteBytes(const void *pData, std::size_t nSize)
GUIDCNamePair const aData
void Write(SvStream *pDataStrm)
Definition: WW8FFData.cxx:78
sal_uInt8 mnTextType
Definition: WW8FFData.hxx:43
void setStatus(const OUString &rStatus)
Definition: WW8FFData.cxx:58
void setHelp(const OUString &rHelp)
Definition: WW8FFData.cxx:52
sal_uInt16 mnDefault
Definition: WW8FFData.hxx:56
unsigned char sal_uInt8
sal_uInt16 mnMaxLen
Definition: WW8FFData.hxx:48
sal_uInt8 mnType
Definition: WW8FFData.hxx:35
sal_uInt64 Tell() const
OUString msMacroExit
Definition: WW8FFData.hxx:61
OUString msDefault
Definition: WW8FFData.hxx:55
static void WriteLong(SvStream &rStrm, sal_Int32 nVal)
Definition: wrtww8.hxx:964
OUString msHelp
Definition: WW8FFData.hxx:58