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.report; 24 25 // import java.util.Vector; 26 import com.sun.star.awt.TextEvent; 27 import com.sun.star.awt.VclWindowPeerAttribute; 28 import com.sun.star.awt.XTextListener; 29 import com.sun.star.beans.PropertyValue; 30 31 import com.sun.star.container.XContentEnumerationAccess; 32 import com.sun.star.deployment.XPackageInformationProvider; 33 import com.sun.star.lang.EventObject; 34 import com.sun.star.lang.XMultiServiceFactory; 35 import com.sun.star.logging.XLogger; 36 import com.sun.star.logging.XLoggerPool; 37 import com.sun.star.sdb.CommandType; 38 39 import com.sun.star.uno.AnyConverter; 40 import com.sun.star.uno.UnoRuntime; 41 import com.sun.star.uno.XComponentContext; 42 43 import com.sun.star.logging.LogLevel; 44 import com.sun.star.wizards.common.Helper; 45 import com.sun.star.wizards.common.JavaTools; 46 import com.sun.star.wizards.common.Resource; 47 import com.sun.star.wizards.common.SystemDialog; 48 import com.sun.star.wizards.common.PropertyNames; 49 import com.sun.star.wizards.db.DBMetaData; 50 import com.sun.star.wizards.db.DatabaseObjectWizard; 51 import com.sun.star.wizards.db.RecordParser; 52 import com.sun.star.wizards.db.SQLQueryComposer; 53 import com.sun.star.wizards.ui.CommandFieldSelection; 54 import com.sun.star.wizards.ui.FieldSelection; 55 import com.sun.star.wizards.ui.SortingComponent; 56 import com.sun.star.wizards.ui.TitlesComponent; 57 import com.sun.star.wizards.ui.UIConsts; 58 import com.sun.star.wizards.ui.UnoDialog; 59 import com.sun.star.wizards.ui.XCompletion; 60 import java.lang.reflect.Method; 61 import java.net.URI; 62 import java.net.URL; 63 import java.net.URLClassLoader; 64 import java.util.Map; 65 66 public class ReportWizard extends DatabaseObjectWizard implements XTextListener, XCompletion 67 { 68 69 protected FieldSelection CurGroupFieldSelection; 70 private SortingComponent CurSortingComponent; 71 private TitlesComponent CurTitlesComponent; 72 private CommandFieldSelection CurDBCommandFieldSelection; 73 private GroupFieldHandler CurGroupFieldHandler; 74 private ReportLayouter CurReportLayouter; 75 private ReportFinalizer CurReportFinalizer; 76 private int nReportMode = ReportFinalizer.SOCREATEDOCUMENT; 77 private String m_sReportName = PropertyNames.EMPTY_STRING; 78 protected static final String SOREPORTFORMNAME = "ReportSource"; 79 private static final int SOMAINPAGE = 1; 80 private static final int SOTITLEPAGE = 2; 81 protected static final int SOGROUPPAGE = 3; 82 private static final int SOSORTPAGE = 4; 83 protected static final int SOTEMPLATEPAGE = 5; 84 protected static final int SOSTOREPAGE = 6; 85 private IReportDocument m_reportDocument; 86 private static String sMsgWizardName; 87 private static String slblFields; 88 private static String slblSelFields; 89 private static String sShowBinaryFields; 90 private String[] WizardHeaderText = new String[6]; 91 private static String slblColumnTitles; 92 private static String slblColumnNames; 93 private static String slblTables; 94 protected static boolean bCloseDocument; 95 private boolean bHasEscapeProcessing = true; 96 ReportWizard(XMultiServiceFactory i_serviceFactory, final PropertyValue[] i_wizardContext)97 public ReportWizard(XMultiServiceFactory i_serviceFactory, final PropertyValue[] i_wizardContext) 98 { 99 super(i_serviceFactory, 34320, i_wizardContext); 100 super.addResourceHandler("Report Wizard", "dbw"); 101 if (getReportResources(false)) 102 { 103 Helper.setUnoPropertyValues(xDialogModel, 104 new String[] 105 { 106 PropertyNames.PROPERTY_HEIGHT, 107 PropertyNames.PROPERTY_MOVEABLE, 108 PropertyNames.PROPERTY_NAME, 109 PropertyNames.PROPERTY_POSITION_X, 110 PropertyNames.PROPERTY_POSITION_Y, 111 PropertyNames.PROPERTY_STEP, 112 PropertyNames.PROPERTY_TABINDEX, 113 PropertyNames.PROPERTY_TITLE, 114 PropertyNames.PROPERTY_WIDTH 115 }, 116 new Object[] 117 { 118 Integer.valueOf(210), 119 Boolean.TRUE, 120 "DialogReport", 121 102, 122 41, 123 1, 124 new Short((short) 0), 125 sMsgWizardName, 126 310 127 }); 128 drawNaviBar(); 129 setRightPaneHeaders(this.WizardHeaderText); 130 } 131 } 132 enterStep(int nOldStep, int nNewStep)133 protected void enterStep(int nOldStep, int nNewStep) 134 { 135 if ((nOldStep >= SOTEMPLATEPAGE) && (nNewStep < SOTEMPLATEPAGE)) 136 { 137 // CurReportDocument.getDoc().oTextSectionHandler.removeTextSectionbyName("RecordSection"); 138 // CurReportDocument.getDoc().oTextTableHandler.removeTextTablebyName("Tbl_RecordSection"); 139 m_reportDocument.removeTextTableAndTextSection(); 140 } 141 switch (nNewStep) 142 { 143 case SOMAINPAGE: 144 CurDBCommandFieldSelection.setModified(false); 145 break; 146 147 case SOTITLEPAGE: 148 String[] aFieldNames = m_reportDocument.getRecordParser().getFieldNames(); 149 Map aFieldTitleSet = m_reportDocument.getRecordParser().getFieldTitleSet(); 150 CurTitlesComponent.initialize(aFieldNames, aFieldTitleSet); 151 break; 152 153 case SOGROUPPAGE: 154 CurGroupFieldHandler.initialize(); 155 break; 156 157 case SOSORTPAGE: 158 String[] aFieldNames2 = m_reportDocument.getRecordParser().getFieldNames(); 159 String[][] aSortFieldNames = m_reportDocument.getRecordParser().getSortFieldNames(); 160 CurSortingComponent.initialize(aFieldNames2, aSortFieldNames); 161 int nLength = m_reportDocument.getRecordParser().GroupFieldNames.length; 162 CurSortingComponent.setReadOnlyUntil(nLength, false); 163 break; 164 165 case SOTEMPLATEPAGE: 166 break; 167 168 case SOSTOREPAGE: 169 //TODO initialize with suitable PathName 170 CurReportFinalizer.initialize(m_reportDocument.getRecordParser()); 171 break; 172 173 default: 174 break; 175 } 176 } 177 leaveStep(int nOldStep, int nNewStep)178 protected void leaveStep(int nOldStep, int nNewStep) 179 { 180 181 switch (nOldStep) 182 { 183 case SOMAINPAGE: 184 String[] aSelectedFieldNames = CurDBCommandFieldSelection.getSelectedFieldNames(); 185 String aTableName = CurDBCommandFieldSelection.getSelectedCommandName(); 186 int nType = CurDBCommandFieldSelection.getSelectedCommandType(); 187 m_reportDocument.initializeFieldColumns(nType, aTableName, aSelectedFieldNames); 188 if (CurDBCommandFieldSelection.isModified()) 189 { 190 // cleanup document 191 m_reportDocument.clearDocument(); 192 m_reportDocument.getRecordParser().setGroupFieldNames(new String[] 193 { 194 }); 195 CurGroupFieldHandler.removeGroupFieldNames(); 196 } 197 break; 198 199 case SOTITLEPAGE: 200 String[] sFieldTitles = CurTitlesComponent.getFieldTitles(); 201 // set new field name titles 202 // CurReportDocument.getRecordParser().setFieldTitles(sFieldTitles); 203 m_reportDocument.setFieldTitles(sFieldTitles); 204 break; 205 206 case SOGROUPPAGE: 207 // TODO: DESIGN!!! a getter should return a value!!! 208 CurGroupFieldHandler.getGroupFieldNames(m_reportDocument.getRecordParser()); 209 String[] aGroupFieldNames = m_reportDocument.getRecordParser().GroupFieldNames; 210 // CurReportDocument.getRecordParser().prependSortFieldNames(aGroupFieldNames); 211 m_reportDocument.setGrouping(aGroupFieldNames); 212 break; 213 214 case SOSORTPAGE: 215 String[][] aSortFieldNames = CurSortingComponent.getSortFieldNames(); 216 // CurReportDocument.getRecordParser().SortFieldNames = aSortFieldNames; 217 m_reportDocument.setSorting(aSortFieldNames); 218 // TODO: why do we make a switch here 219 super.enablefromStep(SOTEMPLATEPAGE, true); 220 break; 221 222 case SOTEMPLATEPAGE: 223 break; 224 225 case SOSTOREPAGE: 226 break; 227 228 default: 229 break; 230 } 231 232 if ((nOldStep < SOTEMPLATEPAGE) && (super.getNewStep() >= SOTEMPLATEPAGE)) 233 { 234 // this is called before SOTEMPLATEPAGE, after SOGROUPPAGE 235 m_reportDocument.getRecordParser().createRecordFieldNames(); 236 CurReportLayouter.initialize(m_reportDocument.getContentPath()); 237 } 238 } 239 dialogFinish()240 private void dialogFinish() 241 { 242 this.xComponent.dispose(); 243 if (bCloseDocument) 244 { 245 m_reportDocument.dispose(); 246 return; 247 } 248 249 if ((nReportMode == ReportFinalizer.SOCREATETEMPLATE) 250 || (nReportMode == ReportFinalizer.SOUSETEMPLATE)) 251 { 252 m_reportDocument.addReportToDBView(); 253 boolean bOpenInDesign = (nReportMode == ReportFinalizer.SOCREATETEMPLATE); 254 m_reportDocument.createAndOpenReportDocument(m_sReportName, true, bOpenInDesign); 255 } 256 else 257 { 258 m_reportDocument.importReportData(this); 259 m_reportDocument.createAndOpenReportDocument(m_sReportName, false, false); 260 } 261 } 262 executeQuery()263 private boolean executeQuery() 264 { 265 boolean bQueryCreated = false; 266 final RecordParser recordParser = m_reportDocument.getRecordParser(); 267 final SQLQueryComposer sqlQueryComposer = recordParser.getSQLQueryComposer(); 268 if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE) 269 { 270 if (m_reportDocument instanceof ReportTextImplementation) 271 { 272 bQueryCreated = sqlQueryComposer.setQueryCommand(this.xWindow, false, false); 273 m_reportDocument.setCommandType(CommandType.COMMAND); 274 String sQuery = sqlQueryComposer.getQuery(); 275 m_reportDocument.setCommand(sQuery); 276 } 277 else 278 { 279 bQueryCreated = true; 280 } 281 } 282 else 283 { 284 try 285 { 286 String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName(); 287 DBMetaData.CommandObject oCommand = recordParser.getQueryByName(sQueryName); 288 bHasEscapeProcessing = recordParser.hasEscapeProcessing(oCommand.getPropertySet()); 289 String sCommand = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND); 290 if (bHasEscapeProcessing) 291 { 292 // String sCommand = (String) oCommand.xPropertySet.getPropertyValue(PropertyNames.COMMAND); 293 bQueryCreated = (!sCommand.equals(PropertyNames.EMPTY_STRING)); 294 if (m_reportDocument instanceof ReportTextImplementation) 295 { 296 sqlQueryComposer.m_xQueryAnalyzer.setQuery(sCommand); 297 sqlQueryComposer.prependSortingCriteria(); 298 m_reportDocument.setCommandType(CommandType.COMMAND); 299 m_reportDocument.setCommand(sqlQueryComposer.getQuery()); 300 } 301 } 302 else 303 { 304 m_reportDocument.setCommandType(CommandType.COMMAND); 305 m_reportDocument.setCommand(sCommand); 306 } 307 bQueryCreated = true; 308 } 309 catch (Exception e) 310 { 311 e.printStackTrace(System.out); 312 } 313 } 314 if (!bQueryCreated) 315 { 316 super.vetoableChange(null); 317 } 318 return bQueryCreated; 319 } 320 buildSteps()321 public void buildSteps() 322 { 323 // CurReportDocument.getDoc().xProgressBar.setValue(30); 324 CurDBCommandFieldSelection = new CommandFieldSelection(this, m_reportDocument.getRecordParser(), 100, slblFields, slblSelFields, slblTables, true, 34330); 325 CurDBCommandFieldSelection.addFieldSelectionListener(new FieldSelectionListener()); 326 if (!isReportBuilderInstalled()) 327 { 328 insertLabel("lblBinaryFields", 329 new String[] 330 { 331 PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH 332 }, 333 new Object[] 334 { 335 16, sShowBinaryFields, 95, 162, 1, 210 336 }); 337 } 338 // CurReportDocument.getDoc().xProgressBar.setValue(40); 339 CurTitlesComponent = new TitlesComponent(this, SOTITLEPAGE, 97, 37, 210, 7, slblColumnNames, slblColumnTitles, 34381); 340 CurTitlesComponent.addTextListener(this); 341 // CurReportDocument.getDoc().xProgressBar.setValue(50); 342 CurGroupFieldHandler = new GroupFieldHandler(m_reportDocument, this); 343 // CurReportDocument.getDoc().xProgressBar.setValue(60); 344 CurSortingComponent = new SortingComponent(this, SOSORTPAGE, 95, 30, 210, 34346); 345 // CurReportDocument.getDoc().xProgressBar.setValue(70); 346 CurReportLayouter = new ReportLayouter(xMSF, m_reportDocument, this); 347 // CurReportDocument.getDoc().xProgressBar.setValue(80); 348 CurReportFinalizer = new ReportFinalizer(xMSF, m_reportDocument, this); 349 // CurReportDocument.getDoc().xProgressBar.setValue(100); 350 bCloseDocument = true; 351 // CurReportDocument.getDoc().xProgressBar.end(); 352 enableNavigationButtons(false, false, false); 353 } 354 finishWizard()355 public boolean finishWizard() 356 { 357 final int ncurStep = getCurrentStep(); 358 if ((switchToStep(ncurStep, SOSTOREPAGE)) || (ncurStep == SOSTOREPAGE)) 359 { 360 if (this.executeQuery()) 361 { 362 if (CurReportFinalizer.finish()) 363 { 364 nReportMode = CurReportFinalizer.getReportOpenMode(); 365 m_sReportName = CurReportFinalizer.getStoreName(); 366 xDialog.endExecute(); 367 return true; 368 } 369 } 370 } 371 return false; 372 } 373 cancelWizard()374 public void cancelWizard() 375 { 376 xDialog.endExecute(); 377 } 378 insertQueryRelatedSteps()379 public void insertQueryRelatedSteps() 380 { 381 setRMItemLabels(m_oResource, UIConsts.RID_QUERY + 80); 382 addRoadmap(); 383 int i = 0; 384 i = insertRoadmapItem(0, true, m_oResource.getResText(UIConsts.RID_QUERY + 80), SOMAINPAGE); 385 i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 68), SOTITLEPAGE); 386 i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 11), SOGROUPPAGE); 387 i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 12), SOSORTPAGE); // Orderby is always supported 388 i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 13), SOTEMPLATEPAGE); 389 i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 14), SOSTOREPAGE); 390 setRoadmapInteractive(true); 391 setRoadmapComplete(true); 392 setCurrentRoadmapItemID((short) 1); 393 } 394 isReportBuilderInstalled()395 private boolean isReportBuilderInstalled() 396 { 397 //! Check if the new Report Builder Extension is available 398 XContentEnumerationAccess a = com.sun.star.uno.UnoRuntime.queryInterface(XContentEnumerationAccess.class, xMSF); 399 com.sun.star.container.XEnumeration e = a.createContentEnumeration("com.sun.star.report.pentaho.SOReportJobFactory"); 400 if (e == null) 401 { 402 return false; 403 } 404 return e.hasMoreElements(); 405 } 406 407 /** 408 * Return the path to the "com.sun.reportdesigner" extension 409 * @param _xMSF 410 * @return 411 */ getPathToExtension(XMultiServiceFactory _xMSF)412 public static String getPathToExtension(XMultiServiceFactory _xMSF) 413 { 414 // Get the path to the extension and try to add the path to the class loader 415 final XComponentContext xComponentContext = Helper.getComponentContext(_xMSF); 416 final Object aSingleton = xComponentContext.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider"); 417 XPackageInformationProvider xProvider = UnoRuntime.queryInterface(XPackageInformationProvider.class, aSingleton); 418 return xProvider.getPackageLocation("com.sun.reportdesigner"); 419 } 420 private static XLogger m_xLogger; 421 initializeLogger(XMultiServiceFactory _xMSF)422 private static void initializeLogger(XMultiServiceFactory _xMSF) 423 { 424 XComponentContext xContext = Helper.getComponentContext(_xMSF); 425 426 final Object aLoggerPool = xContext.getValueByName("/singletons/com.sun.star.logging.LoggerPool"); 427 if (aLoggerPool == null) 428 { 429 System.out.println("Can't get singleton from logging"); 430 } 431 final XLoggerPool xLoggerPool = UnoRuntime.queryInterface(XLoggerPool.class, aLoggerPool); 432 m_xLogger = xLoggerPool.getNamedLogger("com.sun.star.wizards.ReportBuilder"); 433 } 434 getLogger()435 public static XLogger getLogger() 436 { 437 return m_xLogger; 438 } 439 startReportWizard()440 public void startReportWizard() 441 { 442 initializeLogger(xMSF); 443 getLogger().log(LogLevel.SEVERE, "Start Report Wizard"); 444 445 if (isReportBuilderInstalled()) 446 { 447 // Get the path to the extension and try to add the path to the class loader 448 String sLocation = getPathToExtension(xMSF); 449 // TODO: Umlaut in filename! 450 if (sLocation.length() > 0) 451 { 452 try 453 { 454 URI aLocationURI = URI.create(sLocation + "/" + "reportbuilderwizard.jar"); 455 456 URL[] aURLs = new URL[1]; 457 aURLs[0] = aLocationURI.toURL(); 458 URLClassLoader aClassLoader = new URLClassLoader(aURLs, this.getClass().getClassLoader()); 459 Class a = aClassLoader.loadClass("com.sun.star.wizards.reportbuilder.ReportBuilderImplementation"); 460 Method aMethod = a.getMethod("create", new Class[] 461 { 462 XMultiServiceFactory.class 463 }); 464 m_reportDocument = (IReportDocument) aMethod.invoke(a, xMSF 465 ); 466 } 467 catch (Exception e) 468 { 469 // Maybe problems in URI create() if a wrong char is used like '[' ']', ... 470 System.out.println("There could be a problem with the path '" + sLocation + "'"); 471 } 472 } 473 } 474 475 try 476 { 477 if (m_reportDocument == null) 478 { 479 // Fallback, if there is no reportbuilder wizard implementation, we use the old wizard 480 m_reportDocument = new ReportTextImplementation(xMSF); 481 } 482 483 m_reportDocument.initialize(m_docUI, m_oResource); 484 485 if (m_reportDocument.getRecordParser().getConnection(m_wizardContext)) 486 { 487 buildSteps(); 488 489 m_reportDocument.checkInvariants(); 490 491 this.CurDBCommandFieldSelection.preselectCommand(m_wizardContext, false); 492 493 createWindowPeer(m_reportDocument.getWizardParent()); 494 495 m_reportDocument.getRecordParser().setWindowPeer(this.xControl.getPeer()); 496 insertQueryRelatedSteps(); 497 short RetValue = executeDialog(m_reportDocument.getFrame().getComponentWindow().getPosSize()); 498 if (RetValue == 0) 499 { 500 dialogFinish(); 501 } 502 } 503 m_reportDocument.getRecordParser().dispose(); 504 } 505 catch (java.io.IOException e) 506 { 507 String sMessage = e.getMessage(); 508 if (sMessage.equals("default.otr")) 509 { 510 sMessage = m_oResource.getResText(UIConsts.RID_REPORT + 92); 511 } 512 else 513 { 514 } 515 // show a dialog with the error message 516 SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMessage); 517 } 518 catch (java.lang.Exception jexception) 519 { 520 jexception.printStackTrace(System.out); 521 } 522 } 523 importReportData(final XMultiServiceFactory xMSF, final Dataimport CurDataimport)524 public void importReportData(final XMultiServiceFactory xMSF, final Dataimport CurDataimport) 525 { 526 boolean bDocisStored = false; 527 try 528 { 529 boolean bexecute = false; 530 if (!bHasEscapeProcessing) 531 { 532 bexecute = m_reportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.QUERY); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) 533 } 534 else 535 { 536 bexecute = m_reportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.COMMAND); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) 537 } 538 if (bexecute) 539 { 540 bexecute = m_reportDocument.getRecordParser().getFields(m_reportDocument.getRecordParser().getFieldNames(), false); 541 } 542 if (bexecute) 543 { 544 // CurDataimport.insertDatabaseDatatoReportDocument(xMSF); 545 m_reportDocument.insertDatabaseDatatoReportDocument(xMSF); 546 } 547 548 if (CurReportFinalizer.getReportOpenMode() == ReportFinalizer.SOCREATEDOCUMENT) 549 { 550 bDocisStored = m_reportDocument.getRecordParser().storeDatabaseDocumentToTempPath(m_reportDocument.getComponent(), CurReportFinalizer.getStoreName()); 551 } 552 } 553 catch (com.sun.star.wizards.common.InvalidQueryException queryexception) 554 { 555 } 556 CurDataimport.xComponent.dispose(); 557 if (bDocisStored) 558 { 559 m_reportDocument.getRecordParser().addReportDocument(m_reportDocument.getComponent(), false); 560 } 561 562 m_reportDocument.getRecordParser().dispose(); 563 } 564 getReportResources(boolean bgetProgressResourcesOnly)565 public boolean getReportResources(boolean bgetProgressResourcesOnly) 566 { 567 sMsgWizardName = super.m_oResource.getResText(UIConsts.RID_REPORT); 568 if (!bgetProgressResourcesOnly) 569 { 570 sShowBinaryFields = m_oResource.getResText(UIConsts.RID_REPORT + 60); 571 slblTables = m_oResource.getResText(UIConsts.RID_FORM + 6); 572 slblFields = m_oResource.getResText(UIConsts.RID_FORM + 12); 573 slblSelFields = m_oResource.getResText(UIConsts.RID_REPORT + 9); 574 WizardHeaderText[0] = m_oResource.getResText(UIConsts.RID_REPORT + 28); 575 WizardHeaderText[1] = m_oResource.getResText(UIConsts.RID_REPORT + 69); 576 WizardHeaderText[2] = m_oResource.getResText(UIConsts.RID_REPORT + 29); 577 WizardHeaderText[3] = m_oResource.getResText(UIConsts.RID_REPORT + 30); 578 WizardHeaderText[4] = m_oResource.getResText(UIConsts.RID_REPORT + 31); 579 WizardHeaderText[5] = m_oResource.getResText(UIConsts.RID_REPORT + 32); 580 } 581 slblColumnTitles = m_oResource.getResText(UIConsts.RID_REPORT + 70); 582 slblColumnNames = m_oResource.getResText(UIConsts.RID_REPORT + 71); 583 return true; 584 } 585 getBlindTextNote(Object _aDocument, Resource _oResource)586 public static String getBlindTextNote(Object _aDocument, Resource _oResource) 587 { 588 String sBlindTextNote = PropertyNames.EMPTY_STRING; 589 if (_aDocument instanceof ReportTextImplementation) 590 { 591 sBlindTextNote = _oResource.getResText(UIConsts.RID_REPORT + 75); 592 sBlindTextNote = JavaTools.replaceSubString(sBlindTextNote, String.valueOf((char) 13), "<BR>"); 593 } 594 return sBlindTextNote; 595 } 596 enableRoadmapItems(boolean _bEnabled)597 public void enableRoadmapItems(boolean _bEnabled) 598 { 599 try 600 { 601 Object oRoadmapItem = null; 602 int CurStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP)); 603 boolean bEnabled = false; 604 int CurItemID; 605 for (int i = 0; i < getRMItemCount(); i++) 606 { 607 oRoadmapItem = this.xIndexContRoadmap.getByIndex(i); 608 CurItemID = AnyConverter.toInt(Helper.getUnoPropertyValue(oRoadmapItem, "ID")); 609 if (CurItemID > CurStep) 610 { 611 bEnabled = _bEnabled; 612 } 613 else 614 { 615 bEnabled = true; 616 } 617 618 Helper.setUnoPropertyValue(oRoadmapItem, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); 619 } 620 } 621 catch (com.sun.star.uno.Exception exception) 622 { 623 exception.printStackTrace(System.out); 624 } 625 } 626 enableWizardSteps(String[] NewItems)627 private void enableWizardSteps(String[] NewItems) 628 { 629 boolean bEnabled = NewItems.length > 0; 630 setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); 631 setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); 632 enableRoadmapItems(bEnabled); // Note: Performancewise this could be improved 633 } 634 textChanged(TextEvent xTextEvent)635 public void textChanged(TextEvent xTextEvent) 636 { 637 try 638 { 639 Object oModel = UnoDialog.getModel(xTextEvent.Source); 640 String sContent = (String) Helper.getUnoPropertyValue(oModel, "Text"); 641 String fieldname = this.CurTitlesComponent.getFieldNameByTitleControl(oModel); 642 // CurReportDocument.getDoc().oTextFieldHandler.changeUserFieldContent(fieldname, sfieldtitle); 643 m_reportDocument.liveupdate_changeUserFieldContent(fieldname, sContent); 644 } 645 catch (Exception exception) 646 { 647 exception.printStackTrace(System.out); 648 } 649 } 650 disposing(EventObject EventObject)651 public void disposing(EventObject EventObject) 652 { 653 } 654 setmodified(int _ndialogpage, Object ooldValue, Object onewValue)655 public void setmodified(int _ndialogpage, Object ooldValue, Object onewValue) 656 { 657 switch (_ndialogpage) 658 { 659 case SOMAINPAGE: 660 break; 661 default: 662 break; 663 } 664 } 665 toggleSortingPage()666 private void toggleSortingPage() 667 { 668 int nlCommandType = this.CurDBCommandFieldSelection.getSelectedCommandType(); 669 boolean bdoenable = (nlCommandType == CommandType.TABLE); 670 if (!bdoenable) 671 { 672 String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName(); 673 DBMetaData.CommandObject oCommand = m_reportDocument.getRecordParser().getQueryByName(sQueryName); 674 bdoenable = m_reportDocument.getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()); 675 } 676 super.setStepEnabled(SOSORTPAGE, bdoenable); 677 678 // int nCommandType = this.CurDBCommandFieldSelection.getSelectedCommandType(); 679 // super.setStepEnabled(SOSORTPAGE, (nCommandType == CommandType.TABLE)); 680 } 681 682 public class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener 683 { 684 685 protected int m_nID; 686 getID()687 public int getID() 688 { 689 return m_nID; 690 } 691 setID(String sIncSuffix)692 public void setID(String sIncSuffix) 693 { 694 m_nID = 1; 695 if (sIncSuffix != null) 696 { 697 if ((!sIncSuffix.equals(PropertyNames.EMPTY_STRING)) && (!sIncSuffix.equals("_"))) 698 { 699 String sID = JavaTools.ArrayoutofString(sIncSuffix, "_")[1]; 700 m_nID = Integer.parseInt(sID); 701 } 702 } 703 } 704 shiftFromLeftToRight(String[] SelItems, String[] NewItems)705 public void shiftFromLeftToRight(String[] SelItems, String[] NewItems) 706 { 707 if (m_nID == 1) 708 { 709 CurDBCommandFieldSelection.setModified(true); 710 enableWizardSteps(NewItems); 711 toggleSortingPage(); 712 } 713 else 714 { 715 boolean bEnabled = (CurGroupFieldSelection.getSelectedFieldNames().length > 0); 716 Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPPAGE), PropertyNames.PROPERTY_ENABLED, bEnabled); 717 } 718 } 719 shiftFromRightToLeft(String[] SelItems, String[] NewItems)720 public void shiftFromRightToLeft(String[] SelItems, String[] NewItems) 721 { 722 // TODO When the ListFieldbox is refilled only fields of the current Command may be merged into the Listbox 723 if (m_nID == 1) 724 { 725 enableWizardSteps(NewItems); 726 CurDBCommandFieldSelection.setModified(true); 727 } 728 else 729 { 730 boolean bEnabled = (CurGroupFieldSelection.getSelectedFieldNames().length > 0); 731 Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPPAGE), PropertyNames.PROPERTY_ENABLED, bEnabled); 732 } 733 } 734 moveItemDown(String item)735 public void moveItemDown(String item) 736 { 737 } 738 moveItemUp(String item)739 public void moveItemUp(String item) 740 { 741 } 742 } 743 // public void tests() 744 // { 745 // 746 // Calendar aCalendar = new GregorianCalendar(); 747 // aCalendar.setTimeInMillis(1202382900000L); 748 // String aCalStr = aCalendar.toString(); 749 // 750 // Date aDate = new Date(); 751 // aDate.setSeconds(0); 752 // aDate.setMinutes(15); 753 // aDate.setHours(12); 754 // // aDate.setMonth(2); 755 // // aDate.setYear(2008); 756 // // aDate.setDay(7); 757 // long nTime = aDate.getTime(); 758 // Long aLong = new Long(nTime); 759 // String aStr = aLong.toString(); 760 // 761 // Date aNewDate = new Date(1202382900000L); 762 //// aNewDate. 763 // String aDateStr = aNewDate.toString(); 764 //// Datetime aNewTime = new Time(1202382900); 765 //// String aTimeStr = aNewTime.toString(); 766 // 767 // } 768 } 769