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