FaxWizardDialogImpl.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. #
  2. # This file is part of the LibreOffice project.
  3. #
  4. # This Source Code Form is subject to the terms of the Mozilla Public
  5. # License, v. 2.0. If a copy of the MPL was not distributed with this
  6. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. #
  8. # This file incorporates work covered by the following license notice:
  9. #
  10. # Licensed to the Apache Software Foundation (ASF) under one or more
  11. # contributor license agreements. See the NOTICE file distributed
  12. # with this work for additional information regarding copyright
  13. # ownership. The ASF licenses this file to you under the Apache
  14. # License, Version 2.0 (the "License"); you may not use this file
  15. # except in compliance with the License. You may obtain a copy of
  16. # the License at http://www.apache.org/licenses/LICENSE-2.0 .
  17. #
  18. import traceback
  19. import os.path
  20. from .FaxWizardDialog import FaxWizardDialog, uno, HID
  21. from .CGFaxWizard import CGFaxWizard
  22. from .FaxDocument import FaxDocument
  23. from ..ui.PathSelection import PathSelection
  24. from ..ui.event.UnoDataAware import UnoDataAware
  25. from ..ui.event.RadioDataAware import RadioDataAware
  26. from ..ui.event.CommonListener import TerminateListenerProcAdapter
  27. from ..text.TextFieldHandler import TextFieldHandler
  28. from ..text.TextElement import TextElement
  29. from ..common.Configuration import Configuration
  30. from ..common.SystemDialog import SystemDialog
  31. from ..common.NoValidPathException import NoValidPathException
  32. from ..common.HelpIds import HelpIds
  33. from ..common.FileAccess import FileAccess
  34. from ..common.Desktop import Desktop
  35. from ..document.OfficeDocument import OfficeDocument
  36. from com.sun.star.awt.VclWindowPeerAttribute import YES_NO, DEF_NO
  37. from com.sun.star.util import CloseVetoException
  38. from com.sun.star.view.DocumentZoomType import OPTIMAL
  39. from com.sun.star.document.UpdateDocMode import FULL_UPDATE
  40. from com.sun.star.document.MacroExecMode import ALWAYS_EXECUTE
  41. class FaxWizardDialogImpl(FaxWizardDialog):
  42. def leaveStep(self, nOldStep, nNewStep):
  43. pass
  44. def enterStep(self, nOldStep, nNewStep):
  45. pass
  46. RM_SENDERRECEIVER = 3
  47. RM_FOOTER = 4
  48. def __init__(self, xmsf):
  49. super(FaxWizardDialogImpl, self).__init__(xmsf)
  50. self.lstBusinessStylePos = None
  51. self.lstPrivateStylePos = None
  52. self.bSaveSuccess = False
  53. self.filenameChanged = False
  54. def startWizard(self, xMSF):
  55. self.running = True
  56. try:
  57. #Number of steps on WizardDialog
  58. self.nMaxStep = 5
  59. #instantiate The Document Frame for the Preview
  60. self.terminateListener = TerminateListenerProcAdapter(self.queryTermination)
  61. self.myFaxDoc = FaxDocument(xMSF, self.terminateListener)
  62. #create the dialog:
  63. self.drawNaviBar()
  64. self.buildStep1()
  65. self.buildStep2()
  66. self.buildStep3()
  67. self.buildStep4()
  68. self.buildStep5()
  69. self.initializeSalutation()
  70. self.initializeGreeting()
  71. self.initializeCommunication()
  72. self.initializePaths()
  73. #special Control for setting the save Path:
  74. self.insertPathSelectionControl()
  75. self.initializeTemplates(xMSF)
  76. #load the last used settings
  77. #from the registry and apply listeners to the controls:
  78. self.initConfiguration()
  79. if self.myPathSelection.xSaveTextBox.Text.lower() == "":
  80. self.myPathSelection.initializePath()
  81. xContainerWindow = self.myFaxDoc.xFrame.ContainerWindow
  82. self.createWindowPeer(xContainerWindow)
  83. #add the Roadmap to the dialog:
  84. self.insertRoadmap()
  85. #load the last used document and apply last used settings:
  86. #TODO:
  87. self.setConfiguration()
  88. #If the configuration does not define
  89. #Greeting/Salutation/CommunicationType yet choose a default
  90. self.__setDefaultForGreetingAndSalutationAndCommunication()
  91. #disable functionality that is not supported by the template:
  92. self.initializeElements()
  93. #disable the document, so that the user cannot change anything:
  94. self.myFaxDoc.xFrame.ComponentWindow.Enable = False
  95. self.executeDialogFromComponent(self.myFaxDoc.xFrame)
  96. self.removeTerminateListener()
  97. self.closeDocument()
  98. self.running = False
  99. except Exception:
  100. self.removeTerminateListener()
  101. traceback.print_exc()
  102. self.running = False
  103. return
  104. def cancelWizard(self):
  105. self.xUnoDialog.endExecute()
  106. self.running = False
  107. def finishWizard(self):
  108. self.switchToStep(self.getCurrentStep(), self.nMaxStep)
  109. endWizard = True
  110. try:
  111. self.sPath = self.myPathSelection.getSelectedPath()
  112. if not self.sPath or not os.path.exists(self.sPath):
  113. self.myPathSelection.triggerPathPicker()
  114. self.sPath = self.myPathSelection.getSelectedPath()
  115. #first, if the filename was not changed, thus
  116. #it is coming from a saved session, check if the
  117. # file exists and warn the user.
  118. if not self.filenameChanged:
  119. answer = SystemDialog.showMessageBox(
  120. self.xMSF, "MessBox", YES_NO + DEF_NO,
  121. self.resources.resOverwriteWarning,
  122. self.xUnoDialog.Peer)
  123. if answer == 3:
  124. # user said: no, do not overwrite...
  125. endWizard = False
  126. return False
  127. self.myFaxDoc.setWizardTemplateDocInfo( \
  128. self.resources.resFaxWizardDialog_title,
  129. self.resources.resTemplateDescription)
  130. self.myFaxDoc.killEmptyUserFields()
  131. self.myFaxDoc.keepLogoFrame = bool(self.chkUseLogo.State)
  132. self.myFaxDoc.keepTypeFrame = \
  133. bool(self.chkUseCommunicationType.State)
  134. self.myFaxDoc.killEmptyFrames()
  135. self.bSaveSuccess = OfficeDocument.store(self.xMSF,
  136. self.myFaxDoc.xTextDocument, self.sPath, "writer8_template")
  137. if self.bSaveSuccess:
  138. self.saveConfiguration()
  139. xIH = self.xMSF.createInstance( \
  140. "com.sun.star.comp.uui.UUIInteractionHandler")
  141. loadValues = list(range(4))
  142. loadValues[0] = uno.createUnoStruct( \
  143. 'com.sun.star.beans.PropertyValue')
  144. loadValues[0].Name = "AsTemplate"
  145. loadValues[0].Value = True
  146. loadValues[1] = uno.createUnoStruct( \
  147. 'com.sun.star.beans.PropertyValue')
  148. loadValues[1].Name = "MacroExecutionMode"
  149. loadValues[1].Value = ALWAYS_EXECUTE
  150. loadValues[2] = uno.createUnoStruct( \
  151. 'com.sun.star.beans.PropertyValue')
  152. loadValues[2].Name = "UpdateDocMode"
  153. loadValues[2].Value = FULL_UPDATE
  154. loadValues[3] = uno.createUnoStruct( \
  155. 'com.sun.star.beans.PropertyValue')
  156. loadValues[3].Name = "InteractionHandler"
  157. loadValues[3].Value = xIH
  158. if self.bEditTemplate:
  159. loadValues[0].Value = False
  160. else:
  161. loadValues[0].Value = True
  162. oDoc = OfficeDocument.load(Desktop.getDesktop(self.xMSF),
  163. self.sPath, "_default", loadValues)
  164. oDoc.CurrentController.ViewSettings.ZoomType = OPTIMAL
  165. else:
  166. pass
  167. #TODO: Error Handling
  168. except Exception:
  169. traceback.print_exc()
  170. finally:
  171. if endWizard:
  172. self.xUnoDialog.endExecute()
  173. self.running = False
  174. return True
  175. def closeDocument(self):
  176. try:
  177. self.myFaxDoc.xFrame.close(False)
  178. except CloseVetoException:
  179. traceback.print_exc()
  180. def drawConstants(self):
  181. '''Localise the template'''
  182. constRangeList = self.myFaxDoc.searchFillInItems(1)
  183. for i in constRangeList:
  184. text = i.String.lower()
  185. aux = TextElement(i, self.resources.dictConstants[text])
  186. aux.write()
  187. def insertRoadmap(self):
  188. self.addRoadmap()
  189. self.insertRoadMapItems(
  190. self.resources.RoadmapLabels, [True, True, True, False, True])
  191. self.setRoadmapInteractive(True)
  192. self.setRoadmapComplete(True)
  193. self.setCurrentRoadmapItemID(1)
  194. def insertPathSelectionControl(self):
  195. self.myPathSelection = PathSelection(self.xMSF,
  196. self, PathSelection.TransferMode.SAVE,
  197. PathSelection.DialogTypes.FILE)
  198. self.myPathSelection.insert(
  199. 5, 97, 70, 205, 45, self.resources.reslblTemplatePath_value,
  200. True, HelpIds.getHelpIdString(HID + 34),
  201. HelpIds.getHelpIdString(HID + 35))
  202. self.myPathSelection.sDefaultDirectory = self.sUserTemplatePath
  203. self.myPathSelection.sDefaultName = "myFaxTemplate.ott"
  204. self.myPathSelection.sDefaultFilter = "writer8_template"
  205. self.myPathSelection.addSelectionListener(self)
  206. def initializeTemplates(self, xMSF):
  207. try:
  208. self.sFaxPath = self.sTemplatePath + "/wizard/fax"
  209. self.BusinessFiles = FileAccess.getFolderTitles(xMSF, "bus",
  210. self.sFaxPath, self.resources.dictBusinessTemplate)
  211. self.PrivateFiles = FileAccess.getFolderTitles(xMSF, "pri",
  212. self.sFaxPath, self.resources.dictPrivateTemplate)
  213. self.xDialogModel.lstBusinessStyle.StringItemList = \
  214. tuple(self.BusinessFiles[0])
  215. self.xDialogModel.lstPrivateStyle.StringItemList = \
  216. tuple(self.PrivateFiles[0])
  217. self.xDialogModel.lstBusinessStyle.SelectedItems = (0,)
  218. self.xDialogModel.lstPrivateStyle.SelectedItems = (0,)
  219. return True
  220. except NoValidPathException:
  221. traceback.print_exc()
  222. return False
  223. def initializeElements(self):
  224. self.xDialogModel.chkUseLogo.Enabled = \
  225. self.myFaxDoc.hasElement("Company Logo")
  226. self.xDialogModel.chkUseSubject.Enabled = \
  227. self.myFaxDoc.hasElement("Subject Line")
  228. self.xDialogModel.chkUseDate.Enabled = \
  229. self.myFaxDoc.hasElement("Date")
  230. self.myFaxDoc.updateDateFields()
  231. def initializeSalutation(self):
  232. #'Salutation' listbox
  233. self.xDialogModel.lstSalutation.StringItemList = \
  234. tuple(self.resources.SalutationLabels)
  235. def initializeGreeting(self):
  236. #'Complimentary Close' listbox
  237. self.xDialogModel.lstGreeting.StringItemList = \
  238. tuple(self.resources.GreetingLabels)
  239. def initializeCommunication(self):
  240. #'Type of message' listbox
  241. self.xDialogModel.lstCommunicationType.StringItemList = \
  242. tuple(self.resources.CommunicationLabels)
  243. def __setDefaultForGreetingAndSalutationAndCommunication(self):
  244. if not self.lstSalutation.Text:
  245. self.lstSalutation.setText(self.resources.SalutationLabels[0])
  246. if not self.lstGreeting.Text:
  247. self.lstGreeting.setText(self.resources.GreetingLabels[0])
  248. if not self.lstCommunicationType.Text:
  249. self.lstCommunicationType.setText( \
  250. self.resources.CommunicationLabels[0])
  251. def initConfiguration(self):
  252. try:
  253. self.myConfig = CGFaxWizard()
  254. root = Configuration.getConfigurationRoot(self.xMSF,
  255. "/org.openoffice.Office.Writer/Wizards/Fax", False)
  256. self.myConfig.readConfiguration(root, "cp_")
  257. RadioDataAware.attachRadioButtons(
  258. self.myConfig, "cp_FaxType",
  259. (self.optBusinessFax, self.optPrivateFax), True).updateUI()
  260. UnoDataAware.attachListBox(
  261. self.myConfig.cp_BusinessFax, "cp_Style",
  262. self.lstBusinessStyle, True).updateUI()
  263. UnoDataAware.attachListBox(
  264. self.myConfig.cp_PrivateFax, "cp_Style", self.lstPrivateStyle,
  265. True).updateUI()
  266. cgl = self.myConfig.cp_BusinessFax
  267. UnoDataAware.attachCheckBox(cgl,
  268. "cp_PrintCompanyLogo", self.chkUseLogo, True).updateUI()
  269. UnoDataAware.attachCheckBox(cgl,
  270. "cp_PrintSubjectLine", self.chkUseSubject, True).updateUI()
  271. UnoDataAware.attachCheckBox(cgl,
  272. "cp_PrintSalutation", self.chkUseSalutation, True).updateUI()
  273. UnoDataAware.attachCheckBox(cgl,
  274. "cp_PrintDate", self.chkUseDate, True).updateUI()
  275. UnoDataAware.attachCheckBox(cgl, "cp_PrintCommunicationType",
  276. self.chkUseCommunicationType, True).updateUI()
  277. UnoDataAware.attachCheckBox(cgl,
  278. "cp_PrintGreeting", self.chkUseGreeting, True).updateUI()
  279. UnoDataAware.attachCheckBox(cgl,
  280. "cp_PrintFooter", self.chkUseFooter, True).updateUI()
  281. UnoDataAware.attachEditControl(cgl,
  282. "cp_Salutation", self.lstSalutation, True).updateUI()
  283. UnoDataAware.attachEditControl(cgl,
  284. "cp_Greeting", self.lstGreeting, True).updateUI()
  285. UnoDataAware.attachEditControl(cgl, "cp_CommunicationType",
  286. self.lstCommunicationType, True).updateUI()
  287. RadioDataAware.attachRadioButtons(cgl, "cp_SenderAddressType",
  288. (self.optSenderDefine, self.optSenderPlaceholder),
  289. True).updateUI()
  290. UnoDataAware.attachEditControl(cgl, "cp_SenderCompanyName",
  291. self.txtSenderName, True).updateUI()
  292. UnoDataAware.attachEditControl(cgl, "cp_SenderStreet",
  293. self.txtSenderStreet, True).updateUI()
  294. UnoDataAware.attachEditControl(cgl, "cp_SenderPostCode",
  295. self.txtSenderPostCode, True).updateUI()
  296. UnoDataAware.attachEditControl(cgl, "cp_SenderState",
  297. self.txtSenderState, True).updateUI()
  298. UnoDataAware.attachEditControl(cgl, "cp_SenderCity",
  299. self.txtSenderCity, True).updateUI()
  300. UnoDataAware.attachEditControl(cgl, "cp_SenderFax",
  301. self.txtSenderFax, True).updateUI()
  302. RadioDataAware.attachRadioButtons(cgl, "cp_ReceiverAddressType",
  303. (self.optReceiverDatabase, self.optReceiverPlaceholder),
  304. True).updateUI()
  305. UnoDataAware.attachEditControl(cgl, "cp_Footer",
  306. self.txtFooter, True).updateUI()
  307. UnoDataAware.attachCheckBox(cgl, "cp_FooterOnlySecondPage",
  308. self.chkFooterNextPages, True).updateUI()
  309. UnoDataAware.attachCheckBox(cgl, "cp_FooterPageNumbers",
  310. self.chkFooterPageNumbers, True).updateUI()
  311. RadioDataAware.attachRadioButtons(cgl, "cp_CreationType",
  312. (self.optCreateFax, self.optMakeChanges), True).updateUI()
  313. UnoDataAware.attachEditControl(cgl,
  314. "cp_TemplateName", self.txtTemplateName, True).updateUI()
  315. UnoDataAware.attachEditControl(cgl, "cp_TemplatePath",
  316. self.myPathSelection.xSaveTextBox, True).updateUI()
  317. except Exception:
  318. traceback.print_exc()
  319. def saveConfiguration(self):
  320. try:
  321. root = Configuration.getConfigurationRoot(self.xMSF,
  322. "/org.openoffice.Office.Writer/Wizards/Fax", True)
  323. self.myConfig.writeConfiguration(root, "cp_")
  324. root.commitChanges()
  325. except Exception:
  326. traceback.print_exc()
  327. def setConfiguration(self):
  328. #set correct Configuration tree:
  329. if self.optBusinessFax.State:
  330. self.optBusinessFaxItemChanged()
  331. elif self.optPrivateFax.State:
  332. self.optPrivateFaxItemChanged()
  333. def optBusinessFaxItemChanged(self):
  334. self.lstPrivateStylePos = None
  335. self.xDialogModel.lblBusinessStyle.Enabled = True
  336. self.xDialogModel.lstBusinessStyle.Enabled = True
  337. self.xDialogModel.lblPrivateStyle.Enabled = False
  338. self.xDialogModel.lstPrivateStyle.Enabled = False
  339. self.lstBusinessStyleItemChanged()
  340. self.__enableSenderReceiver()
  341. self.__setPossibleFooter(True)
  342. def lstBusinessStyleItemChanged(self):
  343. selectedItemPos = self.lstBusinessStyle.SelectedItemPos
  344. #avoid to load the same item again
  345. if self.lstBusinessStylePos != selectedItemPos:
  346. self.lstBusinessStylePos = selectedItemPos
  347. self.myFaxDoc.loadAsPreview(
  348. self.BusinessFiles[1][selectedItemPos], False)
  349. self.initializeElements()
  350. self.setElements()
  351. self.drawConstants()
  352. def optPrivateFaxItemChanged(self):
  353. self.lstBusinessStylePos = None
  354. self.xDialogModel.lblBusinessStyle.Enabled = False
  355. self.xDialogModel.lstBusinessStyle.Enabled = False
  356. self.xDialogModel.lblPrivateStyle.Enabled = True
  357. self.xDialogModel.lstPrivateStyle.Enabled = True
  358. self.lstPrivateStyleItemChanged()
  359. self.__disableSenderReceiver()
  360. self.__setPossibleFooter(False)
  361. def lstPrivateStyleItemChanged(self):
  362. selectedItemPos = self.lstPrivateStyle.SelectedItemPos
  363. #avoid to load the same item again
  364. if self.lstPrivateStylePos != selectedItemPos:
  365. self.lstPrivateStylePos = selectedItemPos
  366. self.myFaxDoc.loadAsPreview(
  367. self.PrivateFiles[1][selectedItemPos], False)
  368. self.initializeElements()
  369. self.setElements()
  370. def txtTemplateNameTextChanged(self):
  371. # Change Template Title in Properties
  372. xDocProps = self.myFaxDoc.xTextDocument.DocumentProperties
  373. xDocProps.Title = self.txtTemplateName.Text
  374. def optSenderPlaceholderItemChanged(self):
  375. self.xDialogModel.lblSenderName.Enabled = False
  376. self.xDialogModel.lblSenderStreet.Enabled = False
  377. self.xDialogModel.lblPostCodeCity.Enabled = False
  378. self.xDialogModel.lblSenderFax.Enabled = False
  379. self.xDialogModel.txtSenderName.Enabled = False
  380. self.xDialogModel.txtSenderStreet.Enabled = False
  381. self.xDialogModel.txtSenderPostCode.Enabled = False
  382. self.xDialogModel.txtSenderState.Enabled = False
  383. self.xDialogModel.txtSenderCity.Enabled = False
  384. self.xDialogModel.txtSenderFax.Enabled = False
  385. self.myFaxDoc.fillSenderWithUserData()
  386. def optSenderDefineItemChanged(self):
  387. self.xDialogModel.lblSenderName.Enabled = True
  388. self.xDialogModel.lblSenderStreet.Enabled = True
  389. self.xDialogModel.lblPostCodeCity.Enabled = True
  390. self.xDialogModel.lblSenderFax.Enabled = True
  391. self.xDialogModel.txtSenderName.Enabled = True
  392. self.xDialogModel.txtSenderStreet.Enabled = True
  393. self.xDialogModel.txtSenderPostCode.Enabled = True
  394. self.xDialogModel.txtSenderState.Enabled = True
  395. self.xDialogModel.txtSenderCity.Enabled = True
  396. self.xDialogModel.txtSenderFax.Enabled = True
  397. self.myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF,
  398. self.myFaxDoc.xTextDocument)
  399. self.txtSenderNameTextChanged()
  400. self.txtSenderStreetTextChanged()
  401. self.txtSenderPostCodeTextChanged()
  402. self.txtSenderStateTextChanged()
  403. self.txtSenderCityTextChanged()
  404. self.txtSenderFaxTextChanged()
  405. def txtSenderNameTextChanged(self):
  406. self.myFieldHandler.changeUserFieldContent(
  407. "Company", self.txtSenderName.Text)
  408. def txtSenderStreetTextChanged(self):
  409. self.myFieldHandler.changeUserFieldContent(
  410. "Street", self.txtSenderStreet.Text)
  411. def txtSenderCityTextChanged(self):
  412. self.myFieldHandler.changeUserFieldContent(
  413. "City", self.txtSenderCity.Text)
  414. def txtSenderPostCodeTextChanged(self):
  415. self.myFieldHandler.changeUserFieldContent(
  416. "PostCode", self.txtSenderPostCode.Text)
  417. def txtSenderStateTextChanged(self):
  418. self.myFieldHandler.changeUserFieldContent(
  419. "State", self.txtSenderState.Text)
  420. def txtSenderFaxTextChanged(self):
  421. self.myFieldHandler.changeUserFieldContent(
  422. "Fax", self.txtSenderFax.Text)
  423. #switch Elements on/off --------------------------------------------------
  424. def setElements(self):
  425. #UI relevant:
  426. if self.optSenderDefine.State:
  427. self.optSenderDefineItemChanged()
  428. if self.optSenderPlaceholder.State:
  429. self.optSenderPlaceholderItemChanged()
  430. self.chkUseLogoItemChanged()
  431. self.chkUseSubjectItemChanged()
  432. self.chkUseSalutationItemChanged()
  433. self.chkUseGreetingItemChanged()
  434. self.chkUseCommunicationItemChanged()
  435. self.chkUseDateItemChanged()
  436. self.chkUseFooterItemChanged()
  437. self.txtTemplateNameTextChanged()
  438. #not UI relevant:
  439. if self.optReceiverDatabase.State:
  440. self.optReceiverDatabaseItemChanged()
  441. elif self.optReceiverPlaceholder.State:
  442. self.optReceiverPlaceholderItemChanged()
  443. if self.optCreateFax.State:
  444. self.optCreateFromTemplateItemChanged()
  445. elif self.optMakeChanges.State:
  446. self.optMakeChangesItemChanged()
  447. def chkUseLogoItemChanged(self):
  448. if self.myFaxDoc.hasElement("Company Logo"):
  449. self.myFaxDoc.switchElement("Company Logo",
  450. bool(self.chkUseLogo.State))
  451. def chkUseSubjectItemChanged(self):
  452. if self.myFaxDoc.hasElement("Subject Line"):
  453. self.myFaxDoc.switchElement("Subject Line",
  454. bool(self.chkUseSubject.State))
  455. def chkUseDateItemChanged(self):
  456. if self.myFaxDoc.hasElement("Date"):
  457. self.myFaxDoc.switchElement("Date",
  458. bool(self.chkUseDate.State))
  459. def chkUseFooterItemChanged(self):
  460. try:
  461. bFooterPossible = bool(self.chkUseFooter.State) \
  462. and bool(self.xDialogModel.chkUseFooter.Enabled)
  463. if bool(self.chkFooterNextPages.State):
  464. self.myFaxDoc.switchFooter("First Page", False,
  465. bool(self.chkFooterPageNumbers.State),
  466. self.txtFooter.Text)
  467. self.myFaxDoc.switchFooter("Standard", bFooterPossible,
  468. bool(self.chkFooterPageNumbers.State),
  469. self.txtFooter.Text)
  470. else:
  471. self.myFaxDoc.switchFooter("First Page", bFooterPossible,
  472. bool(self.chkFooterPageNumbers.State),
  473. self.txtFooter.Text)
  474. self.myFaxDoc.switchFooter("Standard", bFooterPossible,
  475. bool(self.chkFooterPageNumbers.State),
  476. self.txtFooter.Text)
  477. #enable/disable roadmap item for footer page
  478. BPaperItem = self.getRoadmapItemByID( \
  479. FaxWizardDialogImpl.RM_FOOTER)
  480. BPaperItem.Enabled = bFooterPossible
  481. except Exception:
  482. traceback.print_exc()
  483. def chkFooterNextPagesItemChanged(self):
  484. self.chkUseFooterItemChanged()
  485. def chkFooterPageNumbersItemChanged(self):
  486. self.chkUseFooterItemChanged()
  487. def txtFooterTextChanged(self):
  488. self.myFaxDoc.switchFooter("First Page", True,
  489. bool(self.chkFooterPageNumbers.State),
  490. self.txtFooter.Text)
  491. def chkUseSalutationItemChanged(self):
  492. self.myFaxDoc.switchUserField("Salutation",
  493. self.lstSalutation.Text, bool(self.chkUseSalutation.State))
  494. self.xDialogModel.lstSalutation.Enabled = \
  495. bool(self.chkUseSalutation.State)
  496. def lstSalutationItemChanged(self):
  497. self.myFaxDoc.switchUserField("Salutation",
  498. self.lstSalutation.Text, bool(self.chkUseSalutation.State))
  499. def chkUseCommunicationItemChanged(self):
  500. self.myFaxDoc.switchUserField("CommunicationType",
  501. self.lstCommunicationType.Text,
  502. bool(self.chkUseCommunicationType.State))
  503. self.xDialogModel.lstCommunicationType.Enabled = \
  504. bool(self.chkUseCommunicationType.State)
  505. def lstCommunicationItemChanged(self):
  506. self.myFaxDoc.switchUserField("CommunicationType",
  507. self.lstCommunicationType.Text,
  508. bool(self.chkUseCommunicationType.State))
  509. def chkUseGreetingItemChanged(self):
  510. self.myFaxDoc.switchUserField("Greeting",
  511. self.lstGreeting.Text, bool(self.chkUseGreeting.State))
  512. self.xDialogModel.lstGreeting.Enabled = \
  513. bool(self.chkUseGreeting.State)
  514. def lstGreetingItemChanged(self):
  515. self.myFaxDoc.switchUserField("Greeting", self.lstGreeting.Text,
  516. bool(self.chkUseGreeting.State))
  517. def __setPossibleFooter(self, bState):
  518. self.xDialogModel.chkUseFooter.Enabled = bState
  519. if not bState:
  520. self.chkUseFooter.State = 0
  521. self.chkUseFooterItemChanged()
  522. def optReceiverPlaceholderItemChanged(self):
  523. OfficeDocument.attachEventCall(
  524. self.myFaxDoc.xTextDocument, "OnNew", "StarBasic",
  525. "macro:///Template.Correspondence.Placeholder()")
  526. def optReceiverDatabaseItemChanged(self):
  527. OfficeDocument.attachEventCall(
  528. self.myFaxDoc.xTextDocument, "OnNew", "StarBasic",
  529. "macro:///Template.Correspondence.Database()")
  530. def __enableSenderReceiver(self):
  531. BPaperItem = self.getRoadmapItemByID( \
  532. FaxWizardDialogImpl.RM_SENDERRECEIVER)
  533. BPaperItem.Enabled = True
  534. def __disableSenderReceiver(self):
  535. BPaperItem = self.getRoadmapItemByID( \
  536. FaxWizardDialogImpl.RM_SENDERRECEIVER)
  537. BPaperItem.Enabled = False
  538. def validatePath(self):
  539. if self.myPathSelection.usedPathPicker:
  540. self.filenameChanged = True
  541. self.myPathSelection.usedPathPicker = False