1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MsOfficeDocumentInformation.h: Schnittstelle f�r die Klasse MsOfficeDocumentInformation.
23 //
24 //////////////////////////////////////////////////////////////////////
25 
26 #ifndef _REGISTRATIONCONTEXTINFORMATION_HXX_
27 #define _REGISTRATIONCONTEXTINFORMATION_HXX_
28 
29 #ifdef _MSC_VER
30 #pragma warning(push, 1) /* disable warnings within system headers */
31 #endif
32 #define WIN32_LEAN_AND_MEAN
33 #include <windows.h>
34 #include <msi.h>
35 #ifdef _MSC_VER
36 #pragma warning(pop)
37 #endif
38 
39 #include <string>
40 
41 /** A simple implementation class that returns the
42 	appropriate display names for the Microsoft
43 	Office document types.
44 	Under Windows 9x this class checks if the
45 	document display name is convertable to an ANSI
46 	string and if not returns an english default.
47 	So we avoid garbage if soemone for instance
48 	installs an japanese version
49 	under a German Windows 98 for instance.
50 */
51 class RegistrationContextInformation
52 {
53 public:
54 
55 	enum SHELL_COMMAND {New, Open, Print, Printto};
56 	enum OFFICE_APPLICATION {Office, Writer, Calc, Impress};
57 
58 	RegistrationContextInformation(MSIHANDLE hMsi, const std::wstring& OpenOfficeExecutablePath);
59 
60 	/** Word document information
61 		The icon index is the index of the icon
62 		in soffice.exe to be associated with
63 		word document files
64 	*/
65 	std::wstring GetWordDocumentDisplayName() const;
66 	std::wstring GetWordDocumentFileExtension() const;
67 	std::wstring GetWordDocumentDefaultIconEntry() const;
68 	std::wstring GetWordDocumentDefaultShellCommand() const;
69 
70 	/** Word template information
71 		The icon index is the index of the icon
72 		in soffice.exe to be associated with
73 		word template files
74 	*/
75 	std::wstring GetWordTemplateDisplayName() const;
76 	std::wstring GetWordTemplateFileExtension() const;
77 	std::wstring GetWordTemplateDefaultIconEntry() const;
78 	std::wstring GetWordTemplateDefaultShellCommand() const;
79 
80 	/** Rtf document information
81 		The icon index is the index of the icon
82 		in soffice.exe to be associated with
83 		rtf document files
84 	*/
85 	std::wstring GetRtfDocumentDisplayName() const;
86 	std::wstring GetRtfDocumentFileExtension() const;
87 	std::wstring GetRtfDocumentDefaultIconEntry() const;
88 	std::wstring GetRtfDocumentDefaultShellCommand() const;
89 
90 	/** Excel sheet information
91 		The icon index is the index of the icon
92 		in soffice.exe to be associated with
93 		Excel sheets
94 	*/
95 	std::wstring GetExcelSheetDisplayName() const;
96 	std::wstring GetExcelSheetFileExtension() const;
97 	std::wstring GetExcelSheetDefaultIconEntry() const;
98 	std::wstring GetExcelSheetDefaultShellCommand() const;
99 
100 	/** Excel template information
101 		The icon index is the index of the icon
102 		in soffice.exe to be associated with
103 		Excel template files
104 	*/
105 	std::wstring GetExcelTemplateDisplayName() const;
106 	std::wstring GetExcelTemplateFileExtension() const;
107 	std::wstring GetExcelTemplateDefaultIconEntry() const;
108 	std::wstring GetExcelTemplateDefaultShellCommand() const;
109 
110 	/** PowerPoint document information
111 		The icon index is the index of the icon
112 		in soffice.exe to be associated with
113 		PowerPoint document files
114 	*/
115 	std::wstring GetPowerPointDocumentDisplayName() const;
116 	std::wstring GetPowerPointDocumentFileExtension() const;
117 	std::wstring GetPowerPointDocumentDefaultIconEntry() const;
118 	std::wstring GetPowerPointDocumentDefaultShellCommand() const;
119 
120 	/** PowerPoint template information
121 		The icon index is the index of the icon
122 		in soffice.exe to be associated with
123 		PowerPoint template files
124 	*/
125 	std::wstring GetPowerPointTemplateDisplayName() const;
126 	std::wstring GetPowerPointTemplateFileExtension() const;
127 	std::wstring GetPowerPointTemplateDefaultIconEntry() const;
128 	std::wstring GetPowerPointTemplateDefaultShellCommand() const;
129 
130     /** PowerPoint Show information
131     */
132     std::wstring GetPowerPointShowDisplayName() const;
133 	std::wstring GetPowerPointShowFileExtension() const;
134 	std::wstring GetPowerPointShowDefaultIconEntry() const;
135 	std::wstring GetPowerPointShowDefaultShellCommand() const;
136 
137 	/** The string for the "New" command that should appear
138 		in the Explorer context menu when someone right
139 		clicks a Microsoft document
140 	*/
141 	std::wstring ShellNewCommandDisplayName() const;
142 
143 	/** The string for the "Edit" command that should
144 		appear in the Explorer context menu when someone
145 		right clicks a document
146 	*/
147 	std::wstring ShellEditCommandDisplayName() const;
148 
149 	/** A friendly name for the application
150 	*/
151 	std::wstring GetOpenOfficeFriendlyAppName() const;
152 
153 	/** The path to the office executable
154 	*/
155 	std::wstring GetOpenOfficeExecutablePath() const;
156 
157 	/** The name of the executable (currently "soffice.exe"
158 		but may change in the future, who knows)
159 	*/
160 	std::wstring GetOpenOfficeExecutableName() const;
161 
162 	/** A command line for the specified shell command
163 	*/
164 	std::wstring GetOpenOfficeCommandline(SHELL_COMMAND ShellCommand,
165                                           OFFICE_APPLICATION OfficeApp) const;
166 
167 private:
168 	bool IsConvertableToAnsi(const std::wstring& String)  const;
169 
170 	void ExtractOpenOfficeExecNameFromPath();
171 
172 private:
173 	MSIHANDLE	 msihandle_;
174 	bool		 m_IsWin9x;
175 	std::wstring m_OOExecPath;
176 	std::wstring m_OOExecName;
177 };
178 
179 #endif
180