1 // MsOfficeDocumentInformation.h: Schnittstelle f�r die Klasse MsOfficeDocumentInformation.
2 //
3 //////////////////////////////////////////////////////////////////////
4 
5 #ifndef _REGISTRATIONCONTEXTINFORMATION_HXX_
6 #define _REGISTRATIONCONTEXTINFORMATION_HXX_
7 
8 #ifdef _MSC_VER
9 #pragma warning(push, 1) /* disable warnings within system headers */
10 #endif
11 #define WIN32_LEAN_AND_MEAN
12 #include <windows.h>
13 #include <msi.h>
14 #ifdef _MSC_VER
15 #pragma warning(pop)
16 #endif
17 
18 #include <string>
19 
20 /** A simple implementation class that returns the
21 	appropriate display names for the Microsoft
22 	Office document types.
23 	Under Windows 9x this class checks if the
24 	document display name is convertable to an ANSI
25 	string and if not returns an english default.
26 	So we avoid garbage if soemone for instance
27 	installs an japanese StarOffice/OpenOffice
28 	under a German Windows 98 for instance.
29 */
30 class RegistrationContextInformation
31 {
32 public:
33 
34 	enum SHELL_COMMAND {New, Open, Print, Printto};
35 	enum OFFICE_APPLICATION {Office, Writer, Calc, Impress};
36 
37 	RegistrationContextInformation(MSIHANDLE hMsi, const std::wstring& OpenOfficeExecutablePath);
38 
39 	/** Word document information
40 		The icon index is the index of the icon
41 		in soffice.exe to be associated with
42 		word document files
43 	*/
44 	std::wstring GetWordDocumentDisplayName() const;
45 	std::wstring GetWordDocumentFileExtension() const;
46 	std::wstring GetWordDocumentDefaultIconEntry() const;
47 	std::wstring GetWordDocumentDefaultShellCommand() const;
48 
49 	/** Word template information
50 		The icon index is the index of the icon
51 		in soffice.exe to be associated with
52 		word template files
53 	*/
54 	std::wstring GetWordTemplateDisplayName() const;
55 	std::wstring GetWordTemplateFileExtension() const;
56 	std::wstring GetWordTemplateDefaultIconEntry() const;
57 	std::wstring GetWordTemplateDefaultShellCommand() const;
58 
59 	/** Rtf document information
60 		The icon index is the index of the icon
61 		in soffice.exe to be associated with
62 		rtf document files
63 	*/
64 	std::wstring GetRtfDocumentDisplayName() const;
65 	std::wstring GetRtfDocumentFileExtension() const;
66 	std::wstring GetRtfDocumentDefaultIconEntry() const;
67 	std::wstring GetRtfDocumentDefaultShellCommand() const;
68 
69 	/** Excel sheet information
70 		The icon index is the index of the icon
71 		in soffice.exe to be associated with
72 		Excel sheets
73 	*/
74 	std::wstring GetExcelSheetDisplayName() const;
75 	std::wstring GetExcelSheetFileExtension() const;
76 	std::wstring GetExcelSheetDefaultIconEntry() const;
77 	std::wstring GetExcelSheetDefaultShellCommand() const;
78 
79 	/** Excel template information
80 		The icon index is the index of the icon
81 		in soffice.exe to be associated with
82 		Excel template files
83 	*/
84 	std::wstring GetExcelTemplateDisplayName() const;
85 	std::wstring GetExcelTemplateFileExtension() const;
86 	std::wstring GetExcelTemplateDefaultIconEntry() const;
87 	std::wstring GetExcelTemplateDefaultShellCommand() const;
88 
89 	/** PowerPoint document information
90 		The icon index is the index of the icon
91 		in soffice.exe to be associated with
92 		PowerPoint document files
93 	*/
94 	std::wstring GetPowerPointDocumentDisplayName() const;
95 	std::wstring GetPowerPointDocumentFileExtension() const;
96 	std::wstring GetPowerPointDocumentDefaultIconEntry() const;
97 	std::wstring GetPowerPointDocumentDefaultShellCommand() const;
98 
99 	/** PowerPoint template information
100 		The icon index is the index of the icon
101 		in soffice.exe to be associated with
102 		PowerPoint template files
103 	*/
104 	std::wstring GetPowerPointTemplateDisplayName() const;
105 	std::wstring GetPowerPointTemplateFileExtension() const;
106 	std::wstring GetPowerPointTemplateDefaultIconEntry() const;
107 	std::wstring GetPowerPointTemplateDefaultShellCommand() const;
108 
109     /** PowerPoint Show information
110     */
111     std::wstring GetPowerPointShowDisplayName() const;
112 	std::wstring GetPowerPointShowFileExtension() const;
113 	std::wstring GetPowerPointShowDefaultIconEntry() const;
114 	std::wstring GetPowerPointShowDefaultShellCommand() const;
115 
116 	/** The string for the "New" command that should appear
117 		in the Explorer context menu when someone right
118 		clicks a Microsoft document
119 	*/
120 	std::wstring ShellNewCommandDisplayName() const;
121 
122 	/** The string for the "Edit" command that should
123 		appear in the Explorer context menu when someone
124 		right clicks a document
125 	*/
126 	std::wstring ShellEditCommandDisplayName() const;
127 
128 	/** A friendly name for the application
129 	*/
130 	std::wstring GetOpenOfficeFriendlyAppName() const;
131 
132 	/** The path to the StarOffice/OpenOffice executable
133 	*/
134 	std::wstring GetOpenOfficeExecutablePath() const;
135 
136 	/** The name of the executable (currently "soffice.exe"
137 		but may change in the future, who knows)
138 	*/
139 	std::wstring GetOpenOfficeExecutableName() const;
140 
141 	/** A command line for the specified shell command
142 	*/
143 	std::wstring GetOpenOfficeCommandline(SHELL_COMMAND ShellCommand,
144                                           OFFICE_APPLICATION OfficeApp) const;
145 
146 private:
147 	bool IsConvertableToAnsi(const std::wstring& String)  const;
148 
149 	void ExtractOpenOfficeExecNameFromPath();
150 
151 private:
152 	MSIHANDLE	 msihandle_;
153 	bool		 m_IsWin9x;
154 	std::wstring m_OOExecPath;
155 	std::wstring m_OOExecName;
156 };
157 
158 #endif
159