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 // Registrar.h: Schnittstelle f�r die Klasse Registrar.
23 //
24 //////////////////////////////////////////////////////////////////////
25 
26 #ifndef _REGISTRAR_HXX_
27 #define _REGISTRAR_HXX_
28 
29 #include "registry.hxx"
30 #include "registrationcontextinformation.hxx"
31 
32 #ifndef _CONSTANTS_HXX_
33 #include "constants.hxx"
34 #endif
35 
36 class Registrar
37 {
38 public:
39 
40 	Registrar(const RegistrationContextInformation& RegContext);
41 
42 	virtual ~Registrar();
43 
44     bool IsRegisteredFor(int State) const;
45 
46 	virtual void RegisterForMsWord() const;
47 	virtual void UnregisterForMsWord() const;
48     virtual bool QueryPreselectMsWordRegistration() const;
49 
50 	virtual void RegisterForMsExcel() const;
51 	virtual void UnregisterForMsExcel() const;
52     virtual bool QueryPreselectMsExcelRegistration() const;
53 
54 	virtual void RegisterForMsPowerPoint() const;
55 	virtual void UnregisterForMsPowerPoint() const;
56     virtual bool QueryPreselectMsPowerPointRegistration() const;
57 
58 	virtual void RegisterAsHtmlEditorForInternetExplorer() const;
59 	virtual void UnregisterAsHtmlEditorForInternetExplorer() const;
60 
61 	virtual void RegisterAsDefaultHtmlEditorForInternetExplorer() const;
62 	virtual void UnregisterAsDefaultHtmlEditorForInternetExplorer() const;
63 
64 	virtual void RegisterAsDefaultShellHtmlEditor() const;
65 	virtual void UnregisterAsDefaultShellHtmlEditor() const;
66 
67 	/** Restore the last registration state (necessary for
68 		Setup repair)
69 	*/
70 	virtual void RepairRegistrationState() const;
71 
72     /** Unregisters all and delete all Registry keys we have written
73     */
74     virtual void UnregisterAllAndCleanUpRegistry() const;
75 
76 protected:
77 
78     virtual void RegisterForMsOfficeApplication(
79         const std::wstring& FileExtension,
80         const std::wstring& DocumentDisplayName,
81         const std::wstring& DefaultIconEntry,
82         const std::wstring& DefaultShellCommand,
83         const std::wstring& ShellNewCommandDisplayName,
84         const RegistrationContextInformation::OFFICE_APPLICATION eOfficeApp) const;
85 
86     virtual void UnregisterForMsOfficeApplication(
87         const std::wstring& FileExtension) const;
88 
89     virtual RegistryKey GetRootKeyForDefHtmlEditorForIERegistration() const;
90 
91 	void SaveRegisteredFor(int State) const;
92     void SaveNotRegisteredFor(int State) const;
93 
94     int GetRegisterState() const;
95     void SetRegisterState(int NewState) const;
96 
97     virtual bool QueryPreselectForMsApplication(const std::wstring& file_extension) const;
98 
99     /** A helper function (for readability) returns true if OpenOffice is already
100           registered for a MS application
101 
102           @param DocumentExtensionDefValue
103                       The default value of the appropriate document extension Registry key
104     */
105     bool IsOpenOfficeRegisteredForMsApplication(const std::wstring& DocumentExtensionDefValue) const;
106 
107 protected:
108 	const RegistrationContextInformation&	m_ContextInformation;
109 
110     const std::wstring FORWARD_KEY_PREFIX;
111     const std::wstring DEFAULT_VALUE_NAME;
112     const std::wstring BACKUP_VALUE_NAME;
113     const std::wstring PRIVATE_BACKUP_KEY_NAME;
114     const std::wstring REGISTRATION_STATE;
115 
116     RegistryKey	 m_RootKey;
117 
118 // prevent copy/assignment
119 private:
120 	Registrar(const Registrar&);
121 	Registrar& operator=(const Registrar&);
122 };
123 
124 #endif
125