21
21
* You should have received a copy of the GNU Affero General Public License
22
22
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
*/
24
-
25
24
package com .silverpeas .openoffice .windows ;
26
25
27
26
import com .silverpeas .openoffice .OfficeFinder ;
28
27
import com .silverpeas .openoffice .OfficeNotFoundException ;
29
28
import com .silverpeas .openoffice .util .RegistryKeyReader ;
30
- import java .util .logging .Level ;
31
29
import java .util .logging .Logger ;
32
30
import java .util .regex .Matcher ;
33
31
import java .util .regex .Pattern ;
@@ -45,26 +43,11 @@ public class MsOfficeRegistryHelper implements OfficeFinder {
45
43
static final String POWERPOINT = "Powerpoint.Application" ;
46
44
static final String WORD = "Word.Application" ;
47
45
static final String FRONTPAGE = "FrontPage.Application" ;
48
- static final String BASE_APPLICATION_KEY =
49
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Classes\\ " ;
50
- static final String BASE_KEY_CLSID =
51
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Wow6432Node\\ Classes\\ CLSID\\ " ;
52
- static final String BASE_KEY_64_CLSID =
53
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Classes\\ CLSID\\ " ;
46
+ static final String BASE_APPLICATION_KEY = "\" HKEY_LOCAL_MACHINE\\ Software\\ Classes\\ " ;
47
+ static final String BASE_KEY_64_CLSID = "\" HKEY_LOCAL_MACHINE\\ Software\\ Wow6432Node\\ Classes\\ CLSID\\ " ;
48
+ static final String BASE_KEY_CLSID = "\" HKEY_LOCAL_MACHINE\\ Software\\ Classes\\ CLSID\\ " ;
54
49
static final Pattern AUTOMATION = Pattern .compile (
55
50
"\\ s*/[aA][uU][tT][oO][mM][aA][tT][iI][oO][nN]\\ s*" );
56
- static final String BASE_MSOFFICE_WORD_2007_KEY =
57
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Microsoft\\ Office\\ 12.0\\ Word\\ InstallRoot\" /ve" ;
58
- static final String BASE_MSOFFICE_EXCEL_2007_KEY =
59
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Microsoft\\ Office\\ 12.0\\ Excel\\ InstallRoot\" /ve" ;
60
- static final String BASE_MSOFFICE_POWERPOINT_2007_KEY =
61
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Microsoft\\ Office\\ 12.0\\ PowerPoint\\ InstallRoot\" /ve" ;
62
- static final String BASE_MSOFFICE_WORD_2007_KEY_64 =
63
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Wow6432Node\\ Microsoft\\ Office\\ 12.0\\ Word\\ InstallRoot\" /ve" ;
64
- static final String BASE_MSOFFICE_EXCEL_2007_KEY_64 =
65
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Wow6432Node\\ Microsoft\\ Office\\ 12.0\\ Excel\\ InstallRoot\" /ve" ;
66
- static final String BASE_MSOFFICE_POWERPOINT_2007_KEY_64 =
67
- "\" HKEY_LOCAL_MACHINE\\ Software\\ Wow6432Node\\ Microsoft\\ Office\\ 12.0\\ PowerPoint\\ InstallRoot\" /ve" ;
68
51
69
52
protected String getClsid (String type ) {
70
53
return RegistryKeyReader .readKey (BASE_APPLICATION_KEY + type + "\\ CLSID\" " );
@@ -73,11 +56,9 @@ protected String getClsid(String type) {
73
56
protected String getPath (String type ) {
74
57
String clsid = getClsid (type );
75
58
if (clsid != null ) {
76
- String path = RegistryKeyReader .readKey (BASE_KEY_CLSID + clsid
77
- + "\\ LocalServer32\" " );
59
+ String path = RegistryKeyReader .readKey (BASE_KEY_CLSID + clsid + "\\ LocalServer32\" " );
78
60
if (path == null ) {
79
- path = RegistryKeyReader .readKey (BASE_KEY_64_CLSID + clsid
80
- + "\\ LocalServer32\" " );
61
+ path = RegistryKeyReader .readKey (BASE_KEY_64_CLSID + clsid + "\\ LocalServer32\" " );
81
62
}
82
63
if (path != null ) {
83
64
return '"' + extractPath (path ) + '"' ;
@@ -130,24 +111,7 @@ public String findOther() throws OfficeNotFoundException {
130
111
}
131
112
132
113
@ Override
133
- public boolean isMicrosoftOffice2007 () {
134
- logger .log (Level .INFO , "Are we using Word 2007 : {0}" , RegistryKeyReader
135
- .readKey (BASE_MSOFFICE_WORD_2007_KEY ) != null
136
- ||
137
- RegistryKeyReader .readKey (BASE_MSOFFICE_WORD_2007_KEY_64 ) != null );
138
- logger .log (Level .INFO , "Are we using Excel 2007 : {0}" , RegistryKeyReader
139
- .readKey (BASE_MSOFFICE_EXCEL_2007_KEY ) != null
140
- ||
141
- RegistryKeyReader .readKey (BASE_MSOFFICE_EXCEL_2007_KEY_64 ) != null );
142
- logger .log (Level .INFO , "Are we using Powerpoint 2007 : {0}" , RegistryKeyReader
143
- .readKey (BASE_MSOFFICE_POWERPOINT_2007_KEY ) != null
144
- ||
145
- RegistryKeyReader .readKey (BASE_MSOFFICE_POWERPOINT_2007_KEY_64 ) != null );
146
- return (RegistryKeyReader .readKey (BASE_MSOFFICE_WORD_2007_KEY ) != null
147
- || RegistryKeyReader .readKey (BASE_MSOFFICE_EXCEL_2007_KEY ) != null
148
- || RegistryKeyReader .readKey (BASE_MSOFFICE_POWERPOINT_2007_KEY ) != null
149
- || RegistryKeyReader .readKey (BASE_MSOFFICE_WORD_2007_KEY_64 ) != null
150
- || RegistryKeyReader .readKey (BASE_MSOFFICE_EXCEL_2007_KEY_64 ) != null || RegistryKeyReader
151
- .readKey (BASE_MSOFFICE_POWERPOINT_2007_KEY_64 ) != null );
114
+ public boolean isMicrosoftOffice () {
115
+ return getPath (EXCEL ) != null || getPath (POWERPOINT ) != null || getPath (WORD ) != null ;
152
116
}
153
117
}
0 commit comments