2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 import helper
.OSHelper
;
23 import convwatch
.IniFile
;
27 public static String
getBuildID(String _sApp
)
29 String sOfficePath
= "";
30 if (_sApp
.startsWith("\""))
32 int nIdx
= _sApp
.indexOf("\"", 1);
38 // leave double qoute out.
39 sOfficePath
= _sApp
.substring(1, nIdx
);
44 // check if a space exist, so we get all until space
45 int nIdx
= _sApp
.indexOf(" ", 1);
52 sOfficePath
= _sApp
.substring(0, nIdx
);
55 GlobalLogWriter
.get().println("Office path: " + sOfficePath
);
57 String fs
= System
.getProperty("file.separator");
59 File aSOfficeFile
= new File(sOfficePath
);
60 if (aSOfficeFile
.exists())
62 int nIdx
= sOfficePath
.lastIndexOf(fs
);
63 sOfficePath
= sOfficePath
.substring(0, nIdx
);
64 // ok. System.out.println("directory: " + sOfficePath);
65 sBuildID
= getBuildIDFromBootstrap(sOfficePath
);
66 if (sBuildID
.length() == 0)
68 sBuildID
= getBuildIDFromVersion(sOfficePath
);
73 GlobalLogWriter
.get().println("soffice executable not found.");
79 private static String
getBuildIDFromBootstrap(String _sOfficePath
)
81 String fs
= System
.getProperty("file.separator");
83 String sOfficePath
= _sOfficePath
;
84 if (OSHelper
.isWindows())
86 sOfficePath
+= fs
+ "bootstrap.ini";
90 sOfficePath
+= fs
+ "bootstraprc";
92 IniFile aIniFile
= new IniFile(sOfficePath
);
95 sBuildID
= aIniFile
.getValue("Bootstrap", "buildid");
99 GlobalLogWriter
.get().println("Property Build, can't open file '" + sOfficePath
+ "', please check.");
104 private static String
getBuildIDFromVersion(String _sOfficePath
)
106 String fs
= System
.getProperty("file.separator");
107 String sBuildID
= "";
108 String sOfficePath
= _sOfficePath
;
109 if (OSHelper
.isWindows())
111 sOfficePath
+= fs
+ "version.ini";
115 sOfficePath
+= fs
+ "versionrc";
117 IniFile aIniFile
= new IniFile(sOfficePath
);
120 sBuildID
= aIniFile
.getValue("Version", "buildid");
124 GlobalLogWriter
.get().println("Property Build, can't open file '" + sOfficePath
+ "', please check.");
128 // public static void main(String[] args)
131 // sApp = "/opt/staroffice8_m116/program/soffice --headless --accept=socket,host=localhost,port=8100;urp;";
133 // sBuildID = getBuildID(sApp);
134 // System.out.println("BuildID is: " + sBuildID);
136 // Date aDate = new Date();
137 // long nStart = aDate.getTime();
138 // System.out.println("Time:" + nStart);
139 // // LLA: Just some more tests for getBuildID
140 // // sApp = "/opt/staroffice8_net/program/soffice";
141 // // sBuildID = getBuildID(sApp);
142 // // System.out.println("BuildID is: " + sBuildID);
144 // // sApp = "\"/opt/staroffice8_net/program/soffice\" test blah";
145 // // sBuildID = getBuildID(sApp);
147 // // System.out.println("BuildID is: " + sBuildID);