1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <sal/log.hxx>
21 #include <rtl/ustrbuf.hxx>
22 #include "emfpstringformat.hxx"
24 namespace emfplushelper
26 EMFPStringFormat::EMFPStringFormat()
28 , stringFormatFlags(0)
32 , digitSubstitution(0)
45 static OUString
StringFormatFlags(sal_uInt32 flag
)
47 OUStringBuffer sFlags
;
49 // These are extracted from enum in emfpstringformat.hxx
50 if (flag
& StringFormatDirectionRightToLeft
)
51 sFlags
.append("StringFormatDirectionRightToLeft ");
53 if (flag
& StringFormatDirectionVertical
)
54 sFlags
.append("StringFormatDirectionVertical ");
56 if (flag
& StringFormatNoFitBlackBox
)
57 sFlags
.append("StringFormatNoFitBlackBox ");
59 if (flag
& StringFormatDisplayFormatControl
)
60 sFlags
.append("StringFormatDisplayFormatControl ");
62 if (flag
& StringFormatNoFontFallback
)
63 sFlags
.append("StringFormatNoFontFallback ");
65 if (flag
& StringFormatMeasureTrailingSpaces
)
66 sFlags
.append("StringFormatMeasureTrailingSpaces ");
68 if (flag
& StringFormatNoWrap
)
69 sFlags
.append("StringFormatNoWrap ");
71 if (flag
& StringFormatLineLimit
)
72 sFlags
.append("StringFormatLineLimit ");
74 if (flag
& StringFormatNoClip
)
75 sFlags
.append("StringFormatNoClip ");
77 if (flag
& StringFormatBypassGDI
)
78 sFlags
.append("StringFormatBypassGDI ");
80 // There will be 1 extra space in the end. It could be truncated, but
81 // as it is for SAL_INFO() only, it would not be important
82 return sFlags
.makeStringAndClear();
85 static OUString
StringAlignmentString(sal_uInt32 nAlignment
)
89 case StringAlignment::StringAlignmentNear
:
90 return "StringAlignmentNear";
91 case StringAlignment::StringAlignmentCenter
:
92 return "StringAlignmentCenter";
93 case StringAlignment::StringAlignmentFar
:
94 return "StringAlignmentFar";
96 assert(false && nAlignment
&& "invalid string alignment value");
101 static OUString
DigitSubstitutionString(sal_uInt32 nSubst
)
105 case StringDigitSubstitution::StringDigitSubstitutionUser
:
106 return "StringDigitSubstitutionUser";
107 case StringDigitSubstitution::StringDigitSubstitutionNone
:
108 return "StringDigitSubstitutionNone";
109 case StringDigitSubstitution::StringDigitSubstitutionNational
:
110 return "StringDigitSubstitutionNational";
111 case StringDigitSubstitution::StringDigitSubstitutionTraditional
:
112 return "StringDigitSubstitutionTraditional";
114 assert(false && nSubst
&& "invalid string digit substitution value");
119 static OUString
HotkeyPrefixString(sal_uInt32 nHotkey
)
123 case HotkeyPrefix::HotkeyPrefixNone
:
124 return "HotkeyPrefixNone";
125 case HotkeyPrefix::HotkeyPrefixShow
:
126 return "HotkeyPrefixShow";
127 case HotkeyPrefix::HotkeyPrefixHide
:
128 return "HotkeyPrefixHide";
130 assert(false && nHotkey
&& "invalid hotkey prefix value");
135 static OUString
StringTrimmingString(sal_uInt32 nTrimming
)
139 case StringTrimming::StringTrimmingNone
:
140 return "StringTrimmingNone";
141 case StringTrimming::StringTrimmingCharacter
:
142 return "StringTrimmingCharacter";
143 case StringTrimming::StringTrimmingWord
:
144 return "StringTrimmingWord";
145 case StringTrimming::StringTrimmingEllipsisCharacter
:
146 return "StringTrimmingEllipsisCharacter";
147 case StringTrimming::StringTrimmingEllipsisWord
:
148 return "StringTrimmingEllipsisWord";
149 case StringTrimming::StringTrimmingEllipsisPath
:
150 return "StringTrimmingEllipsisPath";
152 assert(false && nTrimming
&& "invalid trim value");
157 void EMFPStringFormat::Read(SvMemoryStream
&s
)
159 s
.ReadUInt32(header
).ReadUInt32(stringFormatFlags
).ReadUInt32(language
);
160 s
.ReadUInt32(stringAlignment
).ReadUInt32(lineAlign
).ReadUInt32(digitSubstitution
).ReadUInt32(digitLanguage
);
161 s
.ReadFloat(firstTabOffset
).ReadInt32(hotkeyPrefix
).ReadFloat(leadingMargin
).ReadFloat(trailingMargin
).ReadFloat(tracking
);
162 s
.ReadInt32(trimming
).ReadInt32(tabStopCount
).ReadInt32(rangeCount
);
163 // keep only the last 16 bits of language
165 digitLanguage
>>= 16;
166 SAL_WARN_IF((header
>> 12) != 0xdbc01, "drawinglayer.emf", "Invalid header - not 0xdbc01");
167 SAL_INFO("drawinglayer.emf", "EMF+\tString format");
168 SAL_INFO("drawinglayer.emf", "EMF+\t\tHeader: 0x" << std::hex
<< (header
>> 12));
169 SAL_INFO("drawinglayer.emf", "EMF+\t\tVersion: 0x" << (header
& 0x1fff) << std::dec
);
170 SAL_INFO("drawinglayer.emf", "EMF+\t\tStringFormatFlags: " << StringFormatFlags(stringFormatFlags
));
171 SAL_INFO("drawinglayer.emf", "EMF+\t\tLanguage: sublangid: 0x" << std::hex
<< (language
>> 10) << ", primarylangid: 0x" << (language
& 0xF800));
172 SAL_INFO("drawinglayer.emf", "EMF+\t\tLineAlign: " << StringAlignmentString(lineAlign
));
173 SAL_INFO("drawinglayer.emf", "EMF+\t\tDigitSubstitution: " << DigitSubstitutionString(digitSubstitution
));
174 SAL_INFO("drawinglayer.emf", "EMF+\t\tDigitLanguage: sublangid: 0x" << std::hex
<< (digitLanguage
>> 10) << ", primarylangid: 0x" << (digitLanguage
& 0xF800));
175 SAL_INFO("drawinglayer.emf", "EMF+\t\tFirstTabOffset: " << firstTabOffset
);
176 SAL_INFO("drawinglayer.emf", "EMF+\t\tHotkeyPrefix: " << HotkeyPrefixString(hotkeyPrefix
));
177 SAL_INFO("drawinglayer.emf", "EMF+\t\tLeadingMargin: " << leadingMargin
);
178 SAL_INFO("drawinglayer.emf", "EMF+\t\tTrailingMargin: " << trailingMargin
);
179 SAL_INFO("drawinglayer.emf", "EMF+\t\tTracking: " << tracking
);
180 SAL_INFO("drawinglayer.emf", "EMF+\t\tTrimming: " << StringTrimmingString(trimming
));
181 SAL_INFO("drawinglayer.emf", "EMF+\t\tTabStopCount: " << tabStopCount
);
182 SAL_INFO("drawinglayer.emf", "EMF+\t\tRangeCount: " << rangeCount
);
184 SAL_WARN_IF(digitSubstitution
!= StringDigitSubstitution::StringDigitSubstitutionNone
,
185 "drawinglayer.emf", "EMF+\t TODO EMFPStringFormat:digitSubstitution");
186 SAL_WARN_IF(firstTabOffset
!= 0.0, "drawinglayer.emf", "EMF+\t TODO EMFPStringFormat:firstTabOffset");
187 SAL_WARN_IF(hotkeyPrefix
!= HotkeyPrefix::HotkeyPrefixNone
, "drawinglayer.emf", "EMF+\t TODO EMFPStringFormat:hotkeyPrefix");
188 SAL_WARN_IF(tracking
!= 1.0, "drawinglayer.emf", "EMF+\t TODO EMFPStringFormat:tracking");
189 SAL_WARN_IF(trimming
!= StringTrimming::StringTrimmingNone
, "drawinglayer.emf", "EMF+\t TODO EMFPStringFormat:trimming");
190 SAL_WARN_IF(tabStopCount
, "drawinglayer.emf", "EMF+\t TODO EMFPStringFormat:tabStopCount");
191 SAL_WARN_IF(rangeCount
!= 0, "drawinglayer.emf", "EMF+\t TODO EMFPStringFormat:StringFormatData");
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */