1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/log.hxx>
#include "emfpstringformat.hxx"
namespace emfplushelper
{
EMFPStringFormat::EMFPStringFormat()
: header(0)
, stringFormatFlags(0)
, language(0)
, stringAlignment(0)
, lineAlign(0)
, digitSubstitution(0)
, digitLanguage(0)
, firstTabOffset(0.0)
, hotkeyPrefix(0)
, leadingMargin(0.0)
, trailingMargin(0.0)
, tracking(1.0)
, trimming(0)
, tabStopCount(0)
, rangeCount(0)
{
}
static OUString StringFormatFlags(sal_uInt32 flag)
{
OUString sFlags;
if (flag & StringFormatDirectionRightToLeft)
sFlags = sFlags.concat("StringFormatDirectionRightToLeft");
if (flag & StringFormatDirectionRightToLeft)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatDirectionRightToLeft");
}
if (flag & StringFormatNoFitBlackBox)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatNoFitBlackBox");
}
if (flag & StringFormatDisplayFormatControl)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatDisplayFormatControl");
}
if (flag & StringFormatNoFontFallback)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatNoFontFallback");
}
if (flag & StringFormatMeasureTrailingSpaces)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatMeasureTrailingSpaces");
}
if (flag & StringFormatNoWrap)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatNoWrap");
}
if (flag & StringFormatLineLimit)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatLineLimit");
}
if (flag & StringFormatNoClip)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatNoClip");
}
if (flag & StringFormatBypassGDI)
{
if (!sFlags.isEmpty())
sFlags = sFlags.concat(", ");
sFlags = sFlags.concat("StringFormatBypassGDI");
}
return sFlags;
}
static OUString StringAlignmentString(sal_uInt32 nAlignment)
{
switch(nAlignment)
{
case StringAlignment::StringAlignmentNear:
return "StringAlignmentNear";
case StringAlignment::StringAlignmentCenter:
return "StringAlignmentCenter";
case StringAlignment::StringAlignmentFar:
return "StringAlignmentFar";
default:
assert(false && nAlignment && "invalid string alignment value");
return "INVALID";
}
}
static OUString DigitSubstitutionString(sal_uInt32 nSubst)
{
switch(nSubst)
{
case StringDigitSubstitution::StringDigitSubstitutionUser:
return "StringDigitSubstitutionUser";
case StringDigitSubstitution::StringDigitSubstitutionNone:
return "StringDigitSubstitutionNone";
case StringDigitSubstitution::StringDigitSubstitutionNational:
return "StringDigitSubstitutionNational";
case StringDigitSubstitution::StringDigitSubstitutionTraditional:
return "StringDigitSubstitutionTraditional";
default:
assert(false && nSubst && "invalid string digit substitution value");
return "INVALID";
}
}
static OUString HotkeyPrefixString(sal_uInt32 nHotkey)
{
switch(nHotkey)
{
case HotkeyPrefix::HotkeyPrefixNone:
return "HotkeyPrefixNone";
case HotkeyPrefix::HotkeyPrefixShow:
return "HotkeyPrefixShow";
case HotkeyPrefix::HotkeyPrefixHide:
return "HotkeyPrefixHide";
default:
assert(false && nHotkey && "invalid hotkey prefix value");
return "INVALID";
}
}
static OUString StringTrimmingString(sal_uInt32 nTrimming)
{
switch(nTrimming)
{
case StringTrimming::StringTrimmingNone:
return "StringTrimmingNone";
case StringTrimming::StringTrimmingCharacter:
return "StringTrimmingCharacter";
case StringTrimming::StringTrimmingWord:
return "StringTrimmingWord";
case StringTrimming::StringTrimmingEllipsisCharacter:
return "StringTrimmingEllipsisCharacter";
case StringTrimming::StringTrimmingEllipsisWord:
return "StringTrimmingEllipsisWord";
case StringTrimming::StringTrimmingEllipsisPath:
return "StringTrimmingEllipsisPath";
default:
assert(false && nTrimming && "invalid trim value");
return "INVALID";
}
}
void EMFPStringFormat::Read(SvMemoryStream &s)
{
s.ReadUInt32(header).ReadUInt32(stringFormatFlags).ReadUInt32(language);
s.ReadUInt32(stringAlignment).ReadUInt32(lineAlign).ReadUInt32(digitSubstitution).ReadUInt32(digitLanguage);
s.ReadFloat(firstTabOffset).ReadInt32(hotkeyPrefix).ReadFloat(leadingMargin).ReadFloat(trailingMargin).ReadFloat(tracking);
s.ReadInt32(trimming).ReadInt32(tabStopCount).ReadInt32(rangeCount);
// keep only the last 16 bits of language
language >>= 16;
digitLanguage >>= 16;
SAL_WARN_IF((header >> 12) != 0xdbc01, "drawinglayer", "Invalid header - not 0xdbc01");
SAL_INFO("drawinglayer", "EMF+\tString format");
SAL_INFO("drawinglayer", "EMF+\t\tHeader: 0x" << std::hex << (header >> 12));
SAL_INFO("drawinglayer", "EMF+\t\tVersion: 0x" << (header & 0x1fff) << std::dec);
SAL_INFO("drawinglayer", "EMF+\t\tStringFormatFlags: " << StringFormatFlags(stringFormatFlags));
SAL_INFO("drawinglayer", "EMF+\t\tLanguage: sublangid: 0x" << std::hex << (language >> 10) << ", primarylangid: 0x" << (language & 0xF800));
SAL_INFO("drawinglayer", "EMF+\t\tLineAlign: " << StringAlignmentString(lineAlign));
SAL_INFO("drawinglayer", "EMF+\t\tDigitSubstitution: " << DigitSubstitutionString(digitSubstitution));
SAL_INFO("drawinglayer", "EMF+\t\tDigitLanguage: sublangid: 0x" << std::hex << (digitLanguage >> 10) << ", primarylangid: 0x" << (digitLanguage & 0xF800));
SAL_INFO("drawinglayer", "EMF+\t\tFirstTabOffset: " << firstTabOffset);
SAL_INFO("drawinglayer", "EMF+\t\tHotkeyPrefix: " << HotkeyPrefixString(hotkeyPrefix));
SAL_INFO("drawinglayer", "EMF+\t\tLeadingMargin: " << leadingMargin);
SAL_INFO("drawinglayer", "EMF+\t\tTrailingMargin: " << trailingMargin);
SAL_INFO("drawinglayer", "EMF+\t\tTracking: " << tracking);
SAL_INFO("drawinglayer", "EMF+\t\tTrimming: " << StringTrimmingString(trimming));
SAL_INFO("drawinglayer", "EMF+\t\tTabStopCount: " << tabStopCount);
SAL_INFO("drawinglayer", "EMF+\t\tRangeCount: " << rangeCount);
SAL_WARN_IF(stringAlignment != StringAlignment::StringAlignmentNear, "drawinglayer", "EMF+\t TODO EMFPStringFormat:StringAlignment");
SAL_WARN_IF(lineAlign != StringAlignment::StringAlignmentNear, "drawinglayer", "EMF+\t TODO EMFPStringFormat:lineAlign");
SAL_WARN_IF(digitSubstitution != StringDigitSubstitution::StringDigitSubstitutionNone,
"drawinglayer", "EMF+\t TODO EMFPStringFormat:digitSubstitution");
SAL_WARN_IF(firstTabOffset != 0.0, "drawinglayer", "EMF+\t TODO EMFPStringFormat:firstTabOffset");
SAL_WARN_IF(hotkeyPrefix != HotkeyPrefix::HotkeyPrefixNone, "drawinglayer", "EMF+\t TODO EMFPStringFormat:hotkeyPrefix");
SAL_WARN_IF(leadingMargin != 0.0, "drawinglayer", "EMF+\t TODO EMFPStringFormat:leadingMargin");
SAL_WARN_IF(trailingMargin != 0.0, "drawinglayer", "EMF+\t TODO EMFPStringFormat:trailingMargin");
SAL_WARN_IF(tracking != 1.0, "drawinglayer", "EMF+\t TODO EMFPStringFormat:tracking");
SAL_WARN_IF(trimming != StringTrimming::StringTrimmingNone, "drawinglayer", "EMF+\t TODO EMFPStringFormat:trimming");
SAL_WARN_IF(tabStopCount, "drawinglayer", "EMF+\t TODO EMFPStringFormat:tabStopCount");
SAL_WARN_IF(rangeCount, "drawinglayer", "EMF+\t TODO EMFPStringFormat:StringFormatData");
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|