1*a1b4a26bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*a1b4a26bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*a1b4a26bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*a1b4a26bSAndrew Rist * distributed with this work for additional information 6*a1b4a26bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*a1b4a26bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*a1b4a26bSAndrew Rist * "License"); you may not use this file except in compliance 9*a1b4a26bSAndrew Rist * with the License. You may obtain a copy of the License at 10*a1b4a26bSAndrew Rist * 11*a1b4a26bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*a1b4a26bSAndrew Rist * 13*a1b4a26bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*a1b4a26bSAndrew Rist * software distributed under the License is distributed on an 15*a1b4a26bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*a1b4a26bSAndrew Rist * KIND, either express or implied. See the License for the 17*a1b4a26bSAndrew Rist * specific language governing permissions and limitations 18*a1b4a26bSAndrew Rist * under the License. 19*a1b4a26bSAndrew Rist * 20*a1b4a26bSAndrew Rist *************************************************************/ 21*a1b4a26bSAndrew Rist 22*a1b4a26bSAndrew Rist 23cdf0e10cSrcweir package com.sun.star.wizards.letter; 24cdf0e10cSrcweir 25cdf0e10cSrcweir import java.util.Vector; 26cdf0e10cSrcweir import com.sun.star.lang.IllegalArgumentException; 27cdf0e10cSrcweir import com.sun.star.lang.WrappedTargetException; 28cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 29cdf0e10cSrcweir import com.sun.star.wizards.common.Configuration; 30cdf0e10cSrcweir import com.sun.star.wizards.common.Desktop; 31cdf0e10cSrcweir import com.sun.star.wizards.common.NoValidPathException; 32cdf0e10cSrcweir import com.sun.star.wizards.common.SystemDialog; 33cdf0e10cSrcweir import com.sun.star.wizards.common.PropertyNames; 34cdf0e10cSrcweir import com.sun.star.awt.VclWindowPeerAttribute; 35cdf0e10cSrcweir import com.sun.star.awt.XTextComponent; 36cdf0e10cSrcweir import com.sun.star.awt.XWindow; 37cdf0e10cSrcweir import com.sun.star.awt.XWindowPeer; 38cdf0e10cSrcweir import com.sun.star.beans.PropertyValue; 39cdf0e10cSrcweir import com.sun.star.container.NoSuchElementException; 40cdf0e10cSrcweir import com.sun.star.document.MacroExecMode; 41cdf0e10cSrcweir import com.sun.star.document.XDocumentProperties; 42cdf0e10cSrcweir import com.sun.star.document.XDocumentPropertiesSupplier; 43cdf0e10cSrcweir import com.sun.star.ucb.CommandAbortedException; 44cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 45cdf0e10cSrcweir import com.sun.star.uno.Exception; 46cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 47cdf0e10cSrcweir import com.sun.star.wizards.text.*; 48cdf0e10cSrcweir import com.sun.star.wizards.common.*; 49cdf0e10cSrcweir import com.sun.star.task.XInteractionHandler; 50cdf0e10cSrcweir import com.sun.star.text.XTextFrame; 51cdf0e10cSrcweir import com.sun.star.text.XTextDocument; 52cdf0e10cSrcweir import com.sun.star.uno.XInterface; 53cdf0e10cSrcweir import com.sun.star.util.CloseVetoException; 54cdf0e10cSrcweir import com.sun.star.util.XCloseable; 55cdf0e10cSrcweir import com.sun.star.wizards.document.*; 56cdf0e10cSrcweir import com.sun.star.wizards.ui.*; 57cdf0e10cSrcweir import com.sun.star.wizards.ui.event.*; 58cdf0e10cSrcweir import com.sun.star.wizards.common.Helper; 59cdf0e10cSrcweir 60cdf0e10cSrcweir public class LetterWizardDialogImpl extends LetterWizardDialog 61cdf0e10cSrcweir { 62cdf0e10cSrcweir enterStep(int OldStep, int NewStep)63cdf0e10cSrcweir protected void enterStep(int OldStep, int NewStep) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir } 66cdf0e10cSrcweir leaveStep(int OldStep, int NewStep)67cdf0e10cSrcweir protected void leaveStep(int OldStep, int NewStep) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir } 70cdf0e10cSrcweir static LetterDocument myLetterDoc; 71cdf0e10cSrcweir static boolean running; 72cdf0e10cSrcweir XMultiServiceFactory xmsf; 73cdf0e10cSrcweir XTextDocument xTextDocument; 74cdf0e10cSrcweir PathSelection myPathSelection; 75cdf0e10cSrcweir CGLetterWizard myConfig; 76cdf0e10cSrcweir Vector mainDA = new Vector(); 77cdf0e10cSrcweir Vector letterDA = new Vector(); 78cdf0e10cSrcweir Vector businessDA = new Vector(); 79cdf0e10cSrcweir String[][] BusinessFiles; 80cdf0e10cSrcweir String[][] OfficialFiles; 81cdf0e10cSrcweir String[][] PrivateFiles; 82cdf0e10cSrcweir String[] Norms; 83cdf0e10cSrcweir String[] NormPaths; 84cdf0e10cSrcweir String[] NormNames; 85cdf0e10cSrcweir String sTemplatePath; 86cdf0e10cSrcweir String sUserTemplatePath; 87cdf0e10cSrcweir String sBitmapPath; 88cdf0e10cSrcweir String sLetterPath; 89cdf0e10cSrcweir String sLetterLangPackPath; 90cdf0e10cSrcweir String sWorkPath; 91cdf0e10cSrcweir String sCurrentNorm; 92cdf0e10cSrcweir String sPath; 93cdf0e10cSrcweir boolean bEditTemplate; 94cdf0e10cSrcweir boolean bSaveSuccess = false; 95cdf0e10cSrcweir private boolean filenameChanged = false; 96cdf0e10cSrcweir LetterDocument.BusinessPaperObject BusCompanyLogo = null; 97cdf0e10cSrcweir LetterDocument.BusinessPaperObject BusCompanyAddress = null; 98cdf0e10cSrcweir LetterDocument.BusinessPaperObject BusCompanyAddressReceiver = null; 99cdf0e10cSrcweir LetterDocument.BusinessPaperObject BusFooter = null; 100cdf0e10cSrcweir final static int RM_TYPESTYLE = 1; 101cdf0e10cSrcweir final static int RM_BUSINESSPAPER = 2; 102cdf0e10cSrcweir final static int RM_ELEMENTS = 3; 103cdf0e10cSrcweir final static int RM_SENDERRECEIVER = 4; 104cdf0e10cSrcweir final static int RM_FOOTER = 5; 105cdf0e10cSrcweir final static int RM_FINALSETTINGS = 6; 106cdf0e10cSrcweir LetterWizardDialogImpl(XMultiServiceFactory xmsf)107cdf0e10cSrcweir public LetterWizardDialogImpl(XMultiServiceFactory xmsf) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir super(xmsf); 110cdf0e10cSrcweir this.xmsf = xmsf; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir main(String args[])113cdf0e10cSrcweir public static void main(String args[]) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir //only being called when starting wizard remotely 116cdf0e10cSrcweir String ConnectStr = "uno:socket,host=127.0.0.1,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager"; 117cdf0e10cSrcweir XMultiServiceFactory xLocMSF = null; 118cdf0e10cSrcweir try 119cdf0e10cSrcweir { 120cdf0e10cSrcweir xLocMSF = Desktop.connect(ConnectStr); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir catch (Exception e) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir e.printStackTrace(); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir catch (java.lang.Exception e) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir e.printStackTrace(); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir LetterWizardDialogImpl lw = new LetterWizardDialogImpl(xLocMSF); 131cdf0e10cSrcweir lw.startWizard(xLocMSF, null); 132cdf0e10cSrcweir 133cdf0e10cSrcweir } 134cdf0e10cSrcweir startWizard(XMultiServiceFactory xMSF, Object[] CurPropertyValue)135cdf0e10cSrcweir public void startWizard(XMultiServiceFactory xMSF, Object[] CurPropertyValue) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir 138cdf0e10cSrcweir running = true; 139cdf0e10cSrcweir try 140cdf0e10cSrcweir { 141cdf0e10cSrcweir //Number of steps on WizardDialog: 142cdf0e10cSrcweir setMaxStep(6); 143cdf0e10cSrcweir 144cdf0e10cSrcweir //instatiate The Document Frame for the Preview 145cdf0e10cSrcweir myLetterDoc = new LetterDocument(xMSF, this); 146cdf0e10cSrcweir 147cdf0e10cSrcweir //create the dialog: 148cdf0e10cSrcweir drawNaviBar(); 149cdf0e10cSrcweir buildStep1(); 150cdf0e10cSrcweir buildStep2(); 151cdf0e10cSrcweir buildStep3(); 152cdf0e10cSrcweir buildStep4(); 153cdf0e10cSrcweir buildStep5(); 154cdf0e10cSrcweir buildStep6(); 155cdf0e10cSrcweir 156cdf0e10cSrcweir initializePaths(); 157cdf0e10cSrcweir initializeNorms(); 158cdf0e10cSrcweir initializeSalutation(); 159cdf0e10cSrcweir initializeGreeting(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir 162cdf0e10cSrcweir //special Control for setting the save Path: 163cdf0e10cSrcweir insertPathSelectionControl(); 164cdf0e10cSrcweir 165cdf0e10cSrcweir //load the last used settings from the registry and apply listeners to the controls: 166cdf0e10cSrcweir initConfiguration(); 167cdf0e10cSrcweir 168cdf0e10cSrcweir //set the language according to the Linguistic 169cdf0e10cSrcweir int oL = getOfficeLinguistic(); 170cdf0e10cSrcweir myConfig.cp_BusinessLetter.cp_Norm = oL; 171cdf0e10cSrcweir myConfig.cp_PrivateOfficialLetter.cp_Norm = oL; 172cdf0e10cSrcweir myConfig.cp_PrivateLetter.cp_Norm = oL; 173cdf0e10cSrcweir initializeTemplates(xMSF); 174cdf0e10cSrcweir 175cdf0e10cSrcweir if (myConfig.cp_BusinessLetter.cp_Greeting.equals(PropertyNames.EMPTY_STRING)) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir myConfig.cp_BusinessLetter.cp_Greeting = resources.GreetingLabels[0]; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir if (myConfig.cp_BusinessLetter.cp_Salutation.equals(PropertyNames.EMPTY_STRING)) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir myConfig.cp_BusinessLetter.cp_Salutation = resources.SalutationLabels[0]; 182cdf0e10cSrcweir } 183cdf0e10cSrcweir if (myConfig.cp_PrivateOfficialLetter.cp_Greeting.equals(PropertyNames.EMPTY_STRING)) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir myConfig.cp_PrivateOfficialLetter.cp_Greeting = resources.GreetingLabels[1]; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir if (myConfig.cp_PrivateOfficialLetter.cp_Salutation.equals(PropertyNames.EMPTY_STRING)) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir myConfig.cp_PrivateOfficialLetter.cp_Salutation = resources.SalutationLabels[1]; 190cdf0e10cSrcweir } 191cdf0e10cSrcweir if (myConfig.cp_PrivateLetter.cp_Greeting.equals(PropertyNames.EMPTY_STRING)) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir myConfig.cp_PrivateLetter.cp_Greeting = resources.GreetingLabels[2]; 194cdf0e10cSrcweir } 195cdf0e10cSrcweir if (myConfig.cp_PrivateLetter.cp_Salutation.equals(PropertyNames.EMPTY_STRING)) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir myConfig.cp_PrivateLetter.cp_Salutation = resources.SalutationLabels[2]; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir //update the dialog UI according to the loaded Configuration 201cdf0e10cSrcweir updateUI(); 202cdf0e10cSrcweir 203cdf0e10cSrcweir if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(PropertyNames.EMPTY_STRING)) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir myPathSelection.initializePath(); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir XWindow xContainerWindow = myLetterDoc.xFrame.getContainerWindow(); 209cdf0e10cSrcweir XWindowPeer xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xContainerWindow); 210cdf0e10cSrcweir createWindowPeer(xWindowPeer); 211cdf0e10cSrcweir 212cdf0e10cSrcweir //add the Roadmap to the dialog: 213cdf0e10cSrcweir insertRoadmap(); 214cdf0e10cSrcweir 215cdf0e10cSrcweir //load the last used document and apply last used settings: 216cdf0e10cSrcweir setConfiguration(); 217cdf0e10cSrcweir 218cdf0e10cSrcweir //If the configuration does not define Greeting/Salutation yet choose a default 219cdf0e10cSrcweir setDefaultForGreetingAndSalutation(); 220cdf0e10cSrcweir 221cdf0e10cSrcweir //disable funtionality that is not supported by the template: 222cdf0e10cSrcweir initializeElements(); 223cdf0e10cSrcweir 224cdf0e10cSrcweir //disable the document, so that the user cannot change anything: 225cdf0e10cSrcweir myLetterDoc.xFrame.getComponentWindow().setEnable(false); 226cdf0e10cSrcweir 227cdf0e10cSrcweir executeDialog(myLetterDoc.xFrame); 228cdf0e10cSrcweir removeTerminateListener(); 229cdf0e10cSrcweir closeDocument(); 230cdf0e10cSrcweir running = false; 231cdf0e10cSrcweir 232cdf0e10cSrcweir } 233cdf0e10cSrcweir catch (Exception exception) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir removeTerminateListener(); 236cdf0e10cSrcweir exception.printStackTrace(System.out); 237cdf0e10cSrcweir running = false; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir } 240cdf0e10cSrcweir cancelWizard()241cdf0e10cSrcweir public void cancelWizard() 242cdf0e10cSrcweir { 243cdf0e10cSrcweir xDialog.endExecute(); 244cdf0e10cSrcweir running = false; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir finishWizard()247cdf0e10cSrcweir public boolean finishWizard() 248cdf0e10cSrcweir { 249cdf0e10cSrcweir switchToStep(getCurrentStep(), getMaxStep()); 250cdf0e10cSrcweir try 251cdf0e10cSrcweir { 252cdf0e10cSrcweir //myLetterDoc.xTextDocument.lockControllers(); 253cdf0e10cSrcweir FileAccess fileAccess = new FileAccess(xMSF); 254cdf0e10cSrcweir sPath = myPathSelection.getSelectedPath(); 255cdf0e10cSrcweir if (sPath.equals(PropertyNames.EMPTY_STRING)) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir myPathSelection.triggerPathPicker(); 258cdf0e10cSrcweir sPath = myPathSelection.getSelectedPath(); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir sPath = fileAccess.getURL(sPath); 261cdf0e10cSrcweir 262cdf0e10cSrcweir //first, if the filename was not changed, thus 263cdf0e10cSrcweir //it is coming from a saved session, check if the 264cdf0e10cSrcweir // file exists and warn the user. 265cdf0e10cSrcweir if (!filenameChanged) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir if (fileAccess.exists(sPath, true)) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir 270cdf0e10cSrcweir int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resOverwriteWarning); 271cdf0e10cSrcweir if (answer == 3) // user said: no, do not overwrite.... 272cdf0e10cSrcweir { 273cdf0e10cSrcweir return false; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir myLetterDoc.setWizardTemplateDocInfo(resources.resLetterWizardDialog_title, resources.resTemplateDescription); 278cdf0e10cSrcweir myLetterDoc.killEmptyUserFields(); 279cdf0e10cSrcweir myLetterDoc.keepLogoFrame = (chkUseLogo.getState() != 0); 280cdf0e10cSrcweir if ((chkBusinessPaper.getState() != 0) && (chkPaperCompanyLogo.getState() != 0)) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir myLetterDoc.keepLogoFrame = false; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir myLetterDoc.keepBendMarksFrame = (chkUseBendMarks.getState() != 0); 285cdf0e10cSrcweir myLetterDoc.keepLetterSignsFrame = (chkUseSigns.getState() != 0); 286cdf0e10cSrcweir myLetterDoc.keepSenderAddressRepeatedFrame = (chkUseAddressReceiver.getState() != 0); 287cdf0e10cSrcweir 288cdf0e10cSrcweir if (optBusinessLetter.getState()) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir if ((chkBusinessPaper.getState() != 0) && (chkCompanyReceiver.getState() != 0)) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir myLetterDoc.keepSenderAddressRepeatedFrame = false; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir if ((chkBusinessPaper.getState() != 0) && (chkPaperCompanyAddress.getState() != 0)) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir myLetterDoc.keepAddressFrame = false; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir myLetterDoc.killEmptyFrames(); 301cdf0e10cSrcweir 302cdf0e10cSrcweir 303cdf0e10cSrcweir bSaveSuccess = OfficeDocument.store(xMSF, xTextDocument, sPath, "writer8_template", false); 304cdf0e10cSrcweir 305cdf0e10cSrcweir if (bSaveSuccess) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir saveConfiguration(); 308cdf0e10cSrcweir XInteractionHandler xIH = UnoRuntime.queryInterface(XInteractionHandler.class, xMSF.createInstance("com.sun.star.comp.uui.UUIInteractionHandler")); 309cdf0e10cSrcweir PropertyValue loadValues[] = new PropertyValue[4]; 310cdf0e10cSrcweir loadValues[0] = new PropertyValue(); 311cdf0e10cSrcweir loadValues[0].Name = "AsTemplate"; 312cdf0e10cSrcweir loadValues[1] = new PropertyValue(); 313cdf0e10cSrcweir loadValues[1].Name = "MacroExecutionMode"; 314cdf0e10cSrcweir loadValues[1].Value = new Short(MacroExecMode.ALWAYS_EXECUTE); 315cdf0e10cSrcweir loadValues[2] = new PropertyValue(); 316cdf0e10cSrcweir loadValues[2].Name = "UpdateDocMode"; 317cdf0e10cSrcweir loadValues[2].Value = new Short(com.sun.star.document.UpdateDocMode.FULL_UPDATE); 318cdf0e10cSrcweir loadValues[3] = new PropertyValue(); 319cdf0e10cSrcweir loadValues[3].Name = "InteractionHandler"; 320cdf0e10cSrcweir loadValues[3].Value = xIH; 321cdf0e10cSrcweir 322cdf0e10cSrcweir if (bEditTemplate) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir loadValues[0].Value = Boolean.FALSE; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir else 327cdf0e10cSrcweir { 328cdf0e10cSrcweir loadValues[0].Value = Boolean.TRUE; 329cdf0e10cSrcweir } 330cdf0e10cSrcweir Object oDoc = OfficeDocument.load(Desktop.getDesktop(xMSF), sPath, "_default", loadValues); 331cdf0e10cSrcweir XTextDocument xTextDocument = (com.sun.star.text.XTextDocument) oDoc; 332cdf0e10cSrcweir XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 333cdf0e10cSrcweir ViewHandler myViewHandler = new ViewHandler(xDocMSF, xTextDocument); 334cdf0e10cSrcweir myViewHandler.setViewSetting("ZoomType", new Short(com.sun.star.view.DocumentZoomType.OPTIMAL)); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir else 337cdf0e10cSrcweir { 338cdf0e10cSrcweir //TODO: Error Handling 339cdf0e10cSrcweir } 340cdf0e10cSrcweir } 341cdf0e10cSrcweir catch (Exception e) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir e.printStackTrace(); 344cdf0e10cSrcweir } 345cdf0e10cSrcweir finally 346cdf0e10cSrcweir { 347cdf0e10cSrcweir xDialog.endExecute(); 348cdf0e10cSrcweir running = false; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir return true; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir closeDocument()353cdf0e10cSrcweir public void closeDocument() 354cdf0e10cSrcweir { 355cdf0e10cSrcweir try 356cdf0e10cSrcweir { 357cdf0e10cSrcweir //xComponent.dispose(); 358cdf0e10cSrcweir XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, myLetterDoc.xFrame); 359cdf0e10cSrcweir xCloseable.close(false); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir catch (CloseVetoException e) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir e.printStackTrace(); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir } 366cdf0e10cSrcweir optBusinessLetterItemChanged()367cdf0e10cSrcweir public void optBusinessLetterItemChanged() 368cdf0e10cSrcweir { 369cdf0e10cSrcweir DataAware.setDataObject(letterDA, myConfig.cp_BusinessLetter, true); 370cdf0e10cSrcweir setControlProperty("lblBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 371cdf0e10cSrcweir setControlProperty("lstBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 372cdf0e10cSrcweir setControlProperty("chkBusinessPaper", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 373cdf0e10cSrcweir setControlProperty("lblPrivOfficialStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 374cdf0e10cSrcweir setControlProperty("lstPrivOfficialStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 375cdf0e10cSrcweir setControlProperty("lblPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 376cdf0e10cSrcweir setControlProperty("lstPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 377cdf0e10cSrcweir lstBusinessStyleItemChanged(); 378cdf0e10cSrcweir enableSenderReceiver(); 379cdf0e10cSrcweir setPossibleFooter(true); 380cdf0e10cSrcweir if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(PropertyNames.EMPTY_STRING)) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir myPathSelection.initializePath(); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir } 385cdf0e10cSrcweir optPrivOfficialLetterItemChanged()386cdf0e10cSrcweir public void optPrivOfficialLetterItemChanged() 387cdf0e10cSrcweir { 388cdf0e10cSrcweir DataAware.setDataObject(letterDA, myConfig.cp_PrivateOfficialLetter, true); 389cdf0e10cSrcweir setControlProperty("lblBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 390cdf0e10cSrcweir setControlProperty("lstBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 391cdf0e10cSrcweir setControlProperty("chkBusinessPaper", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 392cdf0e10cSrcweir setControlProperty("lblPrivOfficialStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 393cdf0e10cSrcweir setControlProperty("lstPrivOfficialStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 394cdf0e10cSrcweir setControlProperty("lblPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 395cdf0e10cSrcweir setControlProperty("lstPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 396cdf0e10cSrcweir lstPrivOfficialStyleItemChanged(); 397cdf0e10cSrcweir disableBusinessPaper(); 398cdf0e10cSrcweir enableSenderReceiver(); 399cdf0e10cSrcweir setPossibleFooter(true); 400cdf0e10cSrcweir if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(PropertyNames.EMPTY_STRING)) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir myPathSelection.initializePath(); 403cdf0e10cSrcweir } 404cdf0e10cSrcweir } 405cdf0e10cSrcweir optPrivateLetterItemChanged()406cdf0e10cSrcweir public void optPrivateLetterItemChanged() 407cdf0e10cSrcweir { 408cdf0e10cSrcweir DataAware.setDataObject(letterDA, myConfig.cp_PrivateLetter, true); 409cdf0e10cSrcweir setControlProperty("lblBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 410cdf0e10cSrcweir setControlProperty("lstBusinessStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 411cdf0e10cSrcweir setControlProperty("chkBusinessPaper", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 412cdf0e10cSrcweir setControlProperty("lblPrivOfficialStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 413cdf0e10cSrcweir setControlProperty("lstPrivOfficialStyle", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 414cdf0e10cSrcweir setControlProperty("lblPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 415cdf0e10cSrcweir setControlProperty("lstPrivateStyle", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 416cdf0e10cSrcweir lstPrivateStyleItemChanged(); 417cdf0e10cSrcweir disableBusinessPaper(); 418cdf0e10cSrcweir disableSenderReceiver(); 419cdf0e10cSrcweir setPossibleFooter(false); 420cdf0e10cSrcweir if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(PropertyNames.EMPTY_STRING)) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir myPathSelection.initializePath(); 423cdf0e10cSrcweir } 424cdf0e10cSrcweir } 425cdf0e10cSrcweir optSenderPlaceholderItemChanged()426cdf0e10cSrcweir public void optSenderPlaceholderItemChanged() 427cdf0e10cSrcweir { 428cdf0e10cSrcweir setControlProperty("lblSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 429cdf0e10cSrcweir setControlProperty("lblSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 430cdf0e10cSrcweir setControlProperty("lblPostCodeCity", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 431cdf0e10cSrcweir setControlProperty("txtSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 432cdf0e10cSrcweir setControlProperty("txtSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 433cdf0e10cSrcweir setControlProperty("txtSenderPostCode", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 434cdf0e10cSrcweir setControlProperty("txtSenderState", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 435cdf0e10cSrcweir setControlProperty("txtSenderCity", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 436cdf0e10cSrcweir myLetterDoc.fillSenderWithUserData(); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir optSenderDefineItemChanged()439cdf0e10cSrcweir public void optSenderDefineItemChanged() 440cdf0e10cSrcweir { 441cdf0e10cSrcweir setControlProperty("lblSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 442cdf0e10cSrcweir setControlProperty("lblSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 443cdf0e10cSrcweir setControlProperty("lblPostCodeCity", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 444cdf0e10cSrcweir setControlProperty("txtSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 445cdf0e10cSrcweir setControlProperty("txtSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 446cdf0e10cSrcweir setControlProperty("txtSenderPostCode", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 447cdf0e10cSrcweir setControlProperty("txtSenderState", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 448cdf0e10cSrcweir setControlProperty("txtSenderCity", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 449cdf0e10cSrcweir txtSenderNameTextChanged(); 450cdf0e10cSrcweir txtSenderStreetTextChanged(); 451cdf0e10cSrcweir txtSenderPostCodeTextChanged(); 452cdf0e10cSrcweir txtSenderStateTextChanged(); 453cdf0e10cSrcweir txtSenderCityTextChanged(); 454cdf0e10cSrcweir } 455cdf0e10cSrcweir optCreateLetterItemChanged()456cdf0e10cSrcweir public void optCreateLetterItemChanged() 457cdf0e10cSrcweir { 458cdf0e10cSrcweir bEditTemplate = false; 459cdf0e10cSrcweir } 460cdf0e10cSrcweir optMakeChangesItemChanged()461cdf0e10cSrcweir public void optMakeChangesItemChanged() 462cdf0e10cSrcweir { 463cdf0e10cSrcweir bEditTemplate = true; 464cdf0e10cSrcweir } 465cdf0e10cSrcweir optReceiverPlaceholderItemChanged()466cdf0e10cSrcweir public void optReceiverPlaceholderItemChanged() 467cdf0e10cSrcweir { 468cdf0e10cSrcweir OfficeDocument.attachEventCall(xTextDocument, "OnNew", "StarBasic", "macro:///Template.Correspondence.Placeholder()"); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir optReceiverDatabaseItemChanged()471cdf0e10cSrcweir public void optReceiverDatabaseItemChanged() 472cdf0e10cSrcweir { 473cdf0e10cSrcweir OfficeDocument.attachEventCall(xTextDocument, "OnNew", "StarBasic", "macro:///Template.Correspondence.Database()"); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir lstBusinessStyleItemChanged()476cdf0e10cSrcweir public void lstBusinessStyleItemChanged() 477cdf0e10cSrcweir { 478cdf0e10cSrcweir xTextDocument = myLetterDoc.loadAsPreview(BusinessFiles[1][lstBusinessStyle.getSelectedItemPos()], false); 479cdf0e10cSrcweir myLetterDoc.xTextDocument.lockControllers(); 480cdf0e10cSrcweir initializeElements(); 481cdf0e10cSrcweir chkBusinessPaperItemChanged(); 482cdf0e10cSrcweir setElements(false); 483cdf0e10cSrcweir myLetterDoc.xTextDocument.unlockControllers(); 484cdf0e10cSrcweir activate(); 485cdf0e10cSrcweir } 486cdf0e10cSrcweir lstPrivOfficialStyleItemChanged()487cdf0e10cSrcweir public void lstPrivOfficialStyleItemChanged() 488cdf0e10cSrcweir { 489cdf0e10cSrcweir xTextDocument = myLetterDoc.loadAsPreview(OfficialFiles[1][lstPrivOfficialStyle.getSelectedItemPos()], false); 490cdf0e10cSrcweir myLetterDoc.xTextDocument.lockControllers(); 491cdf0e10cSrcweir initializeElements(); 492cdf0e10cSrcweir setPossibleSenderData(true); 493cdf0e10cSrcweir setElements(false); 494cdf0e10cSrcweir myLetterDoc.xTextDocument.unlockControllers(); 495cdf0e10cSrcweir activate(); 496cdf0e10cSrcweir } 497cdf0e10cSrcweir lstPrivateStyleItemChanged()498cdf0e10cSrcweir public void lstPrivateStyleItemChanged() 499cdf0e10cSrcweir { 500cdf0e10cSrcweir xTextDocument = myLetterDoc.loadAsPreview(PrivateFiles[1][lstPrivateStyle.getSelectedItemPos()], false); 501cdf0e10cSrcweir myLetterDoc.xTextDocument.lockControllers(); 502cdf0e10cSrcweir initializeElements(); 503cdf0e10cSrcweir setElements(true); 504cdf0e10cSrcweir myLetterDoc.xTextDocument.unlockControllers(); 505cdf0e10cSrcweir activate(); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir numLogoHeightTextChanged()508cdf0e10cSrcweir public void numLogoHeightTextChanged() 509cdf0e10cSrcweir { 510cdf0e10cSrcweir BusCompanyLogo.iHeight = (int) (numLogoHeight.getValue() * 1000); 511cdf0e10cSrcweir BusCompanyLogo.setFramePosition(); 512cdf0e10cSrcweir } 513cdf0e10cSrcweir numLogoWidthTextChanged()514cdf0e10cSrcweir public void numLogoWidthTextChanged() 515cdf0e10cSrcweir { 516cdf0e10cSrcweir BusCompanyLogo.iWidth = (int) (numLogoWidth.getValue() * 1000); 517cdf0e10cSrcweir BusCompanyLogo.setFramePosition(); 518cdf0e10cSrcweir } 519cdf0e10cSrcweir numLogoXTextChanged()520cdf0e10cSrcweir public void numLogoXTextChanged() 521cdf0e10cSrcweir { 522cdf0e10cSrcweir BusCompanyLogo.iXPos = (int) (numLogoX.getValue() * 1000); 523cdf0e10cSrcweir BusCompanyLogo.setFramePosition(); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir numLogoYTextChanged()526cdf0e10cSrcweir public void numLogoYTextChanged() 527cdf0e10cSrcweir { 528cdf0e10cSrcweir BusCompanyLogo.iYPos = (int) (numLogoY.getValue() * 1000); 529cdf0e10cSrcweir BusCompanyLogo.setFramePosition(); 530cdf0e10cSrcweir } 531cdf0e10cSrcweir numAddressWidthTextChanged()532cdf0e10cSrcweir public void numAddressWidthTextChanged() 533cdf0e10cSrcweir { 534cdf0e10cSrcweir BusCompanyAddress.iWidth = (int) (numAddressWidth.getValue() * 1000); 535cdf0e10cSrcweir BusCompanyAddress.setFramePosition(); 536cdf0e10cSrcweir } 537cdf0e10cSrcweir numAddressXTextChanged()538cdf0e10cSrcweir public void numAddressXTextChanged() 539cdf0e10cSrcweir { 540cdf0e10cSrcweir BusCompanyAddress.iXPos = (int) (numAddressX.getValue() * 1000); 541cdf0e10cSrcweir BusCompanyAddress.setFramePosition(); 542cdf0e10cSrcweir } 543cdf0e10cSrcweir numAddressYTextChanged()544cdf0e10cSrcweir public void numAddressYTextChanged() 545cdf0e10cSrcweir { 546cdf0e10cSrcweir BusCompanyAddress.iYPos = (int) (numAddressY.getValue() * 1000); 547cdf0e10cSrcweir BusCompanyAddress.setFramePosition(); 548cdf0e10cSrcweir } 549cdf0e10cSrcweir numAddressHeightTextChanged()550cdf0e10cSrcweir public void numAddressHeightTextChanged() 551cdf0e10cSrcweir { 552cdf0e10cSrcweir BusCompanyAddress.iHeight = (int) (numAddressHeight.getValue() * 1000); 553cdf0e10cSrcweir BusCompanyAddress.setFramePosition(); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir numFooterHeightTextChanged()556cdf0e10cSrcweir public void numFooterHeightTextChanged() 557cdf0e10cSrcweir { 558cdf0e10cSrcweir BusFooter.iHeight = (int) (numFooterHeight.getValue() * 1000); 559cdf0e10cSrcweir BusFooter.iYPos = myLetterDoc.DocSize.Height - BusFooter.iHeight; 560cdf0e10cSrcweir BusFooter.setFramePosition(); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir chkPaperCompanyLogoItemChanged()563cdf0e10cSrcweir public void chkPaperCompanyLogoItemChanged() 564cdf0e10cSrcweir { 565cdf0e10cSrcweir if (chkPaperCompanyLogo.getState() != 0) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir //minimal value is required, otherwise the frame creation fails 568cdf0e10cSrcweir if (numLogoWidth.getValue() == 0) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir numLogoWidth.setValue(0.1); 571cdf0e10cSrcweir } 572cdf0e10cSrcweir if (numLogoHeight.getValue() == 0) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir numLogoHeight.setValue(0.1); 575cdf0e10cSrcweir } 576cdf0e10cSrcweir BusCompanyLogo = myLetterDoc.new BusinessPaperObject("Company Logo", (int) (numLogoWidth.getValue() * 1000), (int) (numLogoHeight.getValue() * 1000), (int) (numLogoX.getValue() * 1000), (int) (numLogoY.getValue() * 1000)); 577cdf0e10cSrcweir setControlProperty("numLogoHeight", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 578cdf0e10cSrcweir setControlProperty("lblCompanyLogoHeight", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 579cdf0e10cSrcweir setControlProperty("numLogoWidth", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 580cdf0e10cSrcweir setControlProperty("lblCompanyLogoWidth", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 581cdf0e10cSrcweir setControlProperty("numLogoX", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 582cdf0e10cSrcweir setControlProperty("lblCompanyLogoX", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 583cdf0e10cSrcweir setControlProperty("numLogoY", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 584cdf0e10cSrcweir setControlProperty("lblCompanyLogoY", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 585cdf0e10cSrcweir setPossibleLogo(false); 586cdf0e10cSrcweir } 587cdf0e10cSrcweir else 588cdf0e10cSrcweir { 589cdf0e10cSrcweir if (BusCompanyLogo != null) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir BusCompanyLogo.removeFrame(); 592cdf0e10cSrcweir } 593cdf0e10cSrcweir setControlProperty("numLogoHeight", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 594cdf0e10cSrcweir setControlProperty("lblCompanyLogoHeight", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 595cdf0e10cSrcweir setControlProperty("numLogoWidth", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 596cdf0e10cSrcweir setControlProperty("lblCompanyLogoWidth", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 597cdf0e10cSrcweir setControlProperty("numLogoX", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 598cdf0e10cSrcweir setControlProperty("lblCompanyLogoX", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 599cdf0e10cSrcweir setControlProperty("numLogoY", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 600cdf0e10cSrcweir setControlProperty("lblCompanyLogoY", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 601cdf0e10cSrcweir setPossibleLogo(true); 602cdf0e10cSrcweir } 603cdf0e10cSrcweir } 604cdf0e10cSrcweir chkPaperCompanyAddressItemChanged()605cdf0e10cSrcweir public void chkPaperCompanyAddressItemChanged() 606cdf0e10cSrcweir { 607cdf0e10cSrcweir if (chkPaperCompanyAddress.getState() != 0) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir // minimal value is required, otherwise the frame creation fails 610cdf0e10cSrcweir if (numAddressWidth.getValue() == 0) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir numAddressWidth.setValue(0.1); 613cdf0e10cSrcweir } 614cdf0e10cSrcweir if (numAddressHeight.getValue() == 0) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir numAddressHeight.setValue(0.1); 617cdf0e10cSrcweir } 618cdf0e10cSrcweir BusCompanyAddress = myLetterDoc.new BusinessPaperObject("Company Address", (int) (numAddressWidth.getValue() * 1000), (int) (numAddressHeight.getValue() * 1000), (int) (numAddressX.getValue() * 1000), (int) (numAddressY.getValue() * 1000)); 619cdf0e10cSrcweir setControlProperty("numAddressHeight", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 620cdf0e10cSrcweir setControlProperty("lblCompanyAddressHeight", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 621cdf0e10cSrcweir setControlProperty("numAddressWidth", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 622cdf0e10cSrcweir setControlProperty("lblCompanyAddressWidth", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 623cdf0e10cSrcweir setControlProperty("numAddressX", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 624cdf0e10cSrcweir setControlProperty("lblCompanyAddressX", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 625cdf0e10cSrcweir setControlProperty("numAddressY", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 626cdf0e10cSrcweir setControlProperty("lblCompanyAddressY", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 627cdf0e10cSrcweir if (myLetterDoc.hasElement("Sender Address")) 628cdf0e10cSrcweir { 629cdf0e10cSrcweir myLetterDoc.switchElement("Sender Address", (false)); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir if (chkCompanyReceiver.getState() != 0) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir setPossibleSenderData(false); 634cdf0e10cSrcweir } 635cdf0e10cSrcweir } 636cdf0e10cSrcweir else 637cdf0e10cSrcweir { 638cdf0e10cSrcweir if (BusCompanyAddress != null) 639cdf0e10cSrcweir { 640cdf0e10cSrcweir BusCompanyAddress.removeFrame(); 641cdf0e10cSrcweir } 642cdf0e10cSrcweir setControlProperty("numAddressHeight", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 643cdf0e10cSrcweir setControlProperty("lblCompanyAddressHeight", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 644cdf0e10cSrcweir setControlProperty("numAddressWidth", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 645cdf0e10cSrcweir setControlProperty("lblCompanyAddressWidth", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 646cdf0e10cSrcweir setControlProperty("numAddressX", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 647cdf0e10cSrcweir setControlProperty("lblCompanyAddressX", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 648cdf0e10cSrcweir setControlProperty("numAddressY", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 649cdf0e10cSrcweir setControlProperty("lblCompanyAddressY", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 650cdf0e10cSrcweir if (myLetterDoc.hasElement("Sender Address")) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir myLetterDoc.switchElement("Sender Address", (true)); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir setPossibleSenderData(true); 655cdf0e10cSrcweir if (optSenderDefine.getState()) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir optSenderDefineItemChanged(); 658cdf0e10cSrcweir } 659cdf0e10cSrcweir if (optSenderPlaceholder.getState()) 660cdf0e10cSrcweir { 661cdf0e10cSrcweir optSenderPlaceholderItemChanged(); 662cdf0e10cSrcweir } 663cdf0e10cSrcweir } 664cdf0e10cSrcweir } 665cdf0e10cSrcweir chkCompanyReceiverItemChanged()666cdf0e10cSrcweir public void chkCompanyReceiverItemChanged() 667cdf0e10cSrcweir { 668cdf0e10cSrcweir XTextFrame xReceiverFrame = null; 669cdf0e10cSrcweir 670cdf0e10cSrcweir if (chkCompanyReceiver.getState() != 0) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir try 673cdf0e10cSrcweir { 674cdf0e10cSrcweir xReceiverFrame = TextFrameHandler.getFrameByName("Receiver Address", xTextDocument); 675cdf0e10cSrcweir Integer FrameWidth = (Integer) Helper.getUnoPropertyValue(xReceiverFrame, PropertyNames.PROPERTY_WIDTH); 676cdf0e10cSrcweir int iFrameWidth = FrameWidth.intValue(); 677cdf0e10cSrcweir Integer FrameX = (Integer) Helper.getUnoPropertyValue(xReceiverFrame, "HoriOrientPosition"); 678cdf0e10cSrcweir int iFrameX = FrameX.intValue(); 679cdf0e10cSrcweir Integer FrameY = (Integer) Helper.getUnoPropertyValue(xReceiverFrame, "VertOrientPosition"); 680cdf0e10cSrcweir int iFrameY = FrameY.intValue(); 681cdf0e10cSrcweir 682cdf0e10cSrcweir //Height of the Company Address in the Receiver Field 683cdf0e10cSrcweir int iReceiverHeight = (int) (0.5 * 1000); 684cdf0e10cSrcweir BusCompanyAddressReceiver = myLetterDoc.new BusinessPaperObject(PropertyNames.SPACE, iFrameWidth, iReceiverHeight, iFrameX, (iFrameY - iReceiverHeight)); 685cdf0e10cSrcweir 686cdf0e10cSrcweir setPossibleAddressReceiver(false); 687cdf0e10cSrcweir } 688cdf0e10cSrcweir catch (NoSuchElementException e) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir // TODO Error Message: Template modified! 691cdf0e10cSrcweir e.printStackTrace(); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir catch (WrappedTargetException e) 694cdf0e10cSrcweir { 695cdf0e10cSrcweir e.printStackTrace(); 696cdf0e10cSrcweir } 697cdf0e10cSrcweir if (chkPaperCompanyAddress.getState() != 0) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir setPossibleSenderData(false); 700cdf0e10cSrcweir } 701cdf0e10cSrcweir } 702cdf0e10cSrcweir else 703cdf0e10cSrcweir { 704cdf0e10cSrcweir if (BusCompanyAddressReceiver != null) 705cdf0e10cSrcweir { 706cdf0e10cSrcweir BusCompanyAddressReceiver.removeFrame(); 707cdf0e10cSrcweir } 708cdf0e10cSrcweir setPossibleAddressReceiver(true); 709cdf0e10cSrcweir setPossibleSenderData(true); 710cdf0e10cSrcweir if (optSenderDefine.getState()) 711cdf0e10cSrcweir { 712cdf0e10cSrcweir optSenderDefineItemChanged(); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir if (optSenderPlaceholder.getState()) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir optSenderPlaceholderItemChanged(); 717cdf0e10cSrcweir } 718cdf0e10cSrcweir } 719cdf0e10cSrcweir } 720cdf0e10cSrcweir chkPaperFooterItemChanged()721cdf0e10cSrcweir public void chkPaperFooterItemChanged() 722cdf0e10cSrcweir { 723cdf0e10cSrcweir 724cdf0e10cSrcweir if (chkPaperFooter.getState() != 0) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir //minimal value is required, otherwise the frame creation fails 727cdf0e10cSrcweir if (numFooterHeight.getValue() == 0) 728cdf0e10cSrcweir { 729cdf0e10cSrcweir numFooterHeight.setValue(0.1); 730cdf0e10cSrcweir } 731cdf0e10cSrcweir BusFooter = myLetterDoc.new BusinessPaperObject("Footer", myLetterDoc.DocSize.Width, (int) (numFooterHeight.getValue() * 1000), 0, (int) (myLetterDoc.DocSize.Height - (numFooterHeight.getValue() * 1000))); 732cdf0e10cSrcweir this.setControlProperty("numFooterHeight", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 733cdf0e10cSrcweir this.setControlProperty("lblFooterHeight", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 734cdf0e10cSrcweir setPossibleFooter(false); 735cdf0e10cSrcweir } 736cdf0e10cSrcweir else 737cdf0e10cSrcweir { 738cdf0e10cSrcweir if (BusFooter != null) 739cdf0e10cSrcweir { 740cdf0e10cSrcweir BusFooter.removeFrame(); 741cdf0e10cSrcweir } 742cdf0e10cSrcweir setControlProperty("numFooterHeight", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 743cdf0e10cSrcweir setControlProperty("lblFooterHeight", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 744cdf0e10cSrcweir setPossibleFooter(true); 745cdf0e10cSrcweir } 746cdf0e10cSrcweir } 747cdf0e10cSrcweir 748cdf0e10cSrcweir //switch Elements on/off ------------------------------------------------------- chkUseLogoItemChanged()749cdf0e10cSrcweir public void chkUseLogoItemChanged() 750cdf0e10cSrcweir { 751cdf0e10cSrcweir try 752cdf0e10cSrcweir { 753cdf0e10cSrcweir if (myLetterDoc.hasElement("Company Logo")) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir boolean logostatus = AnyConverter.toBoolean(getControlProperty("chkUseLogo", PropertyNames.PROPERTY_ENABLED)) && (chkUseLogo.getState() != 0); 756cdf0e10cSrcweir myLetterDoc.switchElement("Company Logo", logostatus); 757cdf0e10cSrcweir } 758cdf0e10cSrcweir } 759cdf0e10cSrcweir catch (IllegalArgumentException e) 760cdf0e10cSrcweir { 761cdf0e10cSrcweir e.printStackTrace(); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir } 764cdf0e10cSrcweir chkUseAddressReceiverItemChanged()765cdf0e10cSrcweir public void chkUseAddressReceiverItemChanged() 766cdf0e10cSrcweir { 767cdf0e10cSrcweir try 768cdf0e10cSrcweir { 769cdf0e10cSrcweir if (myLetterDoc.hasElement("Sender Address Repeated")) 770cdf0e10cSrcweir { 771cdf0e10cSrcweir boolean rstatus = AnyConverter.toBoolean(getControlProperty("chkUseAddressReceiver", PropertyNames.PROPERTY_ENABLED)) && (chkUseAddressReceiver.getState() != 0); 772cdf0e10cSrcweir myLetterDoc.switchElement("Sender Address Repeated", rstatus); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir } 775cdf0e10cSrcweir catch (IllegalArgumentException e) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir e.printStackTrace(); 778cdf0e10cSrcweir } 779cdf0e10cSrcweir } 780cdf0e10cSrcweir chkUseSignsItemChanged()781cdf0e10cSrcweir public void chkUseSignsItemChanged() 782cdf0e10cSrcweir { 783cdf0e10cSrcweir if (myLetterDoc.hasElement("Letter Signs")) 784cdf0e10cSrcweir { 785cdf0e10cSrcweir myLetterDoc.switchElement("Letter Signs", (chkUseSigns.getState() != 0)); 786cdf0e10cSrcweir } 787cdf0e10cSrcweir } 788cdf0e10cSrcweir chkUseSubjectItemChanged()789cdf0e10cSrcweir public void chkUseSubjectItemChanged() 790cdf0e10cSrcweir { 791cdf0e10cSrcweir if (myLetterDoc.hasElement("Subject Line")) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir myLetterDoc.switchElement("Subject Line", (chkUseSubject.getState() != 0)); 794cdf0e10cSrcweir } 795cdf0e10cSrcweir } 796cdf0e10cSrcweir chkUseBendMarksItemChanged()797cdf0e10cSrcweir public void chkUseBendMarksItemChanged() 798cdf0e10cSrcweir { 799cdf0e10cSrcweir if (myLetterDoc.hasElement("Bend Marks")) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir myLetterDoc.switchElement("Bend Marks", (chkUseBendMarks.getState() != 0)); 802cdf0e10cSrcweir } 803cdf0e10cSrcweir } 804cdf0e10cSrcweir chkUseFooterItemChanged()805cdf0e10cSrcweir public void chkUseFooterItemChanged() 806cdf0e10cSrcweir { 807cdf0e10cSrcweir try 808cdf0e10cSrcweir { 809cdf0e10cSrcweir boolean bFooterPossible = (chkUseFooter.getState() != 0) && AnyConverter.toBoolean(getControlProperty("chkUseFooter", PropertyNames.PROPERTY_ENABLED)); 810cdf0e10cSrcweir 811cdf0e10cSrcweir if (chkFooterNextPages.getState() != 0) 812cdf0e10cSrcweir { 813cdf0e10cSrcweir myLetterDoc.switchFooter("First Page", false, (chkFooterPageNumbers.getState() != 0), txtFooter.getText()); 814cdf0e10cSrcweir myLetterDoc.switchFooter("Standard", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText()); 815cdf0e10cSrcweir } 816cdf0e10cSrcweir else 817cdf0e10cSrcweir { 818cdf0e10cSrcweir myLetterDoc.switchFooter("First Page", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText()); 819cdf0e10cSrcweir myLetterDoc.switchFooter("Standard", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText()); 820cdf0e10cSrcweir } 821cdf0e10cSrcweir 822cdf0e10cSrcweir //enable/disable roadmap item for footer page 823cdf0e10cSrcweir XInterface BPaperItem = getRoadmapItemByID(RM_FOOTER); 824cdf0e10cSrcweir Helper.setUnoPropertyValue(BPaperItem, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bFooterPossible)); 825cdf0e10cSrcweir 826cdf0e10cSrcweir } 827cdf0e10cSrcweir catch (Exception exception) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir exception.printStackTrace(System.out); 830cdf0e10cSrcweir } 831cdf0e10cSrcweir } 832cdf0e10cSrcweir chkFooterNextPagesItemChanged()833cdf0e10cSrcweir public void chkFooterNextPagesItemChanged() 834cdf0e10cSrcweir { 835cdf0e10cSrcweir chkUseFooterItemChanged(); 836cdf0e10cSrcweir } 837cdf0e10cSrcweir chkFooterPageNumbersItemChanged()838cdf0e10cSrcweir public void chkFooterPageNumbersItemChanged() 839cdf0e10cSrcweir { 840cdf0e10cSrcweir chkUseFooterItemChanged(); 841cdf0e10cSrcweir } 842cdf0e10cSrcweir setPossibleFooter(boolean bState)843cdf0e10cSrcweir private void setPossibleFooter(boolean bState) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir setControlProperty("chkUseFooter", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 846cdf0e10cSrcweir chkUseFooterItemChanged(); 847cdf0e10cSrcweir } 848cdf0e10cSrcweir setPossibleAddressReceiver(boolean bState)849cdf0e10cSrcweir private void setPossibleAddressReceiver(boolean bState) 850cdf0e10cSrcweir { 851cdf0e10cSrcweir if (myLetterDoc.hasElement("Sender Address Repeated")) 852cdf0e10cSrcweir { 853cdf0e10cSrcweir setControlProperty("chkUseAddressReceiver", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 854cdf0e10cSrcweir chkUseAddressReceiverItemChanged(); 855cdf0e10cSrcweir } 856cdf0e10cSrcweir } 857cdf0e10cSrcweir setPossibleLogo(boolean bState)858cdf0e10cSrcweir private void setPossibleLogo(boolean bState) 859cdf0e10cSrcweir { 860cdf0e10cSrcweir if (myLetterDoc.hasElement("Company Logo")) 861cdf0e10cSrcweir { 862cdf0e10cSrcweir setControlProperty("chkUseLogo", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 863cdf0e10cSrcweir chkUseLogoItemChanged(); 864cdf0e10cSrcweir } 865cdf0e10cSrcweir } 866cdf0e10cSrcweir txtFooterTextChanged()867cdf0e10cSrcweir public void txtFooterTextChanged() 868cdf0e10cSrcweir { 869cdf0e10cSrcweir chkUseFooterItemChanged(); 870cdf0e10cSrcweir } 871cdf0e10cSrcweir txtSenderNameTextChanged()872cdf0e10cSrcweir public void txtSenderNameTextChanged() 873cdf0e10cSrcweir { 874cdf0e10cSrcweir TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument); 875cdf0e10cSrcweir myFieldHandler.changeUserFieldContent("Company", txtSenderName.getText()); 876cdf0e10cSrcweir } 877cdf0e10cSrcweir txtSenderStreetTextChanged()878cdf0e10cSrcweir public void txtSenderStreetTextChanged() 879cdf0e10cSrcweir { 880cdf0e10cSrcweir TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument); 881cdf0e10cSrcweir myFieldHandler.changeUserFieldContent("Street", txtSenderStreet.getText()); 882cdf0e10cSrcweir } 883cdf0e10cSrcweir txtSenderCityTextChanged()884cdf0e10cSrcweir public void txtSenderCityTextChanged() 885cdf0e10cSrcweir { 886cdf0e10cSrcweir TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument); 887cdf0e10cSrcweir myFieldHandler.changeUserFieldContent("City", txtSenderCity.getText()); 888cdf0e10cSrcweir } 889cdf0e10cSrcweir txtSenderPostCodeTextChanged()890cdf0e10cSrcweir public void txtSenderPostCodeTextChanged() 891cdf0e10cSrcweir { 892cdf0e10cSrcweir TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument); 893cdf0e10cSrcweir myFieldHandler.changeUserFieldContent("PostCode", txtSenderPostCode.getText()); 894cdf0e10cSrcweir } 895cdf0e10cSrcweir txtSenderStateTextChanged()896cdf0e10cSrcweir public void txtSenderStateTextChanged() 897cdf0e10cSrcweir { 898cdf0e10cSrcweir TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument); 899cdf0e10cSrcweir myFieldHandler.changeUserFieldContent(PropertyNames.PROPERTY_STATE, txtSenderState.getText()); 900cdf0e10cSrcweir } 901cdf0e10cSrcweir txtTemplateNameTextChanged()902cdf0e10cSrcweir public void txtTemplateNameTextChanged() 903cdf0e10cSrcweir { 904cdf0e10cSrcweir XDocumentPropertiesSupplier xDocPropsSuppl = UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument); 905cdf0e10cSrcweir XDocumentProperties xDocProps = xDocPropsSuppl.getDocumentProperties(); 906cdf0e10cSrcweir String TitleName = txtTemplateName.getText(); 907cdf0e10cSrcweir xDocProps.setTitle(TitleName); 908cdf0e10cSrcweir } 909cdf0e10cSrcweir chkUseSalutationItemChanged()910cdf0e10cSrcweir public void chkUseSalutationItemChanged() 911cdf0e10cSrcweir { 912cdf0e10cSrcweir XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstSalutation); 913cdf0e10cSrcweir myLetterDoc.switchUserField("Salutation", xTextComponent.getText(), (chkUseSalutation.getState() != 0)); 914cdf0e10cSrcweir setControlProperty("lstSalutation", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(chkUseSalutation.getState() != 0)); 915cdf0e10cSrcweir } 916cdf0e10cSrcweir lstSalutationItemChanged()917cdf0e10cSrcweir public void lstSalutationItemChanged() 918cdf0e10cSrcweir { 919cdf0e10cSrcweir XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstSalutation); 920cdf0e10cSrcweir myLetterDoc.switchUserField("Salutation", xTextComponent.getText(), (chkUseSalutation.getState() != 0)); 921cdf0e10cSrcweir } 922cdf0e10cSrcweir lstSalutationTextChanged()923cdf0e10cSrcweir public void lstSalutationTextChanged() 924cdf0e10cSrcweir { 925cdf0e10cSrcweir } 926cdf0e10cSrcweir chkUseGreetingItemChanged()927cdf0e10cSrcweir public void chkUseGreetingItemChanged() 928cdf0e10cSrcweir { 929cdf0e10cSrcweir XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstGreeting); 930cdf0e10cSrcweir myLetterDoc.switchUserField("Greeting", xTextComponent.getText(), (chkUseGreeting.getState() != 0)); 931cdf0e10cSrcweir setControlProperty("lstGreeting", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(chkUseGreeting.getState() != 0)); 932cdf0e10cSrcweir } 933cdf0e10cSrcweir setDefaultForGreetingAndSalutation()934cdf0e10cSrcweir private void setDefaultForGreetingAndSalutation() 935cdf0e10cSrcweir { 936cdf0e10cSrcweir XTextComponent xTextComponent; 937cdf0e10cSrcweir xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstSalutation); 938cdf0e10cSrcweir if (xTextComponent.getText().equals(PropertyNames.EMPTY_STRING)) 939cdf0e10cSrcweir { 940cdf0e10cSrcweir xTextComponent.setText(resources.SalutationLabels[0]); 941cdf0e10cSrcweir } 942cdf0e10cSrcweir xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstGreeting); 943cdf0e10cSrcweir if (xTextComponent.getText().equals(PropertyNames.EMPTY_STRING)) 944cdf0e10cSrcweir { 945cdf0e10cSrcweir xTextComponent.setText(resources.GreetingLabels[0]); 946cdf0e10cSrcweir } 947cdf0e10cSrcweir } 948cdf0e10cSrcweir lstGreetingItemChanged()949cdf0e10cSrcweir public void lstGreetingItemChanged() 950cdf0e10cSrcweir { 951cdf0e10cSrcweir XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, lstGreeting); 952cdf0e10cSrcweir myLetterDoc.switchUserField("Greeting", xTextComponent.getText(), (chkUseGreeting.getState() != 0)); 953cdf0e10cSrcweir } 954cdf0e10cSrcweir lstGreetingTextChanged()955cdf0e10cSrcweir public void lstGreetingTextChanged() 956cdf0e10cSrcweir { 957cdf0e10cSrcweir } 958cdf0e10cSrcweir 959cdf0e10cSrcweir // ---------------------------------------------------------------------------- chkBusinessPaperItemChanged()960cdf0e10cSrcweir public void chkBusinessPaperItemChanged() 961cdf0e10cSrcweir { 962cdf0e10cSrcweir //enable/disable Roadmap Entry Business Paper 963cdf0e10cSrcweir if (chkBusinessPaper.getState() != 0) 964cdf0e10cSrcweir { 965cdf0e10cSrcweir enableBusinessPaper(); 966cdf0e10cSrcweir } 967cdf0e10cSrcweir else 968cdf0e10cSrcweir { 969cdf0e10cSrcweir disableBusinessPaper(); 970cdf0e10cSrcweir setPossibleSenderData(true); 971cdf0e10cSrcweir } 972cdf0e10cSrcweir } 973cdf0e10cSrcweir getOfficeLinguistic()974cdf0e10cSrcweir private int getOfficeLinguistic() 975cdf0e10cSrcweir { 976cdf0e10cSrcweir int oL = 0; 977cdf0e10cSrcweir boolean found = false; 978cdf0e10cSrcweir String OfficeLinguistic = Configuration.getOfficeLinguistic(xMSF); 979cdf0e10cSrcweir for (int i = 0; i < Norms.length; i++) 980cdf0e10cSrcweir { 981cdf0e10cSrcweir if (Norms[i].equalsIgnoreCase(OfficeLinguistic)) 982cdf0e10cSrcweir { 983cdf0e10cSrcweir oL = i; 984cdf0e10cSrcweir found = true; 985cdf0e10cSrcweir break; 986cdf0e10cSrcweir } 987cdf0e10cSrcweir } 988cdf0e10cSrcweir if (!found) 989cdf0e10cSrcweir { 990cdf0e10cSrcweir //fall back to English: 991cdf0e10cSrcweir for (int i = 0; i < Norms.length; i++) 992cdf0e10cSrcweir { 993cdf0e10cSrcweir if (Norms[i].equalsIgnoreCase("en-US")) 994cdf0e10cSrcweir { 995cdf0e10cSrcweir oL = i; 996cdf0e10cSrcweir found = true; 997cdf0e10cSrcweir break; 998cdf0e10cSrcweir } 999cdf0e10cSrcweir } 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir return oL; 1002cdf0e10cSrcweir } 1003cdf0e10cSrcweir setPossibleSenderData(boolean bState)1004cdf0e10cSrcweir private void setPossibleSenderData(boolean bState) 1005cdf0e10cSrcweir { 1006cdf0e10cSrcweir setControlProperty("optSenderDefine", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1007cdf0e10cSrcweir setControlProperty("optSenderPlaceholder", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1008cdf0e10cSrcweir setControlProperty("lblSenderAddress", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1009cdf0e10cSrcweir if (!bState) 1010cdf0e10cSrcweir { 1011cdf0e10cSrcweir setControlProperty("txtSenderCity", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1012cdf0e10cSrcweir setControlProperty("txtSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1013cdf0e10cSrcweir setControlProperty("txtSenderPostCode", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1014cdf0e10cSrcweir setControlProperty("txtSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1015cdf0e10cSrcweir setControlProperty("txtSenderCity", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1016cdf0e10cSrcweir setControlProperty("txtSenderState", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1017cdf0e10cSrcweir setControlProperty("lblSenderName", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1018cdf0e10cSrcweir setControlProperty("lblSenderStreet", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1019cdf0e10cSrcweir setControlProperty("lblPostCodeCity", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bState)); 1020cdf0e10cSrcweir } 1021cdf0e10cSrcweir } 1022cdf0e10cSrcweir enableSenderReceiver()1023cdf0e10cSrcweir private void enableSenderReceiver() 1024cdf0e10cSrcweir { 1025cdf0e10cSrcweir XInterface BPaperItem = getRoadmapItemByID(RM_SENDERRECEIVER); 1026cdf0e10cSrcweir Helper.setUnoPropertyValue(BPaperItem, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 1027cdf0e10cSrcweir } 1028cdf0e10cSrcweir disableSenderReceiver()1029cdf0e10cSrcweir private void disableSenderReceiver() 1030cdf0e10cSrcweir { 1031cdf0e10cSrcweir XInterface BPaperItem = getRoadmapItemByID(RM_SENDERRECEIVER); 1032cdf0e10cSrcweir Helper.setUnoPropertyValue(BPaperItem, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir enableBusinessPaper()1035cdf0e10cSrcweir private void enableBusinessPaper() 1036cdf0e10cSrcweir { 1037cdf0e10cSrcweir XInterface BPaperItem = getRoadmapItemByID(RM_BUSINESSPAPER); 1038cdf0e10cSrcweir Helper.setUnoPropertyValue(BPaperItem, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); 1039cdf0e10cSrcweir chkPaperCompanyLogoItemChanged(); 1040cdf0e10cSrcweir chkPaperCompanyAddressItemChanged(); 1041cdf0e10cSrcweir chkPaperFooterItemChanged(); 1042cdf0e10cSrcweir chkCompanyReceiverItemChanged(); 1043cdf0e10cSrcweir } 1044cdf0e10cSrcweir disableBusinessPaper()1045cdf0e10cSrcweir private void disableBusinessPaper() 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir XInterface BPaperItem = getRoadmapItemByID(RM_BUSINESSPAPER); 1048cdf0e10cSrcweir Helper.setUnoPropertyValue(BPaperItem, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); 1049cdf0e10cSrcweir if (BusCompanyLogo != null) 1050cdf0e10cSrcweir { 1051cdf0e10cSrcweir BusCompanyLogo.removeFrame(); 1052cdf0e10cSrcweir } 1053cdf0e10cSrcweir if (BusCompanyAddress != null) 1054cdf0e10cSrcweir { 1055cdf0e10cSrcweir BusCompanyAddress.removeFrame(); 1056cdf0e10cSrcweir } 1057cdf0e10cSrcweir if (BusFooter != null) 1058cdf0e10cSrcweir { 1059cdf0e10cSrcweir BusFooter.removeFrame(); 1060cdf0e10cSrcweir } 1061cdf0e10cSrcweir if (BusCompanyAddressReceiver != null) 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir BusCompanyAddressReceiver.removeFrame(); 1064cdf0e10cSrcweir } 1065cdf0e10cSrcweir setPossibleAddressReceiver(true); 1066cdf0e10cSrcweir setPossibleFooter(true); 1067cdf0e10cSrcweir setPossibleLogo(true); 1068cdf0e10cSrcweir if (myLetterDoc.hasElement("Sender Address")) 1069cdf0e10cSrcweir { 1070cdf0e10cSrcweir myLetterDoc.switchElement("Sender Address", (true)); 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir 1073cdf0e10cSrcweir } 1074cdf0e10cSrcweir lstLetterNormItemChanged()1075cdf0e10cSrcweir public void lstLetterNormItemChanged() 1076cdf0e10cSrcweir { 1077cdf0e10cSrcweir //when the norm changes, the correct template needs to be reloaded 1078cdf0e10cSrcweir sCurrentNorm = Norms[getCurrentLetter().cp_Norm]; 1079cdf0e10cSrcweir initializeTemplates(xMSF); 1080cdf0e10cSrcweir if (optBusinessLetter.getState()) 1081cdf0e10cSrcweir { 1082cdf0e10cSrcweir lstBusinessStyleItemChanged(); 1083cdf0e10cSrcweir } 1084cdf0e10cSrcweir if (optPrivOfficialLetter.getState()) 1085cdf0e10cSrcweir { 1086cdf0e10cSrcweir lstPrivOfficialStyleItemChanged(); 1087cdf0e10cSrcweir } 1088cdf0e10cSrcweir if (optPrivateLetter.getState()) 1089cdf0e10cSrcweir { 1090cdf0e10cSrcweir lstPrivateStyleItemChanged(); 1091cdf0e10cSrcweir } 1092cdf0e10cSrcweir } 1093cdf0e10cSrcweir initializeSalutation()1094cdf0e10cSrcweir public void initializeSalutation() 1095cdf0e10cSrcweir { 1096cdf0e10cSrcweir setControlProperty("lstSalutation", PropertyNames.STRING_ITEM_LIST, resources.SalutationLabels); 1097cdf0e10cSrcweir } 1098cdf0e10cSrcweir initializeGreeting()1099cdf0e10cSrcweir public void initializeGreeting() 1100cdf0e10cSrcweir { 1101cdf0e10cSrcweir setControlProperty("lstGreeting", PropertyNames.STRING_ITEM_LIST, resources.GreetingLabels); 1102cdf0e10cSrcweir } 1103cdf0e10cSrcweir initializeNorms()1104cdf0e10cSrcweir public void initializeNorms() 1105cdf0e10cSrcweir { 1106cdf0e10cSrcweir 1107cdf0e10cSrcweir LocaleCodes lc = new LocaleCodes(xmsf); 1108cdf0e10cSrcweir String[] allLocales = lc.getIDs(); 1109cdf0e10cSrcweir Object[] nameList = 1110cdf0e10cSrcweir { 1111cdf0e10cSrcweir PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING 1112cdf0e10cSrcweir }; 1113cdf0e10cSrcweir String[] nameList1 = 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING 1116cdf0e10cSrcweir }; 1117cdf0e10cSrcweir String[] nameList1b = 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING 1120cdf0e10cSrcweir }; 1121cdf0e10cSrcweir String[] nameList2 = 1122cdf0e10cSrcweir { 1123cdf0e10cSrcweir PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING 1124cdf0e10cSrcweir }; 1125cdf0e10cSrcweir Vector allPaths = new Vector(); 1126cdf0e10cSrcweir String sLetterSubPath = "/wizard/letter/"; 1127cdf0e10cSrcweir 1128cdf0e10cSrcweir try 1129cdf0e10cSrcweir { 1130cdf0e10cSrcweir sTemplatePath = FileAccess.deleteLastSlashfromUrl(sTemplatePath); 1131cdf0e10cSrcweir String[] PathParts = sTemplatePath.split("/"); 1132cdf0e10cSrcweir String nuString = PropertyNames.EMPTY_STRING; 1133cdf0e10cSrcweir String sMainPath; 1134cdf0e10cSrcweir for (int i = 0; i < (PathParts.length - 1); i++) 1135cdf0e10cSrcweir { 1136cdf0e10cSrcweir nuString = nuString + PathParts[i] + "/"; 1137cdf0e10cSrcweir } 1138cdf0e10cSrcweir String sLocLetterPath; 1139cdf0e10cSrcweir sMainPath = nuString; 1140cdf0e10cSrcweir sMainPath = FileAccess.deleteLastSlashfromUrl(sMainPath); 1141cdf0e10cSrcweir 1142cdf0e10cSrcweir sLetterPath = sMainPath + sLetterSubPath; 1143cdf0e10cSrcweir //sLetterLangPackPath = FileAccess.combinePaths(xMSF, sTemplatePath, sLetterSubPath); 1144cdf0e10cSrcweir 1145cdf0e10cSrcweir XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); 1146cdf0e10cSrcweir com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface(com.sun.star.ucb.XSimpleFileAccess.class, xInterface); 1147cdf0e10cSrcweir nameList1 = xSimpleFileAccess.getFolderContents(sMainPath, true); 1148cdf0e10cSrcweir nameList2 = xSimpleFileAccess.getFolderContents(sLetterPath, true); 1149cdf0e10cSrcweir for (int i = 0; i < nameList1.length; i++) 1150cdf0e10cSrcweir { 1151cdf0e10cSrcweir String theFileName = FileAccess.getFilename(nameList1[i]); 1152cdf0e10cSrcweir if (!theFileName.equalsIgnoreCase("wizard")) 1153cdf0e10cSrcweir { 1154cdf0e10cSrcweir sLocLetterPath = FileAccess.deleteLastSlashfromUrl(nameList1[i] + sLetterSubPath); 1155cdf0e10cSrcweir try 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir nameList1b = xSimpleFileAccess.getFolderContents(sLocLetterPath, true); 1158cdf0e10cSrcweir for (int j = 0; j < nameList1b.length; j++) 1159cdf0e10cSrcweir { 1160cdf0e10cSrcweir String theFileNameb = FileAccess.getFilename(nameList1b[j]); 1161cdf0e10cSrcweir allPaths.add(nameList1[i] + sLetterSubPath + theFileNameb); 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir } 1164cdf0e10cSrcweir catch (Exception e) 1165cdf0e10cSrcweir { 1166cdf0e10cSrcweir //if the path is invalid an exception is thrown - try the fallback below then 1167cdf0e10cSrcweir } 1168cdf0e10cSrcweir } 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir for (int i = 0; i < nameList2.length; i++) 1171cdf0e10cSrcweir { 1172cdf0e10cSrcweir boolean found = false; 1173cdf0e10cSrcweir for (int t = 0; t < nameList1.length; t++) 1174cdf0e10cSrcweir { 1175cdf0e10cSrcweir if (FileAccess.getFilename(nameList2[i]).equalsIgnoreCase(FileAccess.getFilename(nameList1[t]))) 1176cdf0e10cSrcweir { 1177cdf0e10cSrcweir found = true; 1178cdf0e10cSrcweir } 1179cdf0e10cSrcweir } 1180cdf0e10cSrcweir if (!found) 1181cdf0e10cSrcweir { 1182cdf0e10cSrcweir allPaths.add(nameList2[i]); 1183cdf0e10cSrcweir } 1184cdf0e10cSrcweir } 1185cdf0e10cSrcweir nameList = allPaths.toArray(); 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir 1188cdf0e10cSrcweir } 1189cdf0e10cSrcweir catch (CommandAbortedException e) 1190cdf0e10cSrcweir { 1191cdf0e10cSrcweir // TODO Auto-generated catch block 1192cdf0e10cSrcweir e.printStackTrace(); 1193cdf0e10cSrcweir //} catch (NoValidPathException e) { 1194cdf0e10cSrcweir // TODO Auto-generated catch block 1195cdf0e10cSrcweir // e.printStackTrace(); 1196cdf0e10cSrcweir } 1197cdf0e10cSrcweir catch (Exception e) 1198cdf0e10cSrcweir { 1199cdf0e10cSrcweir // TODO Auto-generated catch block 1200cdf0e10cSrcweir e.printStackTrace(); 1201cdf0e10cSrcweir } 1202cdf0e10cSrcweir 1203cdf0e10cSrcweir Vector NormsVector = new Vector(); 1204cdf0e10cSrcweir Vector NormsPathVector = new Vector(); 1205cdf0e10cSrcweir Vector LanguageLabelsVector = new Vector(); 1206cdf0e10cSrcweir String[] LanguageLabels; 1207cdf0e10cSrcweir 1208cdf0e10cSrcweir boolean found = false; 1209cdf0e10cSrcweir String cIsoCode = PropertyNames.EMPTY_STRING; 1210cdf0e10cSrcweir String MSID = PropertyNames.EMPTY_STRING; 1211cdf0e10cSrcweir int z = 0; 1212cdf0e10cSrcweir for (int i = 0; i < nameList.length; i++) 1213cdf0e10cSrcweir { 1214cdf0e10cSrcweir found = false; 1215cdf0e10cSrcweir cIsoCode = FileAccess.getFilename((String) nameList[i]); 1216cdf0e10cSrcweir for (int t = 0; t < allLocales.length; t++) 1217cdf0e10cSrcweir { 1218cdf0e10cSrcweir String[] aLang = allLocales[t].split(PropertyNames.SEMI_COLON); 1219cdf0e10cSrcweir if (cIsoCode.equalsIgnoreCase(aLang[1])) 1220cdf0e10cSrcweir { 1221cdf0e10cSrcweir MSID = aLang[2]; 1222cdf0e10cSrcweir found = true; 1223cdf0e10cSrcweir t = allLocales.length; 1224cdf0e10cSrcweir } 1225cdf0e10cSrcweir } 1226cdf0e10cSrcweir if (!found) 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir for (int t = 0; t < allLocales.length; t++) 1229cdf0e10cSrcweir { 1230cdf0e10cSrcweir String[] aLang = allLocales[t].split(PropertyNames.SEMI_COLON); 1231cdf0e10cSrcweir if (cIsoCode.equalsIgnoreCase(aLang[1].substring(0, 2))) 1232cdf0e10cSrcweir { 1233cdf0e10cSrcweir MSID = aLang[2]; 1234cdf0e10cSrcweir found = true; 1235cdf0e10cSrcweir t = allLocales.length; 1236cdf0e10cSrcweir } 1237cdf0e10cSrcweir } 1238cdf0e10cSrcweir } 1239cdf0e10cSrcweir 1240cdf0e10cSrcweir if (found) 1241cdf0e10cSrcweir { 1242cdf0e10cSrcweir NormsVector.add(cIsoCode); 1243cdf0e10cSrcweir NormsPathVector.add(nameList[i]); 1244cdf0e10cSrcweir LanguageLabelsVector.add(lc.getLanguageString(MSID)); 1245cdf0e10cSrcweir /* 1246cdf0e10cSrcweir Norms[z] = cIsoCode; 1247cdf0e10cSrcweir NormPaths[z] = (String) nameList[i]; 1248cdf0e10cSrcweir LanguageLabels[z] = lc.getLanguageString(MSID); 1249cdf0e10cSrcweir z++; 1250cdf0e10cSrcweir **/ 1251cdf0e10cSrcweir } 1252cdf0e10cSrcweir } 1253cdf0e10cSrcweir 1254cdf0e10cSrcweir 1255cdf0e10cSrcweir Norms = new String[NormsVector.size()]; 1256cdf0e10cSrcweir NormsVector.toArray(Norms); 1257cdf0e10cSrcweir 1258cdf0e10cSrcweir NormPaths = new String[NormsPathVector.size()]; 1259cdf0e10cSrcweir NormsPathVector.toArray(NormPaths); 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir LanguageLabels = new String[LanguageLabelsVector.size()]; 1262cdf0e10cSrcweir LanguageLabelsVector.toArray(LanguageLabels); 1263cdf0e10cSrcweir 1264cdf0e10cSrcweir //Norms = new String[nameList.length]; 1265cdf0e10cSrcweir //NormPaths = new String[nameList.length]; 1266cdf0e10cSrcweir //LanguageLabels = new String[Norms.length]; 1267cdf0e10cSrcweir 1268cdf0e10cSrcweir setControlProperty("lstLetterNorm", PropertyNames.STRING_ITEM_LIST, LanguageLabels); 1269cdf0e10cSrcweir } 1270cdf0e10cSrcweir getCurrentLetter()1271cdf0e10cSrcweir private CGLetter getCurrentLetter() 1272cdf0e10cSrcweir { 1273cdf0e10cSrcweir switch (myConfig.cp_LetterType) 1274cdf0e10cSrcweir { 1275cdf0e10cSrcweir case 0: 1276cdf0e10cSrcweir return myConfig.cp_BusinessLetter; 1277cdf0e10cSrcweir case 1: 1278cdf0e10cSrcweir return myConfig.cp_PrivateOfficialLetter; 1279cdf0e10cSrcweir case 2: 1280cdf0e10cSrcweir return myConfig.cp_PrivateLetter; 1281cdf0e10cSrcweir default: 1282cdf0e10cSrcweir return null; 1283cdf0e10cSrcweir } 1284cdf0e10cSrcweir } 1285cdf0e10cSrcweir initializePaths()1286cdf0e10cSrcweir private void initializePaths() 1287cdf0e10cSrcweir { 1288cdf0e10cSrcweir try 1289cdf0e10cSrcweir { 1290cdf0e10cSrcweir sTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "share", "/wizard"); 1291cdf0e10cSrcweir sUserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user", PropertyNames.EMPTY_STRING); 1292cdf0e10cSrcweir sBitmapPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/../wizard/bitmap"); 1293cdf0e10cSrcweir } 1294cdf0e10cSrcweir catch (NoValidPathException e) 1295cdf0e10cSrcweir { 1296cdf0e10cSrcweir e.printStackTrace(); 1297cdf0e10cSrcweir } 1298cdf0e10cSrcweir } 1299cdf0e10cSrcweir initializeTemplates(XMultiServiceFactory xMSF)1300cdf0e10cSrcweir public boolean initializeTemplates(XMultiServiceFactory xMSF) 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir sCurrentNorm = Norms[getCurrentLetter().cp_Norm]; 1303cdf0e10cSrcweir //creation of the language independent path: 1304cdf0e10cSrcweir String sLetterPath = NormPaths[getCurrentLetter().cp_Norm]; 1305cdf0e10cSrcweir 1306cdf0e10cSrcweir // try 1307cdf0e10cSrcweir // { 1308cdf0e10cSrcweir BusinessFiles = FileAccess.getFolderTitles(xMSF, "bus", sLetterPath); 1309cdf0e10cSrcweir OfficialFiles = FileAccess.getFolderTitles(xMSF, "off", sLetterPath); 1310cdf0e10cSrcweir PrivateFiles = FileAccess.getFolderTitles(xMSF, "pri", sLetterPath); 1311cdf0e10cSrcweir 1312cdf0e10cSrcweir setControlProperty("lstBusinessStyle", PropertyNames.STRING_ITEM_LIST, BusinessFiles[0]); 1313cdf0e10cSrcweir setControlProperty("lstPrivOfficialStyle", PropertyNames.STRING_ITEM_LIST, OfficialFiles[0]); 1314cdf0e10cSrcweir setControlProperty("lstPrivateStyle", PropertyNames.STRING_ITEM_LIST, PrivateFiles[0]); 1315cdf0e10cSrcweir 1316cdf0e10cSrcweir setControlProperty("lstBusinessStyle", PropertyNames.SELECTED_ITEMS, new short[] 1317cdf0e10cSrcweir { 1318cdf0e10cSrcweir 0 1319cdf0e10cSrcweir }); 1320cdf0e10cSrcweir setControlProperty("lstPrivOfficialStyle", PropertyNames.SELECTED_ITEMS, new short[] 1321cdf0e10cSrcweir { 1322cdf0e10cSrcweir 0 1323cdf0e10cSrcweir }); 1324cdf0e10cSrcweir setControlProperty("lstPrivateStyle", PropertyNames.SELECTED_ITEMS, new short[] 1325cdf0e10cSrcweir { 1326cdf0e10cSrcweir 0 1327cdf0e10cSrcweir }); 1328cdf0e10cSrcweir // } 1329cdf0e10cSrcweir // catch (com.sun.star.wizards.common.NoValidPathException e) 1330cdf0e10cSrcweir // { 1331cdf0e10cSrcweir // return false; 1332cdf0e10cSrcweir // } 1333cdf0e10cSrcweir return true; 1334cdf0e10cSrcweir } 1335cdf0e10cSrcweir initializeElements()1336cdf0e10cSrcweir public void initializeElements() 1337cdf0e10cSrcweir { 1338cdf0e10cSrcweir setControlProperty("chkUseLogo", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(myLetterDoc.hasElement("Company Logo"))); 1339cdf0e10cSrcweir setControlProperty("chkUseBendMarks", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(myLetterDoc.hasElement("Bend Marks"))); 1340cdf0e10cSrcweir setControlProperty("chkUseAddressReceiver", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(myLetterDoc.hasElement("Sender Address Repeated"))); 1341cdf0e10cSrcweir setControlProperty("chkUseSubject", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(myLetterDoc.hasElement("Subject Line"))); 1342cdf0e10cSrcweir setControlProperty("chkUseSigns", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(myLetterDoc.hasElement("Letter Signs"))); 1343cdf0e10cSrcweir myLetterDoc.updateDateFields(); 1344cdf0e10cSrcweir } 1345cdf0e10cSrcweir setConfiguration()1346cdf0e10cSrcweir public void setConfiguration() 1347cdf0e10cSrcweir { 1348cdf0e10cSrcweir //set correct Configuration tree: 1349cdf0e10cSrcweir 1350cdf0e10cSrcweir if (optBusinessLetter.getState()) 1351cdf0e10cSrcweir { 1352cdf0e10cSrcweir optBusinessLetterItemChanged(); 1353cdf0e10cSrcweir } 1354cdf0e10cSrcweir if (optPrivOfficialLetter.getState()) 1355cdf0e10cSrcweir { 1356cdf0e10cSrcweir optPrivOfficialLetterItemChanged(); 1357cdf0e10cSrcweir } 1358cdf0e10cSrcweir if (optPrivateLetter.getState()) 1359cdf0e10cSrcweir { 1360cdf0e10cSrcweir optPrivateLetterItemChanged(); 1361cdf0e10cSrcweir } 1362cdf0e10cSrcweir } 1363cdf0e10cSrcweir setElements(boolean privLetter)1364cdf0e10cSrcweir public void setElements(boolean privLetter) 1365cdf0e10cSrcweir { 1366cdf0e10cSrcweir //UI relevant: 1367cdf0e10cSrcweir if (optSenderDefine.getState()) 1368cdf0e10cSrcweir { 1369cdf0e10cSrcweir optSenderDefineItemChanged(); 1370cdf0e10cSrcweir } 1371cdf0e10cSrcweir if (optSenderPlaceholder.getState()) 1372cdf0e10cSrcweir { 1373cdf0e10cSrcweir optSenderPlaceholderItemChanged(); 1374cdf0e10cSrcweir } 1375cdf0e10cSrcweir chkUseSignsItemChanged(); 1376cdf0e10cSrcweir chkUseSubjectItemChanged(); 1377cdf0e10cSrcweir chkUseSalutationItemChanged(); 1378cdf0e10cSrcweir chkUseGreetingItemChanged(); 1379cdf0e10cSrcweir chkUseBendMarksItemChanged(); 1380cdf0e10cSrcweir chkUseAddressReceiverItemChanged(); 1381cdf0e10cSrcweir txtTemplateNameTextChanged(); 1382cdf0e10cSrcweir 1383cdf0e10cSrcweir //not UI relevant: 1384cdf0e10cSrcweir if (optReceiverDatabase.getState() && !privLetter) 1385cdf0e10cSrcweir { 1386cdf0e10cSrcweir optReceiverDatabaseItemChanged(); 1387cdf0e10cSrcweir } 1388cdf0e10cSrcweir if (optReceiverPlaceholder.getState() && !privLetter) 1389cdf0e10cSrcweir { 1390cdf0e10cSrcweir optReceiverPlaceholderItemChanged(); 1391cdf0e10cSrcweir } 1392cdf0e10cSrcweir if (optCreateLetter.getState()) 1393cdf0e10cSrcweir { 1394cdf0e10cSrcweir optCreateLetterItemChanged(); 1395cdf0e10cSrcweir } 1396cdf0e10cSrcweir if (optMakeChanges.getState()) 1397cdf0e10cSrcweir { 1398cdf0e10cSrcweir optMakeChangesItemChanged(); 1399cdf0e10cSrcweir } 1400cdf0e10cSrcweir } 1401cdf0e10cSrcweir insertRoadmap()1402cdf0e10cSrcweir public void insertRoadmap() 1403cdf0e10cSrcweir { 1404cdf0e10cSrcweir addRoadmap(); 1405cdf0e10cSrcweir int i = 0; 1406cdf0e10cSrcweir i = insertRoadmapItem(0, true, resources.RoadmapLabels[RM_TYPESTYLE], RM_TYPESTYLE); 1407cdf0e10cSrcweir i = insertRoadmapItem(i, false, resources.RoadmapLabels[RM_BUSINESSPAPER], RM_BUSINESSPAPER); 1408cdf0e10cSrcweir i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_ELEMENTS], RM_ELEMENTS); 1409cdf0e10cSrcweir i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_SENDERRECEIVER], RM_SENDERRECEIVER); 1410cdf0e10cSrcweir i = insertRoadmapItem(i, false, resources.RoadmapLabels[RM_FOOTER], RM_FOOTER); 1411cdf0e10cSrcweir i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_FINALSETTINGS], RM_FINALSETTINGS); 1412cdf0e10cSrcweir setRoadmapInteractive(true); 1413cdf0e10cSrcweir setRoadmapComplete(true); 1414cdf0e10cSrcweir setCurrentRoadmapItemID((short) 1); 1415cdf0e10cSrcweir } 1416cdf0e10cSrcweir 1417cdf0e10cSrcweir private class myPathSelectionListener implements XPathSelectionListener 1418cdf0e10cSrcweir { 1419cdf0e10cSrcweir validatePath()1420cdf0e10cSrcweir public void validatePath() 1421cdf0e10cSrcweir { 1422cdf0e10cSrcweir if (myPathSelection.usedPathPicker) 1423cdf0e10cSrcweir { 1424cdf0e10cSrcweir filenameChanged = true; 1425cdf0e10cSrcweir } 1426cdf0e10cSrcweir myPathSelection.usedPathPicker = false; 1427cdf0e10cSrcweir } 1428cdf0e10cSrcweir } 1429cdf0e10cSrcweir insertPathSelectionControl()1430cdf0e10cSrcweir public void insertPathSelectionControl() 1431cdf0e10cSrcweir { 1432cdf0e10cSrcweir myPathSelection = new PathSelection(xMSF, this, PathSelection.TransferMode.SAVE, PathSelection.DialogTypes.FILE); 1433cdf0e10cSrcweir myPathSelection.insert(6, 97, 70, 205, (short) 45, resources.reslblTemplatePath_value, true, HelpIds.getHelpIdString(HID + 47), HelpIds.getHelpIdString(HID + 48)); 1434cdf0e10cSrcweir myPathSelection.sDefaultDirectory = sUserTemplatePath; 1435cdf0e10cSrcweir myPathSelection.sDefaultName = "myLetterTemplate.ott"; 1436cdf0e10cSrcweir myPathSelection.sDefaultFilter = "writer8_template"; 1437cdf0e10cSrcweir myPathSelection.addSelectionListener(new myPathSelectionListener()); 1438cdf0e10cSrcweir } 1439cdf0e10cSrcweir initConfiguration()1440cdf0e10cSrcweir public void initConfiguration() 1441cdf0e10cSrcweir { 1442cdf0e10cSrcweir try 1443cdf0e10cSrcweir { 1444cdf0e10cSrcweir myConfig = new CGLetterWizard(); 1445cdf0e10cSrcweir Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Letter", false); 1446cdf0e10cSrcweir myConfig.readConfiguration(root, "cp_"); 1447cdf0e10cSrcweir mainDA.add(RadioDataAware.attachRadioButtons(myConfig, "cp_LetterType", new Object[] 1448cdf0e10cSrcweir { 1449cdf0e10cSrcweir optBusinessLetter, optPrivOfficialLetter, optPrivateLetter 1450cdf0e10cSrcweir }, null, true)); 1451cdf0e10cSrcweir mainDA.add(UnoDataAware.attachListBox(myConfig.cp_BusinessLetter, "cp_Style", lstBusinessStyle, null, true)); 1452cdf0e10cSrcweir mainDA.add(UnoDataAware.attachListBox(myConfig.cp_PrivateOfficialLetter, "cp_Style", lstPrivOfficialStyle, null, true)); 1453cdf0e10cSrcweir mainDA.add(UnoDataAware.attachListBox(myConfig.cp_PrivateLetter, "cp_Style", lstPrivateStyle, null, true)); 1454cdf0e10cSrcweir mainDA.add(UnoDataAware.attachCheckBox(myConfig.cp_BusinessLetter, "cp_BusinessPaper", chkBusinessPaper, null, true)); 1455cdf0e10cSrcweir 1456cdf0e10cSrcweir CGLetter cgl = myConfig.cp_BusinessLetter; 1457cdf0e10cSrcweir 1458cdf0e10cSrcweir CGPaperElementLocation cgpl = myConfig.cp_BusinessLetter.cp_CompanyLogo; 1459cdf0e10cSrcweir CGPaperElementLocation cgpa = myConfig.cp_BusinessLetter.cp_CompanyAddress; 1460cdf0e10cSrcweir 1461cdf0e10cSrcweir businessDA.add(UnoDataAware.attachCheckBox(cgpl, "cp_Display", chkPaperCompanyLogo, null, true)); 1462cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgpl, "cp_Width", numLogoWidth, null, true)); 1463cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgpl, "cp_Height", numLogoHeight, null, true)); 1464cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgpl, "cp_X", numLogoX, null, true)); 1465cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgpl, "cp_Y", numLogoY, null, true)); 1466cdf0e10cSrcweir businessDA.add(UnoDataAware.attachCheckBox(cgpa, "cp_Display", chkPaperCompanyAddress, null, true)); 1467cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgpa, "cp_Width", numAddressWidth, null, true)); 1468cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgpa, "cp_Height", numAddressHeight, null, true)); 1469cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgpa, "cp_X", numAddressX, null, true)); 1470cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgpa, "cp_Y", numAddressY, null, true)); 1471cdf0e10cSrcweir 1472cdf0e10cSrcweir businessDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PaperCompanyAddressReceiverField", chkCompanyReceiver, null, true)); 1473cdf0e10cSrcweir businessDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PaperFooter", chkPaperFooter, null, true)); 1474cdf0e10cSrcweir businessDA.add(UnoDataAware.attachNumericControl(cgl, "cp_PaperFooterHeight", numFooterHeight, null, true)); 1475cdf0e10cSrcweir 1476cdf0e10cSrcweir letterDA.add(UnoDataAware.attachListBox(cgl, "cp_Norm", lstLetterNorm, null, true)); 1477cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintCompanyLogo", chkUseLogo, null, true)); 1478cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintCompanyAddressReceiverField", chkUseAddressReceiver, null, true)); 1479cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintLetterSigns", chkUseSigns, null, true)); 1480cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintSubjectLine", chkUseSubject, null, true)); 1481cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintSalutation", chkUseSalutation, null, true)); 1482cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintBendMarks", chkUseBendMarks, null, true)); 1483cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintGreeting", chkUseGreeting, null, true)); 1484cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintFooter", chkUseFooter, null, true)); 1485cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_Salutation", lstSalutation, null, true)); 1486cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_Greeting", lstGreeting, null, true)); 1487cdf0e10cSrcweir letterDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_SenderAddressType", new Object[] 1488cdf0e10cSrcweir { 1489cdf0e10cSrcweir optSenderDefine, optSenderPlaceholder 1490cdf0e10cSrcweir }, null, true)); 1491cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderCompanyName", txtSenderName, null, true)); 1492cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderStreet", txtSenderStreet, null, true)); 1493cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderPostCode", txtSenderPostCode, null, true)); 1494cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderState", txtSenderState, null, true)); 1495cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderCity", txtSenderCity, null, true)); 1496cdf0e10cSrcweir letterDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_ReceiverAddressType", new Object[] 1497cdf0e10cSrcweir { 1498cdf0e10cSrcweir optReceiverDatabase, optReceiverPlaceholder 1499cdf0e10cSrcweir }, null, true)); 1500cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_Footer", txtFooter, null, true)); 1501cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_FooterOnlySecondPage", chkFooterNextPages, null, true)); 1502cdf0e10cSrcweir letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_FooterPageNumbers", chkFooterPageNumbers, null, true)); 1503cdf0e10cSrcweir letterDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_CreationType", new Object[] 1504cdf0e10cSrcweir { 1505cdf0e10cSrcweir optCreateLetter, optMakeChanges 1506cdf0e10cSrcweir }, null, true)); 1507cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_TemplateName", txtTemplateName, null, true)); 1508cdf0e10cSrcweir letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_TemplatePath", myPathSelection.xSaveTextBox, null, true)); 1509cdf0e10cSrcweir 1510cdf0e10cSrcweir } 1511cdf0e10cSrcweir catch (Exception exception) 1512cdf0e10cSrcweir { 1513cdf0e10cSrcweir exception.printStackTrace(); 1514cdf0e10cSrcweir } 1515cdf0e10cSrcweir 1516cdf0e10cSrcweir } 1517cdf0e10cSrcweir updateUI()1518cdf0e10cSrcweir private void updateUI() 1519cdf0e10cSrcweir { 1520cdf0e10cSrcweir UnoDataAware.updateUI(mainDA); 1521cdf0e10cSrcweir UnoDataAware.updateUI(letterDA); 1522cdf0e10cSrcweir UnoDataAware.updateUI(businessDA); 1523cdf0e10cSrcweir } 1524cdf0e10cSrcweir saveConfiguration()1525cdf0e10cSrcweir public void saveConfiguration() 1526cdf0e10cSrcweir { 1527cdf0e10cSrcweir try 1528cdf0e10cSrcweir { 1529cdf0e10cSrcweir Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Letter", true); 1530cdf0e10cSrcweir myConfig.writeConfiguration(root, "cp_"); 1531cdf0e10cSrcweir Configuration.commit(root); 1532cdf0e10cSrcweir } 1533cdf0e10cSrcweir catch (Exception e) 1534cdf0e10cSrcweir { 1535cdf0e10cSrcweir e.printStackTrace(); 1536cdf0e10cSrcweir } 1537cdf0e10cSrcweir } 1538cdf0e10cSrcweir } 1539