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 23 package com.sun.star.wizards.reportbuilder; 24 25 import com.sun.star.util.XModeSelector; 26 27 import com.sun.star.awt.XWindowPeer; 28 import com.sun.star.beans.PropertyValue; 29 import com.sun.star.beans.XPropertySet; 30 import com.sun.star.container.XHierarchicalNameContainer; 31 import com.sun.star.frame.XController; 32 import com.sun.star.frame.XDispatch; 33 import com.sun.star.frame.XDispatchProvider; 34 import com.sun.star.frame.XFrame; 35 import com.sun.star.lang.XComponent; 36 import com.sun.star.lang.XMultiServiceFactory; 37 import com.sun.star.report.XReportDefinition; 38 import com.sun.star.sdb.XSubDocument; 39 import com.sun.star.sdb.application.DatabaseObject; 40 import com.sun.star.sdb.application.XDatabaseDocumentUI; 41 import com.sun.star.sdbc.XConnection; 42 import com.sun.star.ucb.XCommandProcessor; 43 import com.sun.star.uno.UnoRuntime; 44 import com.sun.star.util.XModifiable; 45 import com.sun.star.util.XURLTransformer; 46 import com.sun.star.wizards.common.NoValidPathException; 47 import com.sun.star.wizards.common.Resource; 48 import com.sun.star.wizards.db.FieldColumn; 49 import java.lang.reflect.Constructor; 50 import java.util.ArrayList; 51 import java.util.Iterator; 52 import java.util.LinkedHashMap; 53 import java.util.Set; 54 import java.util.Vector; 55 import com.sun.star.wizards.common.FileAccess; 56 import com.sun.star.wizards.common.NamedValueCollection; 57 import com.sun.star.wizards.common.PropertyNames; 58 import com.sun.star.wizards.report.IReportBuilderLayouter; 59 import com.sun.star.wizards.report.IReportDefinitionReadAccess; 60 import com.sun.star.wizards.report.IReportDocument; 61 import com.sun.star.wizards.report.ReportImplementationHelper; 62 import com.sun.star.wizards.report.ReportLayouter; 63 import com.sun.star.wizards.report.ReportWizard; 64 import java.util.logging.Level; 65 import java.util.logging.Logger; 66 67 /** 68 * This class use the IReportDocument Interface to communicate between the UI 69 * and the ReportBuilderLayouter which communicates to the new Sun Report Builder. 70 * 71 * @author ll93751 72 */ 73 public class ReportBuilderImplementation extends ReportImplementationHelper 74 implements IReportDocument, IReportDefinitionReadAccess 75 { 76 77 private Resource m_resource; 78 private XDatabaseDocumentUI m_documentUI; 79 private static final int MAXIMUM_GROUPCOUNT = 4; 80 private String[] groupNames = null; 81 ReportBuilderImplementation(XMultiServiceFactory _serviceFactory)82 private ReportBuilderImplementation(XMultiServiceFactory _serviceFactory) 83 { 84 // creates an access to the ReportBuilder Extension 85 super(_serviceFactory, ReportLayouter.SOOPTLANDSCAPE); 86 } 87 create(XMultiServiceFactory i_serviceFactory)88 public static IReportDocument create(XMultiServiceFactory i_serviceFactory) 89 { 90 return new ReportBuilderImplementation(i_serviceFactory); 91 } 92 initialize(final XDatabaseDocumentUI i_documentUI, final Resource i_resource)93 public void initialize(final XDatabaseDocumentUI i_documentUI, final Resource i_resource) 94 { 95 m_documentUI = i_documentUI; 96 m_resource = i_resource; 97 } 98 clearDocument()99 public void clearDocument() 100 { 101 } 102 getWizardParent()103 public XWindowPeer getWizardParent() 104 { 105 return UnoRuntime.queryInterface(XWindowPeer.class, getFrame().getComponentWindow()); 106 } 107 private XFrame m_xFrame = null; 108 // private ReportBuilderLayouter m_aReportBuilderLayouter = null; 109 private String m_sReportBuilderLayoutName = PropertyNames.EMPTY_STRING; 110 111 /** 112 * Get access to the current ReportLayouter, which depends on the name. 113 * To change the ReportBuilderLayouter use <code>setReportBuilderLayouterName(String Name)</code>. 114 * @return 115 */ getReportBuilderLayouter()116 private IReportBuilderLayouter getReportBuilderLayouter() 117 { 118 return (IReportBuilderLayouter) getLayoutMap().get(m_sReportBuilderLayoutName); 119 } 120 private Object m_aReportDocument; 121 private XPropertySet m_documentDefinition; 122 private XReportDefinition m_reportDocument; 123 124 /** 125 * initialize the Report Builder and open it representation 126 * @param _aDoc 127 * @param _xConnection 128 */ initialize(Object _aDoc)129 private void initialize(Object _aDoc) 130 { 131 m_aReportDocument = _aDoc; 132 133 try 134 { 135 NamedValueCollection creationArgs = new NamedValueCollection(); 136 creationArgs.put("DocumentServiceName", "com.sun.star.report.ReportDefinition"); 137 creationArgs.put("Mode", "remote"); 138 139 XComponent[] docDefinition = new XComponent[] 140 { 141 null 142 }; 143 XComponent reportDefinitionComp = m_documentUI.createComponentWithArguments( 144 DatabaseObject.REPORT, creationArgs.getPropertyValues(), docDefinition); 145 146 m_documentDefinition = UnoRuntime.queryInterface(XPropertySet.class, docDefinition[0]); 147 m_reportDocument = UnoRuntime.queryInterface(XReportDefinition.class, reportDefinitionComp); 148 } 149 catch (com.sun.star.uno.Exception e) 150 { 151 ReportWizard.getLogger().log(com.sun.star.logging.LogLevel.SEVERE, "Problems with initialize the ReportDefinition" + e.getMessage()); 152 153 } 154 155 switchOffPropertyBrowser(); 156 switchOffAddFieldWindow(); 157 158 setPageOrientation(m_nDefaultPageOrientation, false /* NO_LAYOUT*/); 159 } 160 getModeSelector()161 private XModeSelector getModeSelector() 162 { 163 final XController xController = getReportDefinition().getCurrentController(); 164 return UnoRuntime.queryInterface(XModeSelector.class, xController); 165 } 166 switchOffAddFieldWindow()167 private void switchOffAddFieldWindow() 168 { 169 try 170 { 171 getModeSelector().setMode("remote"); 172 } 173 catch (com.sun.star.uno.Exception e) 174 { 175 int dummy = 0; 176 } 177 } 178 switchOnAddFieldWindow()179 private void switchOnAddFieldWindow() 180 { 181 try 182 { 183 getModeSelector().setMode("normal"); 184 } 185 catch (com.sun.star.uno.Exception e) 186 { 187 int dummy = 0; 188 } 189 } 190 sleep(int _nSeconds)191 private void sleep(int _nSeconds) 192 { 193 try 194 { 195 Thread.sleep(_nSeconds * 1000); 196 } 197 catch (java.lang.InterruptedException e) 198 { 199 } 200 201 } 202 switchOffPropertyBrowser()203 private void switchOffPropertyBrowser() 204 { 205 try 206 { 207 final XController xController = getReportDefinition().getCurrentController(); 208 final XDispatchProvider xDP = UnoRuntime.queryInterface(XDispatchProvider.class, xController); 209 210 // Create special service for parsing of given URL. 211 final Object aURLTransformer = getMSF().createInstance("com.sun.star.util.URLTransformer"); 212 final XURLTransformer xURLTransformer = UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class, aURLTransformer); 213 214 com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1]; 215 aURL[0] = new com.sun.star.util.URL(); 216 aURL[0].Complete = ".uno:ControlProperties"; 217 xURLTransformer.parseStrict(aURL); 218 219 final XDispatch xDispatch = xDP.queryDispatch(aURL[0], "_self", 0); 220 PropertyValue[] xEmpty = new PropertyValue[0]; 221 xDispatch.dispatch(aURL[0], xEmpty); 222 } 223 catch (com.sun.star.uno.Exception e) 224 { 225 int dummy = 0; 226 } 227 } 228 switchOnPropertyBrowser()229 private void switchOnPropertyBrowser() 230 { 231 // This is implemented with a toggle algorithm. 232 switchOffPropertyBrowser(); 233 } 234 235 /** 236 * Returns the Frame of the underlieing Document 237 * @return Returns the Frame of the parent (underlieing) Document 238 */ getFrame()239 public XFrame getFrame() 240 { 241 if (m_xFrame == null) 242 { 243 initialize(getRecordParser().getReportDocuments()); 244 m_xFrame = getReportDefinition().getCurrentController().getFrame(); 245 setPageOrientation(m_nDefaultPageOrientation, true /* NO_LAYOUT*/); 246 } 247 return m_xFrame; 248 } 249 reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] Properties)250 public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] Properties) 251 { 252 return false; 253 } 254 insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF)255 public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF) 256 { 257 } 258 StopProcess()259 public void StopProcess() 260 { 261 } 262 store(String Name, int OpenMode)263 public void store(String Name, int OpenMode) throws com.sun.star.uno.Exception 264 { 265 // store into the ZIP Storage 266 if (OpenMode == 1 /* static Report */) 267 { 268 // we will store later 269 return; 270 } 271 272 final XCommandProcessor xProcessor = UnoRuntime.queryInterface(XCommandProcessor.class, m_documentDefinition); 273 final com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command(); 274 aCommand.Name = "store"; 275 276 xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null); 277 278 final XHierarchicalNameContainer aNameContainer = UnoRuntime.queryInterface(XHierarchicalNameContainer.class, m_aReportDocument); 279 aNameContainer.insertByHierarchicalName(Name, m_documentDefinition); 280 } 281 liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount)282 public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount) 283 { 284 final int GroupCount = GroupFieldVector.size(); 285 if (GroupCount < MAXIMUM_GROUPCOUNT) 286 { 287 final FieldColumn CurFieldColumn = getRecordParser().getFieldColumnByTitle(CurGroupTitle); 288 GroupFieldVector.addElement(CurFieldColumn.getFieldName()); 289 } 290 return true; 291 } 292 refreshGroupFields(String[] _sNewNames)293 public void refreshGroupFields(String[] _sNewNames) 294 { 295 } 296 liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, Vector GroupFieldVector)297 public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, Vector GroupFieldVector) 298 { 299 final FieldColumn CurFieldColumn = getRecordParser().getFieldColumnByTitle(CurGroupTitle); 300 GroupFieldVector.removeElement(CurFieldColumn.getFieldName()); 301 } 302 setPageOrientation(int nOrientation, boolean bDoLayout)303 private void setPageOrientation(int nOrientation, boolean bDoLayout) 304 { 305 getReportBuilderLayouter().setPageOrientation(nOrientation); 306 if (bDoLayout) 307 { 308 getReportBuilderLayouter().layout(); 309 } 310 } 311 setPageOrientation(int nOrientation)312 public void setPageOrientation(int nOrientation) 313 { 314 setPageOrientation(nOrientation, true); 315 } 316 liveupdate_changeLayoutTemplate(String LayoutTemplatePath )317 public void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/) 318 { 319 /* Right Listbox */ 320 final IReportBuilderLayouter aLayouter = getReportBuilderLayouter(); 321 aLayouter.loadAndSetBackgroundTemplate(LayoutTemplatePath); 322 aLayouter.layout(); 323 } 324 325 /** 326 * Change the current Layouter by a new one with the given Name _sName. 327 * If there exist no other layouter with the given name, nothing happens, the layouter will not change to 328 * an illegal one. 329 * @param _sName Name of the other layouter. 330 */ setReportBuilderLayouterName(String _sName)331 public void setReportBuilderLayouterName(String _sName) 332 { 333 final IReportBuilderLayouter aCurrentLayouter = getReportBuilderLayouter(); 334 final IReportBuilderLayouter aNewLayouter = (IReportBuilderLayouter) m_aLayoutMap.get(_sName); 335 if (aNewLayouter != null) 336 { 337 m_sReportBuilderLayoutName = _sName; 338 aNewLayouter.initializeData(aCurrentLayouter); 339 aNewLayouter.layout(); 340 } 341 } 342 liveupdate_changeContentTemplate(String ContentTemplatePath)343 public void liveupdate_changeContentTemplate(String ContentTemplatePath) 344 { 345 /* Left Listbox */ 346 setReportBuilderLayouterName(ContentTemplatePath); 347 } 348 layout_setupRecordSection(String TemplateName)349 public void layout_setupRecordSection(String TemplateName) 350 { 351 } 352 removeTextTableAndTextSection()353 public void removeTextTableAndTextSection() 354 { 355 } 356 layout_selectFirstPage()357 public void layout_selectFirstPage() 358 { 359 } 360 closeReportDefinition()361 private void closeReportDefinition() 362 { 363 try 364 { 365 if (m_documentDefinition != null) 366 { 367 // set the document to "not modified", to ensure that it won't ask the user before closing 368 XModifiable documentModify = UnoRuntime.queryInterface(XModifiable.class, m_reportDocument); 369 documentModify.setModified(false); 370 // actually close 371 XSubDocument subComponent = UnoRuntime.queryInterface(XSubDocument.class, m_documentDefinition); 372 subComponent.close(); 373 } 374 } 375 catch (Exception ex) 376 { 377 Logger.getLogger(ReportBuilderImplementation.class.getName()).log(Level.SEVERE, null, ex); 378 } 379 m_documentDefinition = null; 380 m_reportDocument = null; 381 } 382 dispose()383 public void dispose() 384 { 385 getReportBuilderLayouter().dispose(); 386 closeReportDefinition(); 387 } 388 getComponent()389 public XComponent getComponent() 390 { 391 return null; 392 } 393 liveupdate_changeUserFieldContent(String fieldName, String titlename)394 public void liveupdate_changeUserFieldContent(String fieldName, String titlename) 395 { 396 } 397 liveupdate_updateReportTitle(String _sTitleName)398 public void liveupdate_updateReportTitle(String _sTitleName) 399 { 400 } 401 addReportToDBView()402 public void addReportToDBView() 403 { 404 } 405 loadReport(final String i_reportName)406 private XComponent loadReport(final String i_reportName) 407 { 408 try 409 { 410 return m_documentUI.loadComponent(DatabaseObject.REPORT, i_reportName, false); 411 } 412 catch (Exception ex) 413 { 414 Logger.getLogger(ReportBuilderImplementation.class.getName()).log(Level.SEVERE, null, ex); 415 } 416 return null; 417 } 418 loadReportFromDocumentDefinition()419 private XComponent loadReportFromDocumentDefinition() 420 { 421 final XCommandProcessor commandProcessor = UnoRuntime.queryInterface(XCommandProcessor.class, m_documentDefinition); 422 423 com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command(); 424 aCommand.Name = "open"; 425 try 426 { 427 final Object result = commandProcessor.execute(aCommand, commandProcessor.createCommandIdentifier(), null); 428 return UnoRuntime.queryInterface(XComponent.class, result); 429 } 430 catch (Exception ex) 431 { 432 Logger.getLogger(ReportBuilderImplementation.class.getName()).log(Level.SEVERE, null, ex); 433 } 434 return null; 435 } 436 createAndOpenReportDocument(String i_name, boolean i_asTemplate, boolean i_openForEditing)437 public void createAndOpenReportDocument(String i_name, boolean i_asTemplate, boolean i_openForEditing) 438 { 439 if (i_openForEditing) 440 { 441 // we won't destroy the report builder window, also don't create a document 442 // Do we need to reopen the report builder with the known name? 443 switchOnAddFieldWindow(); 444 switchOnPropertyBrowser(); 445 return; 446 } 447 448 if (i_asTemplate) 449 { 450 // don't need the report definition anymore - the document it represents has already been stored 451 closeReportDefinition(); 452 453 // open the report, again, this time not in design, but containing data 454 loadReport(i_name); 455 } 456 else 457 { 458 // execute the report from the (yet unsaved) report definition 459 XComponent document = loadReportFromDocumentDefinition(); 460 461 // don't need the report definition anymore 462 closeReportDefinition(); 463 464 // store the generated report 465 if (getRecordParser().storeDatabaseDocumentToTempPath(document, i_name)) 466 { 467 getRecordParser().addReportDocument(document, false); 468 } 469 } 470 471 dispose(); 472 } 473 getConnection()474 private XConnection getConnection() 475 { 476 return getRecordParser().DBConnection; 477 } 478 initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames)479 public void initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames) 480 { 481 getRecordParser().initializeFieldColumns(FieldNames, TableName); 482 483 final com.sun.star.wizards.db.RecordParser a = getRecordParser(); 484 int[] FieldTypes = new int[FieldNames.length]; 485 int[] FieldWidths = new int[FieldNames.length]; 486 for (int i = 0; i < FieldNames.length; i++) 487 { 488 FieldTypes[i] = a.FieldColumns[i].getFieldType(); 489 FieldWidths[i] = a.FieldColumns[i].getFieldWidth(); 490 } 491 getReportBuilderLayouter().setTableName(_nType, TableName); 492 getReportBuilderLayouter().insertFieldNames(FieldNames); 493 getReportBuilderLayouter().insertFieldTypes(FieldTypes); 494 getReportBuilderLayouter().insertFieldWidths(FieldWidths); 495 496 getReportBuilderLayouter().layout(); 497 } 498 setFieldTitles(String[] _aFieldTitles)499 public void setFieldTitles(String[] _aFieldTitles) 500 { 501 getRecordParser().setFieldTitles(_aFieldTitles); 502 503 getReportBuilderLayouter().insertFieldTitles(_aFieldTitles); 504 getReportBuilderLayouter().layout(); 505 } 506 setSorting(String[][] _aSortFieldNames)507 public void setSorting(String[][] _aSortFieldNames) 508 { 509 getRecordParser().setSortFieldNames(_aSortFieldNames); 510 if (groupNames != null) 511 { 512 getRecordParser().prependSortFieldNames(groupNames); 513 } 514 getReportBuilderLayouter().insertSortingNames(_aSortFieldNames); 515 getReportBuilderLayouter().layout(); 516 } 517 setGrouping(String[] _aGroupFieldNames)518 public void setGrouping(String[] _aGroupFieldNames) 519 { 520 groupNames = _aGroupFieldNames; 521 getRecordParser().prependSortFieldNames(_aGroupFieldNames); 522 523 getReportBuilderLayouter().insertGroupNames(_aGroupFieldNames); 524 getReportBuilderLayouter().layout(); 525 } 526 getLayoutPath()527 public String getLayoutPath() 528 { 529 return "default"; 530 } 531 private ArrayList m_aReportPath; 532 getReportPath()533 public ArrayList getReportPath() 534 { 535 if (m_aReportPath == null) 536 { 537 try 538 { 539 // Check general availability of office paths 540 m_aReportPath = FileAccess.getOfficePaths(getMSF(), "Template", "share", "/wizard"); 541 FileAccess.combinePaths(getMSF(), m_aReportPath, "/wizard/report"); 542 } 543 catch (NoValidPathException ex) 544 { 545 Logger.getLogger(ReportBuilderImplementation.class.getName()).log(Level.SEVERE, null, ex); 546 } 547 } 548 return m_aReportPath; 549 } 550 getContentPath()551 public String getContentPath() 552 { 553 return PropertyNames.EMPTY_STRING; 554 } 555 getDefaultPageOrientation()556 public int getDefaultPageOrientation() 557 { 558 return m_nDefaultPageOrientation; 559 } 560 561 /** 562 * Helper function to get a com.sun.star.wizards.report.layout.ReportBuilderLayouter by it's name 563 * 564 * @param _sClassName 565 * @return the object or null 566 */ getLayoutInstanceFrom(String _sClassName)567 private IReportBuilderLayouter getLayoutInstanceFrom(String _sClassName) 568 { 569 try 570 { 571 // TODO: Use Package.getPackages(...) 572 final Class a = Class.forName(_sClassName); 573 574 final Constructor cTor = a.getConstructor(new Class[] 575 { 576 IReportDefinitionReadAccess.class, Resource.class 577 }); 578 Object[] aParams = new Object[2]; 579 aParams[0] = this; 580 aParams[1] = m_resource; 581 return (IReportBuilderLayouter) cTor.newInstance(aParams); 582 } 583 catch (Exception e) 584 { 585 e.printStackTrace(); 586 } 587 return null; 588 } 589 private LinkedHashMap m_aLayoutMap = null; 590 insertIntoLayoutMap(IReportBuilderLayouter _aLayout)591 private void insertIntoLayoutMap(IReportBuilderLayouter _aLayout) 592 { 593 insertIntoLayoutMap(_aLayout, false); 594 } 595 insertIntoLayoutMap(IReportBuilderLayouter _aLayout, boolean _bDefault)596 private void insertIntoLayoutMap(IReportBuilderLayouter _aLayout, boolean _bDefault) 597 { 598 if (_aLayout != null) 599 { 600 final String sName = _aLayout.getName(); 601 if (_bDefault) 602 { 603 m_sReportBuilderLayoutName = sName; // here we set the default layout name! 604 } 605 m_aLayoutMap.put(sName, _aLayout); 606 } 607 } 608 609 /** 610 * Initialize all well known com.sun.star.wizards.report.layout.ReportBuilderLayouter Objects and create exact one instance. 611 */ getLayoutMap()612 private LinkedHashMap getLayoutMap() 613 { 614 if (m_aLayoutMap == null) 615 { 616 // The LayoutMap is empty, so we create a new LinkedHashMap 617 m_aLayoutMap = new LinkedHashMap(); 618 619 // TODO: We must know the name of a layouts, There should be a way to say where to find, not the names. 620 IReportBuilderLayouter aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.Tabular"); 621 insertIntoLayoutMap(aLayout, true); 622 aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.ColumnarSingleColumn"); 623 insertIntoLayoutMap(aLayout); 624 aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.ColumnarTwoColumns"); 625 insertIntoLayoutMap(aLayout); 626 aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.ColumnarThreeColumns"); 627 insertIntoLayoutMap(aLayout); 628 aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.InBlocksLabelsAbove"); 629 insertIntoLayoutMap(aLayout); 630 aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.InBlocksLabelsLeft"); 631 insertIntoLayoutMap(aLayout); 632 633 } 634 return m_aLayoutMap; 635 } 636 637 /** 638 * Return a string array array with all found layouts 639 * At the moment these layout are hard coded 640 * @return 641 */ getDataLayout()642 public String[][] getDataLayout() 643 { 644 String[][] ContentFiles; 645 ContentFiles = new String[2][]; 646 String[] a = new String[getLayoutMap().size()]; 647 String[] b = new String[getLayoutMap().size()]; 648 649 // run through the whole layoutmap and 650 final Set aKeys = getLayoutMap().keySet(); 651 final Iterator aKeyIterator = aKeys.iterator(); 652 int i = 0; 653 while (aKeyIterator.hasNext()) 654 { 655 final String sKey = (String) aKeyIterator.next(); 656 a[i] = sKey; 657 final IReportBuilderLayouter aLayouter = (IReportBuilderLayouter) m_aLayoutMap.get(sKey); 658 b[i++] = aLayouter.getLocalizedName(); 659 } 660 661 ContentFiles[1] = a; 662 ContentFiles[0] = b; 663 return ContentFiles; 664 } 665 private String m_sDefaultHeaderLayoutPath; 666 getHeaderLayout()667 public String[][] getHeaderLayout() 668 { 669 String[][] LayoutFiles; 670 try 671 { 672 // TODO: check different languages in header layouts 673 ArrayList aReportPath = FileAccess.getOfficePaths(getMSF(), "Template", "share", "/wizard"); 674 FileAccess.combinePaths(getMSF(), aReportPath, "/wizard/report"); 675 676 LayoutFiles = FileAccess.getFolderTitles(getMSF(), null, aReportPath, ".otr"); 677 } 678 catch (com.sun.star.wizards.common.NoValidPathException e) 679 { 680 // if there are problems, don't show anything is a little bit hard. 681 LayoutFiles = new String[2][]; 682 String[] a = new String[1]; 683 String[] b = new String[1]; 684 a[0] = "DefaultLayoutOfHeaders"; 685 b[0] = "default"; 686 LayoutFiles[1] = a; 687 LayoutFiles[0] = b; 688 } 689 for (int i = 0; i < LayoutFiles[0].length; i++) 690 { 691 if (LayoutFiles[0][i].equals("default")) 692 { 693 m_sDefaultHeaderLayoutPath = LayoutFiles[1][i]; 694 break; 695 } 696 } 697 return LayoutFiles; 698 } 699 getReportDefinition()700 public XReportDefinition getReportDefinition() 701 { 702 if (m_reportDocument == null) 703 { 704 throw new NullPointerException("Report Definition is not already initialized, check if you too early access the report definition."); 705 } 706 return m_reportDocument; 707 } 708 getGlobalMSF()709 public XMultiServiceFactory getGlobalMSF() 710 { 711 return getMSF(); 712 } 713 importReportData(ReportWizard aWizard)714 public void importReportData(ReportWizard aWizard) 715 { 716 } 717 getDefaultHeaderLayout()718 public String getDefaultHeaderLayout() 719 { 720 return m_sDefaultHeaderLayoutPath; 721 } 722 setCommand(String _sCommand)723 public void setCommand(String _sCommand) 724 { 725 getRecordParser().Command = _sCommand; 726 getReportDefinition().setCommand(_sCommand); 727 } 728 setCommandType(int _nCommand)729 public void setCommandType(int _nCommand) 730 { 731 getReportDefinition().setCommandType(_nCommand); 732 } 733 checkInvariants()734 public void checkInvariants() throws java.lang.Exception 735 { 736 final String sDefaultHeaderLayoutPath = getDefaultHeaderLayout(); 737 if (sDefaultHeaderLayoutPath == null) 738 { 739 throw new java.io.IOException("default.otr"); 740 } 741 742 FileAccess aAccess = new FileAccess(getGlobalMSF()); 743 if (!aAccess.exists(sDefaultHeaderLayoutPath, true)) 744 { 745 throw new java.io.IOException("default.otr"); 746 } 747 } 748 } 749