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.fax; 24 25 import java.util.Vector; 26 import com.sun.star.lang.XMultiServiceFactory; 27 import com.sun.star.wizards.common.Desktop; 28 import com.sun.star.wizards.common.NoValidPathException; 29 import com.sun.star.wizards.common.SystemDialog; 30 import com.sun.star.awt.VclWindowPeerAttribute; 31 import com.sun.star.awt.XTextComponent; 32 import com.sun.star.awt.XWindow; 33 import com.sun.star.awt.XWindowPeer; 34 import com.sun.star.beans.PropertyValue; 35 import com.sun.star.document.XDocumentProperties; 36 import com.sun.star.document.XDocumentPropertiesSupplier; 37 import com.sun.star.graphic.XGraphicProvider; 38 import com.sun.star.graphic.XGraphic; 39 import com.sun.star.uno.AnyConverter; 40 import com.sun.star.uno.Exception; 41 import com.sun.star.uno.RuntimeException; 42 import com.sun.star.uno.UnoRuntime; 43 import com.sun.star.wizards.text.*; 44 import com.sun.star.wizards.common.*; 45 import com.sun.star.task.XInteractionHandler; 46 import com.sun.star.text.XTextDocument; 47 import com.sun.star.uno.XInterface; 48 import com.sun.star.util.CloseVetoException; 49 import com.sun.star.util.XCloseable; 50 import com.sun.star.wizards.document.*; 51 import com.sun.star.wizards.ui.*; 52 import com.sun.star.wizards.ui.event.*; 53 import com.sun.star.wizards.common.Helper; 54 import com.sun.star.document.MacroExecMode; 55 56 public class FaxWizardDialogImpl extends FaxWizardDialog 57 { 58 enterStep(int OldStep, int NewStep)59 protected void enterStep(int OldStep, int NewStep) 60 { 61 } 62 leaveStep(int OldStep, int NewStep)63 protected void leaveStep(int OldStep, int NewStep) 64 { 65 } 66 static FaxDocument myFaxDoc; 67 static boolean running; 68 XTextDocument xTextDocument; 69 PathSelection myPathSelection; 70 CGFaxWizard myConfig; 71 Vector mainDA = new Vector(); 72 Vector faxDA = new Vector(); 73 String[][] BusinessFiles; 74 String[][] PrivateFiles; 75 String sTemplatePath; 76 String sUserTemplatePath; 77 String sBitmapPath; 78 String sFaxPath; 79 String sWorkPath; 80 String sPath; 81 boolean bEditTemplate; 82 boolean bSaveSuccess = false; 83 private boolean filenameChanged = false; 84 final static int RM_TYPESTYLE = 1; 85 final static int RM_ELEMENTS = 2; 86 final static int RM_SENDERRECEIVER = 3; 87 final static int RM_FOOTER = 4; 88 final static int RM_FINALSETTINGS = 5; 89 FaxWizardDialogImpl(XMultiServiceFactory xmsf)90 public FaxWizardDialogImpl(XMultiServiceFactory xmsf) 91 { 92 super(xmsf); 93 } 94 main(String args[])95 public static void main(String args[]) 96 { 97 //only being called when starting wizard remotely 98 99 try 100 { 101 String ConnectStr = "uno:socket,host=127.0.0.1,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager"; 102 XMultiServiceFactory xLocMSF = Desktop.connect(ConnectStr); 103 FaxWizardDialogImpl lw = new FaxWizardDialogImpl(xLocMSF); 104 lw.startWizard(xLocMSF, null); 105 } 106 catch (RuntimeException e) 107 { 108 // TODO Auto-generated catch block 109 e.printStackTrace(); 110 } 111 catch (Exception e) 112 { 113 // TODO Auto-generated catch block 114 e.printStackTrace(); 115 } 116 catch (java.lang.Exception e) 117 { 118 // TODO Auto-generated catch block 119 e.printStackTrace(); 120 } 121 122 } 123 startWizard(XMultiServiceFactory xMSF, Object[] CurPropertyValue)124 public void startWizard(XMultiServiceFactory xMSF, Object[] CurPropertyValue) 125 { 126 127 running = true; 128 try 129 { 130 //Number of steps on WizardDialog: 131 setMaxStep(5); 132 133 //instatiate The Document Frame for the Preview 134 myFaxDoc = new FaxDocument(xMSF, this); 135 136 //create the dialog: 137 drawNaviBar(); 138 buildStep1(); 139 buildStep2(); 140 buildStep3(); 141 buildStep4(); 142 buildStep5(); 143 144 initializeSalutation(); 145 initializeGreeting(); 146 initializeCommunication(); 147 initializePaths(); 148 149 //special Control for setting the save Path: 150 insertPathSelectionControl(); 151 152 //load the last used settings from the registry and apply listeners to the controls: 153 initConfiguration(); 154 155 initializeTemplates(xMSF); 156 157 //update the dialog UI according to the loaded Configuration 158 updateUI(); 159 160 if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(PropertyNames.EMPTY_STRING)) 161 { 162 myPathSelection.initializePath(); 163 } 164 165 XWindow xContainerWindow = myFaxDoc.xFrame.getContainerWindow(); 166 XWindowPeer xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xContainerWindow); 167 createWindowPeer(xWindowPeer); 168 169 //add the Roadmap to the dialog: 170 insertRoadmap(); 171 172 //load the last used document and apply last used settings: 173 //TODO: 174 setConfiguration(); 175 176 //If the configuration does not define Greeting/Salutation/CommunicationType yet choose a default 177 setDefaultForGreetingAndSalutationAndCommunication(); 178 179 //disable funtionality that is not supported by the template: 180 initializeElements(); 181 182 //disable the document, so that the user cannot change anything: 183 myFaxDoc.xFrame.getComponentWindow().setEnable(false); 184 185 executeDialog(myFaxDoc.xFrame); 186 removeTerminateListener(); 187 closeDocument(); 188 running = false; 189 190 } 191 catch (Exception exception) 192 { 193 removeTerminateListener(); 194 exception.printStackTrace(System.out); 195 running = false; 196 } 197 } 198 cancelWizard()199 public void cancelWizard() 200 { 201 xDialog.endExecute(); 202 running = false; 203 } 204 finishWizard()205 public boolean finishWizard() 206 { 207 switchToStep(getCurrentStep(), getMaxStep()); 208 myFaxDoc.setWizardTemplateDocInfo(resources.resFaxWizardDialog_title, resources.resTemplateDescription); 209 try 210 { 211 //myFaxDoc.xTextDocument.lockControllers(); 212 FileAccess fileAccess = new FileAccess(xMSF); 213 sPath = myPathSelection.getSelectedPath(); 214 if (sPath.equals(PropertyNames.EMPTY_STRING)) 215 { 216 myPathSelection.triggerPathPicker(); 217 sPath = myPathSelection.getSelectedPath(); 218 } 219 sPath = fileAccess.getURL(sPath); 220 221 //first, if the filename was not changed, thus 222 //it is coming from a saved session, check if the 223 // file exists and warn the user. 224 if (!filenameChanged) 225 { 226 if (fileAccess.exists(sPath, true)) 227 { 228 229 int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resOverwriteWarning); 230 if (answer == 3) // user said: no, do not overwrite.... 231 { 232 return false; 233 } 234 } 235 } 236 myFaxDoc.setWizardTemplateDocInfo(resources.resFaxWizardDialog_title, resources.resTemplateDescription); 237 myFaxDoc.killEmptyUserFields(); 238 myFaxDoc.keepLogoFrame = (chkUseLogo.getState() != 0); 239 myFaxDoc.keepTypeFrame = (chkUseCommunicationType.getState() != 0); 240 myFaxDoc.killEmptyFrames(); 241 242 243 bSaveSuccess = OfficeDocument.store(xMSF, xTextDocument, sPath, "writer8_template", false); 244 if (bSaveSuccess) 245 { 246 saveConfiguration(); 247 XInteractionHandler xIH = UnoRuntime.queryInterface(XInteractionHandler.class, xMSF.createInstance("com.sun.star.comp.uui.UUIInteractionHandler")); 248 PropertyValue loadValues[] = new PropertyValue[4]; 249 loadValues[0] = new PropertyValue(); 250 loadValues[0].Name = "AsTemplate"; 251 loadValues[1] = new PropertyValue(); 252 loadValues[1].Name = "MacroExecutionMode"; 253 loadValues[1].Value = new Short(MacroExecMode.ALWAYS_EXECUTE); 254 loadValues[2] = new PropertyValue(); 255 loadValues[2].Name = "UpdateDocMode"; 256 loadValues[2].Value = new Short(com.sun.star.document.UpdateDocMode.FULL_UPDATE); 257 loadValues[3] = new PropertyValue(); 258 loadValues[3].Name = "InteractionHandler"; 259 loadValues[3].Value = xIH; 260 261 262 if (bEditTemplate) 263 { 264 loadValues[0].Value = Boolean.FALSE; 265 } 266 else 267 { 268 loadValues[0].Value = Boolean.TRUE; 269 } 270 Object oDoc = OfficeDocument.load(Desktop.getDesktop(xMSF), sPath, "_default", loadValues); 271 XTextDocument xTextDocument = (com.sun.star.text.XTextDocument) oDoc; 272 XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 273 ViewHandler myViewHandler = new ViewHandler(xDocMSF, xTextDocument); 274 myViewHandler.setViewSetting("ZoomType", new Short(com.sun.star.view.DocumentZoomType.OPTIMAL)); 275 } 276 else 277 { 278 //TODO: Error Handling 279 } 280 } 281 catch (Exception e) 282 { 283 e.printStackTrace(); 284 } 285 finally 286 { 287 xDialog.endExecute(); 288 running = false; 289 } 290 return true; 291 } 292 closeDocument()293 public void closeDocument() 294 { 295 try 296 { 297 //xComponent.dispose(); 298 XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, myFaxDoc.xFrame); 299 xCloseable.close(false); 300 } 301 catch (CloseVetoException e) 302 { 303 e.printStackTrace(); 304 } 305 } 306 insertRoadmap()307 public void insertRoadmap() 308 { 309 addRoadmap(); 310 int i = 0; 311 i = insertRoadmapItem(0, true, resources.RoadmapLabels[RM_TYPESTYLE], RM_TYPESTYLE); 312 i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_ELEMENTS], RM_ELEMENTS); 313 i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_SENDERRECEIVER], RM_SENDERRECEIVER); 314 i = insertRoadmapItem(i, false, resources.RoadmapLabels[RM_FOOTER], RM_FOOTER); 315 i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_FINALSETTINGS], RM_FINALSETTINGS); 316 setRoadmapInteractive(true); 317 setRoadmapComplete(true); 318 setCurrentRoadmapItemID((short) 1); 319 } 320 321 private class myPathSelectionListener implements XPathSelectionListener 322 { 323 validatePath()324 public void validatePath() 325 { 326 if (myPathSelection.usedPathPicker) 327 { 328 filenameChanged = true; 329 } 330 myPathSelection.usedPathPicker = false; 331 } 332 } 333 insertPathSelectionControl()334 public void insertPathSelectionControl() 335 { 336 myPathSelection = new PathSelection(xMSF, this, PathSelection.TransferMode.SAVE, PathSelection.DialogTypes.FILE); 337 myPathSelection.insert(5, 97, 70, 205, (short) 45, resources.reslblTemplatePath_value, true, HelpIds.getHelpIdString(HID + 34), HelpIds.getHelpIdString(HID + 35)); 338 myPathSelection.sDefaultDirectory = sUserTemplatePath; 339 myPathSelection.sDefaultName = "myFaxTemplate.ott"; 340 myPathSelection.sDefaultFilter = "writer8_template"; 341 myPathSelection.addSelectionListener(new myPathSelectionListener()); 342 } 343 insertIcons()344 private void insertIcons() 345 { 346 try 347 { 348 Object oGS = xMSF.createInstance("com.sun.star.graphic.GraphicProvider"); 349 XGraphicProvider xGraphicProvider = UnoRuntime.queryInterface(XGraphicProvider.class, oGS); 350 351 PropertyValue GraphicValues[] = new PropertyValue[1]; 352 GraphicValues[0] = new PropertyValue(); 353 GraphicValues[0].Name = PropertyNames.URL; 354 GraphicValues[0].Value = "private:resource/svx/imagelist/18000/18022"; 355 XGraphic xGraphic = xGraphicProvider.queryGraphic(GraphicValues); 356 357 } 358 catch (Exception e) 359 { 360 // TODO Auto-generated catch block 361 e.printStackTrace(); 362 } 363 364 } 365 updateUI()366 private void updateUI() 367 { 368 UnoDataAware.updateUI(mainDA); 369 UnoDataAware.updateUI(faxDA); 370 } 371 initializePaths()372 private void initializePaths() 373 { 374 try 375 { 376 sTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "share", "/wizard"); 377 sUserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user", PropertyNames.EMPTY_STRING); 378 sBitmapPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/../wizard/bitmap"); 379 } 380 catch (NoValidPathException e) 381 { 382 e.printStackTrace(); 383 } 384 } 385 initializeTemplates(XMultiServiceFactory xMSF)386 public boolean initializeTemplates(XMultiServiceFactory xMSF) 387 { 388 try 389 { 390 String sFaxSubPath = "/wizard/fax"; 391 sFaxPath = FileAccess.combinePaths(xMSF, sTemplatePath, sFaxSubPath); 392 sWorkPath = FileAccess.getOfficePath(xMSF, "Work", PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING); 393 394 BusinessFiles = FileAccess.getFolderTitles(xMSF, "bus", sFaxPath); 395 PrivateFiles = FileAccess.getFolderTitles(xMSF, "pri", sFaxPath); 396 397 setControlProperty("lstBusinessStyle", PropertyNames.STRING_ITEM_LIST, BusinessFiles[0]); 398 setControlProperty("lstPrivateStyle", PropertyNames.STRING_ITEM_LIST, PrivateFiles[0]); 399 400 setControlProperty("lstBusinessStyle", PropertyNames.SELECTED_ITEMS, new short[] 401 { 402 0 403 }); 404 setControlProperty("lstPrivateStyle", PropertyNames.SELECTED_ITEMS, new short[] 405 { 406 0 407 }); 408 409 return true; 410 } 411 catch (NoValidPathException e) 412 { 413 // TODO Auto-generated catch block 414 e.printStackTrace(); 415 return false; 416 } 417 } 418 initializeElements()419 public void initializeElements() 420 { 421 setControlProperty("chkUseLogo", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(myFaxDoc.hasElement("Company Logo"))); 422 setControlProperty("chkUseSubject", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(myFaxDoc.hasElement("Subject Line"))); 423 setControlProperty("chkUseDate", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(myFaxDoc.hasElement("Date"))); 424 myFaxDoc.updateDateFields(); 425 } 426 initializeSalutation()427 public void initializeSalutation() 428 { 429 setControlProperty("lstSalutation", PropertyNames.STRING_ITEM_LIST, resources.SalutationLabels); 430 } 431 initializeGreeting()432 public void initializeGreeting() 433 { 434 setControlProperty("lstGreeting", PropertyNames.STRING_ITEM_LIST, resources.GreetingLabels); 435 } 436 initializeCommunication()437 public void initializeCommunication() 438 { 439 setControlProperty("lstCommunicationType", PropertyNames.STRING_ITEM_LIST, resources.CommunicationLabels); 440 } 441 setDefaultForGreetingAndSalutationAndCommunication()442 private void setDefaultForGreetingAndSalutationAndCommunication() 443 { 444 XTextComponent xTextComponent; 445 xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstSalutation); 446 if (xTextComponent.getText().equals(PropertyNames.EMPTY_STRING)) 447 { 448 xTextComponent.setText(resources.SalutationLabels[0]); 449 } 450 xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstGreeting); 451 if (xTextComponent.getText().equals(PropertyNames.EMPTY_STRING)) 452 { 453 xTextComponent.setText(resources.GreetingLabels[0]); 454 } 455 xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstCommunicationType); 456 if (xTextComponent.getText().equals(PropertyNames.EMPTY_STRING)) 457 { 458 xTextComponent.setText(resources.CommunicationLabels[0]); 459 } 460 } 461 initConfiguration()462 public void initConfiguration() 463 { 464 try 465 { 466 myConfig = new CGFaxWizard(); 467 Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Fax", false); 468 myConfig.readConfiguration(root, "cp_"); 469 mainDA.add(RadioDataAware.attachRadioButtons(myConfig, "cp_FaxType", new Object[] 470 { 471 optBusinessFax, optPrivateFax 472 }, null, true)); 473 mainDA.add(UnoDataAware.attachListBox(myConfig.cp_BusinessFax, "cp_Style", lstBusinessStyle, null, true)); 474 mainDA.add(UnoDataAware.attachListBox(myConfig.cp_PrivateFax, "cp_Style", lstPrivateStyle, null, true)); 475 476 CGFax cgl = myConfig.cp_BusinessFax; 477 478 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintCompanyLogo", chkUseLogo, null, true)); 479 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintSubjectLine", chkUseSubject, null, true)); 480 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintSalutation", chkUseSalutation, null, true)); 481 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintDate", chkUseDate, null, true)); 482 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintCommunicationType", chkUseCommunicationType, null, true)); 483 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintGreeting", chkUseGreeting, null, true)); 484 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintFooter", chkUseFooter, null, true)); 485 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_Salutation", lstSalutation, null, true)); 486 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_Greeting", lstGreeting, null, true)); 487 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_CommunicationType", lstCommunicationType, null, true)); 488 faxDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_SenderAddressType", new Object[] 489 { 490 optSenderDefine, optSenderPlaceholder 491 }, null, true)); 492 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderCompanyName", txtSenderName, null, true)); 493 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderStreet", txtSenderStreet, null, true)); 494 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderPostCode", txtSenderPostCode, null, true)); 495 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderState", txtSenderState, null, true)); 496 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderCity", txtSenderCity, null, true)); 497 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderFax", txtSenderFax, null, true)); 498 faxDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_ReceiverAddressType", new Object[] 499 { 500 optReceiverDatabase, optReceiverPlaceholder 501 }, null, true)); 502 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_Footer", txtFooter, null, true)); 503 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_FooterOnlySecondPage", chkFooterNextPages, null, true)); 504 faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_FooterPageNumbers", chkFooterPageNumbers, null, true)); 505 faxDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_CreationType", new Object[] 506 { 507 optCreateFax, optMakeChanges 508 }, null, true)); 509 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_TemplateName", txtTemplateName, null, true)); 510 faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_TemplatePath", myPathSelection.xSaveTextBox, null, true)); 511 512 } 513 catch (Exception exception) 514 { 515 exception.printStackTrace(); 516 } 517 518 } 519 saveConfiguration()520 public void saveConfiguration() 521 { 522 try 523 { 524 Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Fax", true); 525 myConfig.writeConfiguration(root, "cp_"); 526 Configuration.commit(root); 527 } 528 catch (Exception e) 529 { 530 e.printStackTrace(); 531 } 532 } 533 setConfiguration()534 public void setConfiguration() 535 { 536 //set correct Configuration tree: 537 if (optBusinessFax.getState()) 538 { 539 optBusinessFaxItemChanged(); 540 } 541 if (optPrivateFax.getState()) 542 { 543 optPrivateFaxItemChanged(); 544 } 545 } 546 optBusinessFaxItemChanged()547 public void optBusinessFaxItemChanged() 548 { 549 DataAware.setDataObject(faxDA, myConfig.cp_BusinessFax, true); 550 setControlProperty("lblBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 551 setControlProperty("lstBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 552 setControlProperty("lblPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 553 setControlProperty("lstPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 554 lstBusinessStyleItemChanged(); 555 enableSenderReceiver(); 556 setPossibleFooter(true); 557 } 558 lstBusinessStyleItemChanged()559 public void lstBusinessStyleItemChanged() 560 { 561 xTextDocument = myFaxDoc.loadAsPreview(BusinessFiles[1][lstBusinessStyle.getSelectedItemPos()], false); 562 initializeElements(); 563 setElements(); 564 } 565 optPrivateFaxItemChanged()566 public void optPrivateFaxItemChanged() 567 { 568 DataAware.setDataObject(faxDA, myConfig.cp_PrivateFax, true); 569 setControlProperty("lblBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 570 setControlProperty("lstBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 571 setControlProperty("lblPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 572 setControlProperty("lstPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 573 lstPrivateStyleItemChanged(); 574 disableSenderReceiver(); 575 setPossibleFooter(false); 576 } 577 lstPrivateStyleItemChanged()578 public void lstPrivateStyleItemChanged() 579 { 580 xTextDocument = myFaxDoc.loadAsPreview(PrivateFiles[1][lstPrivateStyle.getSelectedItemPos()], false); 581 initializeElements(); 582 setElements(); 583 } 584 txtTemplateNameTextChanged()585 public void txtTemplateNameTextChanged() 586 { 587 XDocumentPropertiesSupplier xDocPropsSuppl = UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument); 588 XDocumentProperties xDocProps = xDocPropsSuppl.getDocumentProperties(); 589 String TitleName = txtTemplateName.getText(); 590 xDocProps.setTitle(TitleName); 591 } 592 optSenderPlaceholderItemChanged()593 public void optSenderPlaceholderItemChanged() 594 { 595 setControlProperty("lblSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 596 setControlProperty("lblSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 597 setControlProperty("lblPostCodeCity", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 598 setControlProperty("lblSenderFax", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 599 setControlProperty("txtSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 600 setControlProperty("txtSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 601 setControlProperty("txtSenderPostCode", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 602 setControlProperty("txtSenderState", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 603 setControlProperty("txtSenderCity", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 604 setControlProperty("txtSenderFax", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 605 myFaxDoc.fillSenderWithUserData(); 606 } 607 optSenderDefineItemChanged()608 public void optSenderDefineItemChanged() 609 { 610 setControlProperty("lblSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 611 setControlProperty("lblSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 612 setControlProperty("lblPostCodeCity", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 613 setControlProperty("lblSenderFax", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 614 setControlProperty("txtSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 615 setControlProperty("txtSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 616 setControlProperty("txtSenderPostCode", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 617 setControlProperty("txtSenderState", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 618 setControlProperty("txtSenderCity", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 619 setControlProperty("txtSenderFax", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 620 txtSenderNameTextChanged(); 621 txtSenderStreetTextChanged(); 622 txtSenderPostCodeTextChanged(); 623 txtSenderStateTextChanged(); 624 txtSenderCityTextChanged(); 625 txtSenderFaxTextChanged(); 626 } 627 optReceiverPlaceholderItemChanged()628 public void optReceiverPlaceholderItemChanged() 629 { 630 OfficeDocument.attachEventCall(xTextDocument, "OnNew", "StarBasic", "macro:///Template.Correspondence.Placeholder()"); 631 } 632 optReceiverDatabaseItemChanged()633 public void optReceiverDatabaseItemChanged() 634 { 635 OfficeDocument.attachEventCall(xTextDocument, "OnNew", "StarBasic", "macro:///Template.Correspondence.Database()"); 636 } 637 optCreateFaxItemChanged()638 public void optCreateFaxItemChanged() 639 { 640 bEditTemplate = false; 641 } 642 optMakeChangesItemChanged()643 public void optMakeChangesItemChanged() 644 { 645 bEditTemplate = true; 646 } 647 txtSenderNameTextChanged()648 public void txtSenderNameTextChanged() 649 { 650 TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument); 651 myFieldHandler.changeUserFieldContent("Company", txtSenderName.getText()); 652 } 653 txtSenderStreetTextChanged()654 public void txtSenderStreetTextChanged() 655 { 656 TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument); 657 myFieldHandler.changeUserFieldContent("Street", txtSenderStreet.getText()); 658 } 659 txtSenderCityTextChanged()660 public void txtSenderCityTextChanged() 661 { 662 TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument); 663 myFieldHandler.changeUserFieldContent("City", txtSenderCity.getText()); 664 } 665 txtSenderPostCodeTextChanged()666 public void txtSenderPostCodeTextChanged() 667 { 668 TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument); 669 myFieldHandler.changeUserFieldContent("PostCode", txtSenderPostCode.getText()); 670 } 671 txtSenderStateTextChanged()672 public void txtSenderStateTextChanged() 673 { 674 TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument); 675 myFieldHandler.changeUserFieldContent(PropertyNames.PROPERTY_STATE, txtSenderState.getText()); 676 } 677 txtSenderFaxTextChanged()678 public void txtSenderFaxTextChanged() 679 { 680 TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument); 681 myFieldHandler.changeUserFieldContent("Fax", txtSenderFax.getText()); 682 } 683 //switch Elements on/off ------------------------------------------------------- setElements()684 public void setElements() 685 { 686 //UI relevant: 687 if (optSenderDefine.getState()) 688 { 689 optSenderDefineItemChanged(); 690 } 691 if (optSenderPlaceholder.getState()) 692 { 693 optSenderPlaceholderItemChanged(); 694 } 695 chkUseLogoItemChanged(); 696 chkUseSubjectItemChanged(); 697 chkUseSalutationItemChanged(); 698 chkUseGreetingItemChanged(); 699 chkUseCommunicationItemChanged(); 700 chkUseDateItemChanged(); 701 chkUseFooterItemChanged(); 702 txtTemplateNameTextChanged(); 703 704 //not UI relevant: 705 if (optReceiverDatabase.getState()) 706 { 707 optReceiverDatabaseItemChanged(); 708 } 709 if (optReceiverPlaceholder.getState()) 710 { 711 optReceiverPlaceholderItemChanged(); 712 } 713 if (optCreateFax.getState()) 714 { 715 optCreateFaxItemChanged(); 716 } 717 if (optMakeChanges.getState()) 718 { 719 optMakeChangesItemChanged(); 720 } 721 } 722 chkUseLogoItemChanged()723 public void chkUseLogoItemChanged() 724 { 725 if (myFaxDoc.hasElement("Company Logo")) 726 { 727 myFaxDoc.switchElement("Company Logo", (chkUseLogo.getState() != 0)); 728 } 729 } 730 chkUseSubjectItemChanged()731 public void chkUseSubjectItemChanged() 732 { 733 if (myFaxDoc.hasElement("Subject Line")) 734 { 735 myFaxDoc.switchElement("Subject Line", (chkUseSubject.getState() != 0)); 736 } 737 } 738 chkUseDateItemChanged()739 public void chkUseDateItemChanged() 740 { 741 if (myFaxDoc.hasElement("Date")) 742 { 743 myFaxDoc.switchElement("Date", (chkUseDate.getState() != 0)); 744 } 745 } 746 chkUseFooterItemChanged()747 public void chkUseFooterItemChanged() 748 { 749 try 750 { 751 boolean bFooterPossible = (chkUseFooter.getState() != 0) && AnyConverter.toBoolean(getControlProperty("chkUseFooter", PropertyNames.PROPERTY_ENABLED)); 752 753 if (chkFooterNextPages.getState() != 0) 754 { 755 myFaxDoc.switchFooter("First Page", false, (chkFooterPageNumbers.getState() != 0), txtFooter.getText()); 756 myFaxDoc.switchFooter("Standard", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText()); 757 } 758 else 759 { 760 myFaxDoc.switchFooter("First Page", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText()); 761 myFaxDoc.switchFooter("Standard", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText()); 762 } 763 764 //enable/disable roadmap item for footer page 765 XInterface BPaperItem = getRoadmapItemByID(RM_FOOTER); 766 Helper.setUnoPropertyValue(BPaperItem, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bFooterPossible)); 767 768 } 769 catch (Exception exception) 770 { 771 exception.printStackTrace(System.out); 772 } 773 } 774 chkFooterNextPagesItemChanged()775 public void chkFooterNextPagesItemChanged() 776 { 777 chkUseFooterItemChanged(); 778 } 779 chkFooterPageNumbersItemChanged()780 public void chkFooterPageNumbersItemChanged() 781 { 782 chkUseFooterItemChanged(); 783 } 784 txtFooterTextChanged()785 public void txtFooterTextChanged() 786 { 787 chkUseFooterItemChanged(); 788 } 789 chkUseSalutationItemChanged()790 public void chkUseSalutationItemChanged() 791 { 792 XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstSalutation); 793 myFaxDoc.switchUserField("Salutation", xTextComponent.getText(), (chkUseSalutation.getState() != 0)); 794 setControlProperty("lstSalutation", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(chkUseSalutation.getState() != 0)); 795 } 796 lstSalutationItemChanged()797 public void lstSalutationItemChanged() 798 { 799 XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstSalutation); 800 myFaxDoc.switchUserField("Salutation", xTextComponent.getText(), (chkUseSalutation.getState() != 0)); 801 } 802 lstSalutationTextChanged()803 public void lstSalutationTextChanged() 804 { 805 } 806 chkUseCommunicationItemChanged()807 public void chkUseCommunicationItemChanged() 808 { 809 XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstCommunicationType); 810 myFaxDoc.switchUserField("CommunicationType", xTextComponent.getText(), (chkUseCommunicationType.getState() != 0)); 811 setControlProperty("lstCommunicationType", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(chkUseCommunicationType.getState() != 0)); 812 } 813 lstCommunicationItemChanged()814 public void lstCommunicationItemChanged() 815 { 816 XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstCommunicationType); 817 myFaxDoc.switchUserField("CommunicationType", xTextComponent.getText(), (chkUseCommunicationType.getState() != 0)); 818 } 819 lstCommunicationTextChanged()820 public void lstCommunicationTextChanged() 821 { 822 } 823 chkUseGreetingItemChanged()824 public void chkUseGreetingItemChanged() 825 { 826 XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstGreeting); 827 myFaxDoc.switchUserField("Greeting", xTextComponent.getText(), (chkUseGreeting.getState() != 0)); 828 setControlProperty("lstGreeting", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(chkUseGreeting.getState() != 0)); 829 } 830 lstGreetingItemChanged()831 public void lstGreetingItemChanged() 832 { 833 XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstGreeting); 834 myFaxDoc.switchUserField("Greeting", xTextComponent.getText(), (chkUseGreeting.getState() != 0)); 835 } 836 lstGreetingTextChanged()837 public void lstGreetingTextChanged() 838 { 839 } 840 setPossibleFooter(boolean bState)841 private void setPossibleFooter(boolean bState) 842 { 843 setControlProperty("chkUseFooter", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 844 if (!bState) 845 { 846 chkUseFooter.setState((short) 0); 847 } 848 chkUseFooterItemChanged(); 849 } 850 enableSenderReceiver()851 private void enableSenderReceiver() 852 { 853 XInterface BPaperItem = getRoadmapItemByID(RM_SENDERRECEIVER); 854 Helper.setUnoPropertyValue(BPaperItem, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 855 } 856 disableSenderReceiver()857 private void disableSenderReceiver() 858 { 859 XInterface BPaperItem = getRoadmapItemByID(RM_SENDERRECEIVER); 860 Helper.setUnoPropertyValue(BPaperItem, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 861 } 862 } 863 864 865 866 867 868