1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 //Implementierung der Klasse RegistrationContextInformation.
4 #include "registrationcontextinformation.hxx"
5 #include "msihelper.hxx"
7 #define WINDOWS_LEAN_AND_MEAN
12 namespace /* private */
14 const int MAX_REGKEY_LENGTH_WIN9X
= 16300;
17 RegistrationContextInformation::RegistrationContextInformation(MSIHANDLE hMsi
, const std::wstring
& OpenOfficeExecutablePath
) :
19 m_OOExecPath(OpenOfficeExecutablePath
)
21 assert(m_OOExecPath
.length());
22 ExtractOpenOfficeExecNameFromPath();
23 m_OOIconPath
= m_OOExecPath
.replace(m_OOExecPath
.find(m_OOExecName
), m_OOExecName
.size(), std::wstring(TEXT("soffice.bin")));
26 std::wstring
RegistrationContextInformation::GetWordDocumentDisplayName() const
29 GetMsiProp(msihandle_
, TEXT("STR_MS_WORD_DOCUMENT"), str
);
33 std::wstring
RegistrationContextInformation::GetWordDocumentFileExtension() const
35 return std::wstring(TEXT(".doc"));
38 std::wstring
RegistrationContextInformation::GetWordDocumentDefaultIconEntry() const
40 return m_OOIconPath
+ std::wstring(TEXT(",1"));
43 std::wstring
RegistrationContextInformation::GetWordDocumentDefaultShellCommand() const
45 return std::wstring(TEXT("open"));
48 std::wstring
RegistrationContextInformation::GetMOOXWordDocumentDisplayName() const
51 str
= TEXT("Microsoft Word 2007 Document");
55 std::wstring
RegistrationContextInformation::GetMOOXWordDocumentFileExtension() const
57 return std::wstring(TEXT(".docx"));
60 std::wstring
RegistrationContextInformation::GetWordTemplateDisplayName() const
63 GetMsiProp(msihandle_
, TEXT("STR_MS_WORD_TEMPLATE"), str
);
67 std::wstring
RegistrationContextInformation::GetWordTemplateFileExtension() const
69 return std::wstring(TEXT(".dot"));
72 std::wstring
RegistrationContextInformation::GetWordTemplateDefaultIconEntry() const
74 return m_OOIconPath
+ std::wstring(TEXT(",2"));
77 std::wstring
RegistrationContextInformation::GetWordTemplateDefaultShellCommand() const
79 return std::wstring(TEXT("new"));
82 std::wstring
RegistrationContextInformation::GetRtfDocumentDisplayName() const
85 GetMsiProp(msihandle_
, TEXT("STR_RTF_DOCUMENT"), str
);
89 std::wstring
RegistrationContextInformation::GetRtfDocumentFileExtension() const
91 return std::wstring(TEXT(".rtf"));
94 std::wstring
RegistrationContextInformation::GetRtfDocumentDefaultIconEntry() const
96 return m_OOIconPath
+ std::wstring(TEXT(",1"));
99 std::wstring
RegistrationContextInformation::GetRtfDocumentDefaultShellCommand() const
101 return std::wstring(TEXT("open"));
104 std::wstring
RegistrationContextInformation::GetExcelSheetDisplayName() const
107 GetMsiProp(msihandle_
, TEXT("STR_MS_EXCEL_WORKSHEET"), str
);
111 std::wstring
RegistrationContextInformation::GetExcelSheetFileExtension() const
113 return std::wstring(TEXT(".xls"));
116 std::wstring
RegistrationContextInformation::GetExcelSheetDefaultIconEntry() const
118 return m_OOIconPath
+ std::wstring(TEXT(",3"));
121 std::wstring
RegistrationContextInformation::GetExcelSheetDefaultShellCommand() const
123 return std::wstring(TEXT("open"));
126 std::wstring
RegistrationContextInformation::GetMOOXExcelSheetDisplayName() const
129 str
= TEXT("Microsoft Excel 2007 Spreadsheet");
133 std::wstring
RegistrationContextInformation::GetMOOXExcelSheetFileExtension() const
135 return std::wstring(TEXT(".xlsx"));
138 std::wstring
RegistrationContextInformation::GetExcelTemplateDisplayName() const
141 GetMsiProp(msihandle_
, TEXT("STR_MS_EXCEL_TEMPLATE"), str
);
145 std::wstring
RegistrationContextInformation::GetExcelTemplateFileExtension() const
147 return std::wstring(TEXT(".xlt"));
150 std::wstring
RegistrationContextInformation::GetExcelTemplateDefaultIconEntry() const
152 return m_OOIconPath
+ std::wstring(TEXT(",4"));
155 std::wstring
RegistrationContextInformation::GetExcelTemplateDefaultShellCommand() const
157 return std::wstring(TEXT("new"));
160 std::wstring
RegistrationContextInformation::GetPowerPointDocumentDisplayName() const
163 GetMsiProp(msihandle_
, TEXT("STR_MS_POWERPOINT_PRESENTATION"), str
);
167 std::wstring
RegistrationContextInformation::GetPowerPointDocumentFileExtension() const
169 return std::wstring(TEXT(".ppt"));
172 std::wstring
RegistrationContextInformation::GetPowerPointDocumentDefaultIconEntry() const
174 return m_OOIconPath
+ std::wstring(TEXT(",7"));
177 std::wstring
RegistrationContextInformation::GetPowerPointDocumentDefaultShellCommand() const
179 return std::wstring(TEXT("open"));
182 std::wstring
RegistrationContextInformation::GetMOOXPowerPointDocumentDisplayName() const
185 str
= TEXT("Microsoft PowerPoint 2007 Presentation");
189 std::wstring
RegistrationContextInformation::GetMOOXPowerPointDocumentFileExtension() const
191 return std::wstring(TEXT(".pptx"));
194 std::wstring
RegistrationContextInformation::GetPowerPointTemplateDisplayName() const
197 GetMsiProp(msihandle_
, TEXT("STR_MS_POWERPOINT_TEMPLATE"), str
);
201 std::wstring
RegistrationContextInformation::GetPowerPointTemplateFileExtension() const
203 return std::wstring(TEXT(".pot"));
206 std::wstring
RegistrationContextInformation::GetPowerPointTemplateDefaultIconEntry() const
208 return m_OOIconPath
+ std::wstring(TEXT(",8"));
211 std::wstring
RegistrationContextInformation::GetPowerPointTemplateDefaultShellCommand() const
213 return std::wstring(TEXT("new"));
216 std::wstring
RegistrationContextInformation::GetPowerPointShowDisplayName() const
219 GetMsiProp(msihandle_
, TEXT("STR_MS_POWERPOINT_SHOW"), str
);
223 std::wstring
RegistrationContextInformation::GetPowerPointShowFileExtension() const
225 return std::wstring(TEXT(".pps"));
228 std::wstring
RegistrationContextInformation::GetPowerPointShowDefaultIconEntry() const
230 return m_OOIconPath
+ std::wstring(TEXT(",7"));
233 std::wstring
RegistrationContextInformation::GetPowerPointShowDefaultShellCommand() const
235 return std::wstring(TEXT("open"));
238 //----------------------------------------------
239 /** The string for the "New" command that should appear
240 in the Explorer context menu when someone right
241 clicks a Microsoft document
243 std::wstring
RegistrationContextInformation::ShellNewCommandDisplayName() const
246 GetMsiProp(msihandle_
, TEXT("STR_NEW_DISPLAY_NAME"), str
);
247 std::wstring::size_type idx
= str
.find(TEXT("~"));
249 if(std::wstring::npos
!= idx
)
250 str
.replace(idx
, 1, TEXT("&"));
255 /** The string for the "Edit" command that should
256 appear in the Explorer context menu when someone
257 right clicks a document
259 std::wstring
RegistrationContextInformation::ShellEditCommandDisplayName() const
262 GetMsiProp(msihandle_
, TEXT("STR_EDIT"), str
);
263 std::wstring::size_type idx
= str
.find(TEXT("~"));
265 if(std::wstring::npos
!= idx
)
266 str
.replace(idx
, 1, TEXT("&"));
271 std::wstring
RegistrationContextInformation::GetOpenOfficeFriendlyAppName() const
274 GetMsiProp(msihandle_
, TEXT("ProductName"), str
);
278 std::wstring
RegistrationContextInformation::GetOpenOfficeExecutablePath() const
283 //----------------------------------------------
284 /** The name of the executable (currently "soffice.exe"
285 but may change in the future, who knows) */
286 std::wstring
RegistrationContextInformation::GetOpenOfficeExecutableName() const
291 /** A command line for the specified shell command */
292 std::wstring
RegistrationContextInformation::GetOpenOfficeCommandline(SHELL_COMMAND ShellCommand
,
293 OFFICE_APPLICATION OfficeApp
) const
295 // quote the path to OpenOffice, this is important
297 std::wstring cmd_line
= std::wstring(TEXT("\"")) + m_OOExecPath
+ std::wstring(TEXT("\""));
302 cmd_line
+= std::wstring( TEXT( " -writer" ) );
305 cmd_line
+= std::wstring( TEXT( " -calc" ) );
308 cmd_line
+= std::wstring( TEXT( " -impress" ) );
310 case Office
: // default to std command line
312 // default: no default to find new added enums at compile time
317 cmd_line
+= std::wstring(TEXT(" -n \"%1\""));
320 cmd_line
+= std::wstring(TEXT(" -o \"%1\""));
323 cmd_line
+= std::wstring(TEXT(" -p \"%1\""));
326 cmd_line
+= std::wstring(TEXT(" -pt \"%2\" \"%1\""));
328 // default: no default to find new added enums at compile time
333 void RegistrationContextInformation::ExtractOpenOfficeExecNameFromPath()
335 std::wstring::size_type idx
= m_OOExecPath
.find_last_of(TEXT('\\'));
336 assert(idx
!= std::wstring::npos
); // assert valid path
337 m_OOExecName
= m_OOExecPath
.substr(idx
+ 1);
340 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */