1 /* 2 ************************************************************************ 3 * 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * Copyright 2000, 2010 Oracle and/or its affiliates. 7 * 8 * OpenOffice.org - a multi-platform office productivity suite 9 * 10 * This file is part of OpenOffice.org. 11 * 12 * OpenOffice.org is free software: you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License version 3 14 * only, as published by the Free Software Foundation. 15 * 16 * OpenOffice.org is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License version 3 for more details 20 * (a copy is included in the LICENSE file that accompanied this code). 21 * 22 * You should have received a copy of the GNU Lesser General Public License 23 * version 3 along with OpenOffice.org. If not, see 24 * <http://www.openoffice.org/license.html> 25 * for a copy of the LGPLv3 License. 26 * 27 ************************************************************************/ 28 29 package convwatch; 30 31 import java.io.File; 32 import java.util.ArrayList; 33 34 import com.sun.star.beans.PropertyValue; 35 import com.sun.star.beans.XPropertySet; 36 import com.sun.star.container.XNameAccess; 37 import com.sun.star.frame.XComponentLoader; 38 import com.sun.star.frame.XDesktop; 39 import com.sun.star.frame.XModel; 40 import com.sun.star.frame.XStorable; 41 import com.sun.star.lang.XComponent; 42 import com.sun.star.lang.XMultiServiceFactory; 43 import com.sun.star.sdb.XDocumentDataSource; 44 import com.sun.star.sdb.XOfficeDatabaseDocument; 45 import com.sun.star.sdb.XReportDocumentsSupplier; 46 import com.sun.star.sdb.application.XDatabaseDocumentUI; 47 import com.sun.star.uno.UnoRuntime; 48 import com.sun.star.uno.XInterface; 49 import com.sun.star.util.XCloseable; 50 import com.sun.star.lang.XServiceInfo; 51 52 // import util.BasicMacroTools; 53 // import util.DesktopTools; 54 // import util.dbg; 55 import complexlib.ComplexTestCase; 56 import helper.OfficeProvider; 57 import helper.URLHelper; 58 import helper.OfficeWatcher; 59 60 // import convwatch.DB; 61 62 // import java.util.Date; 63 // import java.text.SimpleDateFormat; 64 // import java.text.ParsePosition; 65 // import java.sql.Time; 66 // 67 // import java.io.BufferedReader; 68 // import java.io.File; 69 // import java.io.FileReader; 70 // import java.io.IOException; 71 // import java.io.FilenameFilter; 72 // 73 // import java.util.Vector; 74 // 75 // import helper.AppProvider; 76 // import java.text.DecimalFormat; 77 // import util.DynamicClassLoader; 78 // import java.util.StringTokenizer; 79 80 81 82 83 class PropertySetHelper 84 { 85 XPropertySet m_xPropertySet; 86 public PropertySetHelper(Object _aObj) 87 { 88 m_xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, _aObj); 89 } 90 91 /** 92 get a property and don't convert it 93 @param _sName the string name of the property 94 @return the object value of the property without any conversion 95 */ 96 public Object getPropertyValueAsObject(String _sName) 97 { 98 Object aObject = null; 99 100 if (m_xPropertySet != null) 101 { 102 try 103 { 104 aObject = m_xPropertySet.getPropertyValue(_sName); 105 } 106 catch (com.sun.star.beans.UnknownPropertyException e) 107 { 108 System.out.println("ERROR: UnknownPropertyException caught. '" + _sName + "'"); 109 System.out.println("Message: " + e.getMessage()); 110 } 111 catch (com.sun.star.lang.WrappedTargetException e) 112 { 113 System.out.println("ERROR: WrappedTargetException caught."); 114 System.out.println("Message: " + e.getMessage()); 115 } 116 } 117 return aObject; 118 } 119 } 120 121 class PropertyHelper 122 { 123 /** 124 Create a PropertyValue[] from a ArrayList 125 @param _aArrayList 126 @return a PropertyValue[] 127 */ 128 public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList _aPropertyList) 129 { 130 // copy the whole PropertyValue List to an PropertyValue Array 131 PropertyValue[] aSaveProperties = null; 132 133 if (_aPropertyList == null) 134 { 135 aSaveProperties = new PropertyValue[0]; 136 } 137 else 138 { 139 if (_aPropertyList.size() > 0) 140 { 141 aSaveProperties = new PropertyValue[_aPropertyList.size()]; 142 for (int i = 0;i<_aPropertyList.size(); i++) 143 { 144 aSaveProperties[i] = (PropertyValue) _aPropertyList.get(i); 145 } 146 } 147 else 148 { 149 aSaveProperties = new PropertyValue[0]; 150 } 151 } 152 return aSaveProperties; 153 } 154 } 155 156 public class ReportDesignerTest extends ComplexTestCase { 157 158 String mTestDocumentPath; 159 160 /** 161 * This method returns a list of Strings, each string must be a function name in this class. 162 * @return 163 */ 164 public String[] getTestMethodNames() 165 { 166 return new String[] {"ReportDesignTest"}; // MAIN 167 } 168 169 private void checkIfOfficeExists(String _sOfficePathWithTrash) 170 { 171 String sOfficePath = ""; 172 int nIndex = _sOfficePathWithTrash.indexOf("soffice.exe"); 173 if (nIndex > 0) 174 { 175 sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 11); 176 } 177 else 178 { 179 nIndex = _sOfficePathWithTrash.indexOf("soffice"); 180 if (nIndex > 0) 181 { 182 sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 7); 183 } 184 } 185 186 // if (sOfficePath.startsWith("\"") || 187 // sOfficePath.startsWith("'")) 188 // { 189 // sOfficePath = sOfficePath.substring(1); 190 // } 191 sOfficePath = helper.StringHelper.removeQuoteIfExists(sOfficePath); 192 193 log.println(sOfficePath); 194 File sOffice = new File(sOfficePath); 195 if (! sOffice.exists()) 196 { 197 log.println("ERROR: There exists no office installation at given path: '" + sOfficePath + "'"); 198 System.exit(0); 199 } 200 } 201 202 203 private static XDesktop m_xDesktop = null; 204 public static XDesktop getXDesktop() 205 { 206 207 if (m_xDesktop == null) 208 { 209 try 210 { 211 XInterface xInterface = (XInterface) m_xXMultiServiceFactory.createInstance( "com.sun.star.frame.Desktop" ); 212 m_xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface); 213 } 214 catch (com.sun.star.uno.Exception e) 215 { 216 log.println("ERROR: uno.Exception caught"); 217 log.println("Message: " + e.getMessage()); 218 } 219 } 220 return m_xDesktop; 221 } 222 223 private void showElements(XNameAccess _xNameAccess) 224 { 225 if (_xNameAccess != null) 226 { 227 String[] sElementNames = _xNameAccess.getElementNames(); 228 for(int i=0;i<sElementNames.length; i++) 229 { 230 System.out.println("Value: [" + i + "] := " + sElementNames[i]); 231 } 232 } 233 else 234 { 235 System.out.println("Warning: Given object is null."); 236 } 237 } 238 239 240 private OfficeProvider m_aProvider = null; 241 private static XMultiServiceFactory m_xXMultiServiceFactory = null; 242 private void startOffice() 243 { 244 // int tempTime = param.getInt("SingleTimeOut"); 245 param.put("TimeOut", new Integer(300000)); 246 System.out.println("TimeOut: " + param.getInt("TimeOut")); 247 System.out.println("ThreadTimeOut: " + param.getInt("ThreadTimeOut")); 248 249 // OfficeProvider aProvider = null; 250 m_aProvider = new OfficeProvider(); 251 m_xXMultiServiceFactory = (XMultiServiceFactory) m_aProvider.getManager(param); 252 param.put("ServiceFactory", m_xXMultiServiceFactory); 253 } 254 255 private void stopOffice() 256 { 257 if (m_aProvider != null) 258 { 259 m_aProvider.closeExistingOffice(param, true); 260 m_aProvider = null; 261 } 262 TimeHelper.waitInSeconds(2, "Give close Office some time."); 263 } 264 265 private String m_sMailAddress = null; 266 private String m_sParentDistinct = null; 267 268 // private String m_sUPDMinor; 269 // private String m_sCWS_WORK_STAMP; 270 271 private static String m_sSourceVersion; 272 private static String m_sDestinationVersion; 273 private static String m_sSourceName; 274 private static String m_sDestinationName; 275 276 private static final int WRITER = 1; 277 private static final int CALC = 2; 278 279 /** 280 * This is the main test Function of current ReportDesignerTest 281 */ 282 public void ReportDesignTest() 283 { 284 convwatch.GlobalLogWriter.set(log); 285 286 GlobalLogWriter.get().println("Set office watcher"); 287 OfficeWatcher aWatcher = (OfficeWatcher)param.get("Watcher"); 288 GlobalLogWriter.get().setWatcher(aWatcher); 289 290 try 291 { 292 293 // -------------------- preconditions, try to find an office -------------------- 294 295 String sAppExecutionCommand = (String) param.get("AppExecutionCommand"); 296 log.println("sAppExecutionCommand='" + sAppExecutionCommand + "'"); 297 298 String sUser = System.getProperty("user.name"); 299 log.println("user.name='" + sUser + "'"); 300 301 // String sVCSID = System.getProperty("VCSID"); 302 // log.println("VCSID='" + sVCSID + "'"); 303 // m_sMailAddress = sVCSID + "@openoffice.org"; 304 m_sMailAddress = System.getProperty("MailAddress"); 305 log.println("Assumed mail address: " + m_sMailAddress); 306 307 m_sParentDistinct = System.getProperty("ParentDistinct"); 308 309 m_sSourceVersion = System.getProperty("SourceVersion"); 310 m_sSourceName = System.getProperty("SourceName"); 311 m_sDestinationVersion = System.getProperty("DestinationVersion"); 312 m_sDestinationName = System.getProperty("DestinationName"); 313 // createDBEntry(); 314 // log.println("Current CWS: " + m_sCWS_WORK_STAMP); 315 // log.println("Current MWS: " + m_sUPDMinor); 316 317 if (m_sSourceVersion == null) 318 { 319 System.out.println("Error, Sourceversion is null."); 320 System.exit(1); 321 } 322 323 sAppExecutionCommand = sAppExecutionCommand.replaceAll( "\\$\\{USERNAME\\}", sUser); 324 log.println("sAppExecutionCommand='" + sAppExecutionCommand + "'"); 325 326 // an other way to replace strings 327 // sAppExecutionCommand = utils.replaceAll13(sAppExecutionCommand, "${USERNAME}", sUser); 328 329 checkIfOfficeExists(sAppExecutionCommand); 330 param.put("AppExecutionCommand", new String(sAppExecutionCommand)); 331 332 // System.exit(1); 333 334 // --------------------------- Start the given Office --------------------------- 335 336 startOffice(); 337 338 // ------------------------------ Start a test run ------------------------------ 339 340 // String sCurrentDirectory = System.getProperty("user.dir"); 341 // log.println("Current Dir: " + sCurrentDirectory); 342 String sDocument = (String) param.get(convwatch.PropertyName.DOC_COMPARATOR_INPUT_PATH); 343 sDocument = helper.StringHelper.removeQuoteIfExists( sDocument ); 344 startTestForFile(sDocument); 345 // if (sDocument.toLowerCase().indexOf("writer") >= 0) 346 // { 347 // startTestForFile(sDocument, WRITER); 348 // } 349 // else if (sDocument.toLowerCase().indexOf("calc") >= 0) 350 // { 351 // startTestForFile(sDocument, CALC); 352 // } 353 // else 354 // { 355 // assure("Can't identify the document no 'writer' nor 'calc' in it's name given.", false); 356 // } 357 } 358 catch (AssureException e) 359 { 360 stopOffice(); 361 throw new AssureException(e.getMessage()); 362 } 363 364 // ------------------------------ Office shutdown ------------------------------ 365 stopOffice(); 366 } 367 368 // ----------------------------------------------------------------------------- 369 private void startTestForFile(String _sDocument /*, int _nType*/) 370 { 371 File aFile = new File(_sDocument); 372 assure("Test File '" + _sDocument + "' doesn't exist.", aFile.exists()); 373 374 String sFileURL = URLHelper.getFileURLFromSystemPath(_sDocument); 375 log.println("File URL: " + sFileURL); 376 377 XComponent xDocComponent = loadComponent(sFileURL, getXDesktop(), null); 378 log.println("Load done"); 379 // context = createUnoService("com.sun.star.sdb.DatabaseContext") 380 // oDataBase = context.getByName("hh") 381 // oDBDoc = oDataBase.DatabaseDocument 382 // 383 // dim args(1) as new com.sun.star.beans.PropertyValue 384 // args(0).Name = "ActiveConnection" 385 // args(0).Value = oDBDoc.getCurrentController().getPropertyValue("ActiveConnection") 386 // reportContainer = oDBDoc.getReportDocuments() 387 // report = reportContainer.loadComponentFromURL("Report40","",0,args) 388 389 try 390 { 391 XInterface x = (XInterface)m_xXMultiServiceFactory.createInstance("com.sun.star.sdb.DatabaseContext"); 392 assure("can't create instance of com.sun.star.sdb.DatabaseContext", x != null); 393 log.println("createInstance com.sun.star.sdb.DatabaseContext done"); 394 395 XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, x); 396 showElements(xNameAccess); 397 Object aObj = xNameAccess.getByName(sFileURL); 398 // log.println("1"); 399 400 // PropertySetHelper aHelper = new PropertySetHelper(aObj); 401 XDocumentDataSource xDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(XDocumentDataSource.class, aObj); 402 // Object aDatabaseDocmuent = aHelper.getPropertyValueAsObject("DatabaseDocument"); 403 XOfficeDatabaseDocument xOfficeDBDoc = xDataSource.getDatabaseDocument(); 404 405 // XOfficeDatabaseDocument xOfficeDBDoc = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, aDatabaseDocument); 406 assure("can't access DatabaseDocument", xOfficeDBDoc != null); 407 // log.println("2"); 408 409 XModel xDBSource = (XModel)UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc); 410 Object aController = xDBSource.getCurrentController(); 411 assure("Controller of xOfficeDatabaseDocument is empty!", aController != null); 412 // log.println("3"); 413 414 XDatabaseDocumentUI aDBDocUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController); 415 aDBDocUI.connect(); 416 // if (aDBDocUI.isConnected()) 417 // { 418 // System.out.println("true"); 419 // } 420 // else 421 // { 422 // System.out.println("false"); 423 // } 424 // log.println("4"); 425 426 // aHelper = new PropertySetHelper(aController); 427 428 // Object aActiveConnectionObj = aHelper.getPropertyValueAsObject("ActiveConnection"); 429 Object aActiveConnectionObj = aDBDocUI.getActiveConnection(); 430 assure("ActiveConnection is empty", aActiveConnectionObj != null); 431 // log.println("5"); 432 433 XReportDocumentsSupplier xSupplier = (XReportDocumentsSupplier)UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc); 434 xNameAccess = xSupplier.getReportDocuments(); 435 assure("xOfficeDatabaseDocument returns no Report Document", xNameAccess != null); 436 // log.println("5"); 437 438 showElements(xNameAccess); 439 440 ArrayList aPropertyList = new ArrayList(); 441 442 PropertyValue aActiveConnection = new PropertyValue(); 443 aActiveConnection.Name = "ActiveConnection"; 444 aActiveConnection.Value = aActiveConnectionObj; 445 aPropertyList.add(aActiveConnection); 446 447 loadAndStoreReports(xNameAccess, aPropertyList /*, _nType*/ ); 448 createDBEntry(/*_nType*/); 449 } 450 catch(com.sun.star.uno.Exception e) 451 { 452 log.println("ERROR: Exception caught"); 453 log.println("Message: " + e.getMessage()); 454 } 455 456 // String mTestDocumentPath = (String) param.get("TestDocumentPath"); 457 // System.out.println("mTestDocumentPath: '" + mTestDocumentPath + "'"); 458 // // workaround for issue using deprecated "DOCPTH" prop 459 // System.setProperty("DOCPTH", mTestDocumentPath); 460 461 // Close the document 462 closeComponent(xDocComponent); 463 } 464 465 private String getDocumentPoolName(/*int _nType*/) 466 { 467 return "AutogenReportDesignTest"; 468 // return getFileFormat(_nType); 469 } 470 471 // ----------------------------------------------------------------------------- 472 private void createDBEntry(/*int _nType*/) 473 { 474 // try to connect the database 475 String sDBConnection = (String)param.get( convwatch.PropertyName.DB_CONNECTION_STRING ); 476 log.println("DBConnection: " + sDBConnection); 477 DB.init(sDBConnection); 478 479 // String sFixRefSubDirectory = "ReportDesign_qa_complex_" + getFileFormat(_nType); 480 String sFixRefSubDirectory = "ReportDesignFixRef"; 481 482 String sSourceVersion = m_sSourceVersion; 483 // String sSourceVersion = sFixRefSubDirectory; 484 String sSourceName = m_sSourceName; 485 // String sSourceCreatorType = "fixref"; 486 String sSourceCreatorType = ""; 487 String sDestinationVersion = m_sDestinationVersion; 488 // if (sDestinationVersion.length() == 0) 489 // { 490 // sDestinationVersion = m_sUPDMinor; 491 // } 492 String sDestinationName = m_sDestinationName; 493 String sDestinationCreatorType = ""; 494 String sDocumentPoolDir = getOutputPath(/*_nType*/); 495 String sDocumentPoolName = getDocumentPoolName(/*_nType*/); 496 String sSpecial = ""; 497 498 DB.insertinto_documentcompare(sSourceVersion, sSourceName, sSourceCreatorType, 499 m_sDestinationVersion, sDestinationName, sDestinationCreatorType, 500 sDocumentPoolDir, sDocumentPoolName, m_sMailAddress, 501 sSpecial, m_sParentDistinct); 502 TimeHelper.waitInSeconds(1, "wait for DB."); 503 // DB.test(); 504 // System.exit(1); 505 } 506 507 private void loadAndStoreReports(XNameAccess _xNameAccess, ArrayList _aPropertyList /*, int _nType*/ ) 508 { 509 if (_xNameAccess != null) 510 { 511 String[] sElementNames = _xNameAccess.getElementNames(); 512 for(int i=0;i<sElementNames.length; i++) 513 { 514 String sReportName = sElementNames[i]; 515 XComponent xDoc = loadComponent(sReportName, _xNameAccess, _aPropertyList); 516 // print? or store? 517 storeComponent(sReportName, xDoc /*, _nType*/); 518 closeComponent(xDoc); 519 } 520 } 521 } 522 523 private String getFormatExtension(Object _xComponent /* int _nType*/ ) 524 { 525 String sExtension; 526 XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface( XServiceInfo.class, _xComponent ); 527 if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) ) 528 { 529 // calc 530 sExtension = ".ods"; 531 } 532 else if (xServiceInfo.supportsService("com.sun.star.text.TextDocument")) 533 { 534 //writer 535 sExtension = ".odt"; 536 } 537 else 538 { 539 sExtension = ".UNKNOWN"; 540 } 541 return sExtension; 542 } 543 544 // switch(_nType) 545 // { 546 // case WRITER: 547 // sExtension = ".odt"; 548 // break; 549 // case CALC: 550 // sExtension = ".ods"; 551 // break; 552 // default: 553 // sExtension = ".UNKNOWN"; 554 // } 555 // return sExtension; 556 // } 557 // private String getFileFormat(int _nType) 558 // { 559 // String sFileType; 560 // switch(_nType) 561 // { 562 // case WRITER: 563 // sFileType = "writer8"; 564 // break; 565 // case CALC: 566 // sFileType = "calc8"; 567 // break; 568 // default: 569 // sFileType = "UNKNOWN"; 570 // } 571 // return sFileType; 572 // } 573 574 private String m_sOutputPath = null; 575 576 private String getOutputPath(/*int _nType*/) 577 { 578 if (m_sOutputPath == null) 579 { 580 String sOutputPath = (String)param.get( convwatch.PropertyName.DOC_COMPARATOR_OUTPUT_PATH ); 581 sOutputPath = helper.StringHelper.removeQuoteIfExists(sOutputPath); 582 583 if (!sOutputPath.endsWith("/") || // construct the output file name 584 !sOutputPath.endsWith("\\")) 585 { 586 sOutputPath += System.getProperty("file.separator"); 587 } 588 // sOutputPath += "tmp_123"; 589 sOutputPath += DateHelper.getDateTimeForFilename(); 590 sOutputPath += System.getProperty("file.separator"); 591 592 // sOutputPath += getFileFormat(_nType); 593 // sOutputPath += System.getProperty("file.separator"); 594 595 File aOutputFile = new File(sOutputPath); // create the directory of the given output path 596 aOutputFile.mkdirs(); 597 m_sOutputPath = sOutputPath; 598 } 599 return m_sOutputPath; 600 } 601 602 /* 603 store given _xComponent under the given Name in DOC_COMPARATOR_INPUTPATH 604 */ 605 private void storeComponent(String _sName, Object _xComponent /*, int _nType*/ ) 606 { 607 String sOutputPath = getOutputPath(/*_nType*/); 608 609 // add DocumentPoolName 610 sOutputPath += getDocumentPoolName(/*_nType*/); 611 sOutputPath += System.getProperty("file.separator"); 612 613 File aOutputFile = new File(sOutputPath); // create the directory of the given output path 614 aOutputFile.mkdirs(); 615 616 sOutputPath += _sName; 617 sOutputPath += getFormatExtension(_xComponent /*_nType*/); 618 619 String sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputPath); 620 621 ArrayList aPropertyList = new ArrayList(); // set some properties for storeAsURL 622 623 // PropertyValue aFileFormat = new PropertyValue(); 624 // aFileFormat.Name = "FilterName"; 625 // aFileFormat.Value = getFileFormat(_nType); 626 // aPropertyList.add(aFileFormat); 627 628 PropertyValue aOverwrite = new PropertyValue(); // always overwrite already exist files 629 aOverwrite.Name = "Overwrite"; 630 aOverwrite.Value = Boolean.TRUE; 631 aPropertyList.add(aOverwrite); 632 633 // store the document in an other directory 634 XStorable aStorable = (XStorable) UnoRuntime.queryInterface( XStorable.class, _xComponent); 635 if (aStorable != null) 636 { 637 log.println("store document as URL: '" + sOutputURL + "'"); 638 try 639 { 640 aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList)); 641 } 642 catch (com.sun.star.io.IOException e) 643 { 644 log.println("ERROR: Exception caught"); 645 log.println("Can't write document URL: '" + sOutputURL + "'"); 646 log.println("Message: " + e.getMessage()); 647 } 648 } 649 } 650 651 private XComponent loadComponent(String _sName, Object _xComponent, ArrayList _aPropertyList) 652 { 653 XComponent xDocComponent = null; 654 XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, _xComponent ); 655 656 try 657 { 658 PropertyValue[] aLoadProperties = PropertyHelper.createPropertyValueArrayFormArrayList(_aPropertyList); 659 log.println("Load component: '" + _sName + "'"); 660 xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", 0, aLoadProperties); 661 log.println("Load component: '" + _sName + "' done"); 662 } 663 catch (com.sun.star.io.IOException e) 664 { 665 log.println("ERROR: Exception caught"); 666 log.println("Can't load document '" + _sName + "'"); 667 log.println("Message: " + e.getMessage()); 668 } 669 catch (com.sun.star.lang.IllegalArgumentException e) 670 { 671 log.println("ERROR: Exception caught"); 672 log.println("Illegal Arguments given to loadComponentFromURL."); 673 log.println("Message: " + e.getMessage()); 674 } 675 return xDocComponent; 676 } 677 678 private void closeComponent(XComponent _xDoc) 679 { 680 // Close the document 681 XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, _xDoc); 682 try 683 { 684 xCloseable.close(true); 685 } 686 catch (com.sun.star.util.CloseVetoException e) 687 { 688 log.println("ERROR: CloseVetoException caught"); 689 log.println("CloseVetoException occured Can't close document."); 690 log.println("Message: " + e.getMessage()); 691 } 692 } 693 694 } 695