android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / filter / ww8 / WW8FFData.cxx
blobea7288e349ab3e3d37689a259896c4a7c6778c8d
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 .
20 #include "WW8FFData.hxx"
21 #include <tools/stream.hxx>
22 #include "writerwordglue.hxx"
23 #include "wrtww8.hxx"
25 namespace sw
28 using sw::types::msword_cast;
30 WW8FFData::WW8FFData()
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)
47 WW8FFData::~WW8FFData()
51 void WW8FFData::setHelp(const OUString & rHelp)
53 msHelp = rHelp;
54 mbOwnHelp = true;
57 void WW8FFData::setStatus(const OUString & rStatus)
59 msStatus = rStatus;
60 mbOwnStat = true;
63 void WW8FFData::addListboxEntry(const OUString & rEntry)
65 mbListBox = true;
66 msListEntries.push_back(rEntry);
69 void WW8FFData::WriteOUString(SvStream * pDataStrm, const OUString & rStr,
70 bool bAddZero)
72 sal_uInt16 nStrLen = msword_cast<sal_uInt16>(rStr.getLength());
73 pDataStrm->WriteUInt16( nStrLen );
74 SwWW8Writer::WriteString16(*pDataStrm, rStr, bAddZero);
77 void WW8FFData::Write(SvStream * pDataStrm)
79 sal_uInt64 nDataStt = pDataStrm->Tell();
81 static const sal_uInt8 aHeader[] =
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
91 pDataStrm->WriteBytes(aHeader, sizeof(aHeader));
93 sal_uInt8 aData[10] = {
94 0xff, 0xff, 0xff, 0xff,
95 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
98 aData[4] = mnType | (mnResult << 2);
100 if (mbOwnHelp)
101 aData[4] |= (1 << 7);
103 aData[5] = (mnTextType << 3);
105 if (mbOwnStat)
106 aData[5] |= 1;
108 if (mbProtected)
109 aData[5] |= (1 << 1);
111 if (mbSize)
112 aData[5] |= (1 << 2);
114 if (mbRecalc)
115 aData[5] |= (1 << 6);
117 if (mbListBox)
118 aData[5] |= (1 << 7);
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);
125 pDataStrm->WriteBytes(aData, sizeof(aData));
127 WriteOUString(pDataStrm, msName, true);
129 if (mnType == 0)
130 WriteOUString(pDataStrm, msDefault, true);
131 else
132 pDataStrm->WriteUInt16( mnDefault );
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);
140 if (mnType == 2)
142 sal_uInt8 aData1[2] = { 0xff, 0xff };
143 pDataStrm->WriteBytes(aData1, sizeof(aData1));
145 sal_uInt32 nListboxEntries = msListEntries.size();
146 pDataStrm->WriteUInt32( nListboxEntries );
148 for (const OUString & rEntry : msListEntries)
149 WriteOUString(pDataStrm, rEntry, false);
152 SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
153 pDataStrm->Tell() - nDataStt );
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */