132b1fd08SAndrew Rist /**************************************************************
232b1fd08SAndrew Rist  *
332b1fd08SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
432b1fd08SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
532b1fd08SAndrew Rist  * distributed with this work for additional information
632b1fd08SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
732b1fd08SAndrew Rist  * to you under the Apache License, Version 2.0 (the
832b1fd08SAndrew Rist  * "License"); you may not use this file except in compliance
932b1fd08SAndrew Rist  * with the License.  You may obtain a copy of the License at
1032b1fd08SAndrew Rist  *
1132b1fd08SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1232b1fd08SAndrew Rist  *
1332b1fd08SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1432b1fd08SAndrew Rist  * software distributed under the License is distributed on an
1532b1fd08SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1632b1fd08SAndrew Rist  * KIND, either express or implied.  See the License for the
1732b1fd08SAndrew Rist  * specific language governing permissions and limitations
1832b1fd08SAndrew Rist  * under the License.
1932b1fd08SAndrew Rist  *
2032b1fd08SAndrew Rist  *************************************************************/
2132b1fd08SAndrew Rist 
22cdf0e10cSrcweir //Implementierung der Klasse RegistrationContextInformation.
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <assert.h>
25cdf0e10cSrcweir #include "registrationcontextinformation.hxx"
26cdf0e10cSrcweir #include "msihelper.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #define WINDOWS_LEAN_AND_MEAN
29cdf0e10cSrcweir #include <windows.h>
30cdf0e10cSrcweir #include <assert.h>
31cdf0e10cSrcweir #include <algorithm>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace /* private */
34cdf0e10cSrcweir {
35cdf0e10cSrcweir 	const int MAX_REGKEY_LENGTH_WIN9X = 16300;
36cdf0e10cSrcweir }
37cdf0e10cSrcweir 
RegistrationContextInformation(MSIHANDLE hMsi,const std::wstring & OpenOfficeExecutablePath)38cdf0e10cSrcweir RegistrationContextInformation::RegistrationContextInformation(MSIHANDLE hMsi, const std::wstring& OpenOfficeExecutablePath) :
39cdf0e10cSrcweir 	msihandle_(hMsi),
40cdf0e10cSrcweir 	m_IsWin9x(true),
41cdf0e10cSrcweir 	m_OOExecPath(OpenOfficeExecutablePath)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 	OSVERSIONINFOA osverinfo;
44cdf0e10cSrcweir     ZeroMemory(&osverinfo, sizeof(osverinfo));
45cdf0e10cSrcweir     osverinfo.dwOSVersionInfoSize = sizeof(osverinfo);
46cdf0e10cSrcweir     GetVersionExA(&osverinfo);
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     m_IsWin9x = (osverinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
49cdf0e10cSrcweir 	assert(m_OOExecPath.length());
50cdf0e10cSrcweir 	ExtractOpenOfficeExecNameFromPath();
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
GetWordDocumentDisplayName() const53cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetWordDocumentDisplayName() const
54cdf0e10cSrcweir {
55cdf0e10cSrcweir 	std::wstring str;
56cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_MS_WORD_DOCUMENT"), str);
57cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
58cdf0e10cSrcweir 		str = TEXT("Microsoft Word Document");
59cdf0e10cSrcweir 	return str;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
GetWordDocumentFileExtension() const62cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetWordDocumentFileExtension() const
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	return std::wstring(TEXT(".doc"));
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
GetWordDocumentDefaultIconEntry() const67cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetWordDocumentDefaultIconEntry() const
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	return m_OOExecPath + std::wstring(TEXT(",1"));
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
GetWordDocumentDefaultShellCommand() const72cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetWordDocumentDefaultShellCommand() const
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	return std::wstring(TEXT("open"));
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
GetWordTemplateDisplayName() const77cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetWordTemplateDisplayName() const
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	std::wstring str;
80cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_MS_WORD_TEMPLATE"), str);
81cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
82cdf0e10cSrcweir 		str = TEXT("Microsoft Word Template");
83cdf0e10cSrcweir 	return str;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
GetWordTemplateFileExtension() const86cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetWordTemplateFileExtension() const
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	return std::wstring(TEXT(".dot"));
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
GetWordTemplateDefaultIconEntry() const91cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetWordTemplateDefaultIconEntry() const
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	return m_OOExecPath + std::wstring(TEXT(",2"));
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
GetWordTemplateDefaultShellCommand() const96cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetWordTemplateDefaultShellCommand() const
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	return std::wstring(TEXT("new"));
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
GetRtfDocumentDisplayName() const101cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetRtfDocumentDisplayName() const
102cdf0e10cSrcweir {
103cdf0e10cSrcweir 	std::wstring str;
104cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_RTF_DOCUMENT"), str);
105cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
106cdf0e10cSrcweir 		str = TEXT("Rich Text Document");
107cdf0e10cSrcweir 	return str;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
GetRtfDocumentFileExtension() const110cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetRtfDocumentFileExtension() const
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	return std::wstring(TEXT(".rtf"));
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
GetRtfDocumentDefaultIconEntry() const115cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetRtfDocumentDefaultIconEntry() const
116cdf0e10cSrcweir {
117cdf0e10cSrcweir 	return m_OOExecPath + std::wstring(TEXT(",1"));
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
GetRtfDocumentDefaultShellCommand() const120cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetRtfDocumentDefaultShellCommand() const
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	return std::wstring(TEXT("open"));
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
GetExcelSheetDisplayName() const125cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetExcelSheetDisplayName() const
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	std::wstring str;
128cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_MS_EXCEL_WORKSHEET"), str);
129cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
130cdf0e10cSrcweir 		str = TEXT("Microsoft Excel Worksheet");
131cdf0e10cSrcweir 	return str;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
GetExcelSheetFileExtension() const134cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetExcelSheetFileExtension() const
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	return std::wstring(TEXT(".xls"));
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
GetExcelSheetDefaultIconEntry() const139cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetExcelSheetDefaultIconEntry() const
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	return m_OOExecPath + std::wstring(TEXT(",3"));
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
GetExcelSheetDefaultShellCommand() const144cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetExcelSheetDefaultShellCommand() const
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	return std::wstring(TEXT("open"));
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
GetExcelTemplateDisplayName() const149cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetExcelTemplateDisplayName() const
150cdf0e10cSrcweir {
151cdf0e10cSrcweir 	std::wstring str;
152cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_MS_EXCEL_TEMPLATE"), str);
153cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
154cdf0e10cSrcweir 		str = TEXT("Microsoft Excel Template");
155cdf0e10cSrcweir 	return str;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
GetExcelTemplateFileExtension() const158cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetExcelTemplateFileExtension() const
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	return std::wstring(TEXT(".xlt"));
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
GetExcelTemplateDefaultIconEntry() const163cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetExcelTemplateDefaultIconEntry() const
164cdf0e10cSrcweir {
165cdf0e10cSrcweir 	return m_OOExecPath + std::wstring(TEXT(",4"));
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
GetExcelTemplateDefaultShellCommand() const168cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetExcelTemplateDefaultShellCommand() const
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	return std::wstring(TEXT("new"));
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
GetPowerPointDocumentDisplayName() const173cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointDocumentDisplayName() const
174cdf0e10cSrcweir {
175cdf0e10cSrcweir 	std::wstring str;
176cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_MS_POWERPOINT_PRESENTATION"), str);
177cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
178cdf0e10cSrcweir 		str = TEXT("Microsoft PowerPoint Presentation");
179cdf0e10cSrcweir 	return str;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
GetPowerPointDocumentFileExtension() const182cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointDocumentFileExtension() const
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	return std::wstring(TEXT(".ppt"));
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
GetPowerPointDocumentDefaultIconEntry() const187cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointDocumentDefaultIconEntry() const
188cdf0e10cSrcweir {
189cdf0e10cSrcweir 	return m_OOExecPath + std::wstring(TEXT(",7"));
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
GetPowerPointDocumentDefaultShellCommand() const192cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointDocumentDefaultShellCommand() const
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	return std::wstring(TEXT("open"));
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
GetPowerPointTemplateDisplayName() const197cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointTemplateDisplayName() const
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	std::wstring str;
200cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_MS_POWERPOINT_TEMPLATE"), str);
201cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
202cdf0e10cSrcweir 		str = TEXT("Microsoft PowerPoint Template");
203cdf0e10cSrcweir 	return str;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir 
GetPowerPointTemplateFileExtension() const206cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointTemplateFileExtension() const
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	return std::wstring(TEXT(".pot"));
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
GetPowerPointTemplateDefaultIconEntry() const211cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointTemplateDefaultIconEntry() const
212cdf0e10cSrcweir {
213cdf0e10cSrcweir 	return m_OOExecPath + std::wstring(TEXT(",8"));
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
GetPowerPointTemplateDefaultShellCommand() const216cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointTemplateDefaultShellCommand() const
217cdf0e10cSrcweir {
218cdf0e10cSrcweir 	return std::wstring(TEXT("new"));
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
GetPowerPointShowDisplayName() const221cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointShowDisplayName() const
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     std::wstring str;
224cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_MS_POWERPOINT_SHOW"), str);
225cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
226cdf0e10cSrcweir 		str = TEXT("Microsoft PowerPoint Show");
227cdf0e10cSrcweir 	return str;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir 
GetPowerPointShowFileExtension() const230cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointShowFileExtension() const
231cdf0e10cSrcweir {
232cdf0e10cSrcweir     return std::wstring(TEXT(".pps"));
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
GetPowerPointShowDefaultIconEntry() const235cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointShowDefaultIconEntry() const
236cdf0e10cSrcweir {
237cdf0e10cSrcweir     return m_OOExecPath + std::wstring(TEXT(",7"));
238cdf0e10cSrcweir }
239cdf0e10cSrcweir 
GetPowerPointShowDefaultShellCommand() const240cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetPowerPointShowDefaultShellCommand() const
241cdf0e10cSrcweir {
242cdf0e10cSrcweir     return std::wstring(TEXT("open"));
243cdf0e10cSrcweir }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir //----------------------------------------------
246cdf0e10cSrcweir /** The string for the "New" command that should appear
247cdf0e10cSrcweir 	in the Explorer context menu when someone right
248cdf0e10cSrcweir 	clicks a Microsoft document
249cdf0e10cSrcweir */
ShellNewCommandDisplayName() const250cdf0e10cSrcweir std::wstring RegistrationContextInformation::ShellNewCommandDisplayName() const
251cdf0e10cSrcweir {
252cdf0e10cSrcweir 	std::wstring str;
253cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_NEW_DISPLAY_NAME"), str);
254cdf0e10cSrcweir 	std::wstring::size_type idx = str.find(TEXT("~"));
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	if(std::wstring::npos != idx)
257cdf0e10cSrcweir 		str.replace(idx, 1, TEXT("&"));
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
260cdf0e10cSrcweir 		str = TEXT("&New");
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 	return str;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir /** The string for the "Edit" command that should
266cdf0e10cSrcweir 	appear in the Explorer context menu when someone
267cdf0e10cSrcweir 	right clicks a document
268cdf0e10cSrcweir */
ShellEditCommandDisplayName() const269cdf0e10cSrcweir std::wstring RegistrationContextInformation::ShellEditCommandDisplayName() const
270cdf0e10cSrcweir {
271cdf0e10cSrcweir 	std::wstring str;
272cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("STR_EDIT"), str);
273cdf0e10cSrcweir 	std::wstring::size_type idx = str.find(TEXT("~"));
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	if(std::wstring::npos != idx)
276cdf0e10cSrcweir 		str.replace(idx, 1, TEXT("&"));
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 	if (m_IsWin9x && !IsConvertableToAnsi(str))
279cdf0e10cSrcweir 		str = TEXT("&Edit");
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	return str;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
GetOpenOfficeFriendlyAppName() const284cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetOpenOfficeFriendlyAppName() const
285cdf0e10cSrcweir {
286cdf0e10cSrcweir     std::wstring str;
287cdf0e10cSrcweir     GetMsiProp(msihandle_, TEXT("ProductName"), str);
288cdf0e10cSrcweir 	return str;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
GetOpenOfficeExecutablePath() const291cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetOpenOfficeExecutablePath() const
292cdf0e10cSrcweir {
293cdf0e10cSrcweir 	return m_OOExecPath;
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir //----------------------------------------------
297cdf0e10cSrcweir /** The name of the executable (currently "soffice.exe"
298cdf0e10cSrcweir 	but may change in the future, who knows) */
GetOpenOfficeExecutableName() const299cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetOpenOfficeExecutableName() const
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	return m_OOExecName;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir /** A command line for the specified shell command */
GetOpenOfficeCommandline(SHELL_COMMAND ShellCommand,OFFICE_APPLICATION OfficeApp) const305cdf0e10cSrcweir std::wstring RegistrationContextInformation::GetOpenOfficeCommandline(SHELL_COMMAND ShellCommand,
306cdf0e10cSrcweir                                                                       OFFICE_APPLICATION OfficeApp) const
307cdf0e10cSrcweir {
308*ff3f4ebcSOliver-Rainer Wittmann 	// quote the path to Apache OpenOffice, this is important for Windows 9x
309cdf0e10cSrcweir 	std::wstring cmd_line = std::wstring(TEXT("\"")) + m_OOExecPath + std::wstring(TEXT("\""));
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     switch( OfficeApp )
312cdf0e10cSrcweir     {
313cdf0e10cSrcweir 	case Writer:
314cdf0e10cSrcweir 		cmd_line += std::wstring( TEXT( " -writer" ) );
315cdf0e10cSrcweir 		break;
316cdf0e10cSrcweir 	case Calc:
317cdf0e10cSrcweir 		cmd_line += std::wstring( TEXT( " -calc" ) );
318cdf0e10cSrcweir 		break;
319cdf0e10cSrcweir 	case Impress:
320cdf0e10cSrcweir 		cmd_line += std::wstring( TEXT( " -impress" ) );
321cdf0e10cSrcweir 		break;
322cdf0e10cSrcweir     case Office: // default to std command line
323cdf0e10cSrcweir         break;
324cdf0e10cSrcweir 	// default: no default to find new added enums at compile time
325cdf0e10cSrcweir     }
326cdf0e10cSrcweir 	switch(ShellCommand)
327cdf0e10cSrcweir 	{
328cdf0e10cSrcweir     case New:
329cdf0e10cSrcweir         cmd_line += std::wstring(TEXT(" -n \"%1\""));
330cdf0e10cSrcweir         break;
331cdf0e10cSrcweir     case Open:
332cdf0e10cSrcweir         cmd_line += std::wstring(TEXT(" -o \"%1\""));
333cdf0e10cSrcweir         break;
334cdf0e10cSrcweir     case Print:
335cdf0e10cSrcweir         cmd_line += std::wstring(TEXT(" -p \"%1\""));
336cdf0e10cSrcweir         break;
337cdf0e10cSrcweir     case Printto:
338cdf0e10cSrcweir         cmd_line += std::wstring(TEXT(" -pt \"%2\" \"%1\""));
339cdf0e10cSrcweir         break;
340cdf0e10cSrcweir     // default: no default to find new added enums at compile time
341cdf0e10cSrcweir 	}
342cdf0e10cSrcweir 	return cmd_line;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
IsConvertableToAnsi(const std::wstring & String) const345cdf0e10cSrcweir bool RegistrationContextInformation::IsConvertableToAnsi(const std::wstring& String) const
346cdf0e10cSrcweir {
347cdf0e10cSrcweir 	char buff[MAX_REGKEY_LENGTH_WIN9X];
348cdf0e10cSrcweir 	BOOL bUsedDefChar = 0;
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	if (String.length() > 0)
351cdf0e10cSrcweir 	{
352cdf0e10cSrcweir         WideCharToMultiByte(
353cdf0e10cSrcweir 			CP_ACP,
354cdf0e10cSrcweir 			WC_COMPOSITECHECK | WC_DEFAULTCHAR,
355cdf0e10cSrcweir 			String.c_str(),
356cdf0e10cSrcweir 			static_cast<int>(String.length()),
357cdf0e10cSrcweir 			buff,
358cdf0e10cSrcweir 			sizeof(buff),
359cdf0e10cSrcweir 			NULL,
360cdf0e10cSrcweir 			&bUsedDefChar);
361cdf0e10cSrcweir 	}
362cdf0e10cSrcweir     return !bUsedDefChar;
363cdf0e10cSrcweir }
364cdf0e10cSrcweir 
ExtractOpenOfficeExecNameFromPath()365cdf0e10cSrcweir void RegistrationContextInformation::ExtractOpenOfficeExecNameFromPath()
366cdf0e10cSrcweir {
367cdf0e10cSrcweir     std::wstring::size_type idx = m_OOExecPath.find_last_of(TEXT('\\'));
368cdf0e10cSrcweir     assert(idx != std::wstring::npos); // assert valid path
369cdf0e10cSrcweir 	m_OOExecName = m_OOExecPath.substr(idx + 1);
370cdf0e10cSrcweir }
371cdf0e10cSrcweir 
372