This commit is contained in:
Jane
2024-07-16 15:58:23 +08:00
parent 29bc31ade5
commit 0bbdcd9ef7
1621 changed files with 300787 additions and 0 deletions

View File

@@ -0,0 +1,924 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
import traceback
from ..text.TextElement import TextElement
from ..text.TextDocument import TextDocument
from ..text.TextSectionHandler import TextSectionHandler
from ..common.FileAccess import FileAccess
from datetime import datetime
from com.sun.star.text.PlaceholderType import TEXT
from com.sun.star.i18n.NumberFormatIndex import TIME_HHMM, DATE_SYSTEM_LONG
'''
The classes here implement the whole document-functionality of the agenda wizard:
the live-preview and the final "creation" of the document,
when the user clicks "finish". <br/>
<br/>
<h2>Some terminology:<h2/>
items are names or headings. we don't make any distinction.
<br/>
The Agenda Template is used as general "controller"
of the whole document, whereas the two child-classes ItemsTable
and TopicsTable control the item tables (note plural!) and the
topics table (note singular).<br/>
<br/>
Other small classes are used to abstract the handling of cells and text and we
try to use them as components.
<br/><br/>
We tried to keep the Agenda Template as flexible as possible, though there
must be many limitations, because it is generated dynamically.<br/><br/>
To keep the template flexible the following decisions were made:<br/>
1. Item tables.<br/>
1.a. there might be arbitrary number of Item tables.<br/>
1.b. Item tables design (bordewr, background) is arbitrary.<br/>
1.c. Items text styles are individual,
and use stylelist styles with predefined names.<br/>
As result the following limitations:<br/>
Pairs of Name->value for each item.<br/>
Tables contain *only* those pairs.<br/>
2. Topics table.<br/>
2.a. arbitrary structure.<br/>
2.b. design is arbitrary.<br/>
As result the following limitations:<br/>
No column merge is allowed.<br/>
One compulsory Heading row.<br/>
<br/><br/>
To let the template be flexible, we use a kind of "detection": we look where
the items are read the design of each table, re-applying it after writing the
table.self.xTextDocument
<br/><br/>
A note about threads:<br/>
Many methods here are synchronized, in order to avoid collision made by
events fired too often.
'''
class AgendaDocument(TextDocument):
'''
constructor. The document is *not* loaded here.
only some formal members are set.
'''
def __init__(self, xmsf, agenda, resources, templateConsts, listener):
super(AgendaDocument,self).__init__(xmsf,listener, None,
"WIZARD_LIVE_PREVIEW")
self.agenda = agenda
self.templateConsts = templateConsts
self.resources = resources
self.itemsMap = {}
self.allItems = []
def load(self, templateURL):
# Each template is duplicated. aw-XXX.ott is the template itself
# and XXX.ott is a section link.
self.template = self.calcTemplateName(templateURL)
self.loadAsPreview(templateURL, False)
self.xFrame.ComponentWindow.Enable = False
self.xTextDocument.lockControllers()
self.initialize()
self.initializeData()
self.xTextDocument.unlockControllers()
'''
The agenda templates are in format of aw-XXX.ott
the templates name is then XXX.ott.
This method calculates it.
'''
def calcTemplateName(self, url):
return FileAccess.connectURLs(
FileAccess.getParentDir(url), FileAccess.getFilename(url)[3:])
'''synchronize the document to the model.<br/>
this method rewrites all titles, item tables , and the topics table-
thus synchronizing the document to the data model (CGAgenda).
information (it is only actualized on save) the given list
supplies this information.
'''
def initializeData(self):
for i in self.itemsTables:
try:
i.write()
except Exception:
traceback.print_exc()
self.redrawTitle("txtTitle")
self.redrawTitle("txtDate")
self.redrawTitle("txtTime")
self.redrawTitle("cbLocation")
'''
redraws/rewrites the table which contains the given item
This method is called when the user checks/unchecks an item.
The table is being found, in which the item is, and redrawn.
'''
def redraw(self, itemName):
self.xTextDocument.lockControllers()
try:
# get the table in which the item is...
itemsTable = self.itemsMap[itemName]
# rewrite the table.
itemsTable.write()
except Exception:
traceback.print_exc()
self.xTextDocument.unlockControllers()
'''
checks the data model if the
item corresponding to the given string should be shown
'''
def isShowItem(self, itemName):
if itemName == self.templateConsts.FILLIN_MEETING_TYPE:
return self.agenda.cp_ShowMeetingType
elif itemName == self.templateConsts.FILLIN_READ:
return self.agenda.cp_ShowRead
elif itemName == self.templateConsts.FILLIN_BRING:
return self.agenda.cp_ShowBring
elif itemName == self.templateConsts.FILLIN_NOTES:
return self.agenda.cp_ShowNotes
elif itemName == self.templateConsts.FILLIN_FACILITATOR:
return self.agenda.cp_ShowFacilitator
elif itemName == self.templateConsts.FILLIN_TIMEKEEPER:
return self.agenda.cp_ShowTimekeeper
elif itemName == self.templateConsts.FILLIN_NOTETAKER:
return self.agenda.cp_ShowNotetaker
elif itemName == self.templateConsts.FILLIN_PARTICIPANTS:
return self.agenda.cp_ShowAttendees
elif itemName == self.templateConsts.FILLIN_CALLED_BY:
return self.agenda.cp_ShowCalledBy
elif itemName == self.templateConsts.FILLIN_OBSERVERS:
return self.agenda.cp_ShowObservers
elif itemName == self.templateConsts.FILLIN_RESOURCE_PERSONS:
return self.agenda.cp_ShowResourcePersons
else:
raise ValueError("No such item")
'''itemsCache is a Map containing all agenda item. These are object which
"write themselves" to the table, given a table cursor.
A cache is used in order to reuse the objects, instead of recreate them.
This method fills the cache will all items objects (names and headings).
'''
def initItemsCache(self):
self.itemsCache = {}
# Headings
self.itemsCache[
self.templateConsts.FILLIN_MEETING_TYPE] = \
AgendaItem(self.templateConsts.FILLIN_MEETING_TYPE,
self.resources.itemMeetingType,
PlaceholderElement(
self.resources.reschkMeetingTitle_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_BRING] = \
AgendaItem(self.templateConsts.FILLIN_BRING,
self.resources.itemBring,
PlaceholderElement (
self.resources.reschkBring_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_READ] = \
AgendaItem (self.templateConsts.FILLIN_READ,
self.resources.itemRead,
PlaceholderElement (
self.resources.reschkRead_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_NOTES] = \
AgendaItem (self.templateConsts.FILLIN_NOTES,
self.resources.itemNote,
PlaceholderElement (
self.resources.reschkNotes_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
# Names
self.itemsCache[
self.templateConsts.FILLIN_CALLED_BY] = \
AgendaItem(self.templateConsts.FILLIN_CALLED_BY,
self.resources.itemCalledBy,
PlaceholderElement (
self.resources.reschkConvenedBy_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_FACILITATOR] = \
AgendaItem(self.templateConsts.FILLIN_FACILITATOR,
self.resources.itemFacilitator,
PlaceholderElement (
self.resources.reschkPresiding_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_PARTICIPANTS] = \
AgendaItem(self.templateConsts.FILLIN_PARTICIPANTS,
self.resources.itemAttendees,
PlaceholderElement(
self.resources.reschkAttendees_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_NOTETAKER] = \
AgendaItem(self.templateConsts.FILLIN_NOTETAKER,
self.resources.itemNotetaker,
PlaceholderElement(
self.resources.reschkNoteTaker_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_TIMEKEEPER] = \
AgendaItem(self.templateConsts.FILLIN_TIMEKEEPER,
self.resources.itemTimekeeper,
PlaceholderElement(
self.resources.reschkTimekeeper_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_OBSERVERS] = \
AgendaItem(self.templateConsts.FILLIN_OBSERVERS,
self.resources.itemObservers,
PlaceholderElement(
self.resources.reschkObservers_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
self.itemsCache[
self.templateConsts.FILLIN_RESOURCE_PERSONS] = \
AgendaItem(self.templateConsts.FILLIN_RESOURCE_PERSONS,
self.resources.itemResource,
PlaceholderElement(
self.resources.reschkResourcePersons_value,
self.resources.resPlaceHolderHint, self.xTextDocument))
'''Initializes a template.<br/>
This method does the following tasks:<br/>
get a Time and Date format for the document, and retrieve the null
date of the document (which is document-specific).<br/>
Initializes the Items Cache map.
Analyses the document:<br/>
-find all "filled-ins" (appear as &gt;xxx&lt; in the document).
-analyze all items sections (and the tables in them).
-locate the titles and actualize them
-analyze the topics table
'''
def initialize(self):
'''
Get the default locale of the document,
and create the date and time formatters.
'''
self.dateUtils = self.DateUtils(self.xMSF, self.xTextDocument)
self.formatter = self.dateUtils.formatter
self.dateFormat = self.dateUtils.getFormat(DATE_SYSTEM_LONG)
self.timeFormat = self.dateUtils.getFormat(TIME_HHMM)
self.initItemsCache()
self.allItems = self.searchFillInItems(0)
self.initializeTitles()
self.initializeItemsSections()
self.textSectionHandler = TextSectionHandler(
self.xTextDocument, self.xTextDocument)
self.topics = Topics(self)
'''
locates the titles (name, location, date, time)
and saves a reference to their Text ranges.
'''
def initializeTitles(self):
auxList = []
for i in self.allItems:
text = i.String.lstrip().lower()
if text == self.templateConsts.FILLIN_TITLE:
self.teTitle = PlaceholderTextElement(
i, self.resources.resPlaceHolderTitle,
self.resources.resPlaceHolderHint, self.xTextDocument)
self.trTitle = i
elif text == self.templateConsts.FILLIN_DATE:
self.teDate = PlaceholderTextElement(
i, self.resources.resPlaceHolderDate,
self.resources.resPlaceHolderHint, self.xTextDocument)
self.trDate = i
elif text == self.templateConsts.FILLIN_TIME:
self.teTime = PlaceholderTextElement(
i, self.resources.resPlaceHolderTime,
self.resources.resPlaceHolderHint, self.xTextDocument)
self.trTime = i
elif text == self.templateConsts.FILLIN_LOCATION:
self.teLocation = PlaceholderTextElement(
i, self.resources.resPlaceHolderLocation,
self.resources.resPlaceHolderHint, self.xTextDocument)
self.trLocation = i
else:
auxList.append(i)
self.allItems = auxList
'''
analyze the item sections in the template.
delegates the analyze of each table to the ItemsTable class.
'''
def initializeItemsSections(self):
sections = self.getSections(
self.xTextDocument, self.templateConsts.SECTION_ITEMS)
# for each section - there is a table...
self.itemsTables = []
for i in sections:
try:
self.itemsTables.append(
ItemsTable(self.getSection(i), self.getTable(i), self))
except Exception:
traceback.print_exc()
raise AttributeError (
"Fatal Error while initializing \
Template: items table in section " + i)
def getSections(self, document, s):
allSections = document.TextSections.ElementNames
return self.getNamesWhichStartWith(allSections, s)
def getSection(self, name):
return self.xTextDocument.TextSections.getByName(name)
def getTable(self, name):
return self.xTextDocument.TextTables.getByName(name)
def redrawTitle(self, controlName):
try:
if controlName == "txtTitle":
self.teTitle.placeHolderText = self.agenda.cp_Title
self.teTitle.write(self.trTitle)
elif controlName == "txtDate":
self.teDate.placeHolderText = \
self.getDateString(self.agenda.cp_Date)
self.teDate.write(self.trDate)
elif controlName == "txtTime":
self.teTime.placeHolderText = self.agenda.cp_Time
self.teTime.write(self.trTime)
elif controlName == "cbLocation":
self.teLocation.placeHolderText = self.agenda.cp_Location
self.teLocation.write(self.trLocation)
else:
raise Exception("No such title control...")
except Exception:
traceback.print_exc()
def getDateString(self, date):
if not date:
return ""
dateObject = datetime.strptime(date, '%d/%m/%y').date()
return self.dateUtils.format(self.dateFormat, dateObject)
def finish(self, topics):
self.createMinutes(topics)
self.deleteHiddenSections()
self.textSectionHandler.removeAllTextSections()
'''
hidden sections exist when an item's section is hidden because the
user specified not to display any items which it contains.
When finishing the wizard removes this sections
entirely from the document.
'''
def deleteHiddenSections(self):
allSections = self.xTextDocument.TextSections.ElementNames
try:
for i in allSections:
self.section = self.getSection(i)
visible = bool(self.section.IsVisible)
if not visible:
self.section.Anchor.String = ""
except Exception:
traceback.print_exc()
'''
create the minutes for the given topics or remove the minutes
section from the document.
If no topics are supplied, or the user specified not to create minutes,
the minutes section will be removed,
@param topicsData supplies PropertyValue arrays containing
the values for the topics.
'''
def createMinutes(self, topicsData):
# if the minutes section should be removed (the
# user did not check "create minutes")
if not self.agenda.cp_IncludeMinutes \
or len(topicsData) <= 1:
try:
minutesAllSection = self.getSection(
self.templateConsts.SECTION_MINUTES_ALL)
minutesAllSection.Anchor.String = ""
except Exception:
traceback.print_exc()
# the user checked "create minutes"
else:
try:
topicStartTime = int(self.agenda.cp_Time)
# first I replace the minutes titles...
self.items = self.searchFillInItems()
itemIndex = 0
for item in self.items:
itemText = item.String.lstrip().lower()
if itemText == \
self.templateConsts.FILLIN_MINUTES_TITLE:
self.fillMinutesItem(
item, self.agenda.cp_Title,
self.resources.resPlaceHolderTitle)
elif itemText == \
self.templateConsts.FILLIN_MINUTES_LOCATION:
self.fillMinutesItem(
item, self.agenda.cp_Location,
self.resources.resPlaceHolderLocation)
elif itemText == \
self.templateConsts.FILLIN_MINUTES_DATE:
self.fillMinutesItem(
item, getDateString(self.agenda.cp_Date),
self.resources.resPlaceHolderDate)
elif itemText == \
self.templateConsts.FILLIN_MINUTES_TIME:
self.fillMinutesItem( item, self.agenda.cp_Time,
self.resources.resPlaceHolderTime)
self.items.clear()
'''
now add minutes for each topic.
The template contains *one* minutes section, so
we first use the one available, and then add a one...
topics data has *always* an empty topic at the end...
'''
for i in xrange(len(topicsData) - 1):
topic = topicsData[i]
items = self.searchFillInItems()
itemIndex = 0
for item in items:
itemText = item.String.lstrip().lower()
if itemText == \
self.templateConsts.FILLIN_MINUTE_NUM:
self.fillMinutesItem(item, topic[0].Value, "")
elif itemText == \
self.templateConsts.FILLIN_MINUTE_TOPIC:
self.fillMinutesItem(item, topic[1].Value, "")
elif itemText == \
self.templateConsts.FILLIN_MINUTE_RESPONSIBLE:
self.fillMinutesItem(item, topic[2].Value, "")
elif itemText == \
self.templateConsts.FILLIN_MINUTE_TIME:
topicTime = 0
try:
topicTime = topic[3].Value
except Exception:
pass
'''
if the topic has no time, we do not
display any time here.
'''
if topicTime == 0 or topicStartTime == 0:
time = topic[3].Value
else:
time = str(topicStartTime) + " - "
topicStartTime += topicTime * 1000
time += str(topicStartTime)
self.fillMinutesItem(item, time, "")
self.textSectionHandler.removeTextSectionbyName(
self.templateConsts.SECTION_MINUTES)
# after the last section we do not insert a one.
if i < len(topicsData) - 2:
self.textSectionHandler.insertTextSection(
self.templateConsts.SECTION_MINUTES,
self.template, False)
except Exception:
traceback.print_exc()
'''given a text range and a text, fills the given
text range with the given text.
If the given text is empty, uses a placeholder with the given
placeholder text.
@param range text range to fill
@param text the text to fill to the text range object.
@param placeholder the placeholder text to use, if the
text argument is empty (null or "")
'''
def fillMinutesItem(self, Range, text, placeholder):
paraStyle = Range.ParaStyleName
Range.setString(text)
Range.ParaStyleName = paraStyle
if text is None or text == "":
if placeholder is not None and not placeholder == "":
placeHolder = self.createPlaceHolder(
self.xTextDocument, placeholder,
self.resources.resPlaceHolderHint)
try:
Range.Start.Text.insertTextContent(
Range.Start, placeHolder, True)
except Exception:
traceback.print_exc()
'''
creates a placeholder field with the given text and given hint.
'''
@classmethod
def createPlaceHolder(self, xmsf, ph, hint):
try:
placeHolder = xmsf.createInstance(
"com.sun.star.text.TextField.JumpEdit")
except Exception:
traceback.print_exc()
return None
placeHolder.PlaceHolder = ph
placeHolder.Hint = hint
placeHolder.PlaceHolderType = uno.Any("short",TEXT)
return placeHolder
def getNamesWhichStartWith(self, allNames, prefix):
v = []
for i in allNames:
if i.startswith(prefix):
v.append(i)
return v
'''
Convenience method for inserting some cells into a table.
'''
@classmethod
def insertTableRows(self, table, start, count):
rows = table.Rows
rows.insertByIndex(start, count)
'''
returns the rows count of this table, assuming
there is no vertical merged cells.
'''
@classmethod
def getRowCount(self, table):
cells = table.getCellNames()
return int(cells[len(cells) - 1][1:])
class ItemsTable(object):
'''
the items in the table.
'''
items = []
table = None
def __init__(self, section, table, agenda):
self.agenda = agenda
ItemsTable.table = table
self.section = section
self.items = []
'''
go through all <*> items in the document
and each one if it is in this table.
If they are, register them to belong here, notice their order
and remove them from the list of all <*> items, so the next
search will be faster.
'''
aux = []
for item in self.agenda.allItems:
t = item.TextTable
if t == ItemsTable.table:
iText = item.String.lower().lstrip()
ai = self.agenda.itemsCache[iText]
if ai is not None:
self.items.append(ai)
self.agenda.itemsMap[iText] = self
else:
aux.append(item)
self.agenda.allItems = aux
'''
link the section to the template. this will restore the original table
with all the items.<br/>
then break the link, to make the section editable.<br/>
then, starting at cell one, write all items that should be visible.
then clear the rest and remove obsolete rows.
If no items are visible, hide the section.
'''
def write(self):
name = self.section.Name
# link and unlink the section to the template.
self.agenda.textSectionHandler.linkSectiontoTemplate(
self.agenda.template, name, self.section)
self.agenda.textSectionHandler.breakLinkOfTextSection(
self.section)
# we need to get an instance after linking
ItemsTable.table = self.agenda.getTable(name)
self.section = self.agenda.getSection(name)
cursor = ItemsTable.table.createCursorByCellName("A1")
# should this section be visible?
visible = False
# write items
cellName = ""
'''
now go through all items that belong to this
table. Check each one against the model. If it should
be displayed, call its write method.
All items are of type AgendaItem which means they write
two cells to the table: a title (text) and a placeholder.
see AgendaItem class below.
'''
for i in self.items:
if self.agenda.isShowItem(i.name):
visible = True
i.table = ItemsTable.table
i.write(cursor)
# I store the cell name which was last written...
cellName = cursor.RangeName
cursor.goRight(1, False)
if visible:
boolean = True
else:
boolean = False
self.section.IsVisible = boolean
if not visible:
return
'''
if the cell that was last written is the current cell,
it means this is the end of the table, so we end here.
(because after getting the cellName above,
I call the goRight method.
If it did not go right, it means it's the last cell.
'''
if cellName == cursor.RangeName:
return
'''
if not, we continue and clear all cells until
we are at the end of the row.
'''
while not cellName == cursor.RangeName and \
not cursor.RangeName.startswith("A"):
cell = ItemsTable.table.getCellByName(cursor.RangeName)
cell.String = ""
cellName = cursor.RangeName
cursor.goRight(1, False)
'''
again: if we are at the end of the table, end here.
'''
if cellName == cursor.RangeName:
return
'''
now before deleting i move the cursor up so it
does not disappear, because it will crash office.
'''
cursor.gotoStart(False)
'''
This class handles the preview of the topics table.
You can call it the controller of the topics table.
It differs from ItemsTable in that it has no data model -
the update is done programmatically.<br/>
<br/>
The decision to make this class a class by its own
was done out of logic reasons and not design/functionality reasons,
since there is anyway only one instance of this class at runtime
it could have also be implemented in the AgendaDocument class
but for clarity and separation I decided to make a sub class for it.
'''
class Topics(object):
'''Analyze the structure of the Topics table.
The structure Must be as follows:<br>
-One Header Row. <br>
-arbitrary number of rows per topic <br>
-arbitrary content in the topics row <br>
-only soft formatting will be restored. <br>
-the topic rows must repeat three times. <br>
-in the topics rows, placeholders for number, topic, responsible,
and duration must be placed.<br><br>
A word about table format: to reconstruct the format of the table we hold
to the following formats: first row (header), topic, and last row.
We hold the format of the last row, because one might wish to give it
a special format, other than the one on the bottom of each topic.
The left and right borders of the whole table are, on the other side,
part of the topics rows format, and need not be preserved separately.
'''
table = None
lastRowFormat = []
rowsPerTopic = None
def __init__(self, agenda):
self.firstRowFormat = []
self.agenda = agenda
self.writtenTopics = -1
try:
Topics.table = self.agenda.getTable(
self.agenda.templateConsts.SECTION_TOPICS)
except Exception:
traceback.print_exc()
raise AttributeError (
"Fatal error while loading template: table " + \
self.agenda.templateConsts.SECTION_TOPICS + " could not load.")
'''
first I store all <*> ranges
which are in the topics table.
I store each <*> range in this - the key
is the cell it is in. Later when analyzing the topic,
cell by cell, I check in this map to know
if a cell contains a <*> or not.
'''
try:
items = {}
for i in self.agenda.allItems:
t = i.TextTable
if t == Topics.table:
cell = i.Cell
iText = cell.CellName
items[iText] = i
'''
in the topics table, there are always one
title row and three topics defined.
So no mutter how many rows a topic takes - we
can restore its structure and format.
'''
rows = self.agenda.getRowCount(Topics.table)
Topics.rowsPerTopic = int((rows - 1) / 3)
firstCell = "A" + str(1 + Topics.rowsPerTopic + 1)
afterLastCell = "A" + str(1 + (Topics.rowsPerTopic * 2) + 1)
# go to the first row of the 2. topic
cursor = Topics.table.createCursorByCellName(firstCell)
# analyze the structure of the topic rows.
while not cursor.RangeName == afterLastCell:
cell = Topics.table.getCellByName(cursor.RangeName)
# first I store the content and para style of the cell
ae = TextElement(cell, cell.String)
ae.write()
# goto next cell.
cursor.goRight(1, False)
except Exception:
traceback.print_exc()
'''rewrites a single cell containing.
This is used in order to refresh the topic/responsible/duration data
in the preview document, in response to a change in the gui (by the user)
Since the structure of the topics table is flexible,
The Topics object, which analyzed the structure of the topics table upon
initialization, refreshes the appropriate cell.
'''
def writeCell(self, row, column, data):
# if the whole row should be written...
if self.writtenTopics < row:
self.writtenTopics += 1
rows = self.agenda.getRowCount(Topics.table)
reqRows = 1 + (row + 1) * Topics.rowsPerTopic
firstRow = reqRows - Topics.rowsPerTopic + 1
diff = reqRows - rows
if diff > 0:
# set the item's text...
self.agenda.insertTableRows(Topics.table, rows, diff)
column = 0
cursor = Topics.table.createCursorByCellName("A" + str(firstRow))
else:
# calculate the table row.
firstRow = 1 + (row * Topics.rowsPerTopic) + 1
cursor = Topics.table.createCursorByCellName("A" + str(firstRow))
# move the cursor to the needed cell...
cursor.goRight(column, False)
xc = Topics.table.getCellByName(cursor.RangeName)
# and write it !
te = TextElement(xc, data[column].Value)
te.write()
'''removes obsolete rows, reducing the
topics table to the given number of topics.
Note this method does only reducing - if
the number of topics given is greater than the
number of actual topics it does *not* add
rows!
Note also that the first topic will never be removed.
If the table contains no topics, the whole section will
be removed upon finishing.
The reason for that is a "table-design" one: the first topic is
maintained in order to be able to add rows with a design of this topic,
and not of the header row.
@param topics the number of topics the table should contain.
@throws Exception
'''
def reduceDocumentTo(self, topics):
# we never remove the first topic...
if topics <= 0:
topics = 1
tableRows = Topics.table.Rows
targetNumOfRows = topics * Topics.rowsPerTopic + 1
if tableRows.Count > targetNumOfRows:
tableRows.removeByIndex(
targetNumOfRows, tableRows.Count - targetNumOfRows)
'''
A Text element which, if the text to write is empty (null or "")
inserts a placeholder instead.
'''
class PlaceholderTextElement(TextElement):
def __init__(self, textRange, placeHolderText_, hint_, xmsf_):
super(PlaceholderTextElement,self).__init__(textRange, "")
self.text = placeHolderText_
self.hint = hint_
self.xmsf = xmsf_
self.xTextContentList = []
def write(self, textRange):
textRange.String = self.placeHolderText
if self.placeHolderText is None or self.placeHolderText == "":
try:
xTextContent = AgendaDocument.createPlaceHolder(
self.xmsf, self.text, self.hint)
self.xTextContentList.append(xTextContent)
textRange.Text.insertTextContent(
textRange.Start, xTextContent, True)
except Exception:
traceback.print_exc()
else:
if self.xTextContentList:
for i in self.xTextContentList:
textRange.Text.removeTextContent(i)
self.xTextContentList = []
'''
An Agenda element which writes no text, but inserts a placeholder, and formats
it using a ParaStyleName.
'''
class PlaceholderElement(object):
def __init__(self, placeHolderText_, hint_, textDocument):
self.placeHolderText = placeHolderText_
self.hint = hint_
self.textDocument = textDocument
def write(self, textRange):
try:
xTextContent = AgendaDocument.createPlaceHolder(
self.textDocument, self.placeHolderText, self.hint)
textRange.Text.insertTextContent(
textRange.Start, xTextContent, True)
except Exception:
traceback.print_exc()
'''
An implementation of AgendaElement which
gets as a parameter a table cursor, and writes
a text to the cell marked by this table cursor, and
a place holder to the next cell.
'''
class AgendaItem(object):
def __init__(self, name_, te, f):
self.name = name_
self.field = f
self.textElement = te
def write(self, tableCursor):
cellname = tableCursor.RangeName
cell = ItemsTable.table.getCellByName(cellname)
cell.String = self.textElement
tableCursor.goRight(1, False)
# second field is actually always null...
# this is a preparation for adding placeholders.
if self.field is not None:
self.field.write(ItemsTable.table.getCellByName(
tableCursor.RangeName))

View File

@@ -0,0 +1,320 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..ui.WizardDialog import WizardDialog, uno, UIConsts, PropertyNames
from .AgendaWizardDialogConst import AgendaWizardDialogConst, HID
from .AgendaWizardDialogResources import AgendaWizardDialogResources
from com.sun.star.awt.FontUnderline import SINGLE
class AgendaWizardDialog(WizardDialog):
def __init__(self, xmsf):
super(AgendaWizardDialog,self).__init__(xmsf, HID )
#Load Resources
self.resources = AgendaWizardDialogResources()
#set dialog properties...
self.setDialogProperties(True, 210, True, 200, 52, 1, 1,
self.resources.resAgendaWizardDialog_title, 310)
self.PROPS_LIST = ("Dropdown",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.PROPS_LABEL_B = ("FontDescriptor",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.PROPS_CHECK = (PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.PROPS_BUTTON = (PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.PROPS_X = (PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.PROPS_TEXTAREA = (PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.PROPS_TEXT = (PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.PROPS_IMAGE = ("Border",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_IMAGEURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
"ScaleImage", PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.fontDescriptor4 = \
uno.createUnoStruct('com.sun.star.awt.FontDescriptor')
self.fontDescriptor4.Weight = 150
def buildStep1(self):
self.insertLabel("lblTitle1", self.PROPS_LABEL_B,
(self.fontDescriptor4, 16, self.resources.reslblTitle1_value,
True, 91, 8, 1, 100,212))
self.insertLabel("lblPageDesign", self.PROPS_TEXT,
(8, self.resources.reslblPageDesign_value, 97, 32, 1, 101, 66))
self.listPageDesign = self.insertListBox("listPageDesign",
None, AgendaWizardDialogConst.LISTPAGEDESIGN_ACTION_PERFORMED,
self.PROPS_LIST,
(True, 12, AgendaWizardDialogConst.LISTPAGEDESIGN_HID,
166, 30, 1, 102, 70), self)
self.chkMinutes = self.insertCheckBox("chkMinutes", None,
self.PROPS_CHECK, (9, AgendaWizardDialogConst.CHKMINUTES_HID,
self.resources.reschkMinutes_value, 97, 50, 0, 1, 103, 203), self)
self.insertImage("imgHelp1", self.PROPS_IMAGE,
(0, 10, "", UIConsts.INFOIMAGEURL, 92, 145, False, 1, 104, 10))
self.insertLabel("lblHelp1", self.PROPS_TEXTAREA,
(39, self.resources.reslblHelp1_value,
True, 104, 145, 1, 105, 199))
def buildStep2(self):
self.insertLabel("lblTitle2", self.PROPS_LABEL_B,
(self.fontDescriptor4, 16, self.resources.reslblTitle2_value,
True, 91, 8, 2, 200, 212))
self.insertLabel("lblDate", self.PROPS_TEXT,
(8, self.resources.reslblDate_value, 97, 32, 2, 201,66))
self.txtDate = self.insertDateField(
"txtDate", AgendaWizardDialogConst.TXTDATE_TEXT_CHANGED,
self.PROPS_LIST,
(True, 12, AgendaWizardDialogConst.TXTDATE_HID,
166,30, 2, 202, 70), self)
self.insertLabel("lblTime", self.PROPS_TEXT,
(8, self.resources.reslblTime_value, 97, 50, 2, 203, 66))
self.txtTime = self.insertTimeField("txtTime",
AgendaWizardDialogConst.TXTTIME_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
"StrictFormat",
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(12, AgendaWizardDialogConst.TXTTIME_HID,
166, 48, 2, True, 204, 70), self)
self.insertLabel("lblTitle", self.PROPS_TEXT,
(8, self.resources.reslblTitle_value, 97, 68, 2, 205, 66))
self.txtTitle = self.insertTextField(
"txtTitle", AgendaWizardDialogConst.TXTTITLE_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(26, AgendaWizardDialogConst.TXTTITLE_HID,
True, 166, 66, 2, 206, 138), self)
self.insertLabel("lblLocation", self.PROPS_TEXT,
(8, self.resources.reslblLocation_value, 97, 100, 2, 207, 66))
self.cbLocation = self.insertTextField(
"cbLocation", AgendaWizardDialogConst.TXTLOCATION_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(34, AgendaWizardDialogConst.CBLOCATION_HID,
True, 166,98, 2, 208, 138), self)
self.insertImage("imgHelp2", self.PROPS_IMAGE,
(0, 10, "", UIConsts.INFOIMAGEURL, 92, 145, False, 2, 209, 10))
self.insertLabel("lblHelp2", self.PROPS_TEXTAREA,
(39, self.resources.reslblHelp2_value,
True, 104, 145, 2, 210, 199))
def buildStep3(self):
self.insertLabel("lblTitle3", self.PROPS_LABEL_B,
(self.fontDescriptor4, 16, self.resources.reslblTitle3_value,
True, 91, 8, 3, 300,212))
self.chkMeetingTitle = self.insertCheckBox("chkMeetingTitle",
AgendaWizardDialogConst.CHKUSEMEETINGTYPE_ITEM_CHANGED,
self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKMEETINGTITLE_HID,
self.resources.reschkMeetingTitle_value,
97, 32, 1, 3, 301, 69), self)
self.chkRead = self.insertCheckBox("chkRead",
AgendaWizardDialogConst.CHKUSEREAD_ITEM_CHANGED, self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKREAD_HID,
self.resources.reschkRead_value, 97, 46, 0, 3, 302, 162), self)
self.chkBring = self.insertCheckBox("chkBring",
AgendaWizardDialogConst.CHKUSEBRING_ITEM_CHANGED, self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKBRING_HID,
self.resources.reschkBring_value,
97, 60, 0, 3, 303, 162), self)
self.chkNotes = self.insertCheckBox("chkNotes",
AgendaWizardDialogConst.CHKUSENOTES_ITEM_CHANGED, self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKNOTES_HID,
self.resources.reschkNotes_value,
97, 74, 1, 3, 304, 160), self)
self.insertImage("imgHelp3", self.PROPS_IMAGE, (0, 10,
"", UIConsts.INFOIMAGEURL, 92, 145, False, 3, 305, 10))
self.insertLabel("lblHelp3", self.PROPS_TEXTAREA,
(39, self.resources.reslblHelp3_value, True,104, 145, 3, 306, 199))
def buildStep4(self):
self.insertLabel("lblTitle5", self.PROPS_LABEL_B,
(self.fontDescriptor4, 16, self.resources.reslblTitle5_value,
True, 91, 8, 4, 400, 212))
self.chkConvenedBy = self.insertCheckBox("chkConvenedBy",
AgendaWizardDialogConst.CHKUSECALLEDBYNAME_ITEM_CHANGED,
self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKCONVENEDBY_HID,
self.resources.reschkConvenedBy_value,
97, 32, 1, 4, 401, 150), self)
self.chkPresiding = self.insertCheckBox("chkPresiding",
AgendaWizardDialogConst.CHKUSEFACILITATOR_ITEM_CHANGED,
self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKPRESIDING_HID,
self.resources.reschkPresiding_value,
97, 46, 0, 4, 402, 150), self)
self.chkNoteTaker = self.insertCheckBox("chkNoteTaker",
AgendaWizardDialogConst.CHKUSENOTETAKER_ITEM_CHANGED,
self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKNOTETAKER_HID,
self.resources.reschkNoteTaker_value,
97, 60, 0, 4, 403, 150), self)
self.chkTimekeeper = self.insertCheckBox("chkTimekeeper",
AgendaWizardDialogConst.CHKUSETIMEKEEPER_ITEM_CHANGED,
self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKTIMEKEEPER_HID,
self.resources.reschkTimekeeper_value,
97, 74, 0, 4, 404, 150), self)
self.chkAttendees = self.insertCheckBox("chkAttendees",
AgendaWizardDialogConst.CHKUSEATTENDEES_ITEM_CHANGED,
self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKATTENDEES_HID,
self.resources.reschkAttendees_value,
97, 88, 1, 4, 405, 150), self)
self.chkObservers = self.insertCheckBox("chkObservers",
AgendaWizardDialogConst.CHKUSEOBSERVERS_ITEM_CHANGED,
self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKOBSERVERS_HID,
self.resources.reschkObservers_value,
97, 102, 0, 4, 406, 150), self)
self.chkResourcePersons = self.insertCheckBox("chkResourcePersons",
AgendaWizardDialogConst.CHKUSERESOURCEPERSONS_ITEM_CHANGED,
self.PROPS_CHECK,
(8, AgendaWizardDialogConst.CHKRESOURCEPERSONS_HID,
self.resources.reschkResourcePersons_value,
97, 116, 0, 4, 407, 150), self)
self.insertImage("imgHelp4", self.PROPS_IMAGE,
(0, 10, "", UIConsts.INFOIMAGEURL,
92, 145, False, 4, 408, 10))
self.insertLabel("lblHelp4", self.PROPS_TEXTAREA,
(39, self.resources.reslblHelp4_value, True, 104, 145, 4, 409, 199))
def buildStep5(self):
self.insertLabel("lblTitle4", self.PROPS_LABEL_B,
(self.fontDescriptor4, 16, self.resources.reslblTitle4_value,
True, 91, 8, 5, 500, 212))
self.insertLabel("lblTopic", self.PROPS_TEXT,
(8, self.resources.reslblTopic_value, 107, 28, 5, 71, 501))
self.insertLabel("lblResponsible", self.PROPS_TEXT,
(8, self.resources.reslblResponsible_value, 195, 28, 5, 72, 502))
self.insertLabel("lblDuration", self.PROPS_TEXT,
(8, self.resources.reslblDuration_value, 267, 28, 5, 73, 503))
self.btnInsert = self.insertButton("btnInsert",
AgendaWizardDialogConst.BTNINSERT_ACTION_PERFORMED,
self.PROPS_BUTTON, (14, AgendaWizardDialogConst.BTNINSERT_HID,
self.resources.resButtonInsert, 92, 136, 5, 580, 40), self)
self.btnRemove = self.insertButton("btnRemove",
AgendaWizardDialogConst.BTNREMOVE_ACTION_PERFORMED,
self.PROPS_BUTTON, (14, AgendaWizardDialogConst.BTNREMOVE_HID,
self.resources.resButtonRemove, 134, 136, 5, 581, 40), self)
self.btnUp = self.insertButton("btnUp",
AgendaWizardDialogConst.BTNUP_ACTION_PERFORMED,
self.PROPS_BUTTON, (14, AgendaWizardDialogConst.BTNUP_HID,
self.resources.resButtonUp, 180, 136, 5, 582, 60), self)
self.btnDown = self.insertButton("btnDown",
AgendaWizardDialogConst.BTNDOWN_ACTION_PERFORMED,
self.PROPS_BUTTON, (14, AgendaWizardDialogConst.BTNDOWN_HID,
self.resources.resButtonDown, 244, 136, 5, 583, 60), self)
def buildStep6(self):
self.insertLabel("lblTitle6", self.PROPS_LABEL_B,
(self.fontDescriptor4, 16, self.resources.reslblTitle6_value,
True, 91, 8, 6, 600, 212))
self.insertLabel("lblHelpPg6", self.PROPS_TEXTAREA,
(24, self.resources.reslblHelpPg6_value, True,
97, 32, 6, 601,204))
self.insertLabel("lblTemplateName", self.PROPS_TEXT,
(8, self.resources.reslblTemplateName_value,
97, 62, 6, 602, 101))
self.txtTemplateName = self.insertTextField("txtTemplateName",
None, self.PROPS_X,
(12, AgendaWizardDialogConst.TXTTEMPLATENAME_HID,
202, 60, 6, 603, 100), self)
self.insertLabel("lblProceed", self.PROPS_TEXT,
(8, self.resources.reslblProceed_value, 97, 101, 6, 607,204))
self.optCreateAgenda = self.insertRadioButton("optCreateAgenda", None,
self.PROPS_CHECK, (8, AgendaWizardDialogConst.OPTCREATEAGENDA_HID,
self.resources.resoptCreateAgenda_value,
103, 113, 1, 6, 608, 198), self)
self.optMakeChanges = self.insertRadioButton("optMakeChanges", None,
self.PROPS_BUTTON, (8, AgendaWizardDialogConst.OPTMAKECHANGES_HID,
self.resources.resoptMakeChanges_value,
103, 125, 6, 609, 198), self)
self.insertImage("imgHelp6", self.PROPS_IMAGE, (0, 10, "",
UIConsts.INFOIMAGEURL, 92, 145, False, 6, 610, 10))
self.insertLabel("lblHelp6", self.PROPS_TEXTAREA,
(39, self.resources.reslblHelp6_value, True, 104, 145, 6, 611, 199))

View File

@@ -0,0 +1,77 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..common.HelpIds import HelpIds
HID = 41051
class AgendaWizardDialogConst:
TXTTITLE_TEXT_CHANGED = "txtTitleTextChanged"
TXTDATE_TEXT_CHANGED = "txtDateTextChanged"
TXTTIME_TEXT_CHANGED = "txtTimeTextChanged"
TXTLOCATION_TEXT_CHANGED = "txtLocationTextChanged"
CHKMINUTES_ITEM_CHANGED = "chkMinutesItemChanged"
CHKUSEMEETINGTYPE_ITEM_CHANGED = "chkUseMeetingTypeItemChanged"
CHKUSEREAD_ITEM_CHANGED = "chkUseReadItemChanged"
CHKUSEBRING_ITEM_CHANGED = "chkUseBringItemChanged"
CHKUSENOTES_ITEM_CHANGED = "chkUseNotesItemChanged"
CHKUSECALLEDBYNAME_ITEM_CHANGED = "chkUseCalledByItemChanged"
CHKUSEFACILITATOR_ITEM_CHANGED = "chkUseFacilitatorItemChanged"
CHKUSENOTETAKER_ITEM_CHANGED = "chkUseNoteTakerItemChanged"
CHKUSETIMEKEEPER_ITEM_CHANGED = "chkUseTimeKeeperItemChanged"
CHKUSEATTENDEES_ITEM_CHANGED = "chkUseAttendeesItemChanged"
CHKUSEOBSERVERS_ITEM_CHANGED = "chkUseObserversItemChanged"
CHKUSERESOURCEPERSONS_ITEM_CHANGED = "chkUseResourcePersonsItemChanged"
LISTPAGEDESIGN_ACTION_PERFORMED = "pageDesignChanged"
BTNTEMPLATEPATH_ACTION_PERFORMED = "saveAs"
BTNINSERT_ACTION_PERFORMED = "insertRow"
BTNREMOVE_ACTION_PERFORMED = "removeRow"
BTNUP_ACTION_PERFORMED = "rowUp"
BTNDOWN_ACTION_PERFORMED = "rowDown"
LISTPAGEDESIGN_HID = HelpIds.getHelpIdString(HID + 6)
CHKMINUTES_HID = HelpIds.getHelpIdString(HID + 7)
TXTTIME_HID = HelpIds.getHelpIdString(HID + 8)
TXTDATE_HID = HelpIds.getHelpIdString(HID + 9)
TXTTITLE_HID = HelpIds.getHelpIdString(HID + 10)
CBLOCATION_HID = HelpIds.getHelpIdString(HID + 11)
CHKMEETINGTITLE_HID = HelpIds.getHelpIdString(HID + 12)
CHKREAD_HID = HelpIds.getHelpIdString(HID + 13)
CHKBRING_HID = HelpIds.getHelpIdString(HID + 14)
CHKNOTES_HID = HelpIds.getHelpIdString(HID + 15)
CHKCONVENEDBY_HID = HelpIds.getHelpIdString(HID + 16)
CHKPRESIDING_HID = HelpIds.getHelpIdString(HID + 17)
CHKNOTETAKER_HID = HelpIds.getHelpIdString(HID + 18)
CHKTIMEKEEPER_HID = HelpIds.getHelpIdString(HID + 19)
CHKATTENDEES_HID = HelpIds.getHelpIdString(HID + 20)
CHKOBSERVERS_HID = HelpIds.getHelpIdString(HID + 21)
CHKRESOURCEPERSONS_HID = HelpIds.getHelpIdString(HID + 22)
TXTTEMPLATENAME_HID = HelpIds.getHelpIdString(HID + 23)
TXTTEMPLATEPATH_HID = HelpIds.getHelpIdString(HID + 24)
BTNTEMPLATEPATH_HID = HelpIds.getHelpIdString(HID + 25)
OPTCREATEAGENDA_HID = HelpIds.getHelpIdString(HID + 26)
OPTMAKECHANGES_HID = HelpIds.getHelpIdString(HID + 27)
BTNINSERT_HID = HelpIds.getHelpIdString(HID + 28)
BTNREMOVE_HID = HelpIds.getHelpIdString(HID + 29)
BTNUP_HID = HelpIds.getHelpIdString(HID + 30)
BTNDOWN_HID = HelpIds.getHelpIdString(HID + 31)

View File

@@ -0,0 +1,384 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
import os.path
from .AgendaWizardDialog import AgendaWizardDialog, uno
from .AgendaWizardDialogConst import HID
from .AgendaDocument import AgendaDocument, TextElement
from .TemplateConsts import TemplateConsts
from .TopicsControl import TopicsControl
from .CGAgenda import CGAgenda
from ..ui.PathSelection import PathSelection
from ..ui.event.UnoDataAware import UnoDataAware
from ..ui.event.RadioDataAware import RadioDataAware
from ..ui.event.CommonListener import TerminateListenerProcAdapter
from ..common.NoValidPathException import NoValidPathException
from ..common.SystemDialog import SystemDialog
from ..common.Desktop import Desktop
from ..common.HelpIds import HelpIds
from ..common.Configuration import Configuration
from ..common.FileAccess import FileAccess
from ..document.OfficeDocument import OfficeDocument
from com.sun.star.util import CloseVetoException
from com.sun.star.view.DocumentZoomType import OPTIMAL
from com.sun.star.awt.VclWindowPeerAttribute import YES_NO, DEF_NO
class AgendaWizardDialogImpl(AgendaWizardDialog):
def __init__(self, xmsf):
super(AgendaWizardDialogImpl, self).__init__(xmsf)
self.filenameChanged = False
self.pageDesign = -1
def enterStep(self, OldStep, NewStep):
pass
def leaveStep(self, OldStep, NewStep):
pass
def startWizard(self, xMSF):
self.running = True
try:
#Number of steps on WizardDialog
self.nMaxStep = 6
self.agenda = CGAgenda()
# read configuration data before we initialize the topics
root = Configuration.getConfigurationRoot(
self.xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda",
False)
self.agenda.readConfiguration(root, "cp_")
self.templateConsts = TemplateConsts
self.initializePaths()
# initialize the agenda template
self.terminateListener = TerminateListenerProcAdapter(self.queryTermination)
self.myAgendaDoc = AgendaDocument(
self.xMSF, self.agenda, self.resources,
self.templateConsts, self.terminateListener)
self.initializeTemplates()
self.myAgendaDoc.load(
self.agendaTemplates[1][self.agenda.cp_AgendaType])
self.drawConstants()
# build the dialog.
self.drawNaviBar()
self.buildStep1()
self.buildStep2()
self.buildStep3()
self.buildStep4()
self.buildStep5()
self.buildStep6()
self.topicsControl = TopicsControl(self, self.xMSF, self.agenda)
#special Control for setting the save Path:
self.insertPathSelectionControl()
# synchronize GUI and CGAgenda object.
self.initConfiguration()
if self.myPathSelection.xSaveTextBox.Text.lower() == "":
self.myPathSelection.initializePath()
# create the peer
xContainerWindow = self.myAgendaDoc.xFrame.ContainerWindow
self.createWindowPeer(xContainerWindow)
# initialize roadmap
self.insertRoadmap()
self.executeDialogFromComponent(self.myAgendaDoc.xFrame)
self.removeTerminateListener()
self.closeDocument()
self.running = False
except Exception:
self.removeTerminateListener()
traceback.print_exc()
self.running = False
return
def insertPathSelectionControl(self):
self.myPathSelection = PathSelection(
self.xMSF, self, PathSelection.TransferMode.SAVE,
PathSelection.DialogTypes.FILE)
self.myPathSelection.insert(6, 97, 70, 205, 45,
self.resources.reslblTemplatePath_value, True,
HelpIds.getHelpIdString(HID + 24),
HelpIds.getHelpIdString(HID + 25))
self.myPathSelection.sDefaultDirectory = self.sUserTemplatePath
self.myPathSelection.sDefaultName = "myAgendaTemplate.ott"
self.myPathSelection.sDefaultFilter = "writer8_template"
self.myPathSelection.addSelectionListener(self)
'''
bind controls to the agenda member (DataAware model)
'''
def initConfiguration(self):
self.xDialogModel.listPageDesign.StringItemList = \
tuple(self.agendaTemplates[0])
UnoDataAware.attachListBox(
self.agenda, "cp_AgendaType", self.listPageDesign, True).updateUI()
self.pageDesign = self.agenda.cp_AgendaType
UnoDataAware.attachCheckBox(
self.agenda, "cp_IncludeMinutes", self.chkMinutes, True).updateUI()
UnoDataAware.attachEditControl(
self.agenda, "cp_Title", self.txtTitle, True).updateUI()
UnoDataAware.attachDateControl(
self.agenda, "cp_Date", self.txtDate, True).updateUI()
UnoDataAware.attachTimeControl(
self.agenda, "cp_Time", self.txtTime, True).updateUI()
UnoDataAware.attachEditControl(
self.agenda, "cp_Location", self.cbLocation, True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowMeetingType", self.chkMeetingTitle,
True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowRead", self.chkRead, True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowBring", self.chkBring, True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowNotes", self.chkNotes, True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowCalledBy", self.chkConvenedBy,
True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowFacilitator", self.chkPresiding,
True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowNotetaker", self.chkNoteTaker,
True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowTimekeeper", self.chkTimekeeper,
True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowAttendees", self.chkAttendees,
True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowObservers", self.chkObservers,
True).updateUI()
UnoDataAware.attachCheckBox(
self.agenda, "cp_ShowResourcePersons",self.chkResourcePersons,
True).updateUI()
UnoDataAware.attachEditControl(
self.agenda, "cp_TemplateName", self.txtTemplateName,
True).updateUI()
RadioDataAware.attachRadioButtons(
self.agenda, "cp_ProceedMethod",
(self.optCreateAgenda, self.optMakeChanges), True).updateUI()
def insertRoadmap(self):
self.addRoadmap()
self.insertRoadMapItems(
self.resources.RoadmapLabels, [True, True, True, True, True, True])
self.setRoadmapInteractive(True)
self.setRoadmapComplete(True)
self.setCurrentRoadmapItemID(1)
'''
read the available agenda wizard templates.
'''
def initializeTemplates(self):
try:
sAgendaPath = self.sTemplatePath + "/wizard/agenda"
self.agendaTemplates = FileAccess.getFolderTitles(
self.xMSF, "aw", sAgendaPath, self.resources.dictPageDesign)
return True
except NoValidPathException:
traceback.print_exc()
return False
'''
first page, page design listbox changed.
'''
def pageDesignChanged(self):
try:
SelectedItemPos = self.listPageDesign.SelectedItemPos
#avoid to load the same item again
if self.pageDesign is not SelectedItemPos:
self.pageDesign = SelectedItemPos
self.myAgendaDoc.load(
self.agendaTemplates[1][SelectedItemPos])
self.drawConstants()
except Exception:
traceback.print_exc()
#textFields listeners
def txtTitleTextChanged(self):
self.myAgendaDoc.redrawTitle("txtTitle")
def txtDateTextChanged(self):
self.myAgendaDoc.redrawTitle("txtDate")
def txtTimeTextChanged(self):
self.myAgendaDoc.redrawTitle("txtTime")
def txtLocationTextChanged(self):
self.myAgendaDoc.redrawTitle("cbLocation")
#checkbox listeners
def chkUseMeetingTypeItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_MEETING_TYPE)
def chkUseReadItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_READ)
def chkUseBringItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_BRING)
def chkUseNotesItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_NOTES)
def chkUseCalledByItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_CALLED_BY)
def chkUseFacilitatorItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_FACILITATOR)
def chkUseNoteTakerItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_NOTETAKER)
def chkUseTimeKeeperItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_TIMEKEEPER)
def chkUseAttendeesItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_PARTICIPANTS)
def chkUseObserversItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_OBSERVERS)
def chkUseResourcePersonsItemChanged(self):
self.myAgendaDoc.redraw(self.templateConsts.FILLIN_RESOURCE_PERSONS)
def insertRow(self):
self.topicsControl.insertRow()
def removeRow(self):
self.topicsControl.removeRow()
def rowUp(self):
self.topicsControl.rowUp()
def rowDown(self):
self.topicsControl.rowDown()
def cancelWizard(self):
self.xUnoDialog.endExecute()
self.running = False
def finishWizard(self):
self.switchToStep(self.getCurrentStep(), self.nMaxStep)
bSaveSuccess = False
endWizard = True
try:
self.sPath = self.myPathSelection.getSelectedPath()
if not self.sPath or not os.path.exists(self.sPath):
self.myPathSelection.triggerPathPicker()
self.sPath = self.myPathSelection.getSelectedPath()
#first, if the filename was not changed, thus
#it is coming from a saved session, check if the
# file exists and warn the user.
if not self.filenameChanged:
answer = SystemDialog.showMessageBox(
self.xMSF, "MessBox", YES_NO + DEF_NO,
self.resources.resOverwriteWarning,
self.xUnoDialog.Peer)
if answer == 3:
# user said: no, do not overwrite
endWizard = False
return False
xDocProps = self.myAgendaDoc.xTextDocument.DocumentProperties
xDocProps.Title = self.txtTemplateName.Text
self.myAgendaDoc.setWizardTemplateDocInfo( \
self.resources.resAgendaWizardDialog_title,
self.resources.resTemplateDescription)
bSaveSuccess = OfficeDocument.store(
self.xMSF, self.myAgendaDoc.xTextDocument, self.sPath,
"writer8_template")
if bSaveSuccess:
self.topicsControl.saveTopics(self.agenda)
root = Configuration.getConfigurationRoot(
self.xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda",
True)
self.agenda.writeConfiguration(root, "cp_")
root.commitChanges()
self.myAgendaDoc.finish(self.topicsControl.scrollfields)
loadValues = list(range(2))
loadValues[0] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[0].Name = "AsTemplate"
if self.agenda.cp_ProceedMethod == 1:
loadValues[0].Value = True
else:
loadValues[0].Value = False
loadValues[1] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[1].Name = "InteractionHandler"
xIH = self.xMSF.createInstance(
"com.sun.star.comp.uui.UUIInteractionHandler")
loadValues[1].Value = xIH
oDoc = OfficeDocument.load(
Desktop.getDesktop(self.xMSF),
self.sPath, "_default", loadValues)
oDoc.CurrentController.ViewSettings.ZoomType = OPTIMAL
else:
pass
except Exception:
traceback.print_exc()
finally:
if endWizard:
self.xUnoDialog.endExecute()
self.running = False
return True
def closeDocument(self):
try:
self.myAgendaDoc.xFrame.close(False)
except CloseVetoException:
traceback.print_exc()
def drawConstants(self):
'''Localise the template'''
constRangeList = self.myAgendaDoc.searchFillInItems(1)
for i in constRangeList:
text = i.String.lower()
aux = TextElement(i, self.resources.dictConstants[text])
aux.write()
def validatePath(self):
if self.myPathSelection.usedPathPicker:
self.filenameChanged = True
self.myPathSelection.usedPathPicker = False

View File

@@ -0,0 +1,161 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class AgendaWizardDialogResources(object):
SECTION_ITEMS = "AGENDA_ITEMS"
SECTION_TOPICS = "AGENDA_TOPICS"
SECTION_MINUTES_ALL = "MINUTES_ALL"
SECTION_MINUTES = "MINUTES"
def __init__(self):
import sys, os
if sys.version_info < (3,4):
import imp
imp.load_source('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc'))
import strings
elif sys.version_info < (3,7):
# imp is deprecated since Python v.3.4
from importlib.machinery import SourceFileLoader
SourceFileLoader('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc')).load_module()
import strings
else:
# have to jump through hoops since 3.7, partly because python does not like loading modules that do have a .py extension
import importlib
import importlib.util
import importlib.machinery
module_name = 'strings'
path = os.path.join(os.path.dirname(__file__), '../common/strings.hrc')
spec = importlib.util.spec_from_loader(
module_name,
importlib.machinery.SourceFileLoader(module_name, path)
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[module_name] = module
strings = module
self.resAgendaWizardDialog_title = strings.RID_AGENDAWIZARDDIALOG_START_1
self.resoptMakeChanges_value = strings.RID_AGENDAWIZARDDIALOG_START_2
self.reslblTemplateName_value = strings.RID_AGENDAWIZARDDIALOG_START_3
self.reslblTemplatePath_value = strings.RID_AGENDAWIZARDDIALOG_START_4
self.reslblProceed_value = strings.RID_AGENDAWIZARDDIALOG_START_5
self.reslblTitle1_value = strings.RID_AGENDAWIZARDDIALOG_START_6
self.reslblTitle3_value = strings.RID_AGENDAWIZARDDIALOG_START_7
self.reslblTitle2_value = strings.RID_AGENDAWIZARDDIALOG_START_8
self.reslblTitle4_value = strings.RID_AGENDAWIZARDDIALOG_START_9
self.reslblTitle5_value = strings.RID_AGENDAWIZARDDIALOG_START_10
self.reslblTitle6_value = strings.RID_AGENDAWIZARDDIALOG_START_11
self.reschkMinutes_value = strings.RID_AGENDAWIZARDDIALOG_START_12
self.reslblHelp1_value = strings.RID_AGENDAWIZARDDIALOG_START_13
self.reslblTime_value = strings.RID_AGENDAWIZARDDIALOG_START_14
self.reslblTitle_value = strings.RID_AGENDAWIZARDDIALOG_START_15
self.reslblLocation_value = strings.RID_AGENDAWIZARDDIALOG_START_16
self.reslblHelp2_value = strings.RID_AGENDAWIZARDDIALOG_START_17
self.resbtnTemplatePath_value = strings.RID_AGENDAWIZARDDIALOG_START_18
self.resoptCreateAgenda_value = strings.RID_AGENDAWIZARDDIALOG_START_19
self.reslblHelp6_value = strings.RID_AGENDAWIZARDDIALOG_START_20
self.reslblTopic_value = strings.RID_AGENDAWIZARDDIALOG_START_21
self.reslblResponsible_value = strings.RID_AGENDAWIZARDDIALOG_START_22
self.reslblDuration_value = strings.RID_AGENDAWIZARDDIALOG_START_23
self.reschkConvenedBy_value = strings.RID_AGENDAWIZARDDIALOG_START_24
self.reschkPresiding_value = strings.RID_AGENDAWIZARDDIALOG_START_25
self.reschkNoteTaker_value = strings.RID_AGENDAWIZARDDIALOG_START_26
self.reschkTimekeeper_value = strings.RID_AGENDAWIZARDDIALOG_START_27
self.reschkAttendees_value = strings.RID_AGENDAWIZARDDIALOG_START_28
self.reschkObservers_value = strings.RID_AGENDAWIZARDDIALOG_START_29
self.reschkResourcePersons_value = strings.RID_AGENDAWIZARDDIALOG_START_30
self.reslblHelp4_value = strings.RID_AGENDAWIZARDDIALOG_START_31
self.reschkMeetingTitle_value = strings.RID_AGENDAWIZARDDIALOG_START_32
self.reschkRead_value = strings.RID_AGENDAWIZARDDIALOG_START_33
self.reschkBring_value = strings.RID_AGENDAWIZARDDIALOG_START_34
self.reschkNotes_value = strings.RID_AGENDAWIZARDDIALOG_START_35
self.reslblHelp3_value = strings.RID_AGENDAWIZARDDIALOG_START_36
self.reslblDate_value = strings.RID_AGENDAWIZARDDIALOG_START_38
self.reslblHelpPg6_value = strings.RID_AGENDAWIZARDDIALOG_START_39
self.reslblPageDesign_value = strings.RID_AGENDAWIZARDDIALOG_START_40
self.resDefaultFilename = strings.RID_AGENDAWIZARDDIALOG_START_41
self.resDefaultFilename = self.resDefaultFilename[:-4] + ".ott"
self.resDefaultTitle = strings.RID_AGENDAWIZARDDIALOG_START_42
self.resErrSaveTemplate = strings.RID_AGENDAWIZARDDIALOG_START_43
self.resPlaceHolderTitle = strings.RID_AGENDAWIZARDDIALOG_START_44
self.resPlaceHolderDate = strings.RID_AGENDAWIZARDDIALOG_START_45
self.resPlaceHolderTime = strings.RID_AGENDAWIZARDDIALOG_START_46
self.resPlaceHolderLocation = strings.RID_AGENDAWIZARDDIALOG_START_47
self.resPlaceHolderHint = strings.RID_AGENDAWIZARDDIALOG_START_48
self.resErrOpenTemplate = strings.RID_AGENDAWIZARDDIALOG_START_56
self.itemMeetingType = strings.RID_AGENDAWIZARDDIALOG_START_57
self.itemBring = strings.RID_AGENDAWIZARDDIALOG_START_58
self.itemRead = strings.RID_AGENDAWIZARDDIALOG_START_59
self.itemNote = strings.RID_AGENDAWIZARDDIALOG_START_60
self.itemCalledBy = strings.RID_AGENDAWIZARDDIALOG_START_61
self.itemFacilitator = strings.RID_AGENDAWIZARDDIALOG_START_62
self.itemAttendees = strings.RID_AGENDAWIZARDDIALOG_START_63
self.itemNotetaker = strings.RID_AGENDAWIZARDDIALOG_START_64
self.itemTimekeeper = strings.RID_AGENDAWIZARDDIALOG_START_65
self.itemObservers = strings.RID_AGENDAWIZARDDIALOG_START_66
self.itemResource = strings.RID_AGENDAWIZARDDIALOG_START_67
self.resButtonInsert = strings.RID_AGENDAWIZARDDIALOG_START_68
self.resButtonRemove = strings.RID_AGENDAWIZARDDIALOG_START_69
self.resButtonUp = strings.RID_AGENDAWIZARDDIALOG_START_70
self.resButtonDown = strings.RID_AGENDAWIZARDDIALOG_START_71
#Create a dictionary for localised string in the template
self.dictConstants = {
"#datetitle#" : strings.RID_AGENDAWIZARDDIALOG_START_72,
"#timetitle#" : strings.RID_AGENDAWIZARDDIALOG_START_73,
"#locationtitle#" : strings.RID_AGENDAWIZARDDIALOG_START_74,
"#topics#" : strings.RID_AGENDAWIZARDDIALOG_START_75,
"#num.#" : strings.RID_AGENDAWIZARDDIALOG_START_76,
"#topicheader#" : strings.RID_AGENDAWIZARDDIALOG_START_77,
"#responsibleheader#" : strings.RID_AGENDAWIZARDDIALOG_START_78,
"#timeheader#" : strings.RID_AGENDAWIZARDDIALOG_START_79,
"#additional-information#" : strings.RID_AGENDAWIZARDDIALOG_START_80,
"#minutes-for#" : strings.RID_AGENDAWIZARDDIALOG_START_81,
"#discussion#" : strings.RID_AGENDAWIZARDDIALOG_START_82,
"#conclusion#" : strings.RID_AGENDAWIZARDDIALOG_START_83,
"#to-do#" : strings.RID_AGENDAWIZARDDIALOG_START_84,
"#responsible-party#" : strings.RID_AGENDAWIZARDDIALOG_START_85,
"#deadline#" : strings.RID_AGENDAWIZARDDIALOG_START_86}
#Create a dictionary for localising the page design
self.dictPageDesign = {
"Blue" : strings.RID_AGENDAWIZARDDIALOG_START_87,
"Classic" : strings.RID_AGENDAWIZARDDIALOG_START_88,
"Colorful" : strings.RID_AGENDAWIZARDDIALOG_START_89,
"Elegant" : strings.RID_AGENDAWIZARDDIALOG_START_90,
"Green" : strings.RID_AGENDAWIZARDDIALOG_START_91,
"Grey" : strings.RID_AGENDAWIZARDDIALOG_START_92,
"Modern" : strings.RID_AGENDAWIZARDDIALOG_START_93,
"Orange" : strings.RID_AGENDAWIZARDDIALOG_START_94,
"Red" : strings.RID_AGENDAWIZARDDIALOG_START_95,
"Simple" : strings.RID_AGENDAWIZARDDIALOG_START_96}
#Common Resources
self.resOverwriteWarning = strings.RID_COMMON_START_19
self.resTemplateDescription = strings.RID_COMMON_START_20
self.RoadmapLabels = []
self.RoadmapLabels.append(strings.RID_AGENDAWIZARDDIALOG_START_50)
self.RoadmapLabels.append(strings.RID_AGENDAWIZARDDIALOG_START_51)
self.RoadmapLabels.append(strings.RID_AGENDAWIZARDDIALOG_START_52)
self.RoadmapLabels.append(strings.RID_AGENDAWIZARDDIALOG_START_53)
self.RoadmapLabels.append(strings.RID_AGENDAWIZARDDIALOG_START_54)
self.RoadmapLabels.append(strings.RID_AGENDAWIZARDDIALOG_START_55)

View File

@@ -0,0 +1,46 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..common.ConfigGroup import ConfigGroup
from ..common.ConfigSet import ConfigSet
from .CGTopic import CGTopic
class CGAgenda(ConfigGroup):
def __init__(self):
self.cp_AgendaType = int()
self.cp_IncludeMinutes = bool()
self.cp_Title = ""
self.cp_Date = str()
self.cp_Time = str()
self.cp_Location = ""
self.cp_ShowMeetingType = bool()
self.cp_ShowRead = bool()
self.cp_ShowBring = bool()
self.cp_ShowNotes = bool()
self.cp_ShowCalledBy = bool()
self.cp_ShowFacilitator = bool()
self.cp_ShowNotetaker = bool()
self.cp_ShowTimekeeper = bool()
self.cp_ShowAttendees = bool()
self.cp_ShowObservers = bool()
self.cp_ShowResourcePersons = bool()
self.cp_TemplateName = str()
self.cp_TemplatePath = str()
self.cp_ProceedMethod = int()
self.cp_Topics = ConfigSet(CGTopic)

View File

@@ -0,0 +1,60 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..common.ConfigGroup import ConfigGroup
'''
CGTopic means: Configuration Group Topic.
This object encapsulates a configuration group with topic information.
Since the topic's gui control uses its own data model, there is
also code here to convert from the data model to CGTopic object (the constructor)
and vice versa (setDataToRow method - used when loading the last session...)
'''
class CGTopic(ConfigGroup):
'''
create a new CGTopic object with data from the given row.
the row object is a PropertyValue array, as used
by the TopicsControl's data model.
@param row PropertyValue array as used by the TopicsControl's data model.
'''
def __init__(self, row=None):
if row is None:
self.cp_Index = int()
self.cp_Topic = str()
self.cp_Responsible = str()
self.cp_Time = str()
else:
self.cp_Index = int(row[0].Value[:-1])
self.cp_Topic = row[1].Value
self.cp_Responsible = row[2].Value
self.cp_Time = row[3].Value
'''
copies the data in this CGTopic object
to the given row.
@param row the row object (PropertyValue array) to
copy the data to.
'''
def setDataToRow(self, row):
row[0].Value = "" + str(self.cp_Index) + "."
row[1].Value = self.cp_Topic
row[2].Value = self.cp_Responsible
row[3].Value = self.cp_Time

View File

@@ -0,0 +1,75 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import unohelper
import traceback
from .AgendaWizardDialogImpl import AgendaWizardDialogImpl, Desktop
from com.sun.star.lang import XServiceInfo
from com.sun.star.task import XJobExecutor
# pythonloader looks for a static g_ImplementationHelper variable
g_ImplementationHelper = unohelper.ImplementationHelper()
g_implName = "com.sun.star.wizards.agenda.CallWizard"
# implement a UNO component by deriving from the standard unohelper.Base class
# and from the interface(s) you want to implement.
class CallWizard(unohelper.Base, XJobExecutor, XServiceInfo):
def __init__(self, ctx):
# store the component context for later use
self.ctx = ctx
def trigger(self, args):
try:
fw = AgendaWizardDialogImpl(self.ctx.ServiceManager)
fw.startWizard(self.ctx.ServiceManager)
except Exception as e:
print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
traceback.format_exc())
@classmethod
def callRemote(self):
#Call the wizard remotely(see README)
try:
ConnectStr = \
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
xLocMSF = Desktop.connect(ConnectStr)
lw = AgendaWizardDialogImpl(xLocMSF)
lw.startWizard(xLocMSF)
except Exception as e:
print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
traceback.format_exc())
def getImplementationName(self):
return g_implName
def supportsService(self, ServiceName):
return g_ImplementationHelper.supportsService(g_implName, ServiceName)
def getSupportedServiceNames(self):
return g_ImplementationHelper.getSupportedServiceNames(g_implName)
g_ImplementationHelper.addImplementation( \
CallWizard, # UNO object class
g_implName, # implementation name
("com.sun.star.task.Job",),) # list of implemented services
# (the only service)
# vim:set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -0,0 +1,83 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class TemplateConsts:
FILLIN_TITLE = "<title>"
FILLIN_TITLE = "<title>"
FILLIN_DATE = "<date>"
FILLIN_TIME = "<time>"
FILLIN_LOCATION = "<location>"
'''
section name <b>prefix</b> for sections that contain items.
this is also used as table name prefix, since each items section
must contain a table whose name is identical name to the section's name.
'''
SECTION_ITEMS = "AGENDA_ITEMS"
'''
the name of the section which contains the topics.
'''
SECTION_TOPICS = "AGENDA_TOPICS"
'''
the name of the parent minutes section.
'''
SECTION_MINUTES_ALL = "MINUTES_ALL"
'''
the name of the child minutes section.
This section will be duplicated for each topic.
'''
SECTION_MINUTES = "MINUTES"
'''
tagged headings and names.
These will be searched in item tables (in the template) and will be
replaced with resource strings.
headings...
'''
FILLIN_MEETING_TYPE = "<meeting-type>"
FILLIN_BRING = "<bring>"
FILLIN_READ = "<read>"
FILLIN_NOTES = "<notes>"
'''
names...
'''
FILLIN_CALLED_BY = "<called-by>"
FILLIN_FACILITATOR = "<facilitator>"
FILLIN_PARTICIPANTS = "<attendees>"
FILLIN_NOTETAKER = "<notetaker>"
FILLIN_TIMEKEEPER = "<timekeeper>"
FILLIN_OBSERVERS = "<observers>"
FILLIN_RESOURCE_PERSONS = "<resource-persons>"
'''
fillins for minutes.
These will be searched in the minutes section and will be replaced
with the appropriate data.
'''
FILLIN_MINUTES_TITLE = "<minutes-title>"
FILLIN_MINUTES_LOCATION = "<minutes-location>"
FILLIN_MINUTES_DATE = "<minutes-date>"
FILLIN_MINUTES_TIME = "<minutes-time>"
'''
Minutes-topic fillins
These will be searched in the minutes-child-section, and
will be replaced with topic data.
'''
FILLIN_MINUTE_NUM = "<mnum>"
FILLIN_MINUTE_TOPIC = "<mtopic>"
FILLIN_MINUTE_RESPONSIBLE = "<mresponsible>"
FILLIN_MINUTE_TIME = "<mtime>"

View File

@@ -0,0 +1,857 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
from ..ui.ControlScroller import ControlScroller, PropertyNames, traceback, \
HelpIds
from .AgendaWizardDialogConst import HID
from ..common.Properties import Properties
from ..ui.event.CommonListener import FocusListenerProcAdapter, \
KeyListenerProcAdapter
from com.sun.star.awt.Key import DOWN, UP, TAB
from com.sun.star.awt.KeyModifier import SHIFT, MOD1
'''
This class implements the UI functionality of the topics scroller control.
<br/>
During development, there has been a few changes which were not *fully* done
mainly in converting the topics and time boxes
from combobox and time box to normal textboxes,
so in the code they might be referenced as combobox or timebox. This should be
rather understood as topicstextbox and timetextbox.<br/><br/>
Important behaviour of this control is that there is always a
blank row at the end, in which the user can enter data.<br/>
Once the row is not blank (thus, the user entered data...),
a new blank row is added.<br/>
Once the user removes the last *unempty* row, binsertRowy deleting its data, it becomes
the *last empty row* and the one after is being automatically removed.<br/><br/>
The control shows 5 rows at a time.<br/>
If, for example, only 2 rows exist (from which the 2ed one is empty...)
then the other three rows, which do not exist in the data model, are disabled.
<br/>
The following other functionality is implemented:
<br/>
0. synchronizing data between controls, data model and live preview.
1. Tab scrolling.<br/>
2. Keyboard scrolling.<br/>
3. Removing rows and adding new rows.<br/>
4. Moving rows up and down. <br/>
<br/>
This control relays on the ControlScroller control which uses the following
Data model:<br/>
1. It uses a vector, whose members are arrays of PropertyValue.<br/>
2. Each array represents a row.<br/>
(Note: the Name and Value members of the PropertyValue object are being used)
3. Each property Value represents a value
for a single control with the following rules:<br/>
3. a. the Value of the property is used for as value
of the controls (usually text).<br/>
3. b. the Name of the property is used to map values
to UI controls in the following manner:<br/>
3. b. 1. only the Name of the first X Rows is regarded,
where X is the number of visible rows (in the ainsertRowgenda wizard this would be 5,
since 5 topic rows are visible on the dialog).<br/>
3. b. 2. The Names of the first X (or 5...) rows are the names
of the UI Controls to hold values. When the control scroller scrolls,
it looks at the first 5 rows and uses the names specified there to map the
current values to the specified controls. <br/>
This data model makes the following limitations on the implementation:
When moving rows, only the values should be moved. The Rows objects,
which contain also the Names of the controls should not be switched. <br/>
also when deleting or inserting rows, attention should be paid that no rows
should be removed or inserted. Instead, only the Values should rotate. <br/><br/>
To save the topics in the registry a ConfigSet of objects of type CGTopic is
being used.
This one is not synchronized "live", since it is unnecessary... instead, it is
synchronized on call, before the settings should be saved.
'''
class TopicsControl(ControlScroller):
LABEL = "lblTopicCnt_"
TOPIC = "txtTopicTopic_"
RESP = "cbTopicResp_"
TIME = "txtTopicTime_"
LABEL_PROPS = (PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
TEXT_PROPS = (PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
def __init__(self, dialog, xmsf, agenda):
try:
super(TopicsControl, self).__init__(
dialog, xmsf, 5, 92, 38, 212, 5, 18, HID + 32)
self.dialog = dialog
#fill preview's table
self.initializeScrollFields(agenda)
#fill gui's table
self.fillupControls(True)
self.nscrollvalue = 0
self.lastFocusRow = 0
self.lastFocusControl = None
# set some focus listeners for TAB scroll down and up...
# prepare scroll down on tab press...
self.lastTime = \
self.ControlGroupVector[self.nblockincrement - 1].timebox
self.lastTime.addKeyListener(KeyListenerProcAdapter(
self.lastControlKeyPressed))
#prepare scroll up on tab press...
self.firstTopic = self.ControlGroupVector[0].textbox
self.firstTopic.addKeyListener(KeyListenerProcAdapter(
self.firstControlKeyPressed))
self.enableButtons()
except Exception:
traceback.print_exc()
'''
initializes the data of the control.
'''
def initializeScrollFields(self, agenda):
# create a row for each topic with the given values...
for index,item in enumerate(agenda.cp_Topics.childrenList):
row = self.newRow(index)
item.setDataToRow(row)
# a parent class method
self.registerControlGroup(row, index)
self.updateDocumentRow(index)
# inserts a blank row at the end...
self.insertRowAtEnd()
'''
Insert a blank (empty) row
as last row of the control.
The control has always a blank row at the
end, which enables the user to enter data...
'''
def insertRowAtEnd(self):
l = len(self.scrollfields)
self.registerControlGroup(self.newRow(l), l)
self.setTotalFieldCount(l + 1)
# if the new row is visible, it must have been disabled
# so it should be now enabled...
if l - self.nscrollvalue < self.nblockincrement:
self.ControlGroupVector[l - self.nscrollvalue].\
setEnabled(True)
def saveTopics(self, agenda):
# last row is always empty
agenda.cp_Topics.childrenList = self.scrollfields[:-1]
'''
remove the last row
'''
def removeLastRow(self):
l = len(self.scrollfields)
# if we should scroll up...
if (l - self.nscrollvalue) >= 1 \
and (l - self.nscrollvalue) <= self.nblockincrement \
and self.nscrollvalue > 0:
while (l - self.nscrollvalue >= 1) \
and l - self.nscrollvalue <= self.nblockincrement \
and self.nscrollvalue > 0:
self.setScrollValue(self.nscrollvalue - 1)
# if we should disable a row...
elif self.nscrollvalue == 0 and l - 1 < self.nblockincrement:
self.ControlGroupVector[l - 1].setEnabled(False)
self.unregisterControlGroup(l - 1)
self.setTotalFieldCount(l - 1)
'''
in order to use the "move up", "down" "insert" and "remove" buttons,
we track the last control the gained focus, in order to know which
row should be handled.
@param fe
'''
def focusGained(self, fe):
xc = fe.Source
self.focusGained2(xc)
'''
Sometimes I set the focus programmatically to a control
(for example when moving a row up or down, the focus should move
with it).
In such cases, no VCL event is being triggered so it must
be called programmatically.
This is done by this method.
@param control
'''
def focusGained2(self, control):
try:
#calculate in which row we are...
name = control.Model.Name
num = name[name.index("_") + 1:]
self.lastFocusRow = int(num) + self.nscrollvalue
self.lastFocusControl = control
# enable/disable the buttons...
self.enableButtons()
except Exception:
traceback.print_exc()
'''
enable or disable the buttons according to the
current row we are in.
'''
def enableButtons(self):
self.CurUnoDialog.btnInsert.Model.Enabled = \
self.lastFocusRow < len(self.scrollfields)
self.CurUnoDialog.btnRemove.Model.Enabled = \
self.lastFocusRow < len(self.scrollfields) - 1
if self.lastFocusControl is not None:
self.CurUnoDialog.btnUp.Model.Enabled = self.lastFocusRow > 0
self.CurUnoDialog.btnDown.Model.Enabled = \
self.lastFocusRow < len(self.scrollfields) - 1
else:
self.CurUnoDialog.btnUp.Model.Enabled = False
self.CurUnoDialog.btnDown.Model.Enabled = False
'''
Removes the current row.
See general class documentation explanation about the
data model used and the limitations which explain the implementation here.
'''
def removeRow(self):
try:
for i in range(self.lastFocusRow,
len(self.scrollfields) - 1):
pv1 = self.scrollfields[i]
pv2 = self.scrollfields[i + 1]
pv1[1].Value = pv2[1].Value
pv1[2].Value = pv2[2].Value
pv1[3].Value = pv2[3].Value
self.updateDocumentRow(i)
if i - self.nscrollvalue < self.nblockincrement:
self.fillupControl(i - self.nscrollvalue)
self.removeLastRow()
# update the live preview background document
self.reduceDocumentToTopics()
self.enableButtons()
if self.lastFocusControl is not None:
# the focus should return to the edit control
self.focus(self.lastFocusControl)
except Exception:
traceback.print_exc()
'''
Inserts a row before the current row.
See general class documentation explanation about the
data model used and the limitations which explain the implementation here.
'''
def insertRow(self):
try:
self.insertRowAtEnd()
for i in range(len(self.scrollfields) - 2,
self.lastFocusRow, -1):
pv1 = self.scrollfields[i]
pv2 = self.scrollfields[i - 1]
pv1[1].Value = pv2[1].Value
pv1[2].Value = pv2[2].Value
pv1[3].Value = pv2[3].Value
self.updateDocumentRow(i)
if i - self.nscrollvalue < self.nblockincrement:
self.fillupControl(i - self.nscrollvalue)
# after rotating all the properties from this row on,
# we clear the row, so it is practically a new one...
pv1 = self.scrollfields[self.lastFocusRow]
pv1[1].Value = ""
pv1[2].Value = ""
pv1[3].Value = ""
# update the preview document.
self.updateDocumentRow(self.lastFocusRow)
self.fillupControl(
self.lastFocusRow - self.nscrollvalue)
self.enableButtons()
if self.lastFocusControl is not None:
self.focus(self.lastFocusControl)
except Exception:
traceback.print_exc()
'''
create a new row with the given index.
The index is important because it is used in the
Name member of the PropertyValue objects.
To know why see general class documentation above (data model explanation)
@param i the index of the new row
@return
'''
def newRow(self, i):
pv = list(range(4))
pv[0] = Properties.createProperty(
TopicsControl.LABEL + str(i), "" + str(i + 1) + ".")
pv[1] = Properties.createProperty(TopicsControl.TOPIC + str(i), "")
pv[2] = Properties.createProperty(TopicsControl.RESP + str(i), "")
pv[3] = Properties.createProperty(TopicsControl.TIME + str(i), "")
return pv
'''
Implementation of ControlScroller
This is a UI method which inserts a new row to the control.
It uses the child-class ControlRow. (see below).
'''
def insertControlGroup(self, _index, npos):
oControlRow = ControlRow(
self.CurUnoDialog, self.iCompPosX, npos, _index,
ControlRow.tabIndex, self)
self.ControlGroupVector.append(oControlRow)
ControlRow.tabIndex += 4
'''
Checks if a row is empty.
This is used when the last row is changed.
If it is empty, the next row (which is always blank) is removed.
If it is not empty, a next row must exist.
@param row the index number of the row to check.
@return true if empty. false if not.
'''
def isRowEmpty(self, row):
data = self.getTopicData(row)
# now - is this row empty?
return not data[1].Value and not data[2].Value and not data[3].Value
'''
update the preview document and
remove/insert rows if needed.
@param guiRow
@param column
'''
def fieldChanged(self, guiRow, column):
try:
# First, I update the document
data = self.getTopicData(guiRow + self.nscrollvalue)
if data is None:
return
self.updateDocumentCell(
guiRow + self.nscrollvalue, column, data)
if self.isRowEmpty(guiRow + self.nscrollvalue):
'''
if this is the row before the last one
(the last row is always empty)
delete the last row...
'''
if (guiRow + self.nscrollvalue) \
== len(self.scrollfields) - 2:
self.removeLastRow()
'''now consequently check the last two rows,
and remove the last one if they are both empty.
(actually I check always the "before last" row,
because the last one is always empty...
'''
while len(self.scrollfields) > 1 \
and self.isRowEmpty(
len(self.scrollfields) - 2):
self.removeLastRow()
cr = self.ControlGroupVector[
len(self.scrollfields) - \
self.nscrollvalue - 1]
# if a remove was performed, set focus
#to the last row with some data in it...
self.focus(self.getControlByIndex(cr, column))
# update the preview document.
self.reduceDocumentToTopics()
else:
# row contains data
# is this the last row?
if (guiRow + self.nscrollvalue + 1) \
== len(self.scrollfields):
self.insertRowAtEnd()
except Exception:
traceback.print_exc()
'''
return the corresponding row data for the given index.
@param topic index of the topic to get.
@return a PropertyValue array with the data for the given topic.
'''
def getTopicData(self, topic):
if topic < len(self.scrollfields):
return self.scrollfields[topic]
else:
return None
'''
If the user presses tab on the last control, and
there *are* more rows in the model, scroll down.
@param event
'''
def lastControlKeyPressed(self, event):
# if tab without shift was pressed...
try:
if event.KeyCode == TAB and event.Modifiers == 0:
# if there is another row...
if (self.nblockincrement + self.nscrollvalue) \
< len(self.scrollfields):
self.setScrollValue(self.nscrollvalue + 1)
self.focus(self.getControlByIndex(self.ControlGroupVector[4], 1))
except Exception:
traceback.print_exc()
'''
If the user presses shift-tab on the first control, and
there *are* more rows in the model, scroll up.
@param event
'''
def firstControlKeyPressed(self, event):
# if tab with shift was pressed...
if (event.KeyCode == TAB) and \
(event.Modifiers == SHIFT):
if self.nscrollvalue > 0:
self.setScrollValue(self.nscrollvalue - 1)
self.focus(self.lastTime)
'''
sets focus to the given control.
@param textControl
'''
def focus(self, textControl):
textControl.setFocus()
text = textControl.Text
textControl.Selection = uno.createUnoStruct( \
'com.sun.star.awt.Selection', 0, len(text))
self.focusGained2(textControl)
'''
moves the given row one row down.
@param guiRow the gui index of the row to move.
@param control the control to gain focus after moving.
'''
def rowDown(self, guiRow=None, control=None):
try:
if guiRow is None:
guiRow = self.lastFocusRow - self.nscrollvalue
if control is None:
control = self.lastFocusControl
# only perform if this is not the last row.
actuallRow = guiRow + self.nscrollvalue
if actuallRow + 1 < len(self.scrollfields):
# get the current selection
selection = control.Selection
# the last row should scroll...
scroll = (guiRow == self.nblockincrement - 1)
if scroll:
self.setScrollValue(self.nscrollvalue + 1)
scroll1 = self.nscrollvalue
if scroll:
aux = -1
else:
aux = 1
self.switchRows(guiRow, guiRow + aux)
if self.nscrollvalue != scroll1:
guiRow += (self.nscrollvalue - scroll1)
self.setSelection(guiRow + (not scroll), control, selection)
except Exception:
traceback.print_exc()
'''
move the current row up
'''
def rowUp(self, guiRow=None, control=None):
try:
if guiRow is None:
guiRow = self.lastFocusRow - self.nscrollvalue
if control is None:
control = self.lastFocusControl
# only perform if this is not the first row
actuallRow = guiRow + self.nscrollvalue
if actuallRow > 0:
# get the current selection
selection = control.Selection
# the last row should scroll...
scroll = (guiRow == 0)
if scroll:
self.setScrollValue(self.nscrollvalue - 1)
if scroll:
aux = 1
else:
aux = -1
self.switchRows(guiRow, guiRow + aux)
self.setSelection(guiRow - (not scroll), control, selection)
except Exception:
traceback.print_exc()
'''
moves the cursor up.
@param guiRow
@param control
'''
def cursorUp(self, guiRow, control):
# is this the last full row ?
actuallRow = guiRow + self.nscrollvalue
#if this is the first row
if actuallRow == 0:
return
# the first row should scroll...
scroll = (guiRow == 0)
if scroll:
self.setScrollValue(self.nscrollvalue - 1)
upperRow = self.ControlGroupVector[guiRow]
else:
upperRow = self.ControlGroupVector[guiRow - 1]
self.focus(self.getControl(upperRow, control))
'''
moves the cursor down
@param guiRow
@param control
'''
def cursorDown(self, guiRow, control):
# is this the last full row ?
actuallRow = guiRow + self.nscrollvalue
#if this is the last row, exit
if actuallRow == len(self.scrollfields) - 1:
return
# the first row should scroll...
scroll = (guiRow == self.nblockincrement - 1)
if scroll:
self.setScrollValue(self.nscrollvalue + 1)
lowerRow = self.ControlGroupVector[guiRow]
else:
# if we scrolled we are done...
#otherwise...
lowerRow = self.ControlGroupVector[guiRow + 1]
self.focus(self.getControl(lowerRow, control))
'''
changes the values of the given rows with each other
@param row1 one can figure out what this parameter is...
@param row2 one can figure out what this parameter is...
'''
def switchRows(self, row1, row2):
o1 = self.scrollfields[row1 + self.nscrollvalue]
o2 = self.scrollfields[row2 + self.nscrollvalue]
temp = None
for i in range(1, len(o1)):
temp = o1[i].Value
o1[i].Value = o2[i].Value
o2[i].Value = temp
self.fillupControl(row1)
self.fillupControl(row2)
self.updateDocumentRow(row1 + self.nscrollvalue, o1)
self.updateDocumentRow(row2 + self.nscrollvalue, o2)
'''
if we changed the last row, add another one...
'''
if (row1 + self.nscrollvalue + 1 == \
len(self.scrollfields)) \
or (row2 + self.nscrollvalue + 1 == \
len(self.scrollfields)):
self.insertRowAtEnd()
'''
if we did not change the last row but
we did change the one before - check if we
have two empty rows at the end.
If so, delete the last one...
'''
elif (row1 + self.nscrollvalue) + \
(row2 + self.nscrollvalue) \
== (len(self.scrollfields) * 2 - 5):
if self.isRowEmpty(len(self.scrollfields) - 2) \
and self.isRowEmpty(
len(self.scrollfields) - 1):
self.removeLastRow()
self.reduceDocumentToTopics()
'''
sets a text selection to a given control.
This is used when one moves a row up or down.
After moving row X to X+/-1, the selection (or cursor position) of the
last focused control should be restored.
The control's row is the given guiRow.
The control's column is detected according to the given event.
This method is called as subsequent to different events,
thus it is comfortable to use the event here to detect the column,
rather than in the different event methods.
@param guiRow the row of the control to set the selection to.
@param eventSource helps to detect
the control's column to set the selection to.
@param s the selection object to set.
'''
def setSelection(self, guiRow, eventSource, s):
cr = self.ControlGroupVector[guiRow]
control = self.getControl(cr, eventSource)
control.setFocus()
control.setSelection(s)
'''
returns a control out of the given row, according to a column number.
@param cr control row object.
@param column the column number.
@return the control...
'''
def getControlByIndex(self, cr, column):
tmp_switch_var1 = column
if tmp_switch_var1 == 0:
return cr.label
elif tmp_switch_var1 == 1:
return cr.textbox
elif tmp_switch_var1 == 2:
return cr.combobox
elif tmp_switch_var1 == 3:
return cr.timebox
else:
raise Exception("No such column");
'''getControl
returns a control out of the given row, which is
in the same column as the given control.
@param cr control row object
@param control a control indicating a column.
@return
'''
def getControl(self, cr, control):
column = self.getColumn(control)
return self.getControlByIndex(cr, column)
'''
returns the column number of the given control.
@param control
@return
'''
def getColumn(self, control):
name = control.Model.Name
if name.startswith(TopicsControl.TOPIC):
return 1
if name.startswith(TopicsControl.RESP):
return 2
if name.startswith(TopicsControl.TIME):
return 3
if name.startswith(TopicsControl.LABEL):
return 0
return -1
'''
update the given row in the preview document with the given data.
@param row
@param data
'''
def updateDocumentRow(self, row, data=None):
if data is None:
data = self.scrollfields[row]
try:
for i in range(len(data)):
self.CurUnoDialog.myAgendaDoc.topics.writeCell(
row, i, data)
except Exception:
traceback.print_exc()
'''
updates a single cell in the preview document.
Is called when a single value is changed, since we really
don't have to update the whole row for one small change...
@param row the data row to update (topic number).
@param column the column to update (a gui column, not a document column).
@param data the data of the entire row.
'''
def updateDocumentCell(self, row, column, data):
try:
self.CurUnoDialog.myAgendaDoc.topics.writeCell(
row, column, data)
except Exception:
traceback.print_exc()
'''
when removing rows, this method updates
the preview document to show the number of rows
according to the data model.
'''
def reduceDocumentToTopics(self):
try:
self.CurUnoDialog.myAgendaDoc.topics.reduceDocumentTo(
len(self.scrollfields) - 1)
except Exception:
traceback.print_exc()
'''
A class represting a single GUI row.
Note that the instance methods of this class
are being called and handle controls of
a single row.
'''
class ControlRow(object):
tabIndex = 520
'''
constructor. Create the row in the given dialog given coordinates,
with the given offset (row number) and tabindex.
Note that since I use this specifically for the agenda wizard,
the step and all control coordinates inside the
row are constant (5).
'''
def __init__(self, dialog, x, y, i, tabindex, topicsControl):
self.offset = i
self.dialog = dialog
self.topicsControl = topicsControl
self.label = self.dialog.insertLabel(
self.topicsControl.LABEL + str(i),
self.topicsControl.LABEL_PROPS,
(8, "" + str(i + 1) + ".",
x + 4, y + 2, self.topicsControl.iStep, tabindex, 10))
self.textbox = self.dialog.insertTextField(
self.topicsControl.TOPIC + str(i), "topicTextChanged",
self.topicsControl.TEXT_PROPS,
(12, HelpIds.getHelpIdString(self.topicsControl.curHelpIndex + i * 3 + 1),
x + 15, y, self.topicsControl.iStep, tabindex + 1, 84), self)
self.combobox = self.dialog.insertTextField(
self.topicsControl.RESP + str(i), "responsibleTextChanged",
self.topicsControl.TEXT_PROPS,
(12, HelpIds.getHelpIdString(self.topicsControl.curHelpIndex + i * 3 + 2),
x + 103, y, self.topicsControl.iStep, tabindex + 2, 68), self)
self.timebox = self.dialog.insertTextField(
self.topicsControl.TIME + str(i), "timeTextChanged",
self.topicsControl.TEXT_PROPS,
(12, HelpIds.getHelpIdString(self.topicsControl.curHelpIndex + i * 3 + 3),
x + 175, y, self.topicsControl.iStep, tabindex + 3, 20), self)
self.setEnabled(False)
self.textbox.addKeyListener(KeyListenerProcAdapter(self.keyPressed))
self.combobox.addKeyListener(KeyListenerProcAdapter(self.keyPressed))
self.timebox.addKeyListener(KeyListenerProcAdapter(self.keyPressed))
self.textbox.addFocusListener(FocusListenerProcAdapter(
self.topicsControl.focusGained))
self.combobox.addFocusListener(FocusListenerProcAdapter(
self.topicsControl.focusGained))
self.timebox.addFocusListener(FocusListenerProcAdapter(
self.topicsControl.focusGained))
def topicTextChanged(self):
try:
# update the data model
self.topicsControl.fieldInfo(self.offset, 1)
# update the preview document
self.topicsControl.fieldChanged(self.offset, 1)
except Exception:
traceback.print_exc()
'''
called through an event listener when the
responsible text is changed by the user.
updates the data model and the preview document.
'''
def responsibleTextChanged(self):
try:
# update the data model
self.topicsControl.fieldInfo(self.offset, 2)
# update the preview document
self.topicsControl.fieldChanged(self.offset, 2)
except Exception:
traceback.print_exc()
'''
called through an event listener when the
time text is changed by the user.
updates the data model and the preview document.
'''
def timeTextChanged(self):
try:
# update the data model
self.topicsControl.fieldInfo(self.offset, 3)
# update the preview document
self.topicsControl.fieldChanged(self.offset, 3)
except Exception:
traceback.print_exc()
'''
enables/disables the row.
@param enabled true for enable, false for disable.
'''
def setEnabled(self, enabled):
self.label.Model.Enabled = enabled
self.textbox.Model.Enabled = enabled
self.combobox.Model.Enabled = enabled
self.timebox.Model.Enabled = enabled
'''
Implementation of XKeyListener.
Optionally performs the one of the following:
cursor up, or down, row up or down
'''
def keyPressed(self, event):
try:
if self.isMoveDown(event):
self.topicsControl.rowDown(self.offset, event.Source)
elif self.isMoveUp(event):
self.topicsControl.rowUp(self.offset, event.Source)
elif self.isDown(event):
self.topicsControl.cursorDown(self.offset, event.Source)
elif self.isUp(event):
self.topicsControl.cursorUp(self.offset, event.Source)
self.topicsControl.enableButtons()
except Exception:
traceback.print_exc()
def isMoveDown(self, e):
return (e.KeyCode == DOWN) and (e.Modifiers == MOD1)
def isMoveUp(self, e):
return (e.KeyCode == UP) and (e.Modifiers == MOD1)
def isDown(self, e):
return (e.KeyCode == DOWN) and (e.Modifiers == 0)
def isUp(self, e):
return (e.KeyCode == UP) and (e.Modifiers == 0)

View File

@@ -0,0 +1,59 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import inspect
class ConfigGroup(object):
root = None
def __init__(self):
self.root = None
def writeConfiguration(self, configurationView, param):
for name,data in inspect.getmembers(self):
if name.startswith(param):
self.writeField( name, configurationView, param)
def writeField(self, field, configView, prefix):
propertyName = field[len(prefix):]
child = getattr(self, field)
if isinstance(child, ConfigGroup):
child.writeConfiguration(configView.getByName(propertyName),
prefix)
else:
setattr(configView,propertyName,getattr(self,field))
def readConfiguration(self, configurationView, param):
for name,data in inspect.getmembers(self):
if name.startswith(param):
self.readField( name, configurationView, param)
def readField(self, field, configView, prefix):
propertyName = field[len(prefix):]
child = getattr(self, field)
if isinstance(child, ConfigGroup):
child.setRoot(self.root);
child.readConfiguration(configView.getByName(propertyName),
prefix)
else:
value = configView.getByName(propertyName)
if value is not None:
setattr(self,field, value)
def setRoot(self, newRoot):
self.root = newRoot

View File

@@ -0,0 +1,67 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
from .ConfigGroup import ConfigGroup
class ConfigSet(ConfigGroup):
'''
After reading the configuration set items,
the ConfigSet checks this field.
If it is true, it will remove any nulls from
the vector.
subclasses can change this field in the constructor
to avoid this "deletion" of nulls.
'''
def __init__(self, childType):
self.childType = childType
self.childrenList = []
self.childrenListLen = 0
def writeConfiguration(self, configurationView, param):
for i in range(self.childrenListLen):
#remove previous configuration
configurationView.removeByName(i)
for index,item in enumerate(self.childrenList):
try:
childView = configurationView.createInstance()
configurationView.insertByName(index, childView)
if callable( self.childType ):
topic = self.childType()
topic.cp_Index = item[0].Value
topic.cp_Topic = item[1].Value
topic.cp_Responsible = item[2].Value
topic.cp_Time = item[3].Value
topic.writeConfiguration(childView, param)
except Exception:
traceback.print_exc()
def readConfiguration(self, configurationView, param):
#each iteration represents a Topic row
names = configurationView.ElementNames
if names:
for i in names:
try:
if callable( self.childType ):
topic = self.childType()
topic.readConfiguration(
configurationView.getByName(i), param)
self.childrenList.append(topic)
except Exception:
traceback.print_exc()
self.childrenListLen = len(self.childrenList)

View File

@@ -0,0 +1,70 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
import traceback
class Configuration(object):
'''This class gives access to the OO configuration api.'''
@classmethod
def getConfigurationRoot(self, xmsf, sPath, updateable):
oConfigProvider = xmsf.createInstance(
"com.sun.star.configuration.ConfigurationProvider")
args = []
aPathArgument = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
aPathArgument.Name = "nodepath"
aPathArgument.Value = sPath
args.append(aPathArgument)
if updateable:
sView = "com.sun.star.configuration.ConfigurationUpdateAccess"
else:
sView = "com.sun.star.configuration.ConfigurationAccess"
return oConfigProvider.createInstanceWithArguments(sView, tuple(args))
@classmethod
def getProductName(self, xMSF):
try:
oProdNameAccess = self.getConfigurationRoot(xMSF, "org.openoffice.Setup/Product", False);
return oProdNameAccess.getByName("ooName")
except Exception:
traceback.print_exc()
return "Unknown"
@classmethod
def getNode(self, name, parent):
return parent.getByName(name)
@classmethod
def commit(self, configView):
configView.commitChanges()
@classmethod
def getInt(self, name, parent):
o = getNode(name, parent)
if (com.sun.star.uno.AnyConverter.isVoid(o)):
return 0
return com.sun.star.uno.AnyConverter.toInt(o)
@classmethod
def set(self, value, name, parent):
parent.setHierarchicalPropertyValue(name, value)

View File

@@ -0,0 +1,96 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
import traceback
from com.sun.star.frame.FrameSearchFlag import ALL
from com.sun.star.util import URL
from com.sun.star.i18n.KParseTokens import ANY_LETTER_OR_NUMBER, ASC_UNDERSCORE
class Desktop(object):
@classmethod
def getDesktop(self, xMSF):
xDesktop = None
if xMSF is not None:
try:
xDesktop = xMSF.createInstance( "com.sun.star.frame.Desktop")
except Exception:
traceback.print_exc()
else:
print ("Can't create a desktop. null pointer !")
return xDesktop
@classmethod
def getActiveFrame(self, xMSF):
xDesktop = self.getDesktop(xMSF)
return xDesktop.getActiveFrame()
@classmethod
def getDispatcher(self, xMSF, xFrame, _stargetframe, oURL):
try:
xDispatch = xFrame.queryDispatch(oURL, _stargetframe, ALL)
return xDispatch
except Exception:
traceback.print_exc()
return None
@classmethod
def connect(self, connectStr):
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext)
ctx = resolver.resolve( connectStr )
orb = ctx.ServiceManager
return orb
@classmethod
def getIncrementSuffix(self, xElementContainer, sElementName):
bElementexists = True
i = 1
sIncSuffix = ""
BaseName = sElementName
while bElementexists:
try:
bElementexists = xElementContainer.hasByName(sElementName)
except:
bElementexists = xElementContainer.hasByHierarchicalName(
sElementName)
if bElementexists:
i += 1
sElementName = BaseName + str(i)
if i > 1:
sIncSuffix = str(i)
return sIncSuffix
'''
Checks if the passed Element Name already exists in the ElementContainer.
If yes it appends a suffix to make it unique
@param xElementContainer
@param sElementName
@return a unique Name ready to be added to the container.
'''
@classmethod
def getUniqueName(self, xElementContainer, sElementName):
sIncSuffix = self.getIncrementSuffix(xElementContainer, sElementName)
return sElementName + sIncSuffix

View File

@@ -0,0 +1,226 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
from os import sep as FileSeparator
'''
This class delivers static convenience methods
to use with ucb SimpleFileAccess service.
You can also instantiate the class, to encapsulate
some functionality of SimpleFileAccess. The instance
keeps a reference to an XSimpleFileAccess and an
XFileIdentifierConverter, saves the permanent
overhead of querying for those interfaces, and delivers
convenience methods for using them.
These Convenience methods include mainly Exception-handling.
'''
class FileAccess(object):
def __init__(self, xmsf):
#get the file identifier converter
self.filenameConverter = xmsf.createInstance(
"com.sun.star.ucb.FileContentProvider")
self.xInterface = xmsf.createInstance(
"com.sun.star.ucb.SimpleFileAccess")
@classmethod
def deleteLastSlashfromUrl(self, _sPath):
if _sPath.endswith("/"):
return _sPath[:-1]
else:
return _sPath
'''
Further information on arguments value see in OO Developer Guide,
chapter 6.2.7
@param xMSF
@param sPath
@param xSimpleFileAccess
@return the respective path of the office application.
A probable following "/" at the end is trimmed.
'''
@classmethod
def getOfficePath(self, xMSF, sPath, xSimpleFileAccess):
try:
ResultPath = ""
xInterface = xMSF.createInstance("com.sun.star.util.PathSettings")
ResultPath = str(getattr(xInterface, sPath))
ResultPath = self.deleteLastSlashfromUrl(ResultPath)
return ResultPath
except Exception:
traceback.print_exc()
return ""
@classmethod
def getFolderTitles(self, xMSF, FilterName, FolderName, resDict=None):
#Returns and ordered dict containing the template's name and path
locLayoutFiles = []
try:
xDocInterface = xMSF.createInstance(
"com.sun.star.document.DocumentProperties")
xInterface = xMSF.createInstance(
"com.sun.star.ucb.SimpleFileAccess")
nameList = xInterface.getFolderContents(FolderName, False)
if FilterName is None or FilterName == "":
FilterName = None
else:
FilterName += "-"
locLayoutDict = {}
for i in nameList:
fileName = self.getFilename(i)
if FilterName is None or fileName.startswith(FilterName):
xDocInterface.loadFromMedium(i, tuple())
if resDict is None:
title = xDocInterface.Title
else:
if xDocInterface.Title in resDict:
# localise string at runtime
title = resDict[xDocInterface.Title]
else:
title = xDocInterface.Title
locLayoutDict[title] = i
#sort the dictionary and create a list containing the
#keys list and the values list
keysList = sorted(locLayoutDict.keys())
valuesList= []
for i in keysList:
valuesList.append(locLayoutDict[i])
locLayoutFiles.append(keysList)
locLayoutFiles.append(valuesList)
except Exception:
traceback.print_exc()
return locLayoutFiles
@classmethod
def getTitle(self, xMSF, _sFile):
sTitle = ""
try:
xDocInterface = xMSF.createInstance(
"com.sun.star.document.DocumentProperties")
noArgs = []
xDocInterface.loadFromMedium(_sFile, noArgs)
sTitle = xDocInterface.getTitle()
except Exception:
traceback.print_exc()
return sTitle
def getPath(self, parentURL, childURL):
string = ""
if childURL is not None and childURL != "":
string = "/" + childURL
return self.filenameConverter.getSystemPathFromFileURL(
parentURL + string)
def copy(self, source, target):
try:
self.xInterface.copy(source, target)
return True
except Exception:
traceback.print_exc()
return False
def exists(self, filename, default):
try:
return self.xInterface.exists(filename)
except Exception:
traceback.print_exc()
return default
def delete(self, filename):
try:
self.xInterface.kill(filename)
return True
except Exception:
traceback.print_exc()
return False
# lists the files in a given directory
# @param dir
# @param includeFolders
# @return
def listFiles(self, folder, includeFolders):
try:
return self.xInterface.getFolderContents(folder, includeFolders)
except Exception:
traceback.print_exc()
return [""]
def getSize(self, url):
try:
return self.xInterface.getSize(url)
except Exception:
traceback.print_exc()
return -1
def getURL(self, parentURL, childPath):
if len(childPath) > 0 and childPath[0] == "/":
path = parentURL + childPath
else:
path = parentURL + "/" + childPath
return path
@classmethod
def getFilename(self, path, pathSeparator = "/"):
return path.split(pathSeparator)[-1]
'''
if the path points to file, gives the directory in which the file is.
'''
@classmethod
def getParentDir(self, url):
while url[-1] == "/":
url = url[:-1]
return url[:url.rfind("/")]
@classmethod
def connectURLs(self, urlFolder, urlFilename):
stringFolder = ""
stringFileName = urlFilename
if not urlFolder.endswith("/"):
stringFolder = "/"
if urlFilename.startswith("/"):
stringFileName = urlFilename[1:]
return urlFolder + stringFolder + stringFileName
# @param filename
# @return the extension of the given filename.
@classmethod
def getExtension(self, filename):
p = filename.find(".")
if (p == -1):
return ""
else:
while (True):
filename = filename[(p+1):]
p = filename.find(".")
if (p == -1):
break
return filename
@classmethod
def filename(self, name, ext, i):
return name + ("" if (i == 0) else str(i)) + ("" if (ext == "") else ("." + ext))

View File

@@ -0,0 +1,28 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
from abc import abstractmethod
# A General interface which gives a string
# that represents the rendered argument object.
# Can be used to reference resources, internationalizartion
# a.s.o
class IRenderer:
@abstractmethod
def render(object):
pass

View File

@@ -0,0 +1,35 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from abc import abstractmethod
class ListModel(object):
@abstractmethod
def getSize(self):
pass
@abstractmethod
def getElementAt(self, arg0):
pass
def addListDataListener(self, listener):
pass
def removeListDataListener(self, listener):
pass

View File

@@ -0,0 +1,53 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class NoValidPathException(Exception):
def __init__(self, xMSF, _sText):
super(NoValidPathException,self).__init__(_sText)
# TODO: NEVER open a dialog in an exception
from .SystemDialog import SystemDialog
if xMSF:
import sys, os
if sys.version_info < (3,4):
import imp
imp.load_source('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc'))
import strings
elif sys.version_info < (3,7):
# imp is deprecated since Python v.3.4
from importlib.machinery import SourceFileLoader
SourceFileLoader('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc')).load_module()
import strings
else:
# have to jump through hoops since 3.7, partly because python does not like loading modules that do have a .py extension
import importlib
import importlib.util
import importlib.machinery
module_name = 'strings'
path = os.path.join(os.path.dirname(__file__), '../common/strings.hrc')
spec = importlib.util.spec_from_loader(
module_name,
importlib.machinery.SourceFileLoader(module_name, path)
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[module_name] = module
strings = module
SystemDialog.showErrorBox(xMSF, strings.RID_COMMON_START_21) #OfficePathnotavailable

View File

@@ -0,0 +1,86 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
from com.sun.star.lang import Locale
class NumberFormatter(object):
def __init__(self, _xNumberFormatsSupplier, _aLocale, _xMSF=None):
self.iDateFormatKey = -1
self.iDateTimeFormatKey = -1
self.iNumberFormatKey = -1
self.iTextFormatKey = -1
self.iTimeFormatKey = -1
self.iLogicalFormatKey = -1
self.bNullDateCorrectionIsDefined = False
self.aLocale = _aLocale
if _xMSF is not None:
self.xNumberFormatter = _xMSF.createInstance(
"com.sun.star.util.NumberFormatter")
self.xNumberFormats = _xNumberFormatsSupplier.NumberFormats
self.xNumberFormatSettings = \
_xNumberFormatsSupplier.NumberFormatSettings
self.xNumberFormatter.attachNumberFormatsSupplier(
_xNumberFormatsSupplier)
'''
@param _xMSF
@param _xNumberFormatsSupplier
@return
@throws Exception
@deprecated
'''
@classmethod
def createNumberFormatter(self, _xMSF, _xNumberFormatsSupplier):
oNumberFormatter = _xMSF.createInstance(
"com.sun.star.util.NumberFormatter")
oNumberFormatter.attachNumberFormatsSupplier(_xNumberFormatsSupplier)
return oNumberFormatter
'''
gives a key to pass to a NumberFormat object. <br/>
example: <br/>
<pre>
XNumberFormatsSupplier nsf =
(XNumberFormatsSupplier)UnoRuntime.queryInterface(...,document)
int key = Desktop.getNumberFormatterKey(
nsf, ...star.i18n.NumberFormatIndex.DATE...)
XNumberFormatter nf = Desktop.createNumberFormatter(xmsf, nsf);
nf.convertNumberToString( key, 1972 );
</pre>
@param numberFormatsSupplier
@param type - a constant out of i18n.NumberFormatIndex enumeration.
@return a key to use with a util.NumberFormat instance.
'''
@classmethod
def getNumberFormatterKey(self, numberFormatsSupplier, Type):
return numberFormatsSupplier.NumberFormats.getFormatIndex(
Type, Locale())
def convertNumberToString(self, _nkey, _dblValue, _xNumberFormatter=None):
if _xNumberFormatter is None:
return self.xNumberFormatter.convertNumberToString(
_nkey, _dblValue)
else:
return _xNumberFormatter.convertNumberToString(_nkey, _dblValue)
def convertStringToNumber(self, _nkey, _sString):
return self.xNumberFormatter.convertStringToNumber(_nkey, _sString)

View File

@@ -0,0 +1,62 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from com.sun.star.beans import PropertyValue
'''
Simplifies handling Arrays of PropertyValue.
To make a use of this class, instantiate it, and call
the put(propName,propValue) method.
caution: propName should always be a String.
When finished, call the getProperties() method to get an array of the set properties.
'''
class Properties(dict):
@classmethod
def getPropertyValue(self, props, propName):
for i in props:
if propName == i.Name:
return i.Value
raise AttributeError ("Property '" + propName + "' not found.")
@classmethod
def hasPropertyValue(self, props, propName):
for i in props:
if propName == i.Name:
return True
return False
@classmethod
def getProperties(self, _map):
pv = []
for k,v in _map.items():
pv.append(self.createProperty(k, v))
return pv
@classmethod
def createProperty(self, name, value, handle=None):
pv = PropertyValue()
pv.Name = name
pv.Value = value
if handle is not None:
pv.Handle = handle
return pv
def getProperties1(self):
return self.getProperties(self)

View File

@@ -0,0 +1,34 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class PropertyNames:
PROPERTY_ENABLED = "Enabled"
PROPERTY_HEIGHT = "Height"
PROPERTY_HELPURL = "HelpURL"
PROPERTY_POSITION_X = "PositionX"
PROPERTY_POSITION_Y = "PositionY"
PROPERTY_LABEL = "Label"
PROPERTY_MULTILINE = "MultiLine"
PROPERTY_NAME = "Name"
PROPERTY_STEP = "Step"
PROPERTY_WIDTH = "Width"
PROPERTY_TABINDEX = "TabIndex"
PROPERTY_STATE = "State"
PROPERTY_IMAGEURL = "ImageURL"
PROPERTY_TITLE = "Title"
PROPERTY_MOVEABLE = "Moveable"
PROPERTY_CLOSEABLE = "Closeable"

View File

@@ -0,0 +1,180 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
from .Desktop import Desktop
from com.sun.star.ui.dialogs.TemplateDescription import \
FILESAVE_AUTOEXTENSION, FILEOPEN_SIMPLE
from com.sun.star.ui.dialogs.ExtendedFilePickerElementIds import \
CHECKBOX_AUTOEXTENSION
from com.sun.star.awt import WindowDescriptor
from com.sun.star.awt.WindowClass import MODALTOP
from com.sun.star.lang import IllegalArgumentException
from com.sun.star.awt.VclWindowPeerAttribute import OK
class SystemDialog(object):
def __init__(self, xMSF, ServiceName, Type):
try:
self.xMSF = xMSF
self.systemDialog = xMSF.createInstance(ServiceName)
self.xStringSubstitution = self.createStringSubstitution(xMSF)
# Add a name textbox to the filepicker
if self.systemDialog is not None:
if (hasattr(self.systemDialog, "initialize")):
self.systemDialog.initialize((Type,))
except Exception:
traceback.print_exc()
@classmethod
def createStoreDialog(self, xmsf):
return SystemDialog(
xmsf, "com.sun.star.ui.dialogs.FilePicker",
FILESAVE_AUTOEXTENSION)
def subst(self, path):
try:
s = self.xStringSubstitution.substituteVariables(path, False)
return s
except Exception:
traceback.print_exc()
return path
def callStoreDialog(self, displayDir, defaultName, sDocuType=None):
if sDocuType is not None:
self.addFilterToDialog(defaultName[-3:], sDocuType, True)
self.sStorePath = None
try:
self.systemDialog.setValue(CHECKBOX_AUTOEXTENSION, 0, True)
self.systemDialog.setDefaultName(defaultName)
self.systemDialog.setDisplayDirectory(self.subst(displayDir))
if self.execute(self.systemDialog):
sPathList = self.systemDialog.getFiles()
self.sStorePath = sPathList[0]
except Exception:
traceback.print_exc()
return self.sStorePath
def execute(self, execDialog):
return execDialog.execute() == 1
def addFilterToDialog(self, sExtension, filterName, setToDefault):
try:
#get the localized filtername
uiName = self.getFilterUIName(filterName)
pattern = "*." + sExtension
#add the filter
self.addFilter(uiName, pattern, setToDefault)
except Exception:
traceback.print_exc()
def addFilter(self, uiName, pattern, setToDefault):
try:
self.systemDialog.appendFilter(uiName, pattern)
if setToDefault:
self.systemDialog.setCurrentFilter(uiName)
except Exception:
traceback.print_exc()
'''
note the result should go through conversion of the product name.
@param filterName
@return the UI localized name of the given filter name.
'''
def getFilterUIName(self, filterName):
try:
oFactory = self.xMSF.createInstance(
"com.sun.star.document.FilterFactory")
oObject = oFactory.getByName(filterName)
xPropertyValue = list(oObject)
for i in xPropertyValue:
if i is not None and i.Name == "UIName":
return str(i.Value).replace("%productname%", "LibreOffice")
raise Exception(
"UIName property not found for Filter " + filterName);
except Exception:
traceback.print_exc()
return None
@classmethod
def showErrorBox(self, xMSF, sErrorMessage, AddTag=None, AddString=None):
sErrorMessage = sErrorMessage.replace("%PRODUCTNAME", "LibreOffice" )
sErrorMessage = sErrorMessage.replace(str(13), "<BR>")
if AddTag and AddString:
sErrorMessage = sErrorMessage.replace( AddString, AddTag)
return self.showMessageBox(xMSF, "ErrorBox", OK, sErrorMessage)
'''
example:
(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, "message")
@param windowServiceName one of the following strings:
"ErrorBox", "WarningBox", "MessBox", "InfoBox", "QueryBox".
There are other values possible, look
under src/toolkit/source/awt/vcltoolkit.cxx
@param windowAttribute see com.sun.star.awt.VclWindowPeerAttribute
@return 0 = cancel, 1 = ok, 2 = yes, 3 = no(I'm not sure here)
other values check for yourself ;-)
'''
@classmethod
def showMessageBox(self, xMSF, windowServiceName, windowAttribute,
MessageText, peer=None):
if MessageText is None:
return 0
iMessage = 0
try:
# If the peer is null we try to get one from the desktop...
if peer is None:
xFrame = Desktop.getActiveFrame(xMSF)
peer = xFrame.getComponentWindow()
xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit")
oDescriptor = WindowDescriptor()
oDescriptor.WindowServiceName = windowServiceName
oDescriptor.Parent = peer
oDescriptor.Type = MODALTOP
oDescriptor.WindowAttributes = windowAttribute
xMsgPeer = xToolkit.createWindow(oDescriptor)
xMsgPeer.MessageText = MessageText
iMessage = xMsgPeer.execute()
xMsgPeer.dispose()
except Exception:
traceback.print_exc()
return iMessage
@classmethod
def createStringSubstitution(self, xMSF):
xPathSubst = None
try:
xPathSubst = xMSF.createInstance(
"com.sun.star.util.PathSubstitution")
return xPathSubst
except Exception:
traceback.print_exc()
return None

View File

@@ -0,0 +1,148 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
import uno
import traceback
from abc import abstractmethod
from ..common.FileAccess import FileAccess
from com.sun.star.beans import Property
from com.sun.star.ucb import Command
from com.sun.star.ucb import GlobalTransferCommandArgument
from com.sun.star.ucb.NameClash import OVERWRITE
from com.sun.star.ucb import OpenCommandArgument2
from com.sun.star.ucb.OpenMode import ALL
from com.sun.star.ucb.TransferCommandOperation import COPY
# This class is used to copy the content of a folder to
# another folder.
# There is an inconsistency with argument order.
# It should be always: dir,filename.
class UCB(object):
ucb = None
fa = None
xmsf = None
def __init__(self, xmsf):
self.ucb = xmsf.createInstanceWithArguments("com.sun.star.ucb.UniversalContentBroker", ())
self.fa = FileAccess(xmsf)
self.xmsf = xmsf
def delete(self, filename):
# System.out.println("UCB.delete(" + filename)
self.executeCommand(self.getContent(filename),"delete", True)
def copy(self, sourceDir, targetDir):
self.copy1(sourceDir,targetDir, None)
def copy1(self, sourceDir, targetDir, verifier):
files = self.listFiles(sourceDir, verifier)
for i in range(len(files)):
self.copy2(sourceDir, files[i], targetDir, "")
def copy2(self, sourceDir, filename, targetDir, targetName):
if (not self.fa.exists(targetDir, True)):
self.fa.xInterface.createFolder(targetDir)
self.executeCommand(self.ucb, "globalTransfer", self.copyArg(sourceDir, filename, targetDir, targetName))
# target name can be PropertyNames.EMPTY_STRING, in which case the name stays lige the source name
# @param sourceDir
# @param sourceFilename
# @param targetDir
# @param targetFilename
# @return
def copyArg(self, sourceDir, sourceFilename, targetDir, targetFilename):
aArg = GlobalTransferCommandArgument()
aArg.Operation = COPY
aArg.SourceURL = self.fa.getURL(sourceDir, sourceFilename)
aArg.TargetURL = targetDir
aArg.NewTitle = targetFilename
# fail, if object with same name exists in target folder
aArg.NameClash = OVERWRITE
return aArg
def executeCommand(self, xContent, aCommandName, aArgument):
aCommand = Command()
aCommand.Name = aCommandName
aCommand.Handle = -1 # not available
aCommand.Argument = aArgument
return xContent.execute(aCommand, 0, None)
def listFiles(self, path, verifier):
xContent = self.getContent(path)
aArg = OpenCommandArgument2()
aArg.Mode = ALL
aArg.Priority = 32768
# Fill info for the properties wanted.
aArg.Properties = (Property(),)
aArg.Properties[0].Name = "Title"
aArg.Properties[0].Handle = -1
xSet = self.executeCommand(xContent, "open", aArg)
xResultSet = xSet.getStaticResultSet()
files = []
if (xResultSet.first()):
# obtain XContentAccess interface for child content access and XRow for properties
while (True):
# Obtain URL of child.
if (hasattr(xResultSet, "queryContentIdentifierString")):
aId = xResultSet.queryContentIdentifierString()
aTitle = FileAccess.getFilename(aId)
elif (hasattr(xResultSet, "getString")):
# First column: Title (column numbers are 1-based!)
aTitle = xResultSet.getString(1)
else:
aTitle = ""
#if (len(aTitle) == 0 and xResultSet.wasNull()):
if (len(aTitle) == 0):
# ignore
pass
else:
files.append(aTitle)
if (not xResultSet.next()):
break
# next child
if (verifier is not None):
for i in range(len(files)):
if (not verifier.verify(files[i])):
files.pop(i) # FIXME !!! dangerous
return files
def getContent(self, path):
try:
ident = self.ucb.createContentIdentifier(path)
return self.ucb.queryContent(ident)
except Exception:
traceback.print_exc()
return None
class Verifier:
@abstractmethod
def verify(object):
pass

View File

@@ -0,0 +1,318 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
import gettext
import uno
import unohelper
localeDir = "$BRAND_BASE_DIR/$BRAND_SHARE_RESOURCE_SUBDIR"
gettext.bindtextdomain('wiz', unohelper.fileUrlToSystemPath(
uno.getComponentContext().getByName(
"/singletons/com.sun.star.util.theMacroExpander").expandMacros(localeDir)))
gettext.textdomain('wiz')
def NC_(context, string):
# Contextual strings are stored with the concatenation of
# the context, an EOT byte, and the original string, instead of the original string
# see https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html
ret = gettext.gettext(context + chr(4) + string)
if ret.find(chr(4)) == -1:
return ret
return string
# common section
RID_COMMON_START_0 = NC_("RID_COMMON_START_0", "The directory '%1' could not be created.<BR>There may not be enough space left on your hard disk.")
RID_COMMON_START_1 = NC_("RID_COMMON_START_1", "The text document could not be created.<BR>Please check if the module '%PRODUCTNAME Writer' is installed.")
RID_COMMON_START_2 = NC_("RID_COMMON_START_2", "The spreadsheet could not be created.<BR>Please check if the module '%PRODUCTNAME Calc' is installed.")
RID_COMMON_START_3 = NC_("RID_COMMON_START_3", "The presentation could not be created.<BR>Please check if the module '%PRODUCTNAME Impress' is installed.")
RID_COMMON_START_4 = NC_("RID_COMMON_START_4", "The drawing could not be created.<BR>Please check if the module '%PRODUCTNAME Draw' is installed.")
RID_COMMON_START_5 = NC_("RID_COMMON_START_5", "The formula could not be created.<BR>Please check if the module '%PRODUCTNAME Math' is installed.")
RID_COMMON_START_6 = NC_("RID_COMMON_START_6", "The files required could not be found.<BR>Please start the %PRODUCTNAME Setup and choose 'Repair'.")
RID_COMMON_START_7 = NC_("RID_COMMON_START_7", "The file '<PATH>' already exists.<BR><BR>Would you like to overwrite the existing file?")
RID_COMMON_START_8 = NC_("RID_COMMON_START_8", "Yes")
RID_COMMON_START_9 = NC_("RID_COMMON_START_9", "Yes to All")
RID_COMMON_START_10 = NC_("RID_COMMON_START_10", "No")
RID_COMMON_START_11 = NC_("RID_COMMON_START_11", "Cancel")
RID_COMMON_START_12 = NC_("RID_COMMON_START_12", "~Finish")
RID_COMMON_START_13 = NC_("RID_COMMON_START_13", "< ~Back")
RID_COMMON_START_14 = NC_("RID_COMMON_START_14", "~Next >")
RID_COMMON_START_15 = NC_("RID_COMMON_START_15", "~Help")
RID_COMMON_START_16 = NC_("RID_COMMON_START_16", "Steps")
RID_COMMON_START_17 = NC_("RID_COMMON_START_17", "Close")
RID_COMMON_START_18 = NC_("RID_COMMON_START_18", "OK")
RID_COMMON_START_19 = NC_("RID_COMMON_START_19", "The file already exists. Do you want to overwrite it?")
RID_COMMON_START_20 = NC_("RID_COMMON_START_20", "Template created via <wizard_name> on <current_date>.")
RID_COMMON_START_21 = NC_("RID_COMMON_START_21", "The wizard could not be run, because important files were not found.\nUnder 'Tools - Options - %PRODUCTNAME - Paths' click the 'Default' button to reset the paths to the original default settings.\nThen run the wizard again.")
# LETTER WIZARD RESOURCES
RID_LETTERWIZARDDIALOG_START_1 = NC_("RID_LETTERWIZARDDIALOG_START_1", "Letter Wizard")
RID_LETTERWIZARDDIALOG_START_2 = NC_("RID_LETTERWIZARDDIALOG_START_2", "Label9")
RID_LETTERWIZARDDIALOG_START_3 = NC_("RID_LETTERWIZARDDIALOG_START_3", "~Business Letter")
RID_LETTERWIZARDDIALOG_START_4 = NC_("RID_LETTERWIZARDDIALOG_START_4", "~Formal Personal Letter")
RID_LETTERWIZARDDIALOG_START_5 = NC_("RID_LETTERWIZARDDIALOG_START_5", "~Personal Letter")
RID_LETTERWIZARDDIALOG_START_6 = NC_("RID_LETTERWIZARDDIALOG_START_6", "~Use letterhead paper with pre-printed elements")
RID_LETTERWIZARDDIALOG_START_7 = NC_("RID_LETTERWIZARDDIALOG_START_7", "~Logo")
RID_LETTERWIZARDDIALOG_START_8 = NC_("RID_LETTERWIZARDDIALOG_START_8", "Return address")
RID_LETTERWIZARDDIALOG_START_9 = NC_("RID_LETTERWIZARDDIALOG_START_9", "~Include footer")
RID_LETTERWIZARDDIALOG_START_10 = NC_("RID_LETTERWIZARDDIALOG_START_10", "~Return address in envelope window")
RID_LETTERWIZARDDIALOG_START_11 = NC_("RID_LETTERWIZARDDIALOG_START_11", "~Logo")
RID_LETTERWIZARDDIALOG_START_12 = NC_("RID_LETTERWIZARDDIALOG_START_12", "~Return address in envelope window")
RID_LETTERWIZARDDIALOG_START_13 = NC_("RID_LETTERWIZARDDIALOG_START_13", "Letter signs")
RID_LETTERWIZARDDIALOG_START_14 = NC_("RID_LETTERWIZARDDIALOG_START_14", "S~ubject line")
RID_LETTERWIZARDDIALOG_START_15 = NC_("RID_LETTERWIZARDDIALOG_START_15", "Salu~tation")
RID_LETTERWIZARDDIALOG_START_16 = NC_("RID_LETTERWIZARDDIALOG_START_16", "Fold ~marks")
RID_LETTERWIZARDDIALOG_START_17 = NC_("RID_LETTERWIZARDDIALOG_START_17", "~Complimentary close")
RID_LETTERWIZARDDIALOG_START_18 = NC_("RID_LETTERWIZARDDIALOG_START_18", "~Footer")
RID_LETTERWIZARDDIALOG_START_19 = NC_("RID_LETTERWIZARDDIALOG_START_19", "~Use user data for return address")
RID_LETTERWIZARDDIALOG_START_20 = NC_("RID_LETTERWIZARDDIALOG_START_20", "~New sender address:")
RID_LETTERWIZARDDIALOG_START_21 = NC_("RID_LETTERWIZARDDIALOG_START_21", "Use placeholders for ~recipient's address")
RID_LETTERWIZARDDIALOG_START_22 = NC_("RID_LETTERWIZARDDIALOG_START_22", "Use address database for ~mail merge")
RID_LETTERWIZARDDIALOG_START_23 = NC_("RID_LETTERWIZARDDIALOG_START_23", "Include ~only on second and following pages")
RID_LETTERWIZARDDIALOG_START_24 = NC_("RID_LETTERWIZARDDIALOG_START_24", "~Include page number")
RID_LETTERWIZARDDIALOG_START_25 = NC_("RID_LETTERWIZARDDIALOG_START_25", "Letter Template")
RID_LETTERWIZARDDIALOG_START_26 = NC_("RID_LETTERWIZARDDIALOG_START_26", "Create a ~letter from this template")
RID_LETTERWIZARDDIALOG_START_27 = NC_("RID_LETTERWIZARDDIALOG_START_27", "Make ~manual changes to this letter template")
RID_LETTERWIZARDDIALOG_START_28 = NC_("RID_LETTERWIZARDDIALOG_START_28", "Page design")
RID_LETTERWIZARDDIALOG_START_29 = NC_("RID_LETTERWIZARDDIALOG_START_29", "Page design")
RID_LETTERWIZARDDIALOG_START_30 = NC_("RID_LETTERWIZARDDIALOG_START_30", "Page design")
RID_LETTERWIZARDDIALOG_START_31 = NC_("RID_LETTERWIZARDDIALOG_START_31", "This wizard helps you to create a letter template. You can then use the template as the basis for writing letters as often as desired.")
RID_LETTERWIZARDDIALOG_START_32 = NC_("RID_LETTERWIZARDDIALOG_START_32", "~Height:")
RID_LETTERWIZARDDIALOG_START_33 = NC_("RID_LETTERWIZARDDIALOG_START_33", "~Width:")
RID_LETTERWIZARDDIALOG_START_34 = NC_("RID_LETTERWIZARDDIALOG_START_34", "S~pacing to left margin:")
RID_LETTERWIZARDDIALOG_START_35 = NC_("RID_LETTERWIZARDDIALOG_START_35", "Spacing ~to top margin:")
RID_LETTERWIZARDDIALOG_START_36 = NC_("RID_LETTERWIZARDDIALOG_START_36", "Height:")
RID_LETTERWIZARDDIALOG_START_37 = NC_("RID_LETTERWIZARDDIALOG_START_37", "Width:")
RID_LETTERWIZARDDIALOG_START_38 = NC_("RID_LETTERWIZARDDIALOG_START_38", "S~pacing to left margin:")
RID_LETTERWIZARDDIALOG_START_39 = NC_("RID_LETTERWIZARDDIALOG_START_39", "Spacing ~to top margin:")
RID_LETTERWIZARDDIALOG_START_40 = NC_("RID_LETTERWIZARDDIALOG_START_40", "Height:")
RID_LETTERWIZARDDIALOG_START_42 = NC_("RID_LETTERWIZARDDIALOG_START_42", "Sender's address")
RID_LETTERWIZARDDIALOG_START_43 = NC_("RID_LETTERWIZARDDIALOG_START_43", "Name:")
RID_LETTERWIZARDDIALOG_START_44 = NC_("RID_LETTERWIZARDDIALOG_START_44", "Street:")
RID_LETTERWIZARDDIALOG_START_45 = NC_("RID_LETTERWIZARDDIALOG_START_45", "ZIP code/State/City:")
RID_LETTERWIZARDDIALOG_START_46 = NC_("RID_LETTERWIZARDDIALOG_START_46", "Recipient's address")
RID_LETTERWIZARDDIALOG_START_47 = NC_("RID_LETTERWIZARDDIALOG_START_47", "Footer")
RID_LETTERWIZARDDIALOG_START_48 = NC_("RID_LETTERWIZARDDIALOG_START_48", "This wizard creates a letter template which enables you to create multiple letters with the same layout and settings.")
RID_LETTERWIZARDDIALOG_START_49 = NC_("RID_LETTERWIZARDDIALOG_START_49", "To create another new letter out of the template just navigate to the template location and double-click it.")
RID_LETTERWIZARDDIALOG_START_50 = NC_("RID_LETTERWIZARDDIALOG_START_50", "Template name:")
RID_LETTERWIZARDDIALOG_START_51 = NC_("RID_LETTERWIZARDDIALOG_START_51", "Location and file name:")
RID_LETTERWIZARDDIALOG_START_52 = NC_("RID_LETTERWIZARDDIALOG_START_52", "How do you want to proceed?")
RID_LETTERWIZARDDIALOG_START_53 = NC_("RID_LETTERWIZARDDIALOG_START_53", "Please choose the type of letter and page design")
RID_LETTERWIZARDDIALOG_START_54 = NC_("RID_LETTERWIZARDDIALOG_START_54", "Select the items to be printed")
RID_LETTERWIZARDDIALOG_START_55 = NC_("RID_LETTERWIZARDDIALOG_START_55", "Specify items already on your letterhead paper")
RID_LETTERWIZARDDIALOG_START_56 = NC_("RID_LETTERWIZARDDIALOG_START_56", "Specify the sender and recipient information")
RID_LETTERWIZARDDIALOG_START_57 = NC_("RID_LETTERWIZARDDIALOG_START_57", "Fill in the information you would like in the footer")
RID_LETTERWIZARDDIALOG_START_58 = NC_("RID_LETTERWIZARDDIALOG_START_58", "Please specify last settings")
RID_LETTERWIZARDDIALOG_START_59 = NC_("RID_LETTERWIZARDDIALOG_START_59", "Subject:")
RID_LETTERWIZARDDIALOG_START_60 = NC_("RID_LETTERWIZARDDIALOG_START_60", "Elegant")
RID_LETTERWIZARDDIALOG_START_61 = NC_("RID_LETTERWIZARDDIALOG_START_61", "Modern")
RID_LETTERWIZARDDIALOG_START_62 = NC_("RID_LETTERWIZARDDIALOG_START_62", "Office")
RID_LETTERWIZARDDIALOG_START_63 = NC_("RID_LETTERWIZARDDIALOG_START_63", "Bottle")
RID_LETTERWIZARDDIALOG_START_64 = NC_("RID_LETTERWIZARDDIALOG_START_64", "Mail")
RID_LETTERWIZARDDIALOG_START_65 = NC_("RID_LETTERWIZARDDIALOG_START_65", "Marine")
RID_LETTERWIZARDDIALOG_START_66 = NC_("RID_LETTERWIZARDDIALOG_START_66", "Red Line")
# Letter Wizard Greeting Start
RID_LETTERWIZARDSALUTATION_START_1 = NC_("RID_LETTERWIZARDSALUTATION_START_1", "To Whom it May Concern")
RID_LETTERWIZARDSALUTATION_START_2 = NC_("RID_LETTERWIZARDSALUTATION_START_2", "Dear Sir or Madam")
RID_LETTERWIZARDSALUTATION_START_3 = NC_("RID_LETTERWIZARDSALUTATION_START_3", "Hello")
# Letter Wizard Greeting Start
RID_LETTERWIZARDGREETING_START_1 = NC_("RID_LETTERWIZARDGREETING_START_1", "Sincerely")
RID_LETTERWIZARDGREETING_START_2 = NC_("RID_LETTERWIZARDGREETING_START_2", "Best regards")
RID_LETTERWIZARDGREETING_START_3 = NC_("RID_LETTERWIZARDGREETING_START_3", "Cheers")
# Letter Wizard Roadmap Start
RID_LETTERWIZARDROADMAP_START_1 = NC_("RID_LETTERWIZARDROADMAP_START_1", "Page Design")
RID_LETTERWIZARDROADMAP_START_2 = NC_("RID_LETTERWIZARDROADMAP_START_2", "Letterhead Layout")
RID_LETTERWIZARDROADMAP_START_3 = NC_("RID_LETTERWIZARDROADMAP_START_3", "Printed Items")
RID_LETTERWIZARDROADMAP_START_4 = NC_("RID_LETTERWIZARDROADMAP_START_4", "Recipient and Sender")
RID_LETTERWIZARDROADMAP_START_5 = NC_("RID_LETTERWIZARDROADMAP_START_5", "Footer")
RID_LETTERWIZARDROADMAP_START_6 = NC_("RID_LETTERWIZARDROADMAP_START_6", "Name and Location")
# FAX WIZARD RESOURCES
RID_FAXWIZARDDIALOG_START_1 = NC_("RID_FAXWIZARDDIALOG_START_1", "Fax Wizard")
RID_FAXWIZARDDIALOG_START_2 = NC_("RID_FAXWIZARDDIALOG_START_2", "Label9")
RID_FAXWIZARDDIALOG_START_3 = NC_("RID_FAXWIZARDDIALOG_START_3", "~Business Fax")
RID_FAXWIZARDDIALOG_START_4 = NC_("RID_FAXWIZARDDIALOG_START_4", "~Personal Fax")
RID_FAXWIZARDDIALOG_START_5 = NC_("RID_FAXWIZARDDIALOG_START_5", "~Logo")
RID_FAXWIZARDDIALOG_START_6 = NC_("RID_FAXWIZARDDIALOG_START_6", "S~ubject line")
RID_FAXWIZARDDIALOG_START_7 = NC_("RID_FAXWIZARDDIALOG_START_7", "S~alutation")
RID_FAXWIZARDDIALOG_START_8 = NC_("RID_FAXWIZARDDIALOG_START_8", "~Complimentary close")
RID_FAXWIZARDDIALOG_START_9 = NC_("RID_FAXWIZARDDIALOG_START_9", "~Footer")
RID_FAXWIZARDDIALOG_START_10 = NC_("RID_FAXWIZARDDIALOG_START_10", "~Use user data for return address")
RID_FAXWIZARDDIALOG_START_11 = NC_("RID_FAXWIZARDDIALOG_START_11", "~New return address")
RID_FAXWIZARDDIALOG_START_12 = NC_("RID_FAXWIZARDDIALOG_START_12", "My Fax Template")
RID_FAXWIZARDDIALOG_START_13 = NC_("RID_FAXWIZARDDIALOG_START_13", "Create a ~fax from this template")
RID_FAXWIZARDDIALOG_START_14 = NC_("RID_FAXWIZARDDIALOG_START_14", "Make ~manual changes to this fax template")
RID_FAXWIZARDDIALOG_START_15 = NC_("RID_FAXWIZARDDIALOG_START_15", "Page design")
RID_FAXWIZARDDIALOG_START_16 = NC_("RID_FAXWIZARDDIALOG_START_16", "Page design")
RID_FAXWIZARDDIALOG_START_17 = NC_("RID_FAXWIZARDDIALOG_START_17", "This wizard helps you to create a fax template. The template can then be used to create a fax whenever needed.")
RID_FAXWIZARDDIALOG_START_18 = NC_("RID_FAXWIZARDDIALOG_START_18", "Return address")
RID_FAXWIZARDDIALOG_START_19 = NC_("RID_FAXWIZARDDIALOG_START_19", "Name:")
RID_FAXWIZARDDIALOG_START_20 = NC_("RID_FAXWIZARDDIALOG_START_20", "Street:")
RID_FAXWIZARDDIALOG_START_21 = NC_("RID_FAXWIZARDDIALOG_START_21", "ZIP code/State/City:")
RID_FAXWIZARDDIALOG_START_22 = NC_("RID_FAXWIZARDDIALOG_START_22", "Footer")
RID_FAXWIZARDDIALOG_START_23 = NC_("RID_FAXWIZARDDIALOG_START_23", "This wizard creates a fax template which enables you to create multiple faxes with the same layout and settings.")
RID_FAXWIZARDDIALOG_START_24 = NC_("RID_FAXWIZARDDIALOG_START_24", "To create another new fax out of the template, go to the location where you saved the template and double-click the file.")
RID_FAXWIZARDDIALOG_START_25 = NC_("RID_FAXWIZARDDIALOG_START_25", "Template name:")
RID_FAXWIZARDDIALOG_START_26 = NC_("RID_FAXWIZARDDIALOG_START_26", "Location and file name:")
RID_FAXWIZARDDIALOG_START_27 = NC_("RID_FAXWIZARDDIALOG_START_27", "What do you want to do next?")
RID_FAXWIZARDDIALOG_START_28 = NC_("RID_FAXWIZARDDIALOG_START_28", "Choose the type of fax and a page design")
RID_FAXWIZARDDIALOG_START_29 = NC_("RID_FAXWIZARDDIALOG_START_29", "Select items to include in the fax template")
RID_FAXWIZARDDIALOG_START_30 = NC_("RID_FAXWIZARDDIALOG_START_30", "Specify sender and recipient information")
RID_FAXWIZARDDIALOG_START_31 = NC_("RID_FAXWIZARDDIALOG_START_31", "Enter text for the footer")
RID_FAXWIZARDDIALOG_START_32 = NC_("RID_FAXWIZARDDIALOG_START_32", "Choose a name and save the template")
RID_FAXWIZARDDIALOG_START_33 = NC_("RID_FAXWIZARDDIALOG_START_33", "Include ~only on second and following pages")
RID_FAXWIZARDDIALOG_START_34 = NC_("RID_FAXWIZARDDIALOG_START_34", "~Include page number")
RID_FAXWIZARDDIALOG_START_35 = NC_("RID_FAXWIZARDDIALOG_START_35", "~Date")
RID_FAXWIZARDDIALOG_START_36 = NC_("RID_FAXWIZARDDIALOG_START_36", "~Type of message")
RID_FAXWIZARDDIALOG_START_37 = NC_("RID_FAXWIZARDDIALOG_START_37", "Fax Number:")
RID_FAXWIZARDDIALOG_START_38 = NC_("RID_FAXWIZARDDIALOG_START_38", "Use placeholders for ~recipient's address")
RID_FAXWIZARDDIALOG_START_39 = NC_("RID_FAXWIZARDDIALOG_START_39", "Use address database for ~mail merge")
RID_FAXWIZARDDIALOG_START_40 = NC_("RID_FAXWIZARDDIALOG_START_40", "~New return address")
RID_FAXWIZARDDIALOG_START_41 = NC_("RID_FAXWIZARDDIALOG_START_41", "To:")
RID_FAXWIZARDDIALOG_START_42 = NC_("RID_FAXWIZARDDIALOG_START_42", "From:")
RID_FAXWIZARDDIALOG_START_43 = NC_("RID_FAXWIZARDDIALOG_START_43", "Fax:")
RID_FAXWIZARDDIALOG_START_44 = NC_("RID_FAXWIZARDDIALOG_START_44", "Tel:")
RID_FAXWIZARDDIALOG_START_45 = NC_("RID_FAXWIZARDDIALOG_START_45", "Email:")
RID_FAXWIZARDDIALOG_START_46 = NC_("RID_FAXWIZARDDIALOG_START_46", "This template consists of")
RID_FAXWIZARDDIALOG_START_47 = NC_("RID_FAXWIZARDDIALOG_START_47", "page")
RID_FAXWIZARDDIALOG_START_48 = NC_("RID_FAXWIZARDDIALOG_START_48", "Please inform us if transmission errors occur.")
RID_FAXWIZARDDIALOG_START_49 = NC_("RID_FAXWIZARDDIALOG_START_49", "Bottle")
RID_FAXWIZARDDIALOG_START_50 = NC_("RID_FAXWIZARDDIALOG_START_50", "Lines")
RID_FAXWIZARDDIALOG_START_51 = NC_("RID_FAXWIZARDDIALOG_START_51", "Marine")
RID_FAXWIZARDDIALOG_START_52 = NC_("RID_FAXWIZARDDIALOG_START_52", "Classic Fax")
RID_FAXWIZARDDIALOG_START_53 = NC_("RID_FAXWIZARDDIALOG_START_53", "Classic Fax from Private")
RID_FAXWIZARDDIALOG_START_54 = NC_("RID_FAXWIZARDDIALOG_START_54", "Modern Fax")
RID_FAXWIZARDDIALOG_START_55 = NC_("RID_FAXWIZARDDIALOG_START_55", "Modern Fax from Private")
RID_FAXWIZARDDIALOG_START_56 = NC_("RID_FAXWIZARDDIALOG_START_56", "Fax")
# Fax Wizard Communication Start
RID_FAXWIZARDCOMMUNICATION_START_1 = NC_("RID_FAXWIZARDCOMMUNICATION_START_1", "Important Information!")
RID_FAXWIZARDCOMMUNICATION_START_2 = NC_("RID_FAXWIZARDCOMMUNICATION_START_2", "For your information")
RID_FAXWIZARDCOMMUNICATION_START_3 = NC_("RID_FAXWIZARDCOMMUNICATION_START_3", "News!")
# Fax Wizard Salutation Start
RID_FAXWIZARDSALUTATION_START_1 = NC_("RID_FAXWIZARDSALUTATION_START_1", "To whom it may concern,")
RID_FAXWIZARDSALUTATION_START_2 = NC_("RID_FAXWIZARDSALUTATION_START_2", "Dear Sir or Madam,")
RID_FAXWIZARDSALUTATION_START_3 = NC_("RID_FAXWIZARDSALUTATION_START_3", "Hello,")
RID_FAXWIZARDSALUTATION_START_4 = NC_("RID_FAXWIZARDSALUTATION_START_4", "Hi,")
# Fax Wizard Greeting Start
RID_FAXWIZARDGREETING_START_1 = NC_("RID_FAXWIZARDGREETING_START_1", "Sincerely")
RID_FAXWIZARDGREETING_START_2 = NC_("RID_FAXWIZARDGREETING_START_2", "Yours faithfully")
RID_FAXWIZARDGREETING_START_3 = NC_("RID_FAXWIZARDGREETING_START_3", "Regards")
RID_FAXWIZARDGREETING_START_4 = NC_("RID_FAXWIZARDGREETING_START_4", "Love")
# Fax Wizard Roadmap Start
RID_FAXWIZARDROADMAP_START_1 = NC_("RID_FAXWIZARDROADMAP_START_1", "Page Design")
RID_FAXWIZARDROADMAP_START_2 = NC_("RID_FAXWIZARDROADMAP_START_2", "Items to Include")
RID_FAXWIZARDROADMAP_START_3 = NC_("RID_FAXWIZARDROADMAP_START_3", "Sender and Recipient")
RID_FAXWIZARDROADMAP_START_4 = NC_("RID_FAXWIZARDROADMAP_START_4", "Footer")
RID_FAXWIZARDROADMAP_START_5 = NC_("RID_FAXWIZARDROADMAP_START_5", "Name and Location")
# AGENDA WIZARD RESOURCES
RID_AGENDAWIZARDDIALOG_START_1 = NC_("RID_AGENDAWIZARDDIALOG_START_1", "Agenda Wizard")
RID_AGENDAWIZARDDIALOG_START_2 = NC_("RID_AGENDAWIZARDDIALOG_START_2", "Make ~manual changes to this agenda template")
RID_AGENDAWIZARDDIALOG_START_3 = NC_("RID_AGENDAWIZARDDIALOG_START_3", "Template name:")
RID_AGENDAWIZARDDIALOG_START_4 = NC_("RID_AGENDAWIZARDDIALOG_START_4", "Location and file name:")
RID_AGENDAWIZARDDIALOG_START_5 = NC_("RID_AGENDAWIZARDDIALOG_START_5", "What do you want to do next?")
RID_AGENDAWIZARDDIALOG_START_6 = NC_("RID_AGENDAWIZARDDIALOG_START_6", "Please choose the page design for the agenda")
RID_AGENDAWIZARDDIALOG_START_7 = NC_("RID_AGENDAWIZARDDIALOG_START_7", "Please select the headings you wish to include in your agenda template")
RID_AGENDAWIZARDDIALOG_START_8 = NC_("RID_AGENDAWIZARDDIALOG_START_8", "Please enter general information for the event")
RID_AGENDAWIZARDDIALOG_START_9 = NC_("RID_AGENDAWIZARDDIALOG_START_9", "Please specify items for the agenda")
RID_AGENDAWIZARDDIALOG_START_10 = NC_("RID_AGENDAWIZARDDIALOG_START_10", "Please select the names you wish to include in your agenda template")
RID_AGENDAWIZARDDIALOG_START_11 = NC_("RID_AGENDAWIZARDDIALOG_START_11", "Choose a name and save the template")
RID_AGENDAWIZARDDIALOG_START_12 = NC_("RID_AGENDAWIZARDDIALOG_START_12", "Include form for recording minutes")
RID_AGENDAWIZARDDIALOG_START_13 = NC_("RID_AGENDAWIZARDDIALOG_START_13", "This wizard helps you to create an agenda template. The template can then be used to create an agenda whenever needed.")
RID_AGENDAWIZARDDIALOG_START_14 = NC_("RID_AGENDAWIZARDDIALOG_START_14", "Time:")
RID_AGENDAWIZARDDIALOG_START_15 = NC_("RID_AGENDAWIZARDDIALOG_START_15", "Name:")
RID_AGENDAWIZARDDIALOG_START_16 = NC_("RID_AGENDAWIZARDDIALOG_START_16", "Location:")
RID_AGENDAWIZARDDIALOG_START_17 = NC_("RID_AGENDAWIZARDDIALOG_START_17", "Placeholders will be used in empty fields. You can replace placeholders with text later.")
RID_AGENDAWIZARDDIALOG_START_18 = NC_("RID_AGENDAWIZARDDIALOG_START_18", "...")
RID_AGENDAWIZARDDIALOG_START_19 = NC_("RID_AGENDAWIZARDDIALOG_START_19", "Create an ~agenda from this template")
RID_AGENDAWIZARDDIALOG_START_20 = NC_("RID_AGENDAWIZARDDIALOG_START_20", "To create a new agenda out of the template, go to the location where you saved the template and double-click the file.")
RID_AGENDAWIZARDDIALOG_START_21 = NC_("RID_AGENDAWIZARDDIALOG_START_21", "Agenda item")
RID_AGENDAWIZARDDIALOG_START_22 = NC_("RID_AGENDAWIZARDDIALOG_START_22", "Responsible")
RID_AGENDAWIZARDDIALOG_START_23 = NC_("RID_AGENDAWIZARDDIALOG_START_23", "Duration")
RID_AGENDAWIZARDDIALOG_START_24 = NC_("RID_AGENDAWIZARDDIALOG_START_24", "Meeting called by")
RID_AGENDAWIZARDDIALOG_START_25 = NC_("RID_AGENDAWIZARDDIALOG_START_25", "Chairperson")
RID_AGENDAWIZARDDIALOG_START_26 = NC_("RID_AGENDAWIZARDDIALOG_START_26", "Minute keeper")
RID_AGENDAWIZARDDIALOG_START_27 = NC_("RID_AGENDAWIZARDDIALOG_START_27", "Moderator")
RID_AGENDAWIZARDDIALOG_START_28 = NC_("RID_AGENDAWIZARDDIALOG_START_28", "Attendees")
RID_AGENDAWIZARDDIALOG_START_29 = NC_("RID_AGENDAWIZARDDIALOG_START_29", "Observers")
RID_AGENDAWIZARDDIALOG_START_30 = NC_("RID_AGENDAWIZARDDIALOG_START_30", "Facility personnel")
RID_AGENDAWIZARDDIALOG_START_31 = NC_("RID_AGENDAWIZARDDIALOG_START_31", "The agenda template will include placeholders for the names of the selected people. When creating an agenda from the template, you can replace these placeholder with the appropriate names.")
RID_AGENDAWIZARDDIALOG_START_32 = NC_("RID_AGENDAWIZARDDIALOG_START_32", "Type of meeting")
RID_AGENDAWIZARDDIALOG_START_33 = NC_("RID_AGENDAWIZARDDIALOG_START_33", "Please read")
RID_AGENDAWIZARDDIALOG_START_34 = NC_("RID_AGENDAWIZARDDIALOG_START_34", "Please bring")
RID_AGENDAWIZARDDIALOG_START_35 = NC_("RID_AGENDAWIZARDDIALOG_START_35", "Notes")
RID_AGENDAWIZARDDIALOG_START_36 = NC_("RID_AGENDAWIZARDDIALOG_START_36", "The agenda template will include placeholders for the selected items.")
RID_AGENDAWIZARDDIALOG_START_38 = NC_("RID_AGENDAWIZARDDIALOG_START_38", "Date:")
RID_AGENDAWIZARDDIALOG_START_39 = NC_("RID_AGENDAWIZARDDIALOG_START_39", "This wizard creates an agenda template which enables you to create multiple agendas with the same layout and settings.")
RID_AGENDAWIZARDDIALOG_START_40 = NC_("RID_AGENDAWIZARDDIALOG_START_40", "Page design:")
RID_AGENDAWIZARDDIALOG_START_41 = NC_("RID_AGENDAWIZARDDIALOG_START_41", "myAgendaTemplate.stw")
RID_AGENDAWIZARDDIALOG_START_42 = NC_("RID_AGENDAWIZARDDIALOG_START_42", "My Agenda Template")
RID_AGENDAWIZARDDIALOG_START_43 = NC_("RID_AGENDAWIZARDDIALOG_START_43", "An error occurred while saving the agenda template.")
RID_AGENDAWIZARDDIALOG_START_44 = NC_("RID_AGENDAWIZARDDIALOG_START_44", "Name")
RID_AGENDAWIZARDDIALOG_START_45 = NC_("RID_AGENDAWIZARDDIALOG_START_45", "Date")
RID_AGENDAWIZARDDIALOG_START_46 = NC_("RID_AGENDAWIZARDDIALOG_START_46", "Time")
RID_AGENDAWIZARDDIALOG_START_47 = NC_("RID_AGENDAWIZARDDIALOG_START_47", "Location")
RID_AGENDAWIZARDDIALOG_START_48 = NC_("RID_AGENDAWIZARDDIALOG_START_48", "Click to replace this text")
RID_AGENDAWIZARDDIALOG_START_50 = NC_("RID_AGENDAWIZARDDIALOG_START_50", "Page Design")
RID_AGENDAWIZARDDIALOG_START_51 = NC_("RID_AGENDAWIZARDDIALOG_START_51", "General Information")
RID_AGENDAWIZARDDIALOG_START_52 = NC_("RID_AGENDAWIZARDDIALOG_START_52", "Headings to Include")
RID_AGENDAWIZARDDIALOG_START_53 = NC_("RID_AGENDAWIZARDDIALOG_START_53", "Names")
RID_AGENDAWIZARDDIALOG_START_54 = NC_("RID_AGENDAWIZARDDIALOG_START_54", "Agenda Items")
RID_AGENDAWIZARDDIALOG_START_55 = NC_("RID_AGENDAWIZARDDIALOG_START_55", "Name and Location")
RID_AGENDAWIZARDDIALOG_START_56 = NC_("RID_AGENDAWIZARDDIALOG_START_56", "An error occurred while opening the agenda template.")
RID_AGENDAWIZARDDIALOG_START_57 = NC_("RID_AGENDAWIZARDDIALOG_START_57", "Type of meeting")
RID_AGENDAWIZARDDIALOG_START_58 = NC_("RID_AGENDAWIZARDDIALOG_START_58", "Please bring")
RID_AGENDAWIZARDDIALOG_START_59 = NC_("RID_AGENDAWIZARDDIALOG_START_59", "Please read")
RID_AGENDAWIZARDDIALOG_START_60 = NC_("RID_AGENDAWIZARDDIALOG_START_60", "Notes")
RID_AGENDAWIZARDDIALOG_START_61 = NC_("RID_AGENDAWIZARDDIALOG_START_61", "Meeting called by")
RID_AGENDAWIZARDDIALOG_START_62 = NC_("RID_AGENDAWIZARDDIALOG_START_62", "Chairperson")
RID_AGENDAWIZARDDIALOG_START_63 = NC_("RID_AGENDAWIZARDDIALOG_START_63", "Attendees")
RID_AGENDAWIZARDDIALOG_START_64 = NC_("RID_AGENDAWIZARDDIALOG_START_64", "Minute keeper")
RID_AGENDAWIZARDDIALOG_START_65 = NC_("RID_AGENDAWIZARDDIALOG_START_65", "Moderator")
RID_AGENDAWIZARDDIALOG_START_66 = NC_("RID_AGENDAWIZARDDIALOG_START_66", "Observers")
RID_AGENDAWIZARDDIALOG_START_67 = NC_("RID_AGENDAWIZARDDIALOG_START_67", "Facility personnel")
RID_AGENDAWIZARDDIALOG_START_68 = NC_("RID_AGENDAWIZARDDIALOG_START_68", "Insert")
RID_AGENDAWIZARDDIALOG_START_69 = NC_("RID_AGENDAWIZARDDIALOG_START_69", "Remove")
RID_AGENDAWIZARDDIALOG_START_70 = NC_("RID_AGENDAWIZARDDIALOG_START_70", "Move up")
RID_AGENDAWIZARDDIALOG_START_71 = NC_("RID_AGENDAWIZARDDIALOG_START_71", "Move down")
RID_AGENDAWIZARDDIALOG_START_72 = NC_("RID_AGENDAWIZARDDIALOG_START_72", "Date:")
RID_AGENDAWIZARDDIALOG_START_73 = NC_("RID_AGENDAWIZARDDIALOG_START_73", "Time:")
RID_AGENDAWIZARDDIALOG_START_74 = NC_("RID_AGENDAWIZARDDIALOG_START_74", "Location:")
RID_AGENDAWIZARDDIALOG_START_75 = NC_("RID_AGENDAWIZARDDIALOG_START_75", "Topics")
RID_AGENDAWIZARDDIALOG_START_76 = NC_("RID_AGENDAWIZARDDIALOG_START_76", "Num.")
RID_AGENDAWIZARDDIALOG_START_77 = NC_("RID_AGENDAWIZARDDIALOG_START_77", "Topic")
RID_AGENDAWIZARDDIALOG_START_78 = NC_("RID_AGENDAWIZARDDIALOG_START_78", "Responsible")
RID_AGENDAWIZARDDIALOG_START_79 = NC_("RID_AGENDAWIZARDDIALOG_START_79", "Time")
RID_AGENDAWIZARDDIALOG_START_80 = NC_("RID_AGENDAWIZARDDIALOG_START_80", "Additional information")
RID_AGENDAWIZARDDIALOG_START_81 = NC_("RID_AGENDAWIZARDDIALOG_START_81", "Minutes for")
RID_AGENDAWIZARDDIALOG_START_82 = NC_("RID_AGENDAWIZARDDIALOG_START_82", "Discussion:")
RID_AGENDAWIZARDDIALOG_START_83 = NC_("RID_AGENDAWIZARDDIALOG_START_83", "Conclusion:")
RID_AGENDAWIZARDDIALOG_START_84 = NC_("RID_AGENDAWIZARDDIALOG_START_84", "To do:")
RID_AGENDAWIZARDDIALOG_START_85 = NC_("RID_AGENDAWIZARDDIALOG_START_85", "Responsible party:")
RID_AGENDAWIZARDDIALOG_START_86 = NC_("RID_AGENDAWIZARDDIALOG_START_86", "Deadline:")
RID_AGENDAWIZARDDIALOG_START_87 = NC_("RID_AGENDAWIZARDDIALOG_START_87", "Blue")
RID_AGENDAWIZARDDIALOG_START_88 = NC_("RID_AGENDAWIZARDDIALOG_START_88", "Classic")
RID_AGENDAWIZARDDIALOG_START_89 = NC_("RID_AGENDAWIZARDDIALOG_START_89", "Colorful")
RID_AGENDAWIZARDDIALOG_START_90 = NC_("RID_AGENDAWIZARDDIALOG_START_90", "Elegant")
RID_AGENDAWIZARDDIALOG_START_91 = NC_("RID_AGENDAWIZARDDIALOG_START_91", "Green")
RID_AGENDAWIZARDDIALOG_START_92 = NC_("RID_AGENDAWIZARDDIALOG_START_92", "Grey")
RID_AGENDAWIZARDDIALOG_START_93 = NC_("RID_AGENDAWIZARDDIALOG_START_93", "Modern")
RID_AGENDAWIZARDDIALOG_START_94 = NC_("RID_AGENDAWIZARDDIALOG_START_94", "Orange")
RID_AGENDAWIZARDDIALOG_START_95 = NC_("RID_AGENDAWIZARDDIALOG_START_95", "Red")
RID_AGENDAWIZARDDIALOG_START_96 = NC_("RID_AGENDAWIZARDDIALOG_START_96", "Simple")
# vim: set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -0,0 +1,208 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
import traceback
from unohelper import systemPathToFileUrl, absolutize
from ..common.Desktop import Desktop
from ..common.SystemDialog import SystemDialog
from com.sun.star.awt import WindowDescriptor
from com.sun.star.awt import Rectangle
from com.sun.star.awt.WindowClass import TOP
from com.sun.star.task import ErrorCodeIOException
#Window Constants
com_sun_star_awt_WindowAttribute_BORDER \
= uno.getConstantByName( "com.sun.star.awt.WindowAttribute.BORDER" )
com_sun_star_awt_WindowAttribute_SIZEABLE \
= uno.getConstantByName( "com.sun.star.awt.WindowAttribute.SIZEABLE" )
com_sun_star_awt_WindowAttribute_MOVEABLE \
= uno.getConstantByName( "com.sun.star.awt.WindowAttribute.MOVEABLE" )
com_sun_star_awt_VclWindowPeerAttribute_CLIPCHILDREN \
= uno.getConstantByName(
"com.sun.star.awt.VclWindowPeerAttribute.CLIPCHILDREN" )
class OfficeDocument(object):
'''Creates a new instance of OfficeDocument '''
def __init__(self, _xMSF):
self.xMSF = _xMSF
@classmethod
def attachEventCall(self, xComponent, EventName, EventType, EventURL):
try:
oEventProperties = list(range(2))
oEventProperties[0] = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
oEventProperties[0].Name = "EventType"
oEventProperties[0].Value = EventType
# "Service", "StarBasic"
oEventProperties[1] = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
oEventProperties[1].Name = "Script" #"URL";
oEventProperties[1].Value = EventURL
uno.invoke(xComponent.Events, "replaceByName",
(EventName, uno.Any("[]com.sun.star.beans.PropertyValue",
tuple(oEventProperties))))
except Exception:
traceback.print_exc()
def dispose(self, xMSF, xComponent):
try:
if xComponent is not None:
xFrame = xComponent.CurrentController.Frame
if xComponent.isModified():
xComponent.setModified(False)
Desktop.dispatchURL(xMSF, ".uno:CloseDoc", xFrame)
except Exception:
traceback.print_exc()
@classmethod
def createNewFrame(self, xMSF, listener, FrameName="_blank"):
xFrame = None
if FrameName.lower() == "WIZARD_LIVE_PREVIEW".lower():
xFrame = self.createNewPreviewFrame(xMSF, listener)
else:
xF = Desktop.getDesktop(xMSF)
xFrame = xF.findFrame(FrameName, 0)
if listener is not None:
xFF = xF.getFrames()
xFF.remove(xFrame)
xF.addTerminateListener(listener)
return xFrame
@classmethod
def createNewPreviewFrame(self, xMSF, listener):
xToolkit = None
try:
xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit")
except Exception:
# TODO Auto-generated catch block
traceback.print_exc()
#describe the window and its properties
aDescriptor = WindowDescriptor()
aDescriptor.Type = TOP
aDescriptor.WindowServiceName = "window"
aDescriptor.ParentIndex = -1
aDescriptor.Parent = None
aDescriptor.Bounds = Rectangle(10, 10, 640, 480)
#Set Window Attributes
gnDefaultWindowAttributes = \
com_sun_star_awt_WindowAttribute_BORDER + \
com_sun_star_awt_WindowAttribute_MOVEABLE + \
com_sun_star_awt_WindowAttribute_SIZEABLE + \
com_sun_star_awt_VclWindowPeerAttribute_CLIPCHILDREN
aDescriptor.WindowAttributes = gnDefaultWindowAttributes
#create a new blank container window
xPeer = None
try:
xPeer = xToolkit.createWindow(aDescriptor)
except Exception:
traceback.print_exc()
#define some further properties of the frame window
#if it's needed .-)
#xPeer->setBackground(...);
#create new empty frame and set window on it
xFrame = None
try:
xFrame = xMSF.createInstance("com.sun.star.frame.Frame")
except Exception:
traceback.print_exc()
xFrame.initialize(xPeer)
#from now this frame is usable ...
#and not part of the desktop tree.
#You are alone with him .-)
if listener is not None:
Desktop.getDesktop(xMSF).addTerminateListener(listener)
return xFrame
@classmethod
def load(self, xInterface, sURL, sFrame, xValues):
xComponent = None
try:
if not sURL.startswith("file://"):
sURL = systemPathToFileUrl(sURL)
xComponent = xInterface.loadComponentFromURL(
sURL, sFrame, 0, tuple(xValues))
except Exception:
traceback.print_exc()
return xComponent
@classmethod
def store(self, xMSF, xComponent, StorePath, FilterName):
try:
if len(FilterName):
oStoreProperties = list(range(2))
oStoreProperties[0] = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
oStoreProperties[0].Name = "FilterName"
oStoreProperties[0].Value = FilterName
oStoreProperties[1] = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
oStoreProperties[1].Name = "InteractionHandler"
oStoreProperties[1].Value = xMSF.createInstance(
"com.sun.star.comp.uui.UUIInteractionHandler")
else:
oStoreProperties = list(range(0))
StorePath = systemPathToFileUrl(StorePath)
sPath = StorePath[:(StorePath.rfind("/") + 1)]
sFile = StorePath[(StorePath.rfind("/") + 1):]
xComponent.storeToURL(
absolutize(sPath, sFile), tuple(oStoreProperties))
return True
except ErrorCodeIOException:
#Throw this exception when trying to save a file
#which is already opened in Libreoffice
#TODO: handle it properly
return True
pass
except Exception:
traceback.print_exc()
return False
def close(self, xComponent):
bState = False
if xComponent is not None:
try:
xComponent.close(True)
bState = True
except Exception:
print ("could not close doc")
bState = False
else:
bState = True
return bState
def showMessageBox(
self, xMSF, windowServiceName, windowAttribute, MessageText):
return SystemDialog.showMessageBox(
xMSF, windowServiceName, windowAttribute, MessageText)

View File

@@ -0,0 +1,48 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..common.ConfigGroup import ConfigGroup
class CGFax(ConfigGroup):
def __init__(self):
self.cp_Style = int()
self.cp_PrintCompanyLogo = bool()
self.cp_PrintDate = bool()
self.cp_PrintSubjectLine = bool()
self.cp_PrintSalutation = bool()
self.cp_PrintCommunicationType = bool()
self.cp_PrintGreeting = bool()
self.cp_PrintFooter = bool()
self.cp_CommunicationType = str()
self.cp_Salutation = str()
self.cp_Greeting = str()
self.cp_SenderAddressType = int()
self.cp_SenderCompanyName = str()
self.cp_SenderStreet = str()
self.cp_SenderPostCode = str()
self.cp_SenderState = str()
self.cp_SenderCity = str()
self.cp_SenderFax = str()
self.cp_ReceiverAddressType = int()
self.cp_Footer = str()
self.cp_FooterOnlySecondPage = bool()
self.cp_FooterPageNumbers = bool()
self.cp_CreationType = int()
self.cp_TemplateName = str()
self.cp_TemplatePath = str()

View File

@@ -0,0 +1,27 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from .CGFax import CGFax
from ..common.ConfigGroup import ConfigGroup
class CGFaxWizard(ConfigGroup):
def __init__(self):
self.cp_FaxType = int()
self.cp_BusinessFax = CGFax()
self.cp_PrivateFax = CGFax()

View File

@@ -0,0 +1,75 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import unohelper
import traceback
from .FaxWizardDialogImpl import FaxWizardDialogImpl, Desktop
from com.sun.star.lang import XServiceInfo
from com.sun.star.task import XJobExecutor
# pythonloader looks for a static g_ImplementationHelper variable
g_ImplementationHelper = unohelper.ImplementationHelper()
g_implName = "com.sun.star.wizards.fax.CallWizard"
# implement a UNO component by deriving from the standard unohelper.Base class
# and from the interface(s) you want to implement.
class CallWizard(unohelper.Base, XJobExecutor, XServiceInfo):
def __init__(self, ctx):
# store the component context for later use
self.ctx = ctx
def trigger(self, args):
try:
fw = FaxWizardDialogImpl(self.ctx.ServiceManager)
fw.startWizard(self.ctx.ServiceManager)
except Exception as e:
print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
traceback.format_exc())
@classmethod
def callRemote(self):
#Call the wizard remotely(see README)
try:
ConnectStr = \
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
xLocMSF = Desktop.connect(ConnectStr)
lw = FaxWizardDialogImpl(xLocMSF)
lw.startWizard(xLocMSF)
except Exception as e:
print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
traceback.format_exc())
def getImplementationName(self):
return g_implName
def supportsService(self, ServiceName):
return g_ImplementationHelper.supportsService(g_implName, ServiceName)
def getSupportedServiceNames(self):
return g_ImplementationHelper.getSupportedServiceNames(g_implName)
g_ImplementationHelper.addImplementation( \
CallWizard, # UNO object class
g_implName, # implementation name
("com.sun.star.task.Job",),) # list of implemented services
# (the only service)
# vim:set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -0,0 +1,142 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..text.TextDocument import TextDocument, traceback, \
TextFieldHandler, Configuration
from ..text.TextSectionHandler import TextSectionHandler
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
from com.sun.star.style.ParagraphAdjust import CENTER
from com.sun.star.text.PageNumberType import CURRENT
from com.sun.star.style.NumberingType import ARABIC
class FaxDocument(TextDocument):
def __init__(self, xMSF, listener):
super(FaxDocument,self).__init__(xMSF, listener, None,
"WIZARD_LIVE_PREVIEW")
self.keepLogoFrame = True
self.keepTypeFrame = True
def switchElement(self, sElement, bState):
try:
mySectionHandler = TextSectionHandler(self.xMSF,
self.xTextDocument)
oSection = \
mySectionHandler.xTextDocument.TextSections.getByName(sElement)
oSection.IsVisible = bState
except Exception:
traceback.print_exc()
def updateDateFields(self):
FH = TextFieldHandler(
self.xTextDocument, self.xTextDocument)
FH.updateDateFields()
def switchFooter(self, sPageStyle, bState, bPageNumber, sText):
if self.xTextDocument is not None:
try:
self.xTextDocument.lockControllers()
xPageStyleCollection = \
self.xTextDocument.StyleFamilies.getByName("PageStyles")
xPageStyle = xPageStyleCollection.getByName(sPageStyle)
if bState:
xPageStyle.setPropertyValue("FooterIsOn", True)
xFooterText = xPageStyle.FooterText
xFooterText.String = sText
if bPageNumber:
#Adding the Page Number
myCursor = xFooterText.Text.createTextCursor()
myCursor.gotoEnd(False)
xFooterText.insertControlCharacter(myCursor,
PARAGRAPH_BREAK, False)
myCursor.setPropertyValue("ParaAdjust", CENTER )
xPageNumberField = \
self.xTextDocument.createInstance(
"com.sun.star.text.TextField.PageNumber")
xPageNumberField.setPropertyValue("SubType", CURRENT)
xPageNumberField.NumberingType = ARABIC
xFooterText.insertTextContent(xFooterText.End,
xPageNumberField, False)
else:
xPageStyle.FooterIsOn = False
self.xTextDocument.unlockControllers()
except Exception:
self.xTextDocument.lockControllers()
traceback.print_exc()
def hasElement(self, sElement):
if self.xTextDocument is not None:
mySectionHandler = TextSectionHandler(self.xMSF,
self.xTextDocument)
return mySectionHandler.hasTextSectionByName(sElement)
else:
return False
def switchUserField(self, sFieldName, sNewContent, bState):
myFieldHandler = TextFieldHandler( self.xMSF, self.xTextDocument)
if bState:
myFieldHandler.changeUserFieldContent(sFieldName, sNewContent)
else:
myFieldHandler.changeUserFieldContent(sFieldName, "")
def fillSenderWithUserData(self):
try:
myFieldHandler = TextFieldHandler(self.xTextDocument,
self.xTextDocument)
oUserDataAccess = Configuration.getConfigurationRoot(
self.xMSF, "org.openoffice.UserProfile/Data", False)
myFieldHandler.changeUserFieldContent(
"Company", oUserDataAccess.getByName("o"))
myFieldHandler.changeUserFieldContent(
"Street", oUserDataAccess.getByName("street"))
myFieldHandler.changeUserFieldContent(
"PostCode", oUserDataAccess.getByName("postalcode"))
myFieldHandler.changeUserFieldContent(
"State", oUserDataAccess.getByName("st"))
myFieldHandler.changeUserFieldContent(
"City", oUserDataAccess.getByName("l"))
myFieldHandler.changeUserFieldContent(
"Fax", oUserDataAccess.getByName("facsimiletelephonenumber"))
except Exception:
traceback.print_exc()
def killEmptyUserFields(self):
myFieldHandler = TextFieldHandler(
self.xMSF, self.xTextDocument)
myFieldHandler.removeUserFieldByContent()
def killEmptyFrames(self):
try:
if not self.keepLogoFrame:
xTF = self.getFrameByName("Company Logo",
self.xTextDocument)
if xTF is not None:
xTF.dispose()
if not self.keepTypeFrame:
xTF = self.getFrameByName("Communication Type",
self.xTextDocument)
if xTF is not None:
xTF.dispose()
except Exception:
traceback.print_exc()

View File

@@ -0,0 +1,660 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from .FaxWizardDialogResources import FaxWizardDialogResources
from .FaxWizardDialogConst import FaxWizardDialogConst, HIDMAIN, HID
from ..ui.WizardDialog import WizardDialog, uno, UIConsts, PropertyNames
from com.sun.star.awt.FontUnderline import SINGLE
class FaxWizardDialog(WizardDialog):
def __init__(self, xmsf):
super(FaxWizardDialog,self).__init__(xmsf, HIDMAIN )
#Load Resources
self.resources = FaxWizardDialogResources()
#set dialog properties...
self.setDialogProperties(True, 210, True, 104, 52, 1, 1,
self.resources.resFaxWizardDialog_title, 310)
self.fontDescriptor4 = \
uno.createUnoStruct('com.sun.star.awt.FontDescriptor')
self.fontDescriptor5 = \
uno.createUnoStruct('com.sun.star.awt.FontDescriptor')
self.fontDescriptor4.Weight = 100
self.fontDescriptor5.Weight = 150
def buildStep1(self):
self.optBusinessFax = self.insertRadioButton("optBusinessFax",
FaxWizardDialogConst.OPTBUSINESSFAX_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.OPTBUSINESSFAX_HID,
self.resources.resoptBusinessFax_value, 97, 28, 1, 1, 184),
self)
self.lstBusinessStyle = self.insertListBox("lstBusinessStyle",
FaxWizardDialogConst.LSTBUSINESSSTYLE_ACTION_PERFORMED,
FaxWizardDialogConst.LSTBUSINESSSTYLE_ITEM_CHANGED,
("Dropdown", PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(True, 12, FaxWizardDialogConst.LSTBUSINESSSTYLE_HID,
180, 40, 1, 3, 74), self)
self.optPrivateFax = self.insertRadioButton("optPrivateFax",
FaxWizardDialogConst.OPTPRIVATEFAX_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.OPTPRIVATEFAX_HID,
self.resources.resoptPrivateFax_value,97, 81, 1, 2, 184), self)
self.lstPrivateStyle = self.insertListBox("lstPrivateStyle",
FaxWizardDialogConst.LSTPRIVATESTYLE_ACTION_PERFORMED,
FaxWizardDialogConst.LSTPRIVATESTYLE_ITEM_CHANGED,
("Dropdown", PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(True, 12, FaxWizardDialogConst.LSTPRIVATESTYLE_HID,
180, 95, 1, 4, 74), self)
self.insertLabel("lblBusinessStyle",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.reslblBusinessStyle_value,
110, 42, 1, 32, 60))
self.insertLabel("lblTitle1",
("FontDescriptor", PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(self.fontDescriptor5, 16, self.resources.reslblTitle1_value,
True, 91, 8, 1, 37, 212))
self.insertLabel("lblPrivateStyle",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.reslblPrivateStyle_value, 110, 95, 1, 50, 60))
self.insertLabel("lblIntroduction",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(39, self.resources.reslblIntroduction_value,
True, 104, 145, 1, 55, 199))
self.ImageControl3 = self.insertInfoImage(92, 145, 1)
def buildStep2(self):
self.chkUseLogo = self.insertCheckBox("chkUseLogo",
FaxWizardDialogConst.CHKUSELOGO_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKUSELOGO_HID,
self.resources.reschkUseLogo_value, 97, 28, 0, 2, 5, 212),
self)
self.chkUseDate = self.insertCheckBox("chkUseDate",
FaxWizardDialogConst.CHKUSEDATE_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKUSEDATE_HID,
self.resources.reschkUseDate_value, 97, 43, 0, 2, 6, 212),
self)
self.chkUseCommunicationType = self.insertCheckBox(
"chkUseCommunicationType",
FaxWizardDialogConst.CHKUSECOMMUNICATIONTYPE_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKUSECOMMUNICATIONTYPE_HID,
self.resources.reschkUseCommunicationType_value,
97, 57, 0, 2, 7, 100), self)
self.lstCommunicationType = self.insertComboBox(
"lstCommunicationType",
FaxWizardDialogConst.LSTCOMMUNICATIONTYPE_ACTION_PERFORMED,
FaxWizardDialogConst.LSTCOMMUNICATIONTYPE_ITEM_CHANGED,
FaxWizardDialogConst.LSTCOMMUNICATIONTYPE_TEXT_CHANGED,
("Dropdown", PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(True, 12, FaxWizardDialogConst.LSTCOMMUNICATIONTYPE_HID,
105, 68, 2, 8, 174), self)
self.chkUseSubject = self.insertCheckBox("chkUseSubject",
FaxWizardDialogConst.CHKUSESUBJECT_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKUSESUBJECT_HID,
self.resources.reschkUseSubject_value, 97, 87, 0, 2, 9, 212),
self)
self.chkUseSalutation = self.insertCheckBox("chkUseSalutation",
FaxWizardDialogConst.CHKUSESALUTATION_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKUSESALUTATION_HID,
self.resources.reschkUseSalutation_value,
97, 102, 0, 2, 10, 100), self)
self.lstSalutation = self.insertComboBox("lstSalutation",
FaxWizardDialogConst.LSTSALUTATION_ACTION_PERFORMED,
FaxWizardDialogConst.LSTSALUTATION_ITEM_CHANGED,
FaxWizardDialogConst.LSTSALUTATION_TEXT_CHANGED,
("Dropdown", PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(True, 12, FaxWizardDialogConst.LSTSALUTATION_HID,
105, 113, 2, 11, 174), self)
self.chkUseGreeting = self.insertCheckBox("chkUseGreeting",
FaxWizardDialogConst.CHKUSEGREETING_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKUSEGREETING_HID,
self.resources.reschkUseGreeting_value,
97, 132, 0, 2, 12, 100), self)
self.lstGreeting = self.insertComboBox("lstGreeting",
FaxWizardDialogConst.LSTGREETING_ACTION_PERFORMED,
FaxWizardDialogConst.LSTGREETING_ITEM_CHANGED,
FaxWizardDialogConst.LSTGREETING_TEXT_CHANGED,
("Dropdown", PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(True, 12, FaxWizardDialogConst.LSTGREETING_HID,
105, 143, 2, 13, 174), self)
self.chkUseFooter = self.insertCheckBox("chkUseFooter",
FaxWizardDialogConst.CHKUSEFOOTER_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKUSEFOOTER_HID,
self.resources.reschkUseFooter_value, 97, 163,
0, 2, 14, 212), self)
self.insertLabel("lblTitle3",
("FontDescriptor", PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(self.fontDescriptor5, 16, self.resources.reslblTitle3_value,
True, 91, 8, 2, 59, 212))
def buildStep3(self):
self.optSenderPlaceholder = self.insertRadioButton(
"optSenderPlaceholder",
FaxWizardDialogConst.OPTSENDERPLACEHOLDER_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.OPTSENDERPLACEHOLDER_HID,
self.resources.resoptSenderPlaceholder_value,
104, 42, 3, 15, 149), self)
self.optSenderDefine = self.insertRadioButton("optSenderDefine",
FaxWizardDialogConst.OPTSENDERDEFINE_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.OPTSENDERDEFINE_HID,
self.resources.resoptSenderDefine_value,
104, 54, 3, 16, 149), self)
self.txtSenderName = self.insertTextField("txtSenderName",
FaxWizardDialogConst.TXTSENDERNAME_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(12, FaxWizardDialogConst.TXTSENDERNAME_HID,
182, 67, 3, 17, 119), self)
self.txtSenderStreet = self.insertTextField("txtSenderStreet",
FaxWizardDialogConst.TXTSENDERSTREET_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(12, FaxWizardDialogConst.TXTSENDERSTREET_HID,
182, 81, 3, 18, 119), self)
self.txtSenderPostCode = self.insertTextField("txtSenderPostCode",
FaxWizardDialogConst.TXTSENDERPOSTCODE_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(12, FaxWizardDialogConst.TXTSENDERPOSTCODE_HID,
182, 95, 3, 19, 25), self)
self.txtSenderState = self.insertTextField("txtSenderState",
FaxWizardDialogConst.TXTSENDERSTATE_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(12, FaxWizardDialogConst.TXTSENDERSTATE_HID,
211, 95, 3, 20, 21), self)
self.txtSenderCity = self.insertTextField("txtSenderCity",
FaxWizardDialogConst.TXTSENDERCITY_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(12, FaxWizardDialogConst.TXTSENDERCITY_HID,
236, 95, 3, 21, 65), self)
self.txtSenderFax = self.insertTextField("txtSenderFax",
FaxWizardDialogConst.TXTSENDERFAX_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(12, FaxWizardDialogConst.TXTSENDERFAX_HID,
182, 109, 3, 22, 119), self)
self.optReceiverPlaceholder = self.insertRadioButton(
"optReceiverPlaceholder",
FaxWizardDialogConst.OPTRECEIVERPLACEHOLDER_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.OPTRECEIVERPLACEHOLDER_HID,
self.resources.resoptReceiverPlaceholder_value,
104, 148, 3, 23, 200), self)
self.optReceiverDatabase = self.insertRadioButton(
"optReceiverDatabase",
FaxWizardDialogConst.OPTRECEIVERDATABASE_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.OPTRECEIVERDATABASE_HID,
self.resources.resoptReceiverDatabase_value,
104, 160, 3, 24, 200), self)
self.insertLabel("lblSenderAddress",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.reslblSenderAddress_value,
97, 28, 3, 46, 136))
self.insertFixedLine("FixedLine2", (PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(5, 90, 126, 3, 51, 212))
self.insertLabel("lblSenderName",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.reslblSenderName_value,
113, 69, 3, 52, 68))
self.insertLabel("lblSenderStreet",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.reslblSenderStreet_value,
113, 82, 3, 53, 68))
self.insertLabel("lblPostCodeCity",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.reslblPostCodeCity_value,
113, 97, 3, 54, 68))
self.insertLabel("lblTitle4",
("FontDescriptor",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(self.fontDescriptor5, 16, self.resources.reslblTitle4_value,
True, 91, 8, 3, 60, 212))
self.insertLabel("lblSenderFax",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.resLabel1_value, 113, 111, 3, 68, 68))
self.insertLabel("Label2",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.resLabel2_value, 97, 137, 3, 69, 136))
def buildStep4(self):
self.txtFooter = self.insertTextField("txtFooter",
FaxWizardDialogConst.TXTFOOTER_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(47, FaxWizardDialogConst.TXTFOOTER_HID,
True, 97, 40, 4, 25, 203), self)
self.chkFooterNextPages = self.insertCheckBox("chkFooterNextPages",
FaxWizardDialogConst.CHKFOOTERNEXTPAGES_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKFOOTERNEXTPAGES_HID,
self.resources.reschkFooterNextPages_value,
97, 92, 0, 4, 26, 202), self)
self.chkFooterPageNumbers = self.insertCheckBox("chkFooterPageNumbers",
FaxWizardDialogConst.CHKFOOTERPAGENUMBERS_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STATE,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.CHKFOOTERPAGENUMBERS_HID,
self.resources.reschkFooterPageNumbers_value,
97, 106, 0, 4, 27, 201), self)
self.insertLabel("lblFooter",
("FontDescriptor",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(self.fontDescriptor4, 8, self.resources.reslblFooter_value,
97, 28, 4, 33, 116))
self.insertLabel("lblTitle5",
("FontDescriptor",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(self.fontDescriptor5, 16, self.resources.reslblTitle5_value,
True, 91, 8, 4, 61, 212))
def buildStep5(self):
self.txtTemplateName = self.insertTextField("txtTemplateName",
FaxWizardDialogConst.TXTTEMPLATENAME_TEXT_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
"Text",
PropertyNames.PROPERTY_WIDTH),
(12, FaxWizardDialogConst.TXTTEMPLATENAME_HID, 202, 56, 5, 28,
self.resources.restxtTemplateName_value, 100), self)
self.optCreateFax = self.insertRadioButton("optCreateFax",
FaxWizardDialogConst.OPTCREATEFAX_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.OPTCREATEFAX_HID,
self.resources.resoptCreateFax_value,
104, 111, 5, 30, 198), self)
self.optMakeChanges = self.insertRadioButton("optMakeChanges",
FaxWizardDialogConst.OPTMAKECHANGES_ITEM_CHANGED,
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, FaxWizardDialogConst.OPTMAKECHANGES_HID,
self.resources.resoptMakeChanges_value,
104, 123, 5, 31, 198), self)
self.insertLabel("lblFinalExplanation1",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(28, self.resources.reslblFinalExplanation1_value,
True, 97, 28, 5, 34, 205))
self.insertLabel("lblProceed",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.reslblProceed_value, 97, 100, 5,
35, 204))
self.insertLabel("lblFinalExplanation2",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(33, self.resources.reslblFinalExplanation2_value,
True, 104, 145, 5, 36, 199))
self.insertImage("ImageControl2",
("Border",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_IMAGEURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
"ScaleImage",
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(0, 10, UIConsts.INFOIMAGEURL, 92, 145,
False, 5, 47, 10))
self.insertLabel("lblTemplateName",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(8, self.resources.reslblTemplateName_value, 97, 58, 5,
57, 101))
self.insertLabel("lblTitle6",
("FontDescriptor",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(self.fontDescriptor5, 16, self.resources.reslblTitle6_value,
True, 91, 8, 5, 62, 212))

View File

@@ -0,0 +1,99 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..common.HelpIds import HelpIds
HID = 41119 #enter first hid here
HIDMAIN = 41180
class FaxWizardDialogConst:
OPTBUSINESSFAX_ITEM_CHANGED = "optBusinessFaxItemChanged"
LSTBUSINESSSTYLE_ACTION_PERFORMED = None
LSTBUSINESSSTYLE_ITEM_CHANGED = "lstBusinessStyleItemChanged"
OPTPRIVATEFAX_ITEM_CHANGED = "optPrivateFaxItemChanged"
LSTPRIVATESTYLE_ACTION_PERFORMED = None
LSTPRIVATESTYLE_ITEM_CHANGED = "lstPrivateStyleItemChanged"
CHKUSELOGO_ITEM_CHANGED = "chkUseLogoItemChanged"
CHKUSEDATE_ITEM_CHANGED = "chkUseDateItemChanged"
CHKUSECOMMUNICATIONTYPE_ITEM_CHANGED = "chkUseCommunicationItemChanged"
LSTCOMMUNICATIONTYPE_ACTION_PERFORMED = None
LSTCOMMUNICATIONTYPE_ITEM_CHANGED = "lstCommunicationItemChanged"
LSTCOMMUNICATIONTYPE_TEXT_CHANGED = "lstCommunicationItemChanged"
CHKUSESUBJECT_ITEM_CHANGED = "chkUseSubjectItemChanged"
CHKUSESALUTATION_ITEM_CHANGED = "chkUseSalutationItemChanged"
LSTSALUTATION_ACTION_PERFORMED = None
LSTSALUTATION_ITEM_CHANGED = "lstSalutationItemChanged"
LSTSALUTATION_TEXT_CHANGED = "lstSalutationItemChanged"
CHKUSEGREETING_ITEM_CHANGED = "chkUseGreetingItemChanged"
LSTGREETING_ACTION_PERFORMED = None
LSTGREETING_ITEM_CHANGED = "lstGreetingItemChanged"
LSTGREETING_TEXT_CHANGED = "lstGreetingItemChanged"
CHKUSEFOOTER_ITEM_CHANGED = "chkUseFooterItemChanged"
OPTSENDERPLACEHOLDER_ITEM_CHANGED = "optSenderPlaceholderItemChanged"
OPTSENDERDEFINE_ITEM_CHANGED = "optSenderDefineItemChanged"
TXTSENDERNAME_TEXT_CHANGED = "txtSenderNameTextChanged"
TXTSENDERSTREET_TEXT_CHANGED = "txtSenderStreetTextChanged"
TXTSENDERPOSTCODE_TEXT_CHANGED = "txtSenderPostCodeTextChanged"
TXTSENDERSTATE_TEXT_CHANGED = "txtSenderStateTextChanged"
TXTSENDERCITY_TEXT_CHANGED = "txtSenderCityTextChanged"
TXTSENDERFAX_TEXT_CHANGED = "txtSenderFaxTextChanged"
OPTRECEIVERPLACEHOLDER_ITEM_CHANGED = "optReceiverPlaceholderItemChanged"
OPTRECEIVERDATABASE_ITEM_CHANGED = "optReceiverDatabaseItemChanged"
TXTFOOTER_TEXT_CHANGED = "txtFooterTextChanged"
CHKFOOTERNEXTPAGES_ITEM_CHANGED = "chkFooterNextPagesItemChanged"
CHKFOOTERPAGENUMBERS_ITEM_CHANGED = "chkFooterPageNumbersItemChanged"
TXTTEMPLATENAME_TEXT_CHANGED = "txtTemplateNameTextChanged"
FILETEMPLATEPATH_TEXT_CHANGED = None
OPTCREATEFAX_ITEM_CHANGED = "optCreateFromTemplateItemChanged"
OPTMAKECHANGES_ITEM_CHANGED = "optMakeChangesItemChanged"
#Help IDs
OPTBUSINESSFAX_HID = HelpIds.getHelpIdString(HID + 1)
LSTBUSINESSSTYLE_HID = HelpIds.getHelpIdString(HID + 2)
OPTPRIVATEFAX_HID = HelpIds.getHelpIdString(HID + 3)
LSTPRIVATESTYLE_HID = HelpIds.getHelpIdString(HID + 4)
IMAGECONTROL3_HID = HelpIds.getHelpIdString(HID + 5)
CHKUSELOGO_HID = HelpIds.getHelpIdString(HID + 6)
CHKUSEDATE_HID = HelpIds.getHelpIdString(HID + 7)
CHKUSECOMMUNICATIONTYPE_HID = HelpIds.getHelpIdString(HID + 8)
LSTCOMMUNICATIONTYPE_HID = HelpIds.getHelpIdString(HID + 9)
CHKUSESUBJECT_HID = HelpIds.getHelpIdString(HID + 10)
CHKUSESALUTATION_HID = HelpIds.getHelpIdString(HID + 11)
LSTSALUTATION_HID = HelpIds.getHelpIdString(HID + 12)
CHKUSEGREETING_HID = HelpIds.getHelpIdString(HID + 13)
LSTGREETING_HID = HelpIds.getHelpIdString(HID + 14)
CHKUSEFOOTER_HID = HelpIds.getHelpIdString(HID + 15)
OPTSENDERPLACEHOLDER_HID = HelpIds.getHelpIdString(HID + 16)
OPTSENDERDEFINE_HID = HelpIds.getHelpIdString(HID + 17)
TXTSENDERNAME_HID = HelpIds.getHelpIdString(HID + 18)
TXTSENDERSTREET_HID = HelpIds.getHelpIdString(HID + 19)
TXTSENDERPOSTCODE_HID = HelpIds.getHelpIdString(HID + 20)
TXTSENDERSTATE_HID = HelpIds.getHelpIdString(HID + 21)
TXTSENDERCITY_HID = HelpIds.getHelpIdString(HID + 22)
TXTSENDERFAX_HID = HelpIds.getHelpIdString(HID + 23)
OPTRECEIVERPLACEHOLDER_HID = HelpIds.getHelpIdString(HID + 24)
OPTRECEIVERDATABASE_HID = HelpIds.getHelpIdString(HID + 25)
TXTFOOTER_HID = HelpIds.getHelpIdString(HID + 26)
CHKFOOTERNEXTPAGES_HID = HelpIds.getHelpIdString(HID + 27)
CHKFOOTERPAGENUMBERS_HID = HelpIds.getHelpIdString(HID + 28)
TXTTEMPLATENAME_HID = HelpIds.getHelpIdString(HID + 29)
FILETEMPLATEPATH_HID = HelpIds.getHelpIdString(HID + 30)
OPTCREATEFAX_HID = HelpIds.getHelpIdString(HID + 31)
OPTMAKECHANGES_HID = HelpIds.getHelpIdString(HID + 32)
IMAGECONTROL2_HID = HelpIds.getHelpIdString(HID + 33)

View File

@@ -0,0 +1,631 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
import os.path
from .FaxWizardDialog import FaxWizardDialog, uno, HID
from .CGFaxWizard import CGFaxWizard
from .FaxDocument import FaxDocument
from ..ui.PathSelection import PathSelection
from ..ui.event.UnoDataAware import UnoDataAware
from ..ui.event.RadioDataAware import RadioDataAware
from ..ui.event.CommonListener import TerminateListenerProcAdapter
from ..text.TextFieldHandler import TextFieldHandler
from ..text.TextElement import TextElement
from ..common.Configuration import Configuration
from ..common.SystemDialog import SystemDialog
from ..common.NoValidPathException import NoValidPathException
from ..common.HelpIds import HelpIds
from ..common.FileAccess import FileAccess
from ..common.Desktop import Desktop
from ..document.OfficeDocument import OfficeDocument
from com.sun.star.awt.VclWindowPeerAttribute import YES_NO, DEF_NO
from com.sun.star.util import CloseVetoException
from com.sun.star.view.DocumentZoomType import OPTIMAL
from com.sun.star.document.UpdateDocMode import FULL_UPDATE
from com.sun.star.document.MacroExecMode import ALWAYS_EXECUTE
class FaxWizardDialogImpl(FaxWizardDialog):
def leaveStep(self, nOldStep, nNewStep):
pass
def enterStep(self, nOldStep, nNewStep):
pass
RM_SENDERRECEIVER = 3
RM_FOOTER = 4
def __init__(self, xmsf):
super(FaxWizardDialogImpl, self).__init__(xmsf)
self.lstBusinessStylePos = None
self.lstPrivateStylePos = None
self.bSaveSuccess = False
self.filenameChanged = False
def startWizard(self, xMSF):
self.running = True
try:
#Number of steps on WizardDialog
self.nMaxStep = 5
#instantiate The Document Frame for the Preview
self.terminateListener = TerminateListenerProcAdapter(self.queryTermination)
self.myFaxDoc = FaxDocument(xMSF, self.terminateListener)
#create the dialog:
self.drawNaviBar()
self.buildStep1()
self.buildStep2()
self.buildStep3()
self.buildStep4()
self.buildStep5()
self.initializeSalutation()
self.initializeGreeting()
self.initializeCommunication()
self.initializePaths()
#special Control for setting the save Path:
self.insertPathSelectionControl()
self.initializeTemplates(xMSF)
#load the last used settings
#from the registry and apply listeners to the controls:
self.initConfiguration()
if self.myPathSelection.xSaveTextBox.Text.lower() == "":
self.myPathSelection.initializePath()
xContainerWindow = self.myFaxDoc.xFrame.ContainerWindow
self.createWindowPeer(xContainerWindow)
#add the Roadmap to the dialog:
self.insertRoadmap()
#load the last used document and apply last used settings:
#TODO:
self.setConfiguration()
#If the configuration does not define
#Greeting/Salutation/CommunicationType yet choose a default
self.__setDefaultForGreetingAndSalutationAndCommunication()
#disable functionality that is not supported by the template:
self.initializeElements()
#disable the document, so that the user cannot change anything:
self.myFaxDoc.xFrame.ComponentWindow.Enable = False
self.executeDialogFromComponent(self.myFaxDoc.xFrame)
self.removeTerminateListener()
self.closeDocument()
self.running = False
except Exception:
self.removeTerminateListener()
traceback.print_exc()
self.running = False
return
def cancelWizard(self):
self.xUnoDialog.endExecute()
self.running = False
def finishWizard(self):
self.switchToStep(self.getCurrentStep(), self.nMaxStep)
endWizard = True
try:
self.sPath = self.myPathSelection.getSelectedPath()
if not self.sPath or not os.path.exists(self.sPath):
self.myPathSelection.triggerPathPicker()
self.sPath = self.myPathSelection.getSelectedPath()
#first, if the filename was not changed, thus
#it is coming from a saved session, check if the
# file exists and warn the user.
if not self.filenameChanged:
answer = SystemDialog.showMessageBox(
self.xMSF, "MessBox", YES_NO + DEF_NO,
self.resources.resOverwriteWarning,
self.xUnoDialog.Peer)
if answer == 3:
# user said: no, do not overwrite...
endWizard = False
return False
self.myFaxDoc.setWizardTemplateDocInfo( \
self.resources.resFaxWizardDialog_title,
self.resources.resTemplateDescription)
self.myFaxDoc.killEmptyUserFields()
self.myFaxDoc.keepLogoFrame = bool(self.chkUseLogo.State)
self.myFaxDoc.keepTypeFrame = \
bool(self.chkUseCommunicationType.State)
self.myFaxDoc.killEmptyFrames()
self.bSaveSuccess = OfficeDocument.store(self.xMSF,
self.myFaxDoc.xTextDocument, self.sPath, "writer8_template")
if self.bSaveSuccess:
self.saveConfiguration()
xIH = self.xMSF.createInstance( \
"com.sun.star.comp.uui.UUIInteractionHandler")
loadValues = list(range(4))
loadValues[0] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[0].Name = "AsTemplate"
loadValues[0].Value = True
loadValues[1] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[1].Name = "MacroExecutionMode"
loadValues[1].Value = ALWAYS_EXECUTE
loadValues[2] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[2].Name = "UpdateDocMode"
loadValues[2].Value = FULL_UPDATE
loadValues[3] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[3].Name = "InteractionHandler"
loadValues[3].Value = xIH
if self.bEditTemplate:
loadValues[0].Value = False
else:
loadValues[0].Value = True
oDoc = OfficeDocument.load(Desktop.getDesktop(self.xMSF),
self.sPath, "_default", loadValues)
oDoc.CurrentController.ViewSettings.ZoomType = OPTIMAL
else:
pass
#TODO: Error Handling
except Exception:
traceback.print_exc()
finally:
if endWizard:
self.xUnoDialog.endExecute()
self.running = False
return True
def closeDocument(self):
try:
self.myFaxDoc.xFrame.close(False)
except CloseVetoException:
traceback.print_exc()
def drawConstants(self):
'''Localise the template'''
constRangeList = self.myFaxDoc.searchFillInItems(1)
for i in constRangeList:
text = i.String.lower()
aux = TextElement(i, self.resources.dictConstants[text])
aux.write()
def insertRoadmap(self):
self.addRoadmap()
self.insertRoadMapItems(
self.resources.RoadmapLabels, [True, True, True, False, True])
self.setRoadmapInteractive(True)
self.setRoadmapComplete(True)
self.setCurrentRoadmapItemID(1)
def insertPathSelectionControl(self):
self.myPathSelection = PathSelection(self.xMSF,
self, PathSelection.TransferMode.SAVE,
PathSelection.DialogTypes.FILE)
self.myPathSelection.insert(
5, 97, 70, 205, 45, self.resources.reslblTemplatePath_value,
True, HelpIds.getHelpIdString(HID + 34),
HelpIds.getHelpIdString(HID + 35))
self.myPathSelection.sDefaultDirectory = self.sUserTemplatePath
self.myPathSelection.sDefaultName = "myFaxTemplate.ott"
self.myPathSelection.sDefaultFilter = "writer8_template"
self.myPathSelection.addSelectionListener(self)
def initializeTemplates(self, xMSF):
try:
self.sFaxPath = self.sTemplatePath + "/wizard/fax"
self.BusinessFiles = FileAccess.getFolderTitles(xMSF, "bus",
self.sFaxPath, self.resources.dictBusinessTemplate)
self.PrivateFiles = FileAccess.getFolderTitles(xMSF, "pri",
self.sFaxPath, self.resources.dictPrivateTemplate)
self.xDialogModel.lstBusinessStyle.StringItemList = \
tuple(self.BusinessFiles[0])
self.xDialogModel.lstPrivateStyle.StringItemList = \
tuple(self.PrivateFiles[0])
self.xDialogModel.lstBusinessStyle.SelectedItems = (0,)
self.xDialogModel.lstPrivateStyle.SelectedItems = (0,)
return True
except NoValidPathException:
traceback.print_exc()
return False
def initializeElements(self):
self.xDialogModel.chkUseLogo.Enabled = \
self.myFaxDoc.hasElement("Company Logo")
self.xDialogModel.chkUseSubject.Enabled = \
self.myFaxDoc.hasElement("Subject Line")
self.xDialogModel.chkUseDate.Enabled = \
self.myFaxDoc.hasElement("Date")
self.myFaxDoc.updateDateFields()
def initializeSalutation(self):
#'Salutation' listbox
self.xDialogModel.lstSalutation.StringItemList = \
tuple(self.resources.SalutationLabels)
def initializeGreeting(self):
#'Complimentary Close' listbox
self.xDialogModel.lstGreeting.StringItemList = \
tuple(self.resources.GreetingLabels)
def initializeCommunication(self):
#'Type of message' listbox
self.xDialogModel.lstCommunicationType.StringItemList = \
tuple(self.resources.CommunicationLabels)
def __setDefaultForGreetingAndSalutationAndCommunication(self):
if not self.lstSalutation.Text:
self.lstSalutation.setText(self.resources.SalutationLabels[0])
if not self.lstGreeting.Text:
self.lstGreeting.setText(self.resources.GreetingLabels[0])
if not self.lstCommunicationType.Text:
self.lstCommunicationType.setText( \
self.resources.CommunicationLabels[0])
def initConfiguration(self):
try:
self.myConfig = CGFaxWizard()
root = Configuration.getConfigurationRoot(self.xMSF,
"/org.openoffice.Office.Writer/Wizards/Fax", False)
self.myConfig.readConfiguration(root, "cp_")
RadioDataAware.attachRadioButtons(
self.myConfig, "cp_FaxType",
(self.optBusinessFax, self.optPrivateFax), True).updateUI()
UnoDataAware.attachListBox(
self.myConfig.cp_BusinessFax, "cp_Style",
self.lstBusinessStyle, True).updateUI()
UnoDataAware.attachListBox(
self.myConfig.cp_PrivateFax, "cp_Style", self.lstPrivateStyle,
True).updateUI()
cgl = self.myConfig.cp_BusinessFax
UnoDataAware.attachCheckBox(cgl,
"cp_PrintCompanyLogo", self.chkUseLogo, True).updateUI()
UnoDataAware.attachCheckBox(cgl,
"cp_PrintSubjectLine", self.chkUseSubject, True).updateUI()
UnoDataAware.attachCheckBox(cgl,
"cp_PrintSalutation", self.chkUseSalutation, True).updateUI()
UnoDataAware.attachCheckBox(cgl,
"cp_PrintDate", self.chkUseDate, True).updateUI()
UnoDataAware.attachCheckBox(cgl, "cp_PrintCommunicationType",
self.chkUseCommunicationType, True).updateUI()
UnoDataAware.attachCheckBox(cgl,
"cp_PrintGreeting", self.chkUseGreeting, True).updateUI()
UnoDataAware.attachCheckBox(cgl,
"cp_PrintFooter", self.chkUseFooter, True).updateUI()
UnoDataAware.attachEditControl(cgl,
"cp_Salutation", self.lstSalutation, True).updateUI()
UnoDataAware.attachEditControl(cgl,
"cp_Greeting", self.lstGreeting, True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_CommunicationType",
self.lstCommunicationType, True).updateUI()
RadioDataAware.attachRadioButtons(cgl, "cp_SenderAddressType",
(self.optSenderDefine, self.optSenderPlaceholder),
True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_SenderCompanyName",
self.txtSenderName, True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_SenderStreet",
self.txtSenderStreet, True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_SenderPostCode",
self.txtSenderPostCode, True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_SenderState",
self.txtSenderState, True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_SenderCity",
self.txtSenderCity, True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_SenderFax",
self.txtSenderFax, True).updateUI()
RadioDataAware.attachRadioButtons(cgl, "cp_ReceiverAddressType",
(self.optReceiverDatabase, self.optReceiverPlaceholder),
True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_Footer",
self.txtFooter, True).updateUI()
UnoDataAware.attachCheckBox(cgl, "cp_FooterOnlySecondPage",
self.chkFooterNextPages, True).updateUI()
UnoDataAware.attachCheckBox(cgl, "cp_FooterPageNumbers",
self.chkFooterPageNumbers, True).updateUI()
RadioDataAware.attachRadioButtons(cgl, "cp_CreationType",
(self.optCreateFax, self.optMakeChanges), True).updateUI()
UnoDataAware.attachEditControl(cgl,
"cp_TemplateName", self.txtTemplateName, True).updateUI()
UnoDataAware.attachEditControl(cgl, "cp_TemplatePath",
self.myPathSelection.xSaveTextBox, True).updateUI()
except Exception:
traceback.print_exc()
def saveConfiguration(self):
try:
root = Configuration.getConfigurationRoot(self.xMSF,
"/org.openoffice.Office.Writer/Wizards/Fax", True)
self.myConfig.writeConfiguration(root, "cp_")
root.commitChanges()
except Exception:
traceback.print_exc()
def setConfiguration(self):
#set correct Configuration tree:
if self.optBusinessFax.State:
self.optBusinessFaxItemChanged()
elif self.optPrivateFax.State:
self.optPrivateFaxItemChanged()
def optBusinessFaxItemChanged(self):
self.lstPrivateStylePos = None
self.xDialogModel.lblBusinessStyle.Enabled = True
self.xDialogModel.lstBusinessStyle.Enabled = True
self.xDialogModel.lblPrivateStyle.Enabled = False
self.xDialogModel.lstPrivateStyle.Enabled = False
self.lstBusinessStyleItemChanged()
self.__enableSenderReceiver()
self.__setPossibleFooter(True)
def lstBusinessStyleItemChanged(self):
selectedItemPos = self.lstBusinessStyle.SelectedItemPos
#avoid to load the same item again
if self.lstBusinessStylePos != selectedItemPos:
self.lstBusinessStylePos = selectedItemPos
self.myFaxDoc.loadAsPreview(
self.BusinessFiles[1][selectedItemPos], False)
self.initializeElements()
self.setElements()
self.drawConstants()
def optPrivateFaxItemChanged(self):
self.lstBusinessStylePos = None
self.xDialogModel.lblBusinessStyle.Enabled = False
self.xDialogModel.lstBusinessStyle.Enabled = False
self.xDialogModel.lblPrivateStyle.Enabled = True
self.xDialogModel.lstPrivateStyle.Enabled = True
self.lstPrivateStyleItemChanged()
self.__disableSenderReceiver()
self.__setPossibleFooter(False)
def lstPrivateStyleItemChanged(self):
selectedItemPos = self.lstPrivateStyle.SelectedItemPos
#avoid to load the same item again
if self.lstPrivateStylePos != selectedItemPos:
self.lstPrivateStylePos = selectedItemPos
self.myFaxDoc.loadAsPreview(
self.PrivateFiles[1][selectedItemPos], False)
self.initializeElements()
self.setElements()
def txtTemplateNameTextChanged(self):
# Change Template Title in Properties
xDocProps = self.myFaxDoc.xTextDocument.DocumentProperties
xDocProps.Title = self.txtTemplateName.Text
def optSenderPlaceholderItemChanged(self):
self.xDialogModel.lblSenderName.Enabled = False
self.xDialogModel.lblSenderStreet.Enabled = False
self.xDialogModel.lblPostCodeCity.Enabled = False
self.xDialogModel.lblSenderFax.Enabled = False
self.xDialogModel.txtSenderName.Enabled = False
self.xDialogModel.txtSenderStreet.Enabled = False
self.xDialogModel.txtSenderPostCode.Enabled = False
self.xDialogModel.txtSenderState.Enabled = False
self.xDialogModel.txtSenderCity.Enabled = False
self.xDialogModel.txtSenderFax.Enabled = False
self.myFaxDoc.fillSenderWithUserData()
def optSenderDefineItemChanged(self):
self.xDialogModel.lblSenderName.Enabled = True
self.xDialogModel.lblSenderStreet.Enabled = True
self.xDialogModel.lblPostCodeCity.Enabled = True
self.xDialogModel.lblSenderFax.Enabled = True
self.xDialogModel.txtSenderName.Enabled = True
self.xDialogModel.txtSenderStreet.Enabled = True
self.xDialogModel.txtSenderPostCode.Enabled = True
self.xDialogModel.txtSenderState.Enabled = True
self.xDialogModel.txtSenderCity.Enabled = True
self.xDialogModel.txtSenderFax.Enabled = True
self.myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF,
self.myFaxDoc.xTextDocument)
self.txtSenderNameTextChanged()
self.txtSenderStreetTextChanged()
self.txtSenderPostCodeTextChanged()
self.txtSenderStateTextChanged()
self.txtSenderCityTextChanged()
self.txtSenderFaxTextChanged()
def txtSenderNameTextChanged(self):
self.myFieldHandler.changeUserFieldContent(
"Company", self.txtSenderName.Text)
def txtSenderStreetTextChanged(self):
self.myFieldHandler.changeUserFieldContent(
"Street", self.txtSenderStreet.Text)
def txtSenderCityTextChanged(self):
self.myFieldHandler.changeUserFieldContent(
"City", self.txtSenderCity.Text)
def txtSenderPostCodeTextChanged(self):
self.myFieldHandler.changeUserFieldContent(
"PostCode", self.txtSenderPostCode.Text)
def txtSenderStateTextChanged(self):
self.myFieldHandler.changeUserFieldContent(
"State", self.txtSenderState.Text)
def txtSenderFaxTextChanged(self):
self.myFieldHandler.changeUserFieldContent(
"Fax", self.txtSenderFax.Text)
#switch Elements on/off --------------------------------------------------
def setElements(self):
#UI relevant:
if self.optSenderDefine.State:
self.optSenderDefineItemChanged()
if self.optSenderPlaceholder.State:
self.optSenderPlaceholderItemChanged()
self.chkUseLogoItemChanged()
self.chkUseSubjectItemChanged()
self.chkUseSalutationItemChanged()
self.chkUseGreetingItemChanged()
self.chkUseCommunicationItemChanged()
self.chkUseDateItemChanged()
self.chkUseFooterItemChanged()
self.txtTemplateNameTextChanged()
#not UI relevant:
if self.optReceiverDatabase.State:
self.optReceiverDatabaseItemChanged()
elif self.optReceiverPlaceholder.State:
self.optReceiverPlaceholderItemChanged()
if self.optCreateFax.State:
self.optCreateFromTemplateItemChanged()
elif self.optMakeChanges.State:
self.optMakeChangesItemChanged()
def chkUseLogoItemChanged(self):
if self.myFaxDoc.hasElement("Company Logo"):
self.myFaxDoc.switchElement("Company Logo",
bool(self.chkUseLogo.State))
def chkUseSubjectItemChanged(self):
if self.myFaxDoc.hasElement("Subject Line"):
self.myFaxDoc.switchElement("Subject Line",
bool(self.chkUseSubject.State))
def chkUseDateItemChanged(self):
if self.myFaxDoc.hasElement("Date"):
self.myFaxDoc.switchElement("Date",
bool(self.chkUseDate.State))
def chkUseFooterItemChanged(self):
try:
bFooterPossible = bool(self.chkUseFooter.State) \
and bool(self.xDialogModel.chkUseFooter.Enabled)
if bool(self.chkFooterNextPages.State):
self.myFaxDoc.switchFooter("First Page", False,
bool(self.chkFooterPageNumbers.State),
self.txtFooter.Text)
self.myFaxDoc.switchFooter("Standard", bFooterPossible,
bool(self.chkFooterPageNumbers.State),
self.txtFooter.Text)
else:
self.myFaxDoc.switchFooter("First Page", bFooterPossible,
bool(self.chkFooterPageNumbers.State),
self.txtFooter.Text)
self.myFaxDoc.switchFooter("Standard", bFooterPossible,
bool(self.chkFooterPageNumbers.State),
self.txtFooter.Text)
#enable/disable roadmap item for footer page
BPaperItem = self.getRoadmapItemByID( \
FaxWizardDialogImpl.RM_FOOTER)
BPaperItem.Enabled = bFooterPossible
except Exception:
traceback.print_exc()
def chkFooterNextPagesItemChanged(self):
self.chkUseFooterItemChanged()
def chkFooterPageNumbersItemChanged(self):
self.chkUseFooterItemChanged()
def txtFooterTextChanged(self):
self.myFaxDoc.switchFooter("First Page", True,
bool(self.chkFooterPageNumbers.State),
self.txtFooter.Text)
def chkUseSalutationItemChanged(self):
self.myFaxDoc.switchUserField("Salutation",
self.lstSalutation.Text, bool(self.chkUseSalutation.State))
self.xDialogModel.lstSalutation.Enabled = \
bool(self.chkUseSalutation.State)
def lstSalutationItemChanged(self):
self.myFaxDoc.switchUserField("Salutation",
self.lstSalutation.Text, bool(self.chkUseSalutation.State))
def chkUseCommunicationItemChanged(self):
self.myFaxDoc.switchUserField("CommunicationType",
self.lstCommunicationType.Text,
bool(self.chkUseCommunicationType.State))
self.xDialogModel.lstCommunicationType.Enabled = \
bool(self.chkUseCommunicationType.State)
def lstCommunicationItemChanged(self):
self.myFaxDoc.switchUserField("CommunicationType",
self.lstCommunicationType.Text,
bool(self.chkUseCommunicationType.State))
def chkUseGreetingItemChanged(self):
self.myFaxDoc.switchUserField("Greeting",
self.lstGreeting.Text, bool(self.chkUseGreeting.State))
self.xDialogModel.lstGreeting.Enabled = \
bool(self.chkUseGreeting.State)
def lstGreetingItemChanged(self):
self.myFaxDoc.switchUserField("Greeting", self.lstGreeting.Text,
bool(self.chkUseGreeting.State))
def __setPossibleFooter(self, bState):
self.xDialogModel.chkUseFooter.Enabled = bState
if not bState:
self.chkUseFooter.State = 0
self.chkUseFooterItemChanged()
def optReceiverPlaceholderItemChanged(self):
OfficeDocument.attachEventCall(
self.myFaxDoc.xTextDocument, "OnNew", "StarBasic",
"macro:///Template.Correspondence.Placeholder()")
def optReceiverDatabaseItemChanged(self):
OfficeDocument.attachEventCall(
self.myFaxDoc.xTextDocument, "OnNew", "StarBasic",
"macro:///Template.Correspondence.Database()")
def __enableSenderReceiver(self):
BPaperItem = self.getRoadmapItemByID( \
FaxWizardDialogImpl.RM_SENDERRECEIVER)
BPaperItem.Enabled = True
def __disableSenderReceiver(self):
BPaperItem = self.getRoadmapItemByID( \
FaxWizardDialogImpl.RM_SENDERRECEIVER)
BPaperItem.Enabled = False
def validatePath(self):
if self.myPathSelection.usedPathPicker:
self.filenameChanged = True
self.myPathSelection.usedPathPicker = False

View File

@@ -0,0 +1,137 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class FaxWizardDialogResources(object):
def __init__(self):
import sys, os
if sys.version_info < (3,4):
import imp
imp.load_source('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc'))
import strings
elif sys.version_info < (3,7):
# imp is deprecated since Python v.3.4
from importlib.machinery import SourceFileLoader
SourceFileLoader('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc')).load_module()
import strings
else:
# have to jump through hoops since 3.7, partly because python does not like loading modules that do have a .py extension
import importlib
import importlib.util
import importlib.machinery
module_name = 'strings'
path = os.path.join(os.path.dirname(__file__), '../common/strings.hrc')
spec = importlib.util.spec_from_loader(
module_name,
importlib.machinery.SourceFileLoader(module_name, path)
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[module_name] = module
strings = module
self.resFaxWizardDialog_title = strings.RID_FAXWIZARDDIALOG_START_1
self.resoptBusinessFax_value = strings.RID_FAXWIZARDDIALOG_START_3
self.resoptPrivateFax_value = strings.RID_FAXWIZARDDIALOG_START_4
self.reschkUseLogo_value = strings.RID_FAXWIZARDDIALOG_START_5
self.reschkUseSubject_value = strings.RID_FAXWIZARDDIALOG_START_6
self.reschkUseSalutation_value = strings.RID_FAXWIZARDDIALOG_START_7
self.reschkUseGreeting_value = strings.RID_FAXWIZARDDIALOG_START_8
self.reschkUseFooter_value = strings.RID_FAXWIZARDDIALOG_START_9
self.resoptSenderPlaceholder_value = strings.RID_FAXWIZARDDIALOG_START_10
self.resoptSenderDefine_value = strings.RID_FAXWIZARDDIALOG_START_11
self.restxtTemplateName_value = strings.RID_FAXWIZARDDIALOG_START_12
self.resoptCreateFax_value = strings.RID_FAXWIZARDDIALOG_START_13
self.resoptMakeChanges_value = strings.RID_FAXWIZARDDIALOG_START_14
self.reslblBusinessStyle_value = strings.RID_FAXWIZARDDIALOG_START_15
self.reslblPrivateStyle_value = strings.RID_FAXWIZARDDIALOG_START_16
self.reslblIntroduction_value = strings.RID_FAXWIZARDDIALOG_START_17
self.reslblSenderAddress_value = strings.RID_FAXWIZARDDIALOG_START_18
self.reslblSenderName_value = strings.RID_FAXWIZARDDIALOG_START_19
self.reslblSenderStreet_value = strings.RID_FAXWIZARDDIALOG_START_20
self.reslblPostCodeCity_value = strings.RID_FAXWIZARDDIALOG_START_21
self.reslblFooter_value = strings.RID_FAXWIZARDDIALOG_START_22
self.reslblFinalExplanation1_value = strings.RID_FAXWIZARDDIALOG_START_23
self.reslblFinalExplanation2_value = strings.RID_FAXWIZARDDIALOG_START_24
self.reslblTemplateName_value = strings.RID_FAXWIZARDDIALOG_START_25
self.reslblTemplatePath_value = strings.RID_FAXWIZARDDIALOG_START_26
self.reslblProceed_value = strings.RID_FAXWIZARDDIALOG_START_27
self.reslblTitle1_value = strings.RID_FAXWIZARDDIALOG_START_28
self.reslblTitle3_value = strings.RID_FAXWIZARDDIALOG_START_29
self.reslblTitle4_value = strings.RID_FAXWIZARDDIALOG_START_30
self.reslblTitle5_value = strings.RID_FAXWIZARDDIALOG_START_31
self.reslblTitle6_value = strings.RID_FAXWIZARDDIALOG_START_32
self.reschkFooterNextPages_value = strings.RID_FAXWIZARDDIALOG_START_33
self.reschkFooterPageNumbers_value = strings.RID_FAXWIZARDDIALOG_START_34
self.reschkUseDate_value = strings.RID_FAXWIZARDDIALOG_START_35
self.reschkUseCommunicationType_value = strings.RID_FAXWIZARDDIALOG_START_36
self.resLabel1_value = strings.RID_FAXWIZARDDIALOG_START_37
self.resoptReceiverPlaceholder_value = strings.RID_FAXWIZARDDIALOG_START_38
self.resoptReceiverDatabase_value = strings.RID_FAXWIZARDDIALOG_START_39
self.resLabel2_value = strings.RID_FAXWIZARDDIALOG_START_40
#Create a Dictionary for the constants values.
self.dictConstants = {
"#to#" : strings.RID_FAXWIZARDDIALOG_START_41,
"#from#" : strings.RID_FAXWIZARDDIALOG_START_42,
"#faxconst#" : strings.RID_FAXWIZARDDIALOG_START_43,
"#telconst#" : strings.RID_FAXWIZARDDIALOG_START_44,
"#emailconst#" : strings.RID_FAXWIZARDDIALOG_START_45,
"#consist1#" : strings.RID_FAXWIZARDDIALOG_START_46,
"#consist2#" : strings.RID_FAXWIZARDDIALOG_START_47,
"#consist3#" : strings.RID_FAXWIZARDDIALOG_START_48}
#Create a dictionary for localising the private template
self.dictPrivateTemplate = {
"Bottle" : strings.RID_FAXWIZARDDIALOG_START_49,
"Fax" : strings.RID_FAXWIZARDDIALOG_START_56,
"Lines" : strings.RID_FAXWIZARDDIALOG_START_50,
"Marine" : strings.RID_FAXWIZARDDIALOG_START_51}
#Create a dictionary for localising the business template
self.dictBusinessTemplate = {
"Classic Fax" : strings.RID_FAXWIZARDDIALOG_START_52,
"Classic Fax from Private" : strings.RID_FAXWIZARDDIALOG_START_53,
"Modern Fax" : strings.RID_FAXWIZARDDIALOG_START_54,
"Modern Fax from Private" : strings.RID_FAXWIZARDDIALOG_START_55}
#Common Resources
self.resOverwriteWarning = strings.RID_COMMON_START_19
self.resTemplateDescription = strings.RID_COMMON_START_20
self.RoadmapLabels = []
self.RoadmapLabels.append(strings.RID_FAXWIZARDROADMAP_START_1)
self.RoadmapLabels.append(strings.RID_FAXWIZARDROADMAP_START_2)
self.RoadmapLabels.append(strings.RID_FAXWIZARDROADMAP_START_3)
self.RoadmapLabels.append(strings.RID_FAXWIZARDROADMAP_START_4)
self.RoadmapLabels.append(strings.RID_FAXWIZARDROADMAP_START_5)
self.SalutationLabels = []
self.SalutationLabels.append(strings.RID_FAXWIZARDSALUTATION_START_1)
self.SalutationLabels.append(strings.RID_FAXWIZARDSALUTATION_START_2)
self.SalutationLabels.append(strings.RID_FAXWIZARDSALUTATION_START_3)
self.SalutationLabels.append(strings.RID_FAXWIZARDSALUTATION_START_4)
self.GreetingLabels = []
self.GreetingLabels.append(strings.RID_FAXWIZARDGREETING_START_1)
self.GreetingLabels.append(strings.RID_FAXWIZARDGREETING_START_2)
self.GreetingLabels.append(strings.RID_FAXWIZARDGREETING_START_3)
self.GreetingLabels.append(strings.RID_FAXWIZARDGREETING_START_4)
self.CommunicationLabels = []
self.CommunicationLabels.append(strings.RID_FAXWIZARDCOMMUNICATION_START_1)
self.CommunicationLabels.append(strings.RID_FAXWIZARDCOMMUNICATION_START_2)
self.CommunicationLabels.append(strings.RID_FAXWIZARDCOMMUNICATION_START_3)

View File

@@ -0,0 +1,53 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from .CGPaperElementLocation import CGPaperElementLocation
from ..common.ConfigGroup import ConfigGroup
class CGLetter(ConfigGroup):
def __init__(self):
self.cp_Style = int()
self.cp_BusinessPaper = bool()
self.cp_CompanyLogo = CGPaperElementLocation()
self.cp_CompanyAddress = CGPaperElementLocation()
self.cp_PaperCompanyAddressReceiverField = bool()
self.cp_PaperFooter = bool()
self.cp_PaperFooterHeight = float()
self.cp_PrintCompanyLogo = bool()
self.cp_PrintCompanyAddressReceiverField = bool()
self.cp_PrintLetterSigns = bool()
self.cp_PrintSubjectLine = bool()
self.cp_PrintSalutation = bool()
self.cp_PrintBendMarks = bool()
self.cp_PrintGreeting = bool()
self.cp_PrintFooter = bool()
self.cp_Salutation = str()
self.cp_Greeting = str()
self.cp_SenderAddressType = int()
self.cp_SenderCompanyName = str()
self.cp_SenderStreet = str()
self.cp_SenderPostCode = str()
self.cp_SenderState = str()
self.cp_SenderCity = str()
self.cp_ReceiverAddressType = int()
self.cp_Footer = str()
self.cp_FooterOnlySecondPage = bool()
self.cp_FooterPageNumbers = bool()
self.cp_CreationType = int()
self.cp_TemplateName = str()
self.cp_TemplatePath = str()

View File

@@ -0,0 +1,27 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..common.ConfigGroup import ConfigGroup
from .CGLetter import CGLetter
class CGLetterWizard (ConfigGroup):
def __init__(self):
self.cp_LetterType = int()
self.cp_BusinessLetter = CGLetter()
self.cp_PrivateOfficialLetter = CGLetter()
self.cp_PrivateLetter = CGLetter()

View File

@@ -0,0 +1,27 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..common.ConfigGroup import ConfigGroup
class CGPaperElementLocation(ConfigGroup):
def __init__(self):
self.cp_Display = bool()
self.cp_Width = float()
self.cp_Height = float()
self.cp_X = float()
self.cp_Y = float()

View File

@@ -0,0 +1,75 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import unohelper
import traceback
from .LetterWizardDialogImpl import LetterWizardDialogImpl, Desktop
from com.sun.star.lang import XServiceInfo
from com.sun.star.task import XJobExecutor
# pythonloader looks for a static g_ImplementationHelper variable
g_ImplementationHelper = unohelper.ImplementationHelper()
g_implName = "com.sun.star.wizards.letter.CallWizard"
# implement a UNO component by deriving from the standard unohelper.Base class
# and from the interface(s) you want to implement.
class CallWizard(unohelper.Base, XJobExecutor, XServiceInfo):
def __init__(self, ctx):
# store the component context for later use
self.ctx = ctx
def trigger(self, args):
try:
lw = LetterWizardDialogImpl(self.ctx.ServiceManager)
lw.startWizard(self.ctx.ServiceManager)
except Exception as e:
print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
traceback.format_exc())
@classmethod
def callRemote(self):
#Call the wizard remotely(see README)
try:
ConnectStr = \
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
xLocMSF = Desktop.connect(ConnectStr)
lw = LetterWizardDialogImpl(xLocMSF)
lw.startWizard(xLocMSF)
except Exception as e:
print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
traceback.format_exc())
def getImplementationName(self):
return g_implName
def supportsService(self, ServiceName):
return g_ImplementationHelper.supportsService(g_implName, ServiceName)
def getSupportedServiceNames(self):
return g_ImplementationHelper.getSupportedServiceNames(g_implName)
g_ImplementationHelper.addImplementation( \
CallWizard, # UNO object class
g_implName, # implementation name
("com.sun.star.task.Job",),) # list of implemented services
# (the only service)
# vim:set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -0,0 +1,238 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ..text.TextDocument import TextDocument, traceback, \
TextFieldHandler, Configuration
from ..text.TextSectionHandler import TextSectionHandler
from com.sun.star.table import BorderLine
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
from com.sun.star.style.ParagraphAdjust import CENTER
from com.sun.star.text.PageNumberType import CURRENT
from com.sun.star.style.NumberingType import ARABIC
from com.sun.star.text.HoriOrientation import NONE as NONEHORI
from com.sun.star.text.VertOrientation import NONE as NONEVERT
from com.sun.star.text.RelOrientation import PAGE_FRAME
from com.sun.star.text.TextContentAnchorType import AT_PAGE
from com.sun.star.text.SizeType import FIX
from com.sun.star.text.WrapTextMode import THROUGH
from com.sun.star.awt.FontWeight import BOLD
from com.sun.star.beans import UnknownPropertyException
class LetterDocument(TextDocument):
def __init__(self, xMSF, listener):
super(LetterDocument,self).__init__(xMSF, listener, None,
"WIZARD_LIVE_PREVIEW")
self.keepLogoFrame = True
self.keepBendMarksFrame = True
self.keepLetterSignsFrame = True
self.keepSenderAddressRepeatedFrame = True
self.keepAddressFrame = True
def switchElement(self, sElement, bState):
try:
mySectionHandler = TextSectionHandler(
self.xMSF, self.xTextDocument)
oSection = \
mySectionHandler.xTextDocument.TextSections.getByName(sElement)
oSection.IsVisible = bState
except Exception:
traceback.print_exc()
def updateDateFields(self):
FH = TextFieldHandler(
self.xTextDocument, self.xTextDocument)
FH.updateDateFields()
def switchFooter(self, sPageStyle, bState, bPageNumber, sText):
if self.xTextDocument is not None:
try:
self.xTextDocument.lockControllers()
xNameAccess = self.xTextDocument.StyleFamilies
xPageStyleCollection = xNameAccess.getByName("PageStyles")
xPageStyle = xPageStyleCollection.getByName(sPageStyle)
if bState:
xPageStyle.FooterIsOn = True
xFooterText = xPageStyle.FooterText
xFooterText.String = sText
if bPageNumber:
#Adding the Page Number
myCursor = xFooterText.Text.createTextCursor()
myCursor.gotoEnd(False)
xFooterText.insertControlCharacter(myCursor,
PARAGRAPH_BREAK, False)
myCursor.setPropertyValue("ParaAdjust", CENTER )
xPageNumberField = \
self.xTextDocument.createInstance(
"com.sun.star.text.TextField.PageNumber")
xPageNumberField.setPropertyValue("SubType", CURRENT)
xPageNumberField.NumberingType = ARABIC
xFooterText.insertTextContent(xFooterText.End,
xPageNumberField, False)
else:
xPageStyle.FooterIsOn = False
self.xTextDocument.unlockControllers()
except Exception:
traceback.print_exc()
def hasElement(self, sElement):
if self.xTextDocument is not None:
SH = TextSectionHandler(self.xMSF, self.xTextDocument)
return SH.hasTextSectionByName(sElement)
else:
return False
def switchUserField(self, sFieldName, sNewContent, bState):
myFieldHandler = TextFieldHandler(
self.xMSF, self.xTextDocument)
if bState:
myFieldHandler.changeUserFieldContent(sFieldName, sNewContent)
else:
myFieldHandler.changeUserFieldContent(sFieldName, "")
def fillSenderWithUserData(self):
try:
myFieldHandler = TextFieldHandler(
self.xTextDocument, self.xTextDocument)
oUserDataAccess = Configuration.getConfigurationRoot(
self.xMSF, "org.openoffice.UserProfile/Data", False)
myFieldHandler.changeUserFieldContent(
"Company", oUserDataAccess.getByName("o"))
myFieldHandler.changeUserFieldContent(
"Street", oUserDataAccess.getByName("street"))
myFieldHandler.changeUserFieldContent(
"PostCode", oUserDataAccess.getByName("postalcode"))
myFieldHandler.changeUserFieldContent(
"City", oUserDataAccess.getByName("l"))
myFieldHandler.changeUserFieldContent(
"State", oUserDataAccess.getByName("st"))
except Exception:
traceback.print_exc()
def killEmptyUserFields(self):
myFieldHandler = TextFieldHandler(
self.xMSF, self.xTextDocument)
myFieldHandler.removeUserFieldByContent()
def killEmptyFrames(self):
try:
if not self.keepLogoFrame:
xTF = self.getFrameByName(
"Company Logo", self.xTextDocument)
if xTF is not None:
xTF.dispose()
if not self.keepBendMarksFrame:
xTF = self.getFrameByName(
"Bend Marks", self.xTextDocument)
if xTF is not None:
xTF.dispose()
if not self.keepLetterSignsFrame:
xTF = self.getFrameByName(
"Letter Signs", self.xTextDocument)
if xTF is not None:
xTF.dispose()
if not self.keepSenderAddressRepeatedFrame:
xTF = self.getFrameByName(
"Sender Address Repeated", self.xTextDocument)
if xTF is not None:
xTF.dispose()
if not self.keepAddressFrame:
xTF = self.getFrameByName(
"Sender Address", self.xTextDocument)
if xTF is not None:
xTF.dispose()
except Exception:
traceback.print_exc()
class BusinessPaperObject(object):
def __init__(self, xTextDocument, FrameText, Width, Height, XPos, YPos):
self.xTextDocument = xTextDocument
self.iWidth = Width
self.iHeight = Height
self.iXPos = XPos
self.iYPos = YPos
self.xFrame = None
try:
self.xFrame = \
self.xTextDocument.createInstance(
"com.sun.star.text.TextFrame")
self.setFramePosition()
self.xFrame.AnchorType = AT_PAGE
self.xFrame.SizeType = FIX
self.xFrame.TextWrap = THROUGH
self.xFrame.Opaque = True
self.xFrame.BackColor = 15790320
myBorder = BorderLine()
myBorder.OuterLineWidth = 0
self.xFrame.LeftBorder = myBorder
self.xFrame.RightBorder = myBorder
self.xFrame.TopBorder = myBorder
self.xFrame.BottomBorder = myBorder
self.xFrame.Print = False
xTextCursor = \
self.xTextDocument.Text.createTextCursor()
xTextCursor.gotoEnd(True)
xText = self.xTextDocument.Text
xText.insertTextContent(
xTextCursor, self.xFrame,
False)
xFrameText = self.xFrame.Text
xFrameCursor = xFrameText.createTextCursor()
xFrameCursor.setPropertyValue("CharWeight", BOLD)
xFrameCursor.setPropertyValue("CharColor", 16777215)
xFrameCursor.setPropertyValue("CharFontName", "Albany")
xFrameCursor.setPropertyValue("CharHeight", 18)
xFrameText.insertString(xFrameCursor, FrameText, False)
except Exception:
traceback.print_exc()
def setFramePosition(self):
try:
self.xFrame.HoriOrient = NONEHORI
self.xFrame.VertOrient = NONEVERT
self.xFrame.Height = self.iHeight
self.xFrame.Width = self.iWidth
self.xFrame.HoriOrientPosition = self.iXPos
self.xFrame.VertOrientPosition = self.iYPos
self.xFrame.HoriOrientRelation = PAGE_FRAME
self.xFrame.VertOrientRelation = PAGE_FRAME
except Exception:
traceback.print_exc()
def removeFrame(self):
if self.xFrame is not None:
try:
self.xTextDocument.Text.removeTextContent(
self.xFrame)
except UnknownPropertyException:
pass
except Exception:
traceback.print_exc()

View File

@@ -0,0 +1,76 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
HID = 40768
HIDMAIN = 40820
class LetterWizardDialogConst:
OPTBUSINESSLETTER_ITEM_CHANGED = "optBusinessLetterItemChanged"
OPTBUSINESSLETTER_ITEM_CHANGED = "optBusinessLetterItemChanged"
OPTPRIVOFFICIALLETTER_ITEM_CHANGED = "optPrivOfficialLetterItemChanged"
OPTPRIVATELETTER_ITEM_CHANGED = "optPrivateLetterItemChanged"
LSTBUSINESSSTYLE_ACTION_PERFORMED = None
LSTBUSINESSSTYLE_ITEM_CHANGED = "lstBusinessStyleItemChanged"
LSTPRIVOFFICIALSTYLE_ACTION_PERFORMED = None
LSTPRIVOFFICIALSTYLE_ITEM_CHANGED = "lstPrivOfficialStyleItemChanged"
CHKBUSINESSPAPER_ITEM_CHANGED = "chkBusinessPaperItemChanged"
LSTPRIVATESTYLE_ACTION_PERFORMED = None
LSTPRIVATESTYLE_ITEM_CHANGED = "lstPrivateStyleItemChanged"
CHKPAPERCOMPANYLOGO_ITEM_CHANGED = "chkPaperCompanyLogoItemChanged"
NUMLOGOHEIGHT_TEXT_CHANGED = "numLogoHeightTextChanged"
NUMLOGOX_TEXT_CHANGED = "numLogoXTextChanged"
NUMLOGOWIDTH_TEXT_CHANGED = "numLogoWidthTextChanged"
NUMLOGOY_TEXT_CHANGED = "numLogoYTextChanged"
CHKCOMPANYRECEIVER_ITEM_CHANGED = "chkCompanyReceiverItemChanged"
CHKPAPERFOOTER_ITEM_CHANGED = "chkPaperFooterItemChanged"
NUMFOOTERHEIGHT_TEXT_CHANGED = "numFooterHeightTextChanged"
CHKPAPERCOMPANYADDRESS_ITEM_CHANGED = "chkPaperCompanyAddressItemChanged"
NUMADDRESSHEIGHT_TEXT_CHANGED = "numAddressHeightTextChanged"
NUMADDRESSX_TEXT_CHANGED = "numAddressXTextChanged"
NUMADDRESSWIDTH_TEXT_CHANGED = "numAddressWidthTextChanged"
NUMADDRESSY_TEXT_CHANGED = "numAddressYTextChanged"
CHKUSELOGO_ITEM_CHANGED = "chkUseLogoItemChanged"
CHKUSEADDRESSRECEIVER_ITEM_CHANGED = "chkUseAddressReceiverItemChanged"
CHKUSESIGNS_ITEM_CHANGED = "chkUseSignsItemChanged"
CHKUSESUBJECT_ITEM_CHANGED = "chkUseSubjectItemChanged"
CHKUSEBENDMARKS_ITEM_CHANGED = "chkUseBendMarksItemChanged"
CHKUSEFOOTER_ITEM_CHANGED = "chkUseFooterItemChanged"
CHKUSESALUTATION_ITEM_CHANGED = "chkUseSalutationItemChanged"
CHKUSEGREETING_ITEM_CHANGED = "chkUseGreetingItemChanged"
LSTSALUTATION_ACTION_PERFORMED = None
LSTSALUTATION_ITEM_CHANGED = "lstSalutationItemChanged"
LSTSALUTATION_TEXT_CHANGED = "lstSalutationItemChanged"
LSTGREETING_ACTION_PERFORMED = None
LSTGREETING_ITEM_CHANGED = "lstGreetingItemChanged"
LSTGREETING_TEXT_CHANGED = "lstGreetingItemChanged"
OPTSENDERPLACEHOLDER_ITEM_CHANGED = "optSenderPlaceholderItemChanged"
OPTSENDERDEFINE_ITEM_CHANGED = "optSenderDefineItemChanged"
OPTRECEIVERPLACEHOLDER_ITEM_CHANGED = "optReceiverPlaceholderItemChanged"
OPTRECEIVERDATABASE_ITEM_CHANGED = "optReceiverDatabaseItemChanged"
TXTSENDERNAME_TEXT_CHANGED = "txtSenderNameTextChanged"
TXTSENDERSTREET_TEXT_CHANGED = "txtSenderStreetTextChanged"
TXTSENDERCITY_TEXT_CHANGED = "txtSenderCityTextChanged"
TXTSENDERPOSTCODE_TEXT_CHANGED = "txtSenderPostCodeTextChanged"
TXTSENDERSTATE_TEXT_CHANGED = "txtSenderStateTextChanged"
TXTFOOTER_TEXT_CHANGED = "txtFooterTextChanged"
CHKFOOTERNEXTPAGES_ITEM_CHANGED = "chkFooterNextPagesItemChanged"
CHKFOOTERPAGENUMBERS_ITEM_CHANGED = "chkFooterPageNumbersItemChanged"
TXTTEMPLATENAME_TEXT_CHANGED = "txtTemplateNameTextChanged"
OPTCREATELETTER_ITEM_CHANGED = "optCreateFromTemplateItemChanged"
OPTMAKECHANGES_ITEM_CHANGED = "optMakeChangesItemChanged"
FILETEMPLATEPATH_TEXT_CHANGED = None

View File

@@ -0,0 +1,976 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
import os.path
from .LetterWizardDialog import LetterWizardDialog, uno, HelpIds, HID
from .LetterDocument import LetterDocument, BusinessPaperObject
from .CGLetterWizard import CGLetterWizard
from ..common.FileAccess import FileAccess
from ..common.Configuration import Configuration
from ..common.SystemDialog import SystemDialog
from ..common.Desktop import Desktop
from ..ui.PathSelection import PathSelection
from ..ui.event.UnoDataAware import UnoDataAware
from ..ui.event.RadioDataAware import RadioDataAware
from ..ui.event.CommonListener import TerminateListenerProcAdapter
from ..text.TextElement import TextElement
from ..text.TextFieldHandler import TextFieldHandler
from ..document.OfficeDocument import OfficeDocument
from com.sun.star.awt.VclWindowPeerAttribute import YES_NO, DEF_NO
from com.sun.star.util import CloseVetoException
from com.sun.star.view.DocumentZoomType import OPTIMAL
from com.sun.star.document.UpdateDocMode import FULL_UPDATE
from com.sun.star.document.MacroExecMode import ALWAYS_EXECUTE
class LetterWizardDialogImpl(LetterWizardDialog):
RM_TYPESTYLE = 1
RM_BUSINESSPAPER = 2
RM_SENDERRECEIVER = 4
RM_FOOTER = 5
def enterStep(self, OldStep, NewStep):
pass
def leaveStep(self, OldStep, NewStep):
pass
def __init__(self, xmsf):
super(LetterWizardDialogImpl, self).__init__(xmsf)
self.lstBusinessStylePos = None
self.lstPrivateStylePos = None
self.lstPrivOfficialStylePos = None
self.xmsf = xmsf
self.bSaveSuccess = False
self.filenameChanged = False
self.BusCompanyLogo = None
self.BusCompanyAddress = None
self.BusCompanyAddressReceiver = None
self.BusFooter = None
def startWizard(self, xMSF):
self.running = True
try:
#Number of steps on WizardDialog
self.nMaxStep = 6
#instantiate The Document Frame for the Preview
self.terminateListener = TerminateListenerProcAdapter(self.queryTermination)
self.myLetterDoc = LetterDocument(xMSF, self.terminateListener)
#create the dialog
self.drawNaviBar()
self.buildStep1()
self.buildStep2()
self.buildStep3()
self.buildStep4()
self.buildStep5()
self.buildStep6()
self.initializePaths()
self.initializeSalutation()
self.initializeGreeting()
#special Control fFrameor setting the save Path:
self.insertPathSelectionControl()
self.myConfig = CGLetterWizard()
self.initializeTemplates(xMSF)
#load the last used settings
#from the registry and apply listeners to the controls:
self.initConfiguration()
if self.myConfig.cp_BusinessLetter.cp_Greeting :
self.myConfig.cp_BusinessLetter.cp_Greeting = \
self.resources.GreetingLabels[0]
if self.myConfig.cp_BusinessLetter.cp_Salutation:
self.myConfig.cp_BusinessLetter.cp_Salutation = \
self.resources.SalutationLabels[0]
if self.myConfig.cp_PrivateOfficialLetter.cp_Greeting:
self.myConfig.cp_PrivateOfficialLetter.cp_Greeting = \
self.resources.GreetingLabels[1]
if self.myConfig.cp_PrivateOfficialLetter.cp_Salutation:
self.myConfig.cp_PrivateOfficialLetter.cp_Salutation = \
self.resources.SalutationLabels[1]
if self.myConfig.cp_PrivateLetter.cp_Greeting:
self.myConfig.cp_PrivateLetter.cp_Greeting = \
self.resources.GreetingLabels[2]
if self.myConfig.cp_PrivateLetter.cp_Salutation:
self.myConfig.cp_PrivateLetter.cp_Salutation = \
self.resources.SalutationLabels[2]
if self.myPathSelection.xSaveTextBox.Text.lower() == "":
self.myPathSelection.initializePath()
xContainerWindow = self.myLetterDoc.xFrame.ContainerWindow
self.createWindowPeer(xContainerWindow)
self.insertRoadmap()
self.setConfiguration()
self.setDefaultForGreetingAndSalutation()
self.initializeElements()
self.myLetterDoc.xFrame.ComponentWindow.Enable = False
self.executeDialogFromComponent(self.myLetterDoc.xFrame)
self.removeTerminateListener()
self.closeDocument()
self.running = False
except Exception:
self.removeTerminateListener()
traceback.print_exc()
self.running = False
return
def cancelWizard(self):
self.xUnoDialog.endExecute()
self.running = False
def finishWizard(self):
self.switchToStep(self.getCurrentStep(), self.nMaxStep)
endWizard = True
try:
self.sPath = self.myPathSelection.getSelectedPath()
if not self.sPath or not os.path.exists(self.sPath):
self.myPathSelection.triggerPathPicker()
self.sPath = self.myPathSelection.getSelectedPath()
if not self.filenameChanged:
answer = SystemDialog.showMessageBox(
self.xMSF, "MessBox", YES_NO + DEF_NO,
self.resources.resOverwriteWarning,
self.xUnoDialog.Peer)
if answer == 3:
# user said: no, do not overwrite...
endWizard = False
return False
self.myLetterDoc.setWizardTemplateDocInfo(
self.resources.resLetterWizardDialog_title,
self.resources.resTemplateDescription)
self.myLetterDoc.killEmptyUserFields()
self.myLetterDoc.keepLogoFrame = self.chkUseLogo.State != 0
if self.chkBusinessPaper.State != 0 \
and self.chkPaperCompanyLogo.State != 0:
self.myLetterDoc.keepLogoFrame = False
self.myLetterDoc.keepBendMarksFrame = \
self.chkUseBendMarks.State != 0
self.myLetterDoc.keepLetterSignsFrame = \
self.chkUseSigns.State != 0
self.myLetterDoc.keepSenderAddressRepeatedFrame = \
self.chkUseAddressReceiver.State != 0
if self.optBusinessLetter.State:
if self.chkBusinessPaper.State != 0 \
and self.chkCompanyReceiver.State != 0:
self.myLetterDoc.keepSenderAddressRepeatedFrame = False
if self.chkBusinessPaper.State != 0 \
and self.chkPaperCompanyAddress.State != 0:
self.myLetterDoc.keepAddressFrame = False
self.myLetterDoc.killEmptyFrames()
self.bSaveSuccess = \
OfficeDocument.store(
self.xMSF, self.myLetterDoc.xTextDocument,
self.sPath, "writer8_template")
if self.bSaveSuccess:
self.saveConfiguration()
xIH = self.xMSF.createInstance(
"com.sun.star.comp.uui.UUIInteractionHandler")
loadValues = list(range(4))
loadValues[0] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[0].Name = "AsTemplate"
loadValues[1] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[1].Name = "MacroExecutionMode"
loadValues[1].Value = ALWAYS_EXECUTE
loadValues[2] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[2].Name = "UpdateDocMode"
loadValues[2].Value = FULL_UPDATE
loadValues[3] = uno.createUnoStruct( \
'com.sun.star.beans.PropertyValue')
loadValues[3].Name = "InteractionHandler"
loadValues[3].Value = xIH
if self.bEditTemplate:
loadValues[0].Value = False
else:
loadValues[0].Value = True
oDoc = OfficeDocument.load(
Desktop.getDesktop(self.xMSF),
self.sPath, "_default", loadValues)
oDoc.CurrentController.ViewSettings.ZoomType = OPTIMAL
else:
pass
except Exception:
traceback.print_exc()
finally:
if endWizard:
self.xUnoDialog.endExecute()
self.running = False
return True;
def closeDocument(self):
try:
xCloseable = self.myLetterDoc.xFrame
xCloseable.close(False)
except CloseVetoException:
traceback.print_exc()
def optBusinessLetterItemChanged(self):
self.lstPrivateStylePos = None
self.lstPrivOfficialStylePos = None
self.xDialogModel.lblBusinessStyle.Enabled = True
self.xDialogModel.lstBusinessStyle.Enabled = True
self.xDialogModel.chkBusinessPaper.Enabled = True
self.xDialogModel.lblPrivOfficialStyle.Enabled = False
self.xDialogModel.lstPrivOfficialStyle.Enabled = False
self.xDialogModel.lblPrivateStyle.Enabled = False
self.xDialogModel.lstPrivateStyle.Enabled = False
self.lstBusinessStyleItemChanged()
self.enableSenderReceiver()
self.setPossibleFooter(True)
if self.myPathSelection.xSaveTextBox.Text.lower() == "":
self.myPathSelection.initializePath()
def optPrivOfficialLetterItemChanged(self):
self.lstBusinessStylePos = None
self.lstPrivateStylePos = None
self.xDialogModel.lblBusinessStyle.Enabled = False
self.xDialogModel.lstBusinessStyle.Enabled = False
self.xDialogModel.chkBusinessPaper.Enabled = False
self.xDialogModel.lblPrivOfficialStyle.Enabled = True
self.xDialogModel.lstPrivOfficialStyle.Enabled = True
self.xDialogModel.lblPrivateStyle.Enabled = False
self.xDialogModel.lstPrivateStyle.Enabled = False
self.lstPrivOfficialStyleItemChanged()
self.disableBusinessPaper()
self.disableSenderReceiver()
self.setPossibleFooter(True)
if self.myPathSelection.xSaveTextBox.Text.lower() == "":
self.myPathSelection.initializePath()
self.myLetterDoc.fillSenderWithUserData()
def optPrivateLetterItemChanged(self):
self.lstBusinessStylePos = None
self.lstPrivOfficialStylePos = None
self.xDialogModel.lblBusinessStyle.Enabled = False
self.xDialogModel.lstBusinessStyle.Enabled = False
self.xDialogModel.chkBusinessPaper.Enabled = False
self.xDialogModel.lblPrivOfficialStyle.Enabled = False
self.xDialogModel.lstPrivOfficialStyle.Enabled = False
self.xDialogModel.lblPrivateStyle.Enabled = True
self.xDialogModel.lstPrivateStyle.Enabled = True
self.lstPrivateStyleItemChanged()
self.disableBusinessPaper()
self.disableSenderReceiver()
self.setPossibleFooter(False)
if self.myPathSelection.xSaveTextBox.Text.lower() == "":
self.myPathSelection.initializePath()
def optSenderPlaceholderItemChanged(self):
self.xDialogModel.lblSenderName.Enabled = False
self.xDialogModel.lblSenderStreet.Enabled = False
self.xDialogModel.lblPostCodeCity.Enabled = False
self.xDialogModel.txtSenderName.Enabled = False
self.xDialogModel.txtSenderStreet.Enabled = False
self.xDialogModel.txtSenderPostCode.Enabled = False
self.xDialogModel.txtSenderState.Enabled = False
self.xDialogModel.txtSenderCity.Enabled = False
self.myLetterDoc.fillSenderWithUserData()
def optSenderDefineItemChanged(self):
self.xDialogModel.lblSenderName.Enabled = True
self.xDialogModel.lblSenderStreet.Enabled = True
self.xDialogModel.lblPostCodeCity.Enabled = True
self.xDialogModel.txtSenderName.Enabled = True
self.xDialogModel.txtSenderStreet.Enabled = True
self.xDialogModel.txtSenderPostCode.Enabled = True
self.xDialogModel.txtSenderState.Enabled = True
self.xDialogModel.txtSenderCity.Enabled = True
self.txtSenderNameTextChanged()
self.txtSenderStreetTextChanged()
self.txtSenderPostCodeTextChanged()
self.txtSenderStateTextChanged()
self.txtSenderCityTextChanged()
def lstBusinessStyleItemChanged(self):
selectedItemPos = self.lstBusinessStyle.SelectedItemPos
if self.lstBusinessStylePos != selectedItemPos:
self.lstBusinessStylePos = selectedItemPos
self.myLetterDoc.loadAsPreview(
self.BusinessFiles[1][selectedItemPos], False)
self.initializeElements()
self.chkBusinessPaperItemChanged()
self.setElements(False)
self.drawConstants()
def lstPrivOfficialStyleItemChanged(self):
selectedItemPos = self.lstPrivOfficialStyle.SelectedItemPos
if self.lstPrivOfficialStylePos != selectedItemPos:
self.lstPrivOfficialStylePos = selectedItemPos
self.myLetterDoc.loadAsPreview(
self.OfficialFiles[1][selectedItemPos], False)
self.initializeElements()
self.setPossibleSenderData(True)
self.setElements(False)
self.drawConstants()
def lstPrivateStyleItemChanged(self):
selectedItemPos = self.lstPrivateStyle.SelectedItemPos
if self.lstPrivateStylePos != selectedItemPos:
self.lstPrivateStylePos = selectedItemPos
self.myLetterDoc.xTextDocument = \
self.myLetterDoc.loadAsPreview(
self.PrivateFiles[1][selectedItemPos], False)
self.initializeElements()
self.setElements(True)
def numLogoHeightTextChanged(self):
self.BusCompanyLogo.iHeight = int(self.numLogoHeight.Value * 1000)
self.BusCompanyLogo.setFramePosition()
def numLogoWidthTextChanged(self):
self.BusCompanyLogo.iWidth = int(self.numLogoWidth.Value * 1000)
self.BusCompanyLogo.setFramePosition()
def numLogoXTextChanged(self):
self.BusCompanyLogo.iXPos = int(self.numLogoX.Value * 1000)
self.BusCompanyLogo.setFramePosition()
def numLogoYTextChanged(self):
self.BusCompanyLogo.iYPos = int(self.numLogoY.Value * 1000)
self.BusCompanyLogo.setFramePosition()
def numAddressWidthTextChanged(self):
self.BusCompanyAddress.iWidth = int(self.numAddressWidth.Value * 1000)
self.BusCompanyAddress.setFramePosition()
def numAddressXTextChanged(self):
self.BusCompanyAddress.iXPos = int(self.numAddressX.Value * 1000)
self.BusCompanyAddress.setFramePosition()
def numAddressYTextChanged(self):
self.BusCompanyAddress.iYPos = int(self.numAddressY.Value * 1000)
self.BusCompanyAddress.setFramePosition()
def numAddressHeightTextChanged(self):
self.BusCompanyAddress.iHeight = int(self.numAddressHeight.Value * 1000)
self.BusCompanyAddress.setFramePosition()
def numFooterHeightTextChanged(self):
self.BusFooter.iHeight = int(self.numFooterHeight.Value * 1000)
self.BusFooter.iYPos = \
self.myLetterDoc.DocSize.Height - self.BusFooter.iHeight
self.BusFooter.setFramePosition()
def chkPaperCompanyLogoItemChanged(self):
if self.chkPaperCompanyLogo.State != 0:
if self.numLogoWidth.Value == 0:
self.numLogoWidth.Value = 0.1
if self.numLogoHeight.Value == 0:
self.numLogoHeight.Value = 0.1
self.BusCompanyLogo = BusinessPaperObject(
self.myLetterDoc.xTextDocument, "Company Logo",
int(self.numLogoWidth.Value * 1000),
int(self.numLogoHeight.Value * 1000),
int(self.numLogoX.Value * 1000),
self.numLogoY.Value * 1000)
self.xDialogModel.numLogoHeight.Enabled = True
self.xDialogModel.numLogoWidth.Enabled = True
self.xDialogModel.numLogoX.Enabled = True
self.xDialogModel.numLogoY.Enabled = True
self.setPossibleLogo(False)
else:
if self.BusCompanyLogo is not None:
self.BusCompanyLogo.removeFrame()
self.xDialogModel.numLogoHeight.Enabled = False
self.xDialogModel.numLogoWidth.Enabled = False
self.xDialogModel.numLogoX.Enabled = False
self.xDialogModel.numLogoY.Enabled = False
self.setPossibleLogo(True)
def chkPaperCompanyAddressItemChanged(self):
if self.chkPaperCompanyAddress.State != 0:
if self.numAddressWidth.Value == 0:
self.numAddressWidth.Value = 0.1
if self.numAddressHeight.Value == 0:
self.numAddressHeight.Value = 0.1
self.BusCompanyAddress = BusinessPaperObject(
self.myLetterDoc.xTextDocument, "Company Address",
int(self.numAddressWidth.Value * 1000),
int(self.numAddressHeight.Value * 1000),
int(self.numAddressX.Value * 1000),
int(self.numAddressY.Value * 1000))
self.xDialogModel.numAddressHeight.Enabled = True
self.xDialogModel.numAddressWidth.Enabled = True
self.xDialogModel.numAddressX.Enabled = True
self.xDialogModel.numAddressY.Enabled = True
if self.myLetterDoc.hasElement("Sender Address"):
self.myLetterDoc.switchElement(
"Sender Address", False)
if self.chkCompanyReceiver.State != 0:
self.setPossibleSenderData(False)
else:
if self.BusCompanyAddress is not None:
self.BusCompanyAddress.removeFrame()
self.xDialogModel.numAddressHeight.Enabled = False
self.xDialogModel.numAddressWidth.Enabled = False
self.xDialogModel.numAddressX.Enabled = False
self.xDialogModel.numAddressY.Enabled = False
if self.myLetterDoc.hasElement("Sender Address"):
self.myLetterDoc.switchElement("Sender Address", True)
self.setPossibleSenderData(True)
if self.optSenderDefine.State:
self.optSenderDefineItemChanged()
if self.optSenderPlaceholder.State:
self.optSenderPlaceholderItemChanged()
def chkCompanyReceiverItemChanged(self):
xReceiverFrame = None
if self.chkCompanyReceiver.State != 0:
try:
xReceiverFrame = self.myLetterDoc.getFrameByName(
"Receiver Address", self.myLetterDoc.xTextDocument)
iFrameWidth = int(xReceiverFrame.Width)
iFrameX = int(xReceiverFrame.HoriOrientPosition)
iFrameY = int(xReceiverFrame.VertOrientPosition)
iReceiverHeight = int(0.5 * 1000)
self.BusCompanyAddressReceiver = BusinessPaperObject(
self.myLetterDoc.xTextDocument, " ", iFrameWidth, iReceiverHeight,
iFrameX, iFrameY - iReceiverHeight)
self.setPossibleAddressReceiver(False)
except Exception:
traceback.print_exc()
if self.chkPaperCompanyAddress.State != 0:
self.setPossibleSenderData(False)
else:
if self.BusCompanyAddressReceiver is not None:
self.BusCompanyAddressReceiver.removeFrame()
self.setPossibleAddressReceiver(True)
self.setPossibleSenderData(True)
if self.optSenderDefine.State:
self.optSenderDefineItemChanged()
if self.optSenderPlaceholder.State:
self.optSenderPlaceholderItemChanged()
def chkPaperFooterItemChanged(self):
if self.chkPaperFooter.State != 0:
if self.numFooterHeight.Value == 0:
self.numFooterHeight.Value = 0.1
self.BusFooter = BusinessPaperObject(
self.myLetterDoc.xTextDocument, "Footer",
self.myLetterDoc.DocSize.Width,
int(self.numFooterHeight.Value * 1000), 0,
int(self.myLetterDoc.DocSize.Height - \
(self.numFooterHeight.Value * 1000)))
self.xDialogModel.numFooterHeight.Enabled = True
self.xDialogModel.lblFooterHeight.Enabled = True
self.setPossibleFooter(False)
else:
if self.BusFooter is not None:
self.BusFooter.removeFrame()
self.xDialogModel.numFooterHeight.Enabled = False
self.xDialogModel.lblFooterHeight.Enabled = False
self.setPossibleFooter(True)
def chkUseLogoItemChanged(self):
try:
if self.myLetterDoc.hasElement("Company Logo"):
logostatus = \
bool(self.xDialogModel.chkUseLogo.Enabled) \
and (self.chkUseLogo.State != 0)
self.myLetterDoc.switchElement(
"Company Logo", logostatus)
except Exception:
traceback.print_exc()
def chkUseAddressReceiverItemChanged(self):
try:
if self.myLetterDoc.hasElement("Sender Address Repeated"):
rstatus = \
bool(self.xDialogModel.chkUseAddressReceiver.Enabled) \
and (self.chkUseAddressReceiver.State != 0)
self.myLetterDoc.switchElement(
"Sender Address Repeated", rstatus)
except Exception:
traceback.print_exc()
def chkUseSignsItemChanged(self):
if self.myLetterDoc.hasElement("Letter Signs"):
self.myLetterDoc.switchElement(
"Letter Signs", self.chkUseSigns.State != 0)
def chkUseSubjectItemChanged(self):
if self.myLetterDoc.hasElement("Subject Line"):
self.myLetterDoc.switchElement(
"Subject Line", self.chkUseSubject.State != 0)
def chkUseBendMarksItemChanged(self):
if self.myLetterDoc.hasElement("Bend Marks"):
self.myLetterDoc.switchElement(
"Bend Marks", self.chkUseBendMarks.State != 0)
def chkUseFooterItemChanged(self):
try:
bFooterPossible = (self.chkUseFooter.State != 0) \
and bool(self.xDialogModel.chkUseFooter.Enabled)
if self.chkFooterNextPages.State != 0:
self.myLetterDoc.switchFooter(
"First Page", False, self.chkFooterPageNumbers.State != 0,
self.txtFooter.Text)
self.myLetterDoc.switchFooter("Standard", bFooterPossible,
self.chkFooterPageNumbers.State != 0, self.txtFooter.Text)
else:
self.myLetterDoc.switchFooter(
"First Page", bFooterPossible,
self.chkFooterPageNumbers.State != 0, self.txtFooter.Text)
self.myLetterDoc.switchFooter(
"Standard", bFooterPossible,
self.chkFooterPageNumbers.State != 0, self.txtFooter.Text)
BPaperItem = \
self.getRoadmapItemByID(LetterWizardDialogImpl.RM_FOOTER)
BPaperItem.Enabled = bFooterPossible
except Exception:
traceback.print_exc()
def chkFooterNextPagesItemChanged(self):
self.chkUseFooterItemChanged()
def chkFooterPageNumbersItemChanged(self):
self.chkUseFooterItemChanged()
def setPossibleFooter(self, bState):
self.xDialogModel.chkUseFooter.Enabled = bState
self.chkUseFooterItemChanged()
def setPossibleAddressReceiver(self, bState):
if self.myLetterDoc.hasElement("Sender Address Repeated"):
self.xDialogModel.chkUseAddressReceiver.Enabled = bState
self.chkUseAddressReceiverItemChanged()
def setPossibleLogo(self, bState):
if self.myLetterDoc.hasElement("Company Logo"):
self.xDialogModel.chkUseLogo.Enabled = bState
self.chkUseLogoItemChanged()
def txtFooterTextChanged(self):
self.chkUseFooterItemChanged()
def txtSenderNameTextChanged(self):
myFieldHandler = TextFieldHandler(
self.myLetterDoc.xMSF, self.myLetterDoc.xTextDocument)
myFieldHandler.changeUserFieldContent(
"Company", self.txtSenderName.Text)
def txtSenderStreetTextChanged(self):
myFieldHandler = TextFieldHandler(
self.myLetterDoc.xMSF, self.myLetterDoc.xTextDocument)
myFieldHandler.changeUserFieldContent(
"Street", self.txtSenderStreet.Text)
def txtSenderCityTextChanged(self):
myFieldHandler = TextFieldHandler(
self.myLetterDoc.xMSF, self.myLetterDoc.xTextDocument)
myFieldHandler.changeUserFieldContent(
"City", self.txtSenderCity.Text)
def txtSenderPostCodeTextChanged(self):
myFieldHandler = TextFieldHandler(
self.myLetterDoc.xMSF, self.myLetterDoc.xTextDocument)
myFieldHandler.changeUserFieldContent(
"PostCode", self.txtSenderPostCode.Text)
def txtSenderStateTextChanged(self):
myFieldHandler = TextFieldHandler(
self.myLetterDoc.xMSF, self.myLetterDoc.xTextDocument)
myFieldHandler.changeUserFieldContent(
"State", self.txtSenderState.Text)
def txtTemplateNameTextChanged(self):
xDocProps = self.myLetterDoc.xTextDocument.DocumentProperties
TitleName = self.txtTemplateName.Text
xDocProps.Title = TitleName
def chkUseSalutationItemChanged(self):
self.myLetterDoc.switchUserField(
"Salutation", self.lstSalutation.Text,
self.chkUseSalutation.State != 0)
self.xDialogModel.lstSalutation.Enabled = \
self.chkUseSalutation.State != 0
def lstSalutationItemChanged(self):
self.myLetterDoc.switchUserField(
"Salutation", self.lstSalutation.Text,
self.chkUseSalutation.State != 0)
def chkUseGreetingItemChanged(self):
self.myLetterDoc.switchUserField(
"Greeting", self.lstGreeting.Text, self.chkUseGreeting.State != 0)
self.xDialogModel.lstGreeting.Enabled = \
self.chkUseGreeting.State != 0
def setDefaultForGreetingAndSalutation(self):
if self.lstSalutation.Text:
self.lstSalutation.Text = self.resources.SalutationLabels[0]
if self.lstGreeting.Text:
self.lstGreeting.Text = self.resources.GreetingLabels[0]
def lstGreetingItemChanged(self):
self.myLetterDoc.switchUserField(
"Greeting", self.lstGreeting.Text, self.chkUseGreeting.State != 0)
def chkBusinessPaperItemChanged(self):
if self.chkBusinessPaper.State != 0:
self.enableBusinessPaper()
else:
self.disableBusinessPaper()
self.setPossibleSenderData(True)
def setPossibleSenderData(self, bState):
self.xDialogModel.optSenderDefine.Enabled = bState
self.xDialogModel.optSenderPlaceholder.Enabled = bState
self.xDialogModel.lblSenderAddress.Enabled = bState
if not bState:
self.xDialogModel.txtSenderCity.Enabled = bState
self.xDialogModel.txtSenderName.Enabled = bState
self.xDialogModel.txtSenderPostCode.Enabled = bState
self.xDialogModel.txtSenderStreet.Enabled = bState
self.xDialogModel.txtSenderCity.Enabled = bState
self.xDialogModel.txtSenderState.Enabled = bState
self.xDialogModel.lblSenderName.Enabled = bState
self.xDialogModel.lblSenderStreet.Enabled = bState
self.xDialogModel.lblPostCodeCity.Enabled = bState
def enableSenderReceiver(self):
BPaperItem = self.getRoadmapItemByID(
LetterWizardDialogImpl.RM_SENDERRECEIVER)
BPaperItem.Enabled = True
def disableSenderReceiver(self):
BPaperItem = self.getRoadmapItemByID(
LetterWizardDialogImpl.RM_SENDERRECEIVER)
BPaperItem.Enabled = False
def enableBusinessPaper(self):
try:
BPaperItem = self.getRoadmapItemByID(
LetterWizardDialogImpl.RM_BUSINESSPAPER)
BPaperItem.Enabled = True
self.chkPaperCompanyLogoItemChanged()
self.chkPaperCompanyAddressItemChanged()
self.chkPaperFooterItemChanged()
self.chkCompanyReceiverItemChanged()
except Exception:
traceback.print_exc()
def disableBusinessPaper(self):
try:
BPaperItem = self.getRoadmapItemByID(
LetterWizardDialogImpl.RM_BUSINESSPAPER)
BPaperItem.Enabled = False
if self.BusCompanyLogo is not None:
self.BusCompanyLogo.removeFrame()
if self.BusCompanyAddress is not None:
self.BusCompanyAddress.removeFrame()
if self.BusFooter is not None:
self.BusFooter.removeFrame()
if self.BusCompanyAddressReceiver is not None:
self.BusCompanyAddressReceiver.removeFrame()
self.setPossibleAddressReceiver(True)
self.setPossibleFooter(True)
self.setPossibleLogo(True)
if self.myLetterDoc.hasElement("Sender Address"):
self.myLetterDoc.switchElement(
"Sender Address", True)
except Exception:
traceback.print_exc()
def initializeSalutation(self):
self.xDialogModel.lstSalutation.StringItemList = \
tuple(self.resources.SalutationLabels)
def initializeGreeting(self):
self.xDialogModel.lstGreeting.StringItemList = \
tuple(self.resources.GreetingLabels)
def initializeTemplates(self, xMSF):
sLetterPath = self.sTemplatePath + "/wizard/letter"
self.BusinessFiles = \
FileAccess.getFolderTitles(
xMSF, "bus", sLetterPath, self.resources.dictBusinessTemplate)
self.OfficialFiles = \
FileAccess.getFolderTitles(
xMSF, "off", sLetterPath, self.resources.dictOfficialTemplate)
self.PrivateFiles = \
FileAccess.getFolderTitles(
xMSF, "pri", sLetterPath, self.resources.dictPrivateTemplate)
self.xDialogModel.lstBusinessStyle.StringItemList = \
tuple(self.BusinessFiles[0])
self.xDialogModel.lstPrivOfficialStyle.StringItemList = \
tuple(self.OfficialFiles[0])
self.xDialogModel.lstPrivateStyle.StringItemList = \
tuple(self.PrivateFiles[0])
self.xDialogModel.lstBusinessStyle.SelectedItems = (0,)
self.xDialogModel.lstPrivOfficialStyle.SelectedItems = (0,)
self.xDialogModel.lstPrivateStyle.SelectedItems = (0,)
return True
def initializeElements(self):
self.xDialogModel.chkUseLogo.Enabled = \
self.myLetterDoc.hasElement("Company Logo")
self.xDialogModel.chkUseBendMarks.Enabled = \
self.myLetterDoc.hasElement("Bend Marks")
self.xDialogModel.chkUseAddressReceiver.Enabled = \
self.myLetterDoc.hasElement("Sender Address Repeated")
self.xDialogModel.chkUseSubject.Enabled = \
self.myLetterDoc.hasElement("Subject Line")
self.xDialogModel.chkUseSigns.Enabled = \
self.myLetterDoc.hasElement("Letter Signs")
self.myLetterDoc.updateDateFields()
def setConfiguration(self):
if self.optBusinessLetter.State:
self.optBusinessLetterItemChanged()
elif self.optPrivOfficialLetter.State:
self.optPrivOfficialLetterItemChanged()
elif self.optPrivateLetter.State:
self.optPrivateLetterItemChanged()
def optReceiverPlaceholderItemChanged(self):
OfficeDocument.attachEventCall(
self.myLetterDoc.xTextDocument, "OnNew", "StarBasic",
"macro:///Template.Correspondence.Placeholder()")
def optReceiverDatabaseItemChanged(self):
OfficeDocument.attachEventCall(
self.myLetterDoc.xTextDocument, "OnNew", "StarBasic",
"macro:///Template.Correspondence.Database()")
def setElements(self, privLetter):
if self.optSenderDefine.State:
self.optSenderDefineItemChanged()
if self.optSenderPlaceholder.State:
self.optSenderPlaceholderItemChanged()
self.chkUseSignsItemChanged()
self.chkUseSubjectItemChanged()
self.chkUseSalutationItemChanged()
self.chkUseGreetingItemChanged()
self.chkUseBendMarksItemChanged()
self.chkUseAddressReceiverItemChanged()
self.txtTemplateNameTextChanged()
if self.optReceiverDatabase.State and not privLetter:
self.optReceiverDatabaseItemChanged()
if self.optReceiverPlaceholder.State and not privLetter:
self.optReceiverPlaceholderItemChanged()
if self.optCreateLetter.State:
self.optCreateFromTemplateItemChanged()
if self.optMakeChanges.State:
self.optMakeChangesItemChanged()
def drawConstants(self):
'''Localise the template'''
constRangeList = self.myLetterDoc.searchFillInItems(1)
for i in constRangeList:
text = i.String.lower()
aux = TextElement(i, self.resources.dictConstants[text])
aux.write()
def insertRoadmap(self):
self.addRoadmap()
self.insertRoadMapItems(
self.resources.RoadmapLabels,
[True, False, True, True, False, True])
self.setRoadmapInteractive(True)
self.setRoadmapComplete(True)
self.setCurrentRoadmapItemID(1)
def insertPathSelectionControl(self):
self.myPathSelection = \
PathSelection(self.xMSF, self, PathSelection.TransferMode.SAVE,
PathSelection.DialogTypes.FILE)
self.myPathSelection.insert(
6, 97, 70, 205, 45, self.resources.reslblTemplatePath_value,
True, HelpIds.getHelpIdString(HID + 47),
HelpIds.getHelpIdString(HID + 48))
self.myPathSelection.sDefaultDirectory = self.sUserTemplatePath
self.myPathSelection.sDefaultName = "myLetterTemplate.ott"
self.myPathSelection.sDefaultFilter = "writer8_template"
self.myPathSelection.addSelectionListener(self)
def initConfiguration(self):
try:
root = Configuration.getConfigurationRoot(
self.xMSF, "/org.openoffice.Office.Writer/Wizards/Letter",
False)
self.myConfig.readConfiguration(root, "cp_")
RadioDataAware.attachRadioButtons(self.myConfig, "cp_LetterType",
(self.optBusinessLetter, self.optPrivOfficialLetter,
self.optPrivateLetter), True).updateUI()
UnoDataAware.attachListBox(
self.myConfig.cp_BusinessLetter, "cp_Style",
self.lstBusinessStyle, True).updateUI()
UnoDataAware.attachListBox(
self.myConfig.cp_PrivateOfficialLetter, "cp_Style",
self.lstPrivOfficialStyle, True).updateUI()
UnoDataAware.attachListBox(
self.myConfig.cp_PrivateLetter, "cp_Style",
self.lstPrivateStyle, True).updateUI()
UnoDataAware.attachCheckBox(
self.myConfig.cp_BusinessLetter, "cp_BusinessPaper",
self.chkBusinessPaper, True).updateUI()
cgl = self.myConfig.cp_BusinessLetter
cgpl = self.myConfig.cp_BusinessLetter.cp_CompanyLogo
cgpa = self.myConfig.cp_BusinessLetter.cp_CompanyAddress
UnoDataAware.attachCheckBox(
cgpl, "cp_Display", self.chkPaperCompanyLogo, True).updateUI()
UnoDataAware.attachNumericControl(
cgpl, "cp_Width", self.numLogoWidth, True).updateUI()
UnoDataAware.attachNumericControl(
cgpl, "cp_Height", self.numLogoHeight, True).updateUI()
UnoDataAware.attachNumericControl(
cgpl, "cp_X", self.numLogoX, True).updateUI()
UnoDataAware.attachNumericControl(
cgpl, "cp_Y", self.numLogoY, True).updateUI()
UnoDataAware.attachCheckBox(
cgpa, "cp_Display", self.chkPaperCompanyAddress, True).updateUI()
UnoDataAware.attachNumericControl(
cgpa, "cp_Width", self.numAddressWidth, True).updateUI()
UnoDataAware.attachNumericControl(
cgpa, "cp_Height", self.numAddressHeight, True).updateUI()
UnoDataAware.attachNumericControl(
cgpa, "cp_X", self.numAddressX, True).updateUI()
UnoDataAware.attachNumericControl(
cgpa, "cp_Y", self.numAddressY, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PaperCompanyAddressReceiverField",
self.chkCompanyReceiver, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PaperFooter", self.chkPaperFooter, True).updateUI()
UnoDataAware.attachNumericControl(
cgl, "cp_PaperFooterHeight", self.numFooterHeight, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PrintCompanyLogo", self.chkUseLogo, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PrintCompanyAddressReceiverField",
self.chkUseAddressReceiver, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PrintLetterSigns", self.chkUseSigns, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PrintSubjectLine", self.chkUseSubject, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PrintSalutation", self.chkUseSalutation, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PrintBendMarks", self.chkUseBendMarks, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PrintGreeting", self.chkUseGreeting, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_PrintFooter", self.chkUseFooter, True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_Salutation", self.lstSalutation, True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_Greeting", self.lstGreeting, True).updateUI()
RadioDataAware.attachRadioButtons(
cgl, "cp_SenderAddressType",
(self.optSenderDefine, self.optSenderPlaceholder), True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_SenderCompanyName", self.txtSenderName, True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_SenderStreet", self.txtSenderStreet, True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_SenderPostCode", self.txtSenderPostCode, True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_SenderState", self.txtSenderState, True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_SenderCity", self.txtSenderCity, True).updateUI()
RadioDataAware.attachRadioButtons(
cgl, "cp_ReceiverAddressType",
(self.optReceiverDatabase, self.optReceiverPlaceholder),
True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_Footer", self.txtFooter, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_FooterOnlySecondPage",
self.chkFooterNextPages, True).updateUI()
UnoDataAware.attachCheckBox(
cgl, "cp_FooterPageNumbers",
self.chkFooterPageNumbers, True).updateUI()
RadioDataAware.attachRadioButtons(
cgl, "cp_CreationType",
(self.optCreateLetter, self.optMakeChanges), True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_TemplateName", self.txtTemplateName, True).updateUI()
UnoDataAware.attachEditControl(
cgl, "cp_TemplatePath", self.myPathSelection.xSaveTextBox,
True).updateUI()
except Exception:
traceback.print_exc()
def saveConfiguration(self):
try:
root = Configuration.getConfigurationRoot(self.xMSF,
"/org.openoffice.Office.Writer/Wizards/Letter", True)
self.myConfig.writeConfiguration(root, "cp_")
root.commitChanges()
except Exception:
traceback.print_exc()
def validatePath(self):
if self.myPathSelection.usedPathPicker:
self.filenameChanged = True
self.myPathSelection.usedPathPicker = False

View File

@@ -0,0 +1,150 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class LetterWizardDialogResources(object):
def __init__(self):
import sys, os
if sys.version_info < (3,4):
import imp
imp.load_source('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc'))
import strings
elif sys.version_info < (3,7):
# imp is deprecated since Python v.3.4
from importlib.machinery import SourceFileLoader
SourceFileLoader('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc')).load_module()
import strings
else:
# have to jump through hoops since 3.7, partly because python does not like loading modules that do have a .py extension
import importlib
import importlib.util
import importlib.machinery
module_name = 'strings'
path = os.path.join(os.path.dirname(__file__), '../common/strings.hrc')
spec = importlib.util.spec_from_loader(
module_name,
importlib.machinery.SourceFileLoader(module_name, path)
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[module_name] = module
strings = module
import strings
self.resLetterWizardDialog_title = strings.RID_LETTERWIZARDDIALOG_START_1
self.resLabel9_value = strings.RID_LETTERWIZARDDIALOG_START_2
self.resoptBusinessLetter_value = strings.RID_LETTERWIZARDDIALOG_START_3
self.resoptPrivOfficialLetter_value = strings.RID_LETTERWIZARDDIALOG_START_4
self.resoptPrivateLetter_value = strings.RID_LETTERWIZARDDIALOG_START_5
self.reschkBusinessPaper_value = strings.RID_LETTERWIZARDDIALOG_START_6
self.reschkPaperCompanyLogo_value = strings.RID_LETTERWIZARDDIALOG_START_7
self.reschkPaperCompanyAddress_value = strings.RID_LETTERWIZARDDIALOG_START_8
self.reschkPaperFooter_value = strings.RID_LETTERWIZARDDIALOG_START_9
self.reschkCompanyReceiver_value = strings.RID_LETTERWIZARDDIALOG_START_10
self.reschkUseLogo_value = strings.RID_LETTERWIZARDDIALOG_START_11
self.reschkUseAddressReceiver_value = strings.RID_LETTERWIZARDDIALOG_START_12
self.reschkUseSigns_value = strings.RID_LETTERWIZARDDIALOG_START_13
self.reschkUseSubject_value = strings.RID_LETTERWIZARDDIALOG_START_14
self.reschkUseSalutation_value = strings.RID_LETTERWIZARDDIALOG_START_15
self.reschkUseBendMarks_value = strings.RID_LETTERWIZARDDIALOG_START_16
self.reschkUseGreeting_value = strings.RID_LETTERWIZARDDIALOG_START_17
self.reschkUseFooter_value = strings.RID_LETTERWIZARDDIALOG_START_18
self.resoptSenderPlaceholder_value = strings.RID_LETTERWIZARDDIALOG_START_19
self.resoptSenderDefine_value = strings.RID_LETTERWIZARDDIALOG_START_20
self.resoptReceiverPlaceholder_value = strings.RID_LETTERWIZARDDIALOG_START_21
self.resoptReceiverDatabase_value = strings.RID_LETTERWIZARDDIALOG_START_22
self.reschkFooterNextPages_value = strings.RID_LETTERWIZARDDIALOG_START_23
self.reschkFooterPageNumbers_value = strings.RID_LETTERWIZARDDIALOG_START_24
self.restxtTemplateName_value = strings.RID_LETTERWIZARDDIALOG_START_25
self.resoptCreateLetter_value = strings.RID_LETTERWIZARDDIALOG_START_26
self.resoptMakeChanges_value = strings.RID_LETTERWIZARDDIALOG_START_27
self.reslblBusinessStyle_value = strings.RID_LETTERWIZARDDIALOG_START_28
self.reslblPrivOfficialStyle_value = strings.RID_LETTERWIZARDDIALOG_START_29
self.reslblPrivateStyle_value = strings.RID_LETTERWIZARDDIALOG_START_30
self.reslblIntroduction_value = strings.RID_LETTERWIZARDDIALOG_START_31
self.reslblLogoHeight_value = strings.RID_LETTERWIZARDDIALOG_START_32
self.reslblLogoWidth_value = strings.RID_LETTERWIZARDDIALOG_START_33
self.reslblLogoX_value = strings.RID_LETTERWIZARDDIALOG_START_34
self.reslblLogoY_value = strings.RID_LETTERWIZARDDIALOG_START_35
self.reslblAddressHeight_value = strings.RID_LETTERWIZARDDIALOG_START_36
self.reslblAddressWidth_value = strings.RID_LETTERWIZARDDIALOG_START_37
self.reslblAddressX_value = strings.RID_LETTERWIZARDDIALOG_START_38
self.reslblAddressY_value = strings.RID_LETTERWIZARDDIALOG_START_39
self.reslblFooterHeight_value = strings.RID_LETTERWIZARDDIALOG_START_40
self.reslblSenderAddress_value = strings.RID_LETTERWIZARDDIALOG_START_42
self.reslblSenderName_value = strings.RID_LETTERWIZARDDIALOG_START_43
self.reslblSenderStreet_value = strings.RID_LETTERWIZARDDIALOG_START_44
self.reslblPostCodeCity_value = strings.RID_LETTERWIZARDDIALOG_START_45
self.reslblReceiverAddress_value = strings.RID_LETTERWIZARDDIALOG_START_46
self.reslblFooter_value = strings.RID_LETTERWIZARDDIALOG_START_47
self.reslblFinalExplanation1_value = strings.RID_LETTERWIZARDDIALOG_START_48
self.reslblFinalExplanation2_value = strings.RID_LETTERWIZARDDIALOG_START_49
self.reslblTemplateName_value = strings.RID_LETTERWIZARDDIALOG_START_50
self.reslblTemplatePath_value = strings.RID_LETTERWIZARDDIALOG_START_51
self.reslblProceed_value = strings.RID_LETTERWIZARDDIALOG_START_52
self.reslblTitle1_value = strings.RID_LETTERWIZARDDIALOG_START_53
self.reslblTitle3_value = strings.RID_LETTERWIZARDDIALOG_START_54
self.reslblTitle2_value = strings.RID_LETTERWIZARDDIALOG_START_55
self.reslblTitle4_value = strings.RID_LETTERWIZARDDIALOG_START_56
self.reslblTitle5_value = strings.RID_LETTERWIZARDDIALOG_START_57
self.reslblTitle6_value = strings.RID_LETTERWIZARDDIALOG_START_58
#Create a Dictionary for the constants values.
self.dictConstants = {
"#subjectconst#" : strings.RID_LETTERWIZARDDIALOG_START_59}
#Create a dictionary for localising the business templates
self.dictBusinessTemplate = {
"Elegant" : strings.RID_LETTERWIZARDDIALOG_START_60,
"Modern" : strings.RID_LETTERWIZARDDIALOG_START_61,
"Office" : strings.RID_LETTERWIZARDDIALOG_START_62}
#Create a dictionary for localising the official templates
self.dictOfficialTemplate = {
"Elegant" : strings.RID_LETTERWIZARDDIALOG_START_60,
"Modern" : strings.RID_LETTERWIZARDDIALOG_START_61,
"Office" : strings.RID_LETTERWIZARDDIALOG_START_62}
#Create a dictionary for localising the private templates
self.dictPrivateTemplate = {
"Bottle" : strings.RID_LETTERWIZARDDIALOG_START_63,
"Mail" : strings.RID_LETTERWIZARDDIALOG_START_64,
"Marine" : strings.RID_LETTERWIZARDDIALOG_START_65,
"Red Line" : strings.RID_LETTERWIZARDDIALOG_START_66}
#Common Resources
self.resOverwriteWarning = strings.RID_COMMON_START_19
self.resTemplateDescription = strings.RID_COMMON_START_20
self.RoadmapLabels = []
self.RoadmapLabels.append(strings.RID_LETTERWIZARDROADMAP_START_1)
self.RoadmapLabels.append(strings.RID_LETTERWIZARDROADMAP_START_2)
self.RoadmapLabels.append(strings.RID_LETTERWIZARDROADMAP_START_3)
self.RoadmapLabels.append(strings.RID_LETTERWIZARDROADMAP_START_4)
self.RoadmapLabels.append(strings.RID_LETTERWIZARDROADMAP_START_5)
self.RoadmapLabels.append(strings.RID_LETTERWIZARDROADMAP_START_6)
self.SalutationLabels = []
self.SalutationLabels.append(strings.RID_LETTERWIZARDSALUTATION_START_1)
self.SalutationLabels.append(strings.RID_LETTERWIZARDSALUTATION_START_2)
self.SalutationLabels.append(strings.RID_LETTERWIZARDSALUTATION_START_3)
self.GreetingLabels = []
self.GreetingLabels.append(strings.RID_LETTERWIZARDGREETING_START_1)
self.GreetingLabels.append(strings.RID_LETTERWIZARDGREETING_START_2)
self.GreetingLabels.append(strings.RID_LETTERWIZARDGREETING_START_3)

View File

@@ -0,0 +1,258 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
import traceback
import time
from datetime import date as dateTimeObject
from .TextFieldHandler import TextFieldHandler
from ..document.OfficeDocument import OfficeDocument
from ..common.Desktop import Desktop
from ..common.Configuration import Configuration
from ..common.NumberFormatter import NumberFormatter
from com.sun.star.i18n.NumberFormatIndex import DATE_SYS_DDMMYY
from com.sun.star.view.DocumentZoomType import ENTIRE_PAGE
from com.sun.star.beans.PropertyState import DIRECT_VALUE
class TextDocument(object):
def __init__(self, xMSF,listener=None,bShowStatusIndicator=None,
FrameName=None,_sPreviewURL=None,_moduleIdentifier=None,
_textDocument=None, xArgs=None):
self.xMSF = xMSF
self.xTextDocument = None
if listener is not None:
if FrameName is not None:
'''creates an instance of TextDocument
and creates a named frame.
No document is actually loaded into this frame.'''
self.xFrame = OfficeDocument.createNewFrame(
xMSF, listener, FrameName)
return
elif _sPreviewURL is not None:
'''creates an instance of TextDocument by
loading a given URL as preview'''
self.xFrame = OfficeDocument.createNewFrame(xMSF, listener)
self.xTextDocument = self.loadAsPreview(_sPreviewURL, True)
elif xArgs is not None:
'''creates an instance of TextDocument
and creates a frame and loads a document'''
self.xDesktop = Desktop.getDesktop(xMSF);
self.xFrame = OfficeDocument.createNewFrame(xMSF, listener)
self.xTextDocument = OfficeDocument.load(
self.xFrame, URL, "_self", xArgs);
self.xWindowPeer = self.xFrame.getComponentWindow()
self.m_xDocProps = self.xTextDocument.DocumentProperties
CharLocale = self.xTextDocument.CharLocale
return
else:
'''creates an instance of TextDocument from
the desktop's current frame'''
self.xDesktop = Desktop.getDesktop(xMSF);
self.xFrame = self.xDesktop.getActiveFrame()
self.xTextDocument = self.xFrame.getController().Model
elif _moduleIdentifier is not None:
try:
'''create the empty document, and set its module identifier'''
self.xTextDocument = xMSF.createInstance(
"com.sun.star.text.TextDocument")
self.xTextDocument.initNew()
self.xTextDocument.setIdentifier(
_moduleIdentifier.Identifier)
# load the document into a blank frame
xDesktop = Desktop.getDesktop(xMSF)
loadArgs = list(range(1))
loadArgs[0] = "Model"
loadArgs[0] = -1
loadArgs[0] = self.xTextDocument
loadArgs[0] = DIRECT_VALUE
xDesktop.loadComponentFromURL(
"private:object", "_blank", 0, loadArgs)
# remember some things for later usage
self.xFrame = self.xTextDocument.CurrentController.Frame
except Exception:
traceback.print_exc()
elif _textDocument is not None:
'''creates an instance of TextDocument
from a given XTextDocument'''
self.xFrame = _textDocument.CurrentController.Frame
self.xTextDocument = _textDocument
if bShowStatusIndicator:
self.showStatusIndicator()
self.init()
def init(self):
self.xWindowPeer = self.xFrame.getComponentWindow()
self.m_xDocProps = self.xTextDocument.DocumentProperties
self.CharLocale = self.xTextDocument.CharLocale
self.xText = self.xTextDocument.Text
def showStatusIndicator(self):
self.xProgressBar = self.xFrame.createStatusIndicator()
self.xProgressBar.start("", 100)
self.xProgressBar.setValue(5)
def loadAsPreview(self, sDefaultTemplate, asTemplate):
loadValues = list(range(3))
# open document in the Preview mode
loadValues[0] = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
loadValues[0].Name = "ReadOnly"
loadValues[0].Value = True
loadValues[1] = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
loadValues[1].Name = "AsTemplate"
if asTemplate:
loadValues[1].Value = True
else:
loadValues[1].Value = False
loadValues[2] = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
loadValues[2].Name = "Preview"
loadValues[2].Value = True
self.xTextDocument = OfficeDocument.load(
self.xFrame, sDefaultTemplate, "_self", loadValues)
self.DocSize = self.getPageSize()
try:
self.xTextDocument.CurrentController.ViewSettings.ZoomType = ENTIRE_PAGE
except Exception:
traceback.print_exc()
myFieldHandler = TextFieldHandler(self.xMSF, self.xTextDocument)
myFieldHandler.updateDocInfoFields()
return self.xTextDocument
def getPageSize(self):
try:
xNameAccess = self.xTextDocument.StyleFamilies
xPageStyleCollection = xNameAccess.getByName("PageStyles")
xPageStyle = xPageStyleCollection.getByName("First Page")
return xPageStyle.Size
except Exception:
traceback.print_exc()
return None
'''creates an instance of TextDocument and creates a
frame and loads a document'''
def createTextCursor(self, oCursorContainer):
xTextCursor = oCursorContainer.createTextCursor()
return xTextCursor
def refresh(self):
self.xTextDocument.refresh()
'''
This method sets the Author of a Wizard-generated template correctly
and adds an explanatory sentence to the template description.
@param WizardName The name of the Wizard.
@param TemplateDescription The old Description which is being
appended with another sentence.
@return void.
'''
def setWizardTemplateDocInfo(self, WizardName, TemplateDescription):
try:
xNA = Configuration.getConfigurationRoot(
self.xMSF, "/org.openoffice.UserProfile/Data", False)
gn = xNA.getByName("givenname")
sn = xNA.getByName("sn")
fullname = str(gn) + " " + str(sn)
now = time.localtime(time.time())
year = time.strftime("%Y", now)
month = time.strftime("%m", now)
day = time.strftime("%d", now)
dateObject = dateTimeObject(int(year), int(month), int(day))
du = self.DateUtils(self.xMSF, self.xTextDocument)
ff = du.getFormat(DATE_SYS_DDMMYY)
myDate = du.format(ff, dateObject)
xDocProps2 = self.xTextDocument.DocumentProperties
xDocProps2.Author = fullname
xDocProps2.ModifiedBy = fullname
description = xDocProps2.Description
description = description + " " + TemplateDescription
description = description.replace("<wizard_name>", WizardName)
description = description.replace("<current_date>", myDate)
xDocProps2.Description = description
except Exception:
traceback.print_exc()
@classmethod
def getFrameByName(self, sFrameName, xTD):
if xTD.TextFrames.hasByName(sFrameName):
return xTD.TextFrames.getByName(sFrameName)
return None
def searchFillInItems(self, typeSearch):
sd = self.xTextDocument.createSearchDescriptor()
if typeSearch == 0:
sd.setSearchString("<[^>]+>")
elif typeSearch == 1:
sd.setSearchString("#[^#]+#")
sd.setPropertyValue("SearchRegularExpression", True)
sd.setPropertyValue("SearchWords", True)
auxList = []
allItems = self.xTextDocument.findAll(sd)
for i in list(range(allItems.Count)):
auxList.append(allItems.getByIndex(i))
return auxList
class DateUtils(object):
def __init__(self, xmsf, document):
self.formatSupplier = document
formatSettings = self.formatSupplier.getNumberFormatSettings()
date = formatSettings.NullDate
self.calendar = dateTimeObject(date.Year, date.Month, date.Day)
self.formatter = NumberFormatter.createNumberFormatter(xmsf,
self.formatSupplier)
'''
@param format a constant of the enumeration NumberFormatIndex
@return
'''
def getFormat(self, format):
return NumberFormatter.getNumberFormatterKey(
self.formatSupplier, format)
'''
@param date a VCL date in form of 20041231
@return a document relative date
'''
def format(self, formatIndex, date):
difference = date - self.calendar
return self.formatter.convertNumberToString(formatIndex,
difference.days)

View File

@@ -0,0 +1,27 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class TextElement(object):
def __init__(self, item, placeHolderText):
self.item = item
self.placeHolderText = placeHolderText
def write(self):
if self.item is not None:
self.item.String = self.placeHolderText

View File

@@ -0,0 +1,115 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
import time
from com.sun.star.util import DateTime
from com.sun.star.uno import RuntimeException
from com.sun.star.beans import UnknownPropertyException
class TextFieldHandler(object):
xTextFieldsSupplierAux = None
arrayTextFields = []
dictTextFields = {}
def __init__(self, xMSF, xTextDocument):
self.xMSFDoc = xMSF
self.xTextFieldsSupplier = xTextDocument
if TextFieldHandler.xTextFieldsSupplierAux is not \
self.xTextFieldsSupplier:
self.__getTextFields()
TextFieldHandler.xTextFieldsSupplierAux = self.xTextFieldsSupplier
def refreshTextFields(self):
xUp = self.xTextFieldsSupplier.TextFields
xUp.refresh()
def __getTextFields(self):
try:
if self.xTextFieldsSupplier.TextFields.hasElements():
xEnum = \
self.xTextFieldsSupplier.TextFields.createEnumeration()
while xEnum.hasMoreElements():
oTextField = xEnum.nextElement()
TextFieldHandler.arrayTextFields.append(oTextField)
xPropertySet = oTextField.TextFieldMaster
if xPropertySet.Name:
TextFieldHandler.dictTextFields[xPropertySet.Name] = \
oTextField
except Exception:
traceback.print_exc()
def changeUserFieldContent(self, _FieldName, _FieldContent):
try:
DependentTextFields = \
TextFieldHandler.dictTextFields[_FieldName]
except KeyError:
return None
try:
if hasattr(DependentTextFields, "TextFieldMaster"):
DependentTextFields.TextFieldMaster.Content = _FieldContent
self.refreshTextFields()
except UnknownPropertyException:
pass
def updateDocInfoFields(self):
try:
for i in TextFieldHandler.arrayTextFields:
if i.supportsService(
"com.sun.star.text.TextField.ExtendedUser"):
i.update()
if i.supportsService(
"com.sun.star.text.TextField.User"):
i.update()
except Exception:
traceback.print_exc()
def updateDateFields(self):
try:
now = time.localtime(time.time())
dt = DateTime()
dt.Day = time.strftime("%d", now)
dt.Year = time.strftime("%Y", now)
dt.Month = time.strftime("%m", now)
dt.Month += 1
for i in TextFieldHandler.arrayTextFields:
if i.supportsService(
"com.sun.star.text.TextField.DateTime"):
try:
i.IsFixed = False
i.DateTimeValue = dt
except RuntimeException:
pass
except Exception:
traceback.print_exc()
def removeUserFieldByContent(self):
#Remove userfield when its text is empty
xDependentTextFields = TextFieldHandler.arrayTextFields
for i in xDependentTextFields:
try:
if not i.TextFieldMaster.Content:
i.dispose()
except Exception:
#TextField doesn't even have the attribute Content,
#so it's empty
i.dispose()

View File

@@ -0,0 +1,116 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
import traceback
class TextSectionHandler(object):
'''Creates a new instance of TextSectionHandler'''
def __init__(self, xMSF, xTextDocument):
self.xMSFDoc = xMSF
self.xTextDocument = xTextDocument
self.xText = xTextDocument.Text
def removeTextSectionbyName(self, SectionName):
try:
xAllTextSections = self.xTextDocument.TextSections
if xAllTextSections.hasByName(SectionName):
oTextSection = self.xTextDocument.TextSections.getByName(
SectionName)
self.removeTextSection(oTextSection)
except Exception:
traceback.print_exc()
def hasTextSectionByName(self, SectionName):
xAllTextSections = self.xTextDocument.TextSections
return xAllTextSections.hasByName(SectionName)
def removeTextSection(self, _oTextSection):
try:
self.xText.removeTextContent(_oTextSection)
except Exception:
traceback.print_exc()
def removeAllTextSections(self):
try:
TextSectionCount = self.xTextDocument.TextSections.Count
xAllTextSections = self.xTextDocument.TextSections
for i in range(TextSectionCount - 1, -1, -1):
xTextContentTextSection = xAllTextSections.getByIndex(i)
self.xText.removeTextContent(xTextContentTextSection)
except Exception:
traceback.print_exc()
def breakLinkOfTextSection(self, oTextSection):
try:
oSectionLink = \
uno.createUnoStruct('com.sun.star.text.SectionFileLink')
oSectionLink.FileURL = ""
uno.invoke(oTextSection, "setPropertyValues",
(("FileLink", "LinkRegion"), (oSectionLink, "")))
except Exception:
traceback.print_exc()
def linkSectiontoTemplate(
self, TemplateName, SectionName, oTextSection=None):
try:
if not oTextSection:
oTextSection = self.xTextDocument.TextSections.getByName(
SectionName)
oSectionLink = \
uno.createUnoStruct('com.sun.star.text.SectionFileLink')
oSectionLink.FileURL = TemplateName
uno.invoke(oTextSection, "setPropertyValues",
(("FileLink", "LinkRegion"), (oSectionLink, SectionName)))
NewSectionName = oTextSection.Name
if NewSectionName is not SectionName:
oTextSection.Name = SectionName
except Exception:
traceback.print_exc()
def insertTextSection(self, GroupName, TemplateName, _bAddParagraph):
try:
if _bAddParagraph:
xTextCursor = self.xText.createTextCursor()
self.xText.insertControlCharacter(
xTextCursor, ControlCharacter.PARAGRAPH_BREAK, False)
xTextCursor.collapseToEnd()
xSecondTextCursor = self.xText.createTextCursor()
xSecondTextCursor.gotoEnd(False)
insertTextSection(GroupName, TemplateName, xSecondTextCursor)
except Exception:
traceback.print_exc()
def insertTextSection(self, sectionName, templateName, position):
try:
if self.xTextDocument.TextSections.hasByName(sectionName):
xTextSection = \
self.xTextDocument.TextSections.getByName(sectionName)
else:
xTextSection = self.xMSFDoc.createInstance(
"com.sun.star.text.TextSection")
position.getText().insertTextContent(
position, xTextSection, False)
linkSectiontoTemplate(xTextSection, templateName, sectionName)
except Exception:
traceback.print_exc()

View File

@@ -0,0 +1,176 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
from .UnoDialog import UnoDialog
from ..common.Desktop import Desktop
from ..common.PropertyNames import PropertyNames
from ..common.HelpIds import HelpIds
from com.sun.star.awt.ScrollBarOrientation import VERTICAL
class ControlScroller(object):
SORELFIRSTPOSY = 3
iScrollBarWidth = 10
# TODO add parameters for tabindices and helpindex
def __init__(self, _CurUnoDialog, _xMSF, _iStep, _iCompPosX, _iCompPosY,
_iCompWidth, _nblockincrement, _nlinedistance, _firsthelpindex):
self.xMSF = _xMSF
self.scrollfields = []
self.ControlGroupVector = []
ControlScroller.nblockincrement = _nblockincrement
self.CurUnoDialog = _CurUnoDialog
self.iStep = _iStep
self.curHelpIndex = _firsthelpindex
self.curtabindex = self.iStep * 100
self.linedistance = _nlinedistance
self.iCompPosX = _iCompPosX
self.iCompPosY = _iCompPosY
self.iCompWidth = _iCompWidth
self.iCompHeight = 2 * ControlScroller.SORELFIRSTPOSY + \
ControlScroller.nblockincrement * self.linedistance
self.iStartPosY = self.iCompPosY + ControlScroller.SORELFIRSTPOSY
ScrollHeight = self.iCompHeight - 2
self.nlineincrement = 1
self.sincSuffix = Desktop.getIncrementSuffix(
self.CurUnoDialog.xDialogModel, "imgBackground")
self.xScrollBar = self.CurUnoDialog.insertScrollBar(
"TitleScrollBar" + self.sincSuffix,
("Border", PropertyNames.PROPERTY_ENABLED,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL, "Orientation",
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_WIDTH),
(0, True, ScrollHeight,
HelpIds.getHelpIdString(self.curHelpIndex),
VERTICAL, self.iCompPosX + self.iCompWidth - \
ControlScroller.iScrollBarWidth - 1,
self.iCompPosY + 1, self.iStep,
ControlScroller.iScrollBarWidth), 0, self)
self.nscrollvalue = 0
ypos = self.iStartPosY + ControlScroller.SORELFIRSTPOSY
for i in range(ControlScroller.nblockincrement):
self.insertControlGroup(i, ypos)
ypos += self.linedistance
def fillupControls(self, binitialize):
for i in range(ControlScroller.nblockincrement):
if i < self.ncurfieldcount:
self.fillupControl(i)
if binitialize:
self.CurUnoDialog.repaintDialogStep()
def fillupControl(self, guiRow):
nameProps = self.scrollfields[guiRow]
valueProps = self.scrollfields[guiRow + self.nscrollvalue]
for index, item in enumerate(nameProps):
if self.CurUnoDialog.xDialogModel.hasByName(item.Name):
self.setControlData(item.Name, valueProps[index].Value)
else:
raise AttributeError("No such control !")
self.ControlGroupVector[guiRow].setEnabled(True)
def setScrollValue(self, _nscrollvalue, _ntotfieldcount=None):
if _ntotfieldcount is not None:
self.setTotalFieldCount(_ntotfieldcount)
if _nscrollvalue >= 0:
self.xScrollBar.Model.ScrollValue = _nscrollvalue
self.scrollControls()
def setCurFieldCount(self):
if self.ntotfieldcount > ControlScroller.nblockincrement:
self.ncurfieldcount = ControlScroller.nblockincrement
else:
self.ncurfieldcount = self.ntotfieldcount
def setTotalFieldCount(self, _ntotfieldcount):
self.ntotfieldcount = _ntotfieldcount
self.setCurFieldCount()
if self.ntotfieldcount > ControlScroller.nblockincrement:
self.xScrollBar.Model.Enabled = True
self.xScrollBar.Model.ScrollValueMax = \
self.ntotfieldcount - ControlScroller.nblockincrement
else:
self.xScrollBar.Model.Enabled = False
def scrollControls(self):
try:
self.nscrollvalue = \
int(self.xScrollBar.Model.ScrollValue)
if self.nscrollvalue + ControlScroller.nblockincrement \
>= self.ntotfieldcount:
self.nscrollvalue = \
self.ntotfieldcount - ControlScroller.nblockincrement
self.fillupControls(False)
except Exception:
traceback.print_exc()
'''
updates the corresponding data to
the control in guiRow and column
@param guiRow 0 based row index
@param column 0 based column index
@return the propertyValue object corresponding to
this control.
'''
def fieldInfo(self, guiRow, column):
if guiRow + self.nscrollvalue < len(self.scrollfields):
valueProp = (self.scrollfields[guiRow + self.nscrollvalue])[column]
nameProp = (self.scrollfields[guiRow])[column]
if self.CurUnoDialog.xDialogModel.hasByName(nameProp.Name):
valueProp.Value = self.getControlData(nameProp.Name)
else:
valueProp.Value = nameProp.Value
return valueProp
else:
return None
def unregisterControlGroup(self, _index):
del self.scrollfields[_index]
def registerControlGroup(self, _currowproperties, _i):
if _i == 0:
del self.scrollfields[:]
if _i >= len(self.scrollfields):
self.scrollfields.append(_currowproperties)
else:
self.scrollfields.insert(_currowproperties, _i)
def setControlData(self, controlname, newvalue):
oControlModel = self.CurUnoDialog.xUnoDialog.getControl(
controlname).Model
propertyname = UnoDialog.getDisplayProperty(oControlModel)
if propertyname:
setattr(oControlModel, propertyname, newvalue)
def getControlData(self, controlname):
oControlModel = self.CurUnoDialog.xUnoDialog.getControl(
controlname).Model
propertyname = UnoDialog.getDisplayProperty(oControlModel)
if propertyname:
return getattr(oControlModel, propertyname)
else:
return None

View File

@@ -0,0 +1,96 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
from ..common.Properties import Properties
from com.sun.star.awt import WindowDescriptor
from com.sun.star.awt import Rectangle
from com.sun.star.awt.WindowClass import SIMPLE
from com.sun.star.awt.VclWindowPeerAttribute import CLIPCHILDREN
from com.sun.star.awt.WindowAttribute import SHOW
'''
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
'''
class DocumentPreview(object):
PREVIEW_MODE = 1
'''
create new frame with window inside
load a component as preview into this frame
'''
def __init__(self, xmsf, control):
self.xControl = control
self.createPreviewFrame(xmsf, self.xControl)
def setDocument(self, url_, propNames, propValues=None):
if propValues is None:
if propNames == DocumentPreview.PREVIEW_MODE:
self.setDocument(url_, ("Preview", "ReadOnly"), (True, True))
else:
self.loadArgs = propNames
self.xFrame.activate()
self.xComponent = self.xFrame.loadComponentFromURL(url_, "_self", 0, tuple(self.loadArgs))
return self.xComponent
else:
self.url = url_
ps = Properties()
for index,item in enumerate(propNames):
ps[item] = propValues[index]
return self.setDocument(self.url, ps.getProperties1())
def closeFrame(self):
if self.xFrame is not None:
self.xFrame.close(False)
'''
create a new frame with a new container window inside,
which is not part of the global frame tree.
Attention:
a) This frame won't be destroyed by the office. It must be closed by you!
Do so - please call XCloseable::close().
b) The container window is part of the frame. Don't hold it alive - nor try to kill it.
It will be destroyed inside close().
'''
def createPreviewFrame(self, xmsf, xControl):
controlPeer = xControl.Peer
r = xControl.PosSize
toolkit = xmsf.createInstance("com.sun.star.awt.Toolkit")
aDescriptor = WindowDescriptor()
aDescriptor.Type = SIMPLE
aDescriptor.WindowServiceName = "window"
aDescriptor.ParentIndex = -1
aDescriptor.Parent = controlPeer
#xWindowPeer; #argument !
aDescriptor.Bounds = Rectangle(0, 0, r.Width, r.Height)
aDescriptor.WindowAttributes = CLIPCHILDREN | SHOW
self.xWindow = toolkit.createWindow(aDescriptor)
self.xFrame = xmsf.createInstance("com.sun.star.frame.Frame")
self.xFrame.initialize(self.xWindow)
self.xWindow.setVisible(True)
def dispose(self):
try:
self.closeFrame()
except Exception:
traceback.print_exc()

View File

@@ -0,0 +1,137 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
from ..common.PropertyNames import PropertyNames
from ..common.FileAccess import FileAccess
from ..common.SystemDialog import SystemDialog
class PathSelection(object):
class DialogTypes(object):
FOLDER = 0
FILE = 1
class TransferMode(object):
SAVE = 0
LOAD = 1
def __init__(self, xMSF, CurUnoDialog, TransferMode, DialogType):
self.CurUnoDialog = CurUnoDialog
self.xMSF = xMSF
self.iDialogType = DialogType
self.iTransferMode = TransferMode
self.sDefaultDirectory = ""
self.sDefaultName = ""
self.sDefaultFilter = ""
self.usedPathPicker = False
self.CMDSELECTPATH = 1
self.TXTSAVEPATH = 1
def insert(
self, DialogStep, XPos, YPos, Width,
CurTabIndex, LabelText, Enabled, TxtHelpURL, BtnHelpURL):
self.CurUnoDialog.insertControlModel(
"com.sun.star.awt.UnoControlFixedTextModel", "lblSaveAs",
(PropertyNames.PROPERTY_ENABLED,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(Enabled, 8, LabelText, XPos, YPos, DialogStep,
CurTabIndex, Width))
self.xSaveTextBox = self.CurUnoDialog.insertTextField(
"txtSavePath", "callXPathSelectionListener",
(PropertyNames.PROPERTY_ENABLED,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(Enabled, 12, TxtHelpURL, XPos, YPos + 10, DialogStep,
(CurTabIndex + 1), Width - 26), self)
self.CurUnoDialog.xDialogModel.txtSavePath.Enabled = False
self.CurUnoDialog.insertButton("cmdSelectPath", "triggerPathPicker",
(PropertyNames.PROPERTY_ENABLED,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(Enabled, 14, BtnHelpURL, "...",XPos + Width - 16, YPos + 9,
DialogStep, (CurTabIndex + 2), 16), self)
def addSelectionListener(self, xAction):
self.xAction = xAction
def getSelectedPath(self):
return self.xSaveTextBox.Text
def initializePath(self):
try:
myFA = FileAccess(self.xMSF)
self.xSaveTextBox.setText(
myFA.getPath(self.sDefaultDirectory + \
"/" + \
self.sDefaultName, None))
except Exception:
traceback.print_exc()
def triggerPathPicker(self):
try:
if self.iTransferMode == self.TransferMode.SAVE:
if self.iDialogType == self.DialogTypes.FOLDER:
#TODO: write code for picking a folder for saving
return
elif self.iDialogType == self.DialogTypes.FILE:
self.usedPathPicker = True
myFilePickerDialog = \
SystemDialog.createStoreDialog(self.xMSF)
myFilePickerDialog.callStoreDialog(
self.sDefaultDirectory,
self.sDefaultName, self.sDefaultFilter)
sStorePath = myFilePickerDialog.sStorePath
if sStorePath is not None:
myFA = FileAccess(self.xMSF)
self.xSaveTextBox.Text = myFA.getPath(sStorePath, None)
self.sDefaultDirectory = \
FileAccess.getParentDir(sStorePath)
self.sDefaultName = myFA.getFilename(sStorePath)
return
elif self.iTransferMode == self.TransferMode.LOAD:
if self.iDialogType == self.DialogTypes.FOLDER:
#TODO: write code for picking a folder for loading
return
elif self.iDialogType == self.DialogTypes.FILE:
#TODO: write code for picking a file for loading
return
except Exception:
traceback.print_exc()
def callXPathSelectionListener(self):
if self.xAction is not None:
self.xAction.validatePath()

View File

@@ -0,0 +1,61 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
from .event.CommonListener import WindowListenerProcAdapter
'''
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
'''
class PeerConfig(object):
def __init__(self, _oUnoDialog):
self.oUnoDialog = _oUnoDialog
self.oUnoDialog.xUnoDialog.addWindowListener(
WindowListenerProcAdapter(self.windowShown))
self.m_aPeerTasks = []
self.aImageUrlTasks = []
class PeerTask(object):
def __init__(self, _xControl, _propNames, _propValues):
self.propnames = _propNames
self.propvalues = _propValues
self.xControl = _xControl
class ImageUrlTask(object):
def __init__(self, _oModel, _oResource):
self.oModel = _oModel
self.oResource = _oResource
def windowShown(self):
try:
for i in self.m_aPeerTasks:
xVclWindowPeer = i.xControl.Peer
xVclWindowPeer.setProperty(i.propnames, i.propvalues)
for aImageUrlTask in self.aImageUrlTasks:
sImageUrl = aImageUrlTask.oResource
if sImageUrl != "":
aImageUrlTask.oModel.ImageURL = sImageUrl
except Exception:
traceback.print_exc()

View File

@@ -0,0 +1,38 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class UIConsts():
INVISIBLESTEP = 99
INFOIMAGEURL = "private:graphicrepository/dbaccess/res/exinfo.png"
'''
The tabindex of the navigation buttons in a wizard must be assigned a very
high tabindex because on every step their taborder must appear at the end
'''
SOFIRSTWIZARDNAVITABINDEX = 30000
# Steps of the QueryWizard
SOFIELDSELECTIONPAGE = 1
SOSORTINGPAGE = 2
SOFILTERPAGE = 3
SOAGGREGATEPAGE = 4
SOGROUPSELECTIONPAGE = 5
SOGROUPFILTERPAGE = 6
SOTITLESPAGE = 7
SOSUMMARYPAGE = 8

View File

@@ -0,0 +1,254 @@
#
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
import traceback
from .PeerConfig import PeerConfig
from .UIConsts import UIConsts
from ..common.PropertyNames import PropertyNames
from com.sun.star.awt import Rectangle
from com.sun.star.awt.PosSize import POS
class UnoDialog(object):
createDict = False
dictProperties = None
BisHighContrastModeActivated = None
xVclWindowPeer = None
def __init__(self, xMSF, PropertyNames, PropertyValues):
try:
self.xMSF = xMSF
self.ControlList = {}
self.xDialogModel = xMSF.createInstance(
"com.sun.star.awt.UnoControlDialogModel")
self.xUnoDialog = xMSF.createInstance(
"com.sun.star.awt.UnoControlDialog")
self.xUnoDialog.setModel(self.xDialogModel)
self.m_oPeerConfig = None
self.xWindowPeer = None
except Exception:
traceback.print_exc()
# repaints the currentDialogStep
def repaintDialogStep(self):
try:
ncurstep = int(self.xDialogModel.Step)
self.xDialogModel.Step = 99
self.xDialogModel.Step = ncurstep
except Exception:
traceback.print_exc()
def insertControlModel(self, serviceName, componentName, sPropNames, oPropValues):
try:
xControlModel = self.xDialogModel.createInstance(serviceName)
uno.invoke(xControlModel, "setPropertyValues",
(sPropNames, oPropValues))
self.xDialogModel.insertByName(componentName, xControlModel)
xControlModel.Name = componentName
except Exception:
traceback.print_exc()
aObj = self.xUnoDialog.getControl(componentName)
return aObj
def setFocus(self, ControlName):
oFocusControl = self.xUnoDialog.getControl(ControlName)
oFocusControl.setFocus()
def calculateDialogPosition(self, FramePosSize):
# Todo:check if it would be useful or possible to create a dialog peer
# that can be used for the messageboxes to
# maintain modality when they pop up.
CurPosSize = self.xUnoDialog.getPosSize()
WindowHeight = FramePosSize.Height
WindowWidth = FramePosSize.Width
DialogWidth = CurPosSize.Width
DialogHeight = CurPosSize.Height
iXPos = ((WindowWidth / 2) - (DialogWidth / 2))
iYPos = ((WindowHeight / 2) - (DialogHeight / 2))
self.xUnoDialog.setPosSize(
iXPos, iYPos, DialogWidth, DialogHeight, POS)
'''
@param FramePosSize
@return 0 for cancel, 1 for ok
@throws com.sun.star.uno.Exception
'''
def executeDialog(self, FramePosSize):
if self.xUnoDialog.getPeer() is None:
raise AttributeError(
"Please create a peer, using your own frame")
self.calculateDialogPosition(FramePosSize)
if self.xWindowPeer is None:
self.createWindowPeer()
self.xVclWindowPeer = self.xWindowPeer
self.BisHighContrastModeActivated = self.isHighContrastModeActivated()
return self.xUnoDialog.execute()
def setVisible(self, parent):
self.calculateDialogPosition(parent.xUnoDialog.getPosSize())
if self.xWindowPeer == None:
self.createWindowPeer()
self.xUnoDialog.setVisible(True)
'''
@param XComponent
@return 0 for cancel, 1 for ok
@throws com.sun.star.uno.Exception
'''
def executeDialogFromComponent(self, xComponent):
if xComponent is not None:
w = xComponent.ComponentWindow
if w is not None:
return self.executeDialog(w.PosSize)
return self.executeDialog( Rectangle (0, 0, 640, 400))
'''
create a peer for this
dialog, using the given
peer as a parent.
@param parentPeer
@return
@throws java.lang.Exception
'''
def createWindowPeer(self, parentPeer=None):
self.xUnoDialog.setVisible(False)
xToolkit = self.xMSF.createInstance("com.sun.star.awt.Toolkit")
if parentPeer is None:
parentPeer = xToolkit.getDesktopWindow()
self.xUnoDialog.createPeer(xToolkit, parentPeer)
self.xWindowPeer = self.xUnoDialog.getPeer()
return self.xUnoDialog.getPeer()
@classmethod
def setEnabled(self, control, enabled):
control.Model.Enabled = enabled
@classmethod
def getModel(self, control):
return control.getModel()
@classmethod
def getDisplayProperty(self, xServiceInfo):
if xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlFixedTextModel"):
return PropertyNames.PROPERTY_LABEL
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlButtonModel"):
return PropertyNames.PROPERTY_LABEL
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlCurrencyFieldModel"):
return "Value"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlDateFieldModel"):
return "Date"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlFixedLineModel"):
return PropertyNames.PROPERTY_LABEL
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlFormattedFieldModel"):
return "EffectiveValue"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlNumericFieldModel"):
return "Value"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlPatternFieldModel"):
return "Text"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlProgressBarModel"):
return "ProgressValue"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlTimeFieldModel"):
return "Time"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlImageControlModel"):
return PropertyNames.PROPERTY_IMAGEURL
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlRadioButtonModel"):
return PropertyNames.PROPERTY_STATE
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlCheckBoxModel"):
return PropertyNames.PROPERTY_STATE
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlEditModel"):
return "Text"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlComboBoxModel"):
return "Text"
elif xServiceInfo.supportsService(
"com.sun.star.awt.UnoControlListBoxModel"):
return "SelectedItems"
else:
return ""
def isHighContrastModeActivated(self):
if (self.xVclWindowPeer is not None):
if (self.BisHighContrastModeActivated is None):
nUIColor = 0
try:
nUIColor = self.xVclWindowPeer.getProperty("DisplayBackgroundColor")
except Exception:
traceback.print_exc()
return False
# TODO: The following methods could be wrapped in an own class implementation
nRed = self.getRedColorShare(nUIColor)
nGreen = self.getGreenColorShare(nUIColor)
nBlue = self.getBlueColorShare(nUIColor)
nLuminance = ((nBlue * 28 + nGreen * 151 + nRed * 77) / 256)
bisactivated = (nLuminance <= 25)
self.BisHighContrastModeActivated = bool(bisactivated)
return bisactivated;
else:
return self.BisHighContrastModeActivated
else:
return False
def getRedColorShare(self, _nColor):
nRed = _nColor / 65536
nRedModulo = _nColor % 65536
nGreen = nRedModulo / 256
nGreenModulo = (nRedModulo % 256)
nBlue = nGreenModulo
return nRed
def getGreenColorShare(self, _nColor):
nRed = _nColor / 65536
nRedModulo = _nColor % 65536
nGreen = nRedModulo / 256
return nGreen
def getBlueColorShare(self, _nColor):
nRed = _nColor / 65536
nRedModulo = _nColor % 65536
nGreen = nRedModulo / 256
nGreenModulo = (nRedModulo % 256)
nBlue = nGreenModulo
return nBlue

View File

@@ -0,0 +1,204 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from .UnoDialog import UnoDialog, UIConsts
from ..common.Desktop import Desktop
from ..common.PropertyNames import PropertyNames
from ..common.SystemDialog import SystemDialog
from .event.CommonListener import ItemListenerProcAdapter, \
ActionListenerProcAdapter, TextListenerProcAdapter, \
AdjustmentListenerProcAdapter
'''
This class contains convenience methods for inserting components to a dialog.
It was created for use with the automatic conversion of Basic XML Dialog
description files to a Java class which builds
the same dialog through the UNO API.<br/>
It uses an Event-Listener method, which calls a method through reflection
when an event on a component is triggered.
see the classes CommonListener for details
'''
class UnoDialog2(UnoDialog):
'''
Override this method to return another listener.
@return
'''
def __init__(self, xmsf):
super(UnoDialog2,self).__init__(xmsf,(), ())
ControlList = {}
def insertButton(
self, sName, actionPerformed, sPropNames, oPropValues, listener):
xButton = self.insertControlModel(
"com.sun.star.awt.UnoControlButtonModel",
sName, sPropNames, oPropValues)
if actionPerformed is not None:
actionPerformed = getattr(listener, actionPerformed)
xButton.addActionListener(
ActionListenerProcAdapter(actionPerformed))
return xButton
def insertCheckBox(
self, sName, itemChanged, sPropNames, oPropValues, listener):
xCheckBox = self.insertControlModel(
"com.sun.star.awt.UnoControlCheckBoxModel",
sName, sPropNames, oPropValues)
if itemChanged is not None:
itemChanged = getattr(listener, itemChanged)
xCheckBox.addItemListener(ItemListenerProcAdapter(itemChanged))
return xCheckBox
def insertComboBox(
self, sName, actionPerformed, itemChanged,
textChanged, sPropNames, oPropValues, listener):
xComboBox = self.insertControlModel(
"com.sun.star.awt.UnoControlComboBoxModel",
sName, sPropNames, oPropValues)
if actionPerformed is not None:
actionPerformed = getattr(listener, actionPerformed)
xComboBox.addActionListener(
ActionListenerProcAdapter(actionPerformed))
if itemChanged is not None:
itemChanged = getattr(listener, itemChanged)
xComboBox.addItemListener(ItemListenerProcAdapter(itemChanged))
if textChanged is not None:
textChanged = getattr(listener, textChanged)
xComboBox.addTextListener(TextListenerProcAdapter(textChanged))
return xComboBox
def insertListBox(
self, sName, actionPerformed, itemChanged,
sPropNames, oPropValues, listener):
xListBox = self.insertControlModel(
"com.sun.star.awt.UnoControlListBoxModel",
sName, sPropNames, oPropValues)
if itemChanged is not None:
itemChanged = getattr(listener, itemChanged)
xListBox.addItemListener(ItemListenerProcAdapter(itemChanged))
return xListBox
def insertRadioButton(
self, sName, itemChanged, sPropNames, oPropValues, listener):
xRadioButton = self.insertControlModel(
"com.sun.star.awt.UnoControlRadioButtonModel",
sName, sPropNames, oPropValues)
if itemChanged is not None:
itemChanged = getattr(listener, itemChanged)
xRadioButton.addItemListener(
ItemListenerProcAdapter(itemChanged))
return xRadioButton
def insertTextField(
self, sName, sTextChanged, sPropNames, oPropValues, listener):
return self.insertEditField(
sName, sTextChanged, "com.sun.star.awt.UnoControlEditModel",
sPropNames, oPropValues, listener)
def insertImage(self, sName, sPropNames, oPropValues):
return self.insertControlModel(
"com.sun.star.awt.UnoControlImageControlModel",
sName, sPropNames, oPropValues)
def insertInfoImage(self, _posx, _posy, _iStep):
xImgControl = self.insertImage(
Desktop.getUniqueName(self.xDialogModel, "imgHint"),
("Border",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_IMAGEURL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y, "ScaleImage",
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_WIDTH),
(0, 10, UIConsts.INFOIMAGEURL, _posx, _posy, False, _iStep, 10))
return xImgControl
'''
This method is used for creating Edit, Currency, Date, Formatted,
Pattern, File and Time edit components.
'''
def insertEditField(
self, sName, sTextChanged, sModelClass,
sPropNames, oPropValues, listener):
xField = self.insertControlModel(sModelClass,
sName, sPropNames, oPropValues)
if sTextChanged is not None:
sTextChanged = getattr(listener, sTextChanged)
xField.addTextListener(TextListenerProcAdapter(sTextChanged))
return xField
def insertDateField(
self, sName, sTextChanged, sPropNames, oPropValues, listener):
return self.insertEditField(
sName, sTextChanged,
"com.sun.star.awt.UnoControlDateFieldModel",
sPropNames, oPropValues, listener)
def insertNumericField(
self, sName, sTextChanged, sPropNames, oPropValues, listener):
return self.insertEditField(
sName, sTextChanged,
"com.sun.star.awt.UnoControlNumericFieldModel",
sPropNames, oPropValues, listener)
def insertTimeField(
self, sName, sTextChanged, sPropNames, oPropValues, listener):
return self.insertEditField(
sName, sTextChanged,
"com.sun.star.awt.UnoControlTimeFieldModel",
sPropNames, oPropValues, listener)
def insertFixedLine(self, sName, sPropNames, oPropValues):
oLine = self.insertControlModel(
"com.sun.star.awt.UnoControlFixedLineModel",
sName, sPropNames, oPropValues)
return oLine
def insertLabel(self, sName, sPropNames, oPropValues):
oFixedText = self.insertControlModel(
"com.sun.star.awt.UnoControlFixedTextModel",
sName, sPropNames, oPropValues)
return oFixedText
def insertScrollBar(self, sName, sPropNames, oPropValues,
iControlKey, listener):
oScrollBar = self.insertControlModel(
"com.sun.star.awt.UnoControlScrollBarModel",
sName, sPropNames, oPropValues)
if listener is not None:
method = getattr(listener, "scrollControls")
oScrollBar.addAdjustmentListener(
AdjustmentListenerProcAdapter(method))
if self.ControlList is not None:
self.ControlList[sName] = iControlKey
return oScrollBar
def showMessageBox(self, windowServiceName, windowAttribute, MessageText):
return SystemDialog.showMessageBox(
super().xMSF, self.xControl.Peer,
windowServiceName, windowAttribute, MessageText)

View File

@@ -0,0 +1,470 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
import traceback
from abc import ABCMeta, abstractmethod
from .UnoDialog2 import UnoDialog2, Desktop, PropertyNames, UIConsts, \
ItemListenerProcAdapter
from ..common.HelpIds import HelpIds
from ..common.FileAccess import FileAccess
from com.sun.star.lang import NoSuchMethodException
from com.sun.star.frame import TerminationVetoException
from com.sun.star.awt.PushButtonType import HELP, STANDARD
from com.sun.star.awt.FontWeight import BOLD
import sys, os
if sys.version_info < (3,4):
import imp
imp.load_source('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc'))
import strings
elif sys.version_info < (3,7):
# imp is deprecated since Python v.3.4
from importlib.machinery import SourceFileLoader
SourceFileLoader('strings', os.path.join(os.path.dirname(__file__), '../common/strings.hrc')).load_module()
import strings
else:
# have to jump through hoops since 3.7, partly because python does not like loading modules that do have a .py extension
import importlib
import importlib.util
import importlib.machinery
module_name = 'strings'
path = os.path.join(os.path.dirname(__file__), '../common/strings.hrc')
spec = importlib.util.spec_from_loader(
module_name,
importlib.machinery.SourceFileLoader(module_name, path)
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[module_name] = module
strings = module
class WizardDialog(UnoDialog2):
__metaclass__ = ABCMeta
__NEXT_ACTION_PERFORMED = "gotoNextAvailableStep"
__BACK_ACTION_PERFORMED = "gotoPreviousAvailableStep"
__FINISH_ACTION_PERFORMED = "finishWizard_1"
__CANCEL_ACTION_PERFORMED = "cancelWizard_1"
__HELP_ACTION_PERFORMED = None
'''
Creates a new instance of WizardDialog
the hid is used as following :
"HID:(hid)" - the dialog
"HID:(hid+1) - the help button
"HID:(hid+2)" - the back button
"HID:(hid+3)" - the next button
"HID:(hid+4)" - the create button
"HID:(hid+5)" - the cancel button
@param xMSF
@param hid_
'''
def __init__(self, xMSF, hid_):
super(WizardDialog,self).__init__(xMSF)
self.__hid = hid_
self.iButtonWidth = 50
self.nNewStep = 1
self.nOldStep = 1
self.nMaxStep = 1
self.bTerminateListenermustberemoved = True
self.oRoadmap = None
self.terminateListener = None
def activate(self):
try:
self.xUnoDialog.toFront()
except Exception:
pass
# do nothing;
def itemStateChanged(self, itemEvent):
try:
self.nNewStep = itemEvent.ItemId
self.nOldStep = int(self.xDialogModel.Step)
if self.nNewStep != self.nOldStep:
self.switchToStep()
except Exception:
traceback.print_exc()
def setDialogProperties(self, closeable, height, moveable, position_x,
position_Y, step, tabIndex, title, width):
uno.invoke(self.xDialogModel, "setPropertyValues",
((PropertyNames.PROPERTY_CLOSEABLE,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_MOVEABLE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_TITLE,
PropertyNames.PROPERTY_WIDTH),
(closeable, height, moveable, position_x, position_Y, step,
tabIndex, title, width)))
def setRoadmapInteractive(self, _bInteractive):
self.oRoadmap.Activated = _bInteractive
def setRoadmapComplete(self, bComplete):
self.oRoadmap.Complete = bComplete
def isRoadmapComplete(self):
try:
return bool(self.oRoadmap.Complete)
except Exception:
traceback.print_exc()
return False
def setCurrentRoadmapItemID(self, ID):
if self.oRoadmap is not None:
nCurItemID = self.getCurrentRoadmapItemID()
if nCurItemID != ID:
self.oRoadmap.CurrentItemID = ID
def getCurrentRoadmapItemID(self):
try:
return int(self.oRoadmap.CurrentItemID)
except Exception:
traceback.print_exc()
return -1
def initializePaths(self):
xPropertySet = \
self.xMSF.createInstance("com.sun.star.util.PathSettings")
self.sUserTemplatePath = \
xPropertySet.getPropertyValue("Template_writable")
myFA = FileAccess(self.xMSF)
aInternalPaths = xPropertySet.getPropertyValue("Template_internal")
self.sTemplatePath = ""
for path in aInternalPaths:
if myFA.exists(path + "/wizard", False):
self.sTemplatePath = path
break
if self.sTemplatePath == "":
raise Exception("could not find wizard templates")
def addRoadmap(self):
try:
iDialogHeight = self.xDialogModel.Height
# the roadmap control has got no real TabIndex ever
# that is not correct, but changing this would need time,
# so it is used without TabIndex as before
xRoadmapControl = self.insertControlModel(
"com.sun.star.awt.UnoControlRoadmapModel",
"rdmNavi",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX, "Tabstop",
PropertyNames.PROPERTY_WIDTH),
((iDialogHeight - 26), 0, 0, 0,
0, True, 85))
self.oRoadmap = xRoadmapControl.Model
method = getattr(self, "itemStateChanged")
xRoadmapControl.addItemListener(
ItemListenerProcAdapter(method))
self.oRoadmap.Text = strings.RID_COMMON_START_16
except NoSuchMethodException:
from com.sun.star.awt.VclWindowPeerAttribute import OK
from .SystemDialog import SystemDialog
sError = "The files required could not be found.\n" + \
"Please start the LibreOffice Setup and choose 'Repair'."
SystemDialog.showMessageBox(super().xMSF, "ErrorBox", OK, sError)
except Exception:
traceback.print_exc()
def getRoadmapItemByID(self, _ID):
try:
getByIndex = self.oRoadmap.getByIndex
for i in list(range(self.oRoadmap.Count)):
CurRoadmapItem = getByIndex(i)
CurID = int(CurRoadmapItem.ID)
if CurID == _ID:
return CurRoadmapItem
return None
except Exception:
traceback.print_exc()
return None
def switchToStep(self,_nOldStep=None, _nNewStep=None):
if _nOldStep is not None and _nNewStep is not None:
self.nOldStep = _nOldStep
self.nNewStep = _nNewStep
self.leaveStep(self.nOldStep, self.nNewStep)
if self.nNewStep != self.nOldStep:
if self.nNewStep == self.nMaxStep:
self.xDialogModel.btnWizardNext.DefaultButton = False
self.xDialogModel.btnWizardFinish.DefaultButton = True
else:
self.xDialogModel.btnWizardNext.DefaultButton = True
self.xDialogModel.btnWizardFinish.DefaultButton = False
self.changeToStep(self.nNewStep)
self.enterStep(self.nOldStep, self.nNewStep)
return True
return False
@abstractmethod
def leaveStep(self, nOldStep, nNewStep):
pass
@abstractmethod
def enterStep(self, nOldStep, nNewStep):
pass
def changeToStep(self, nNewStep):
self.xDialogModel.Step = nNewStep
self.setCurrentRoadmapItemID(nNewStep)
self.enableNextButton(self.getNextAvailableStep() > 0)
self.enableBackButton(nNewStep != 1)
def drawNaviBar(self):
try:
curtabindex = UIConsts.SOFIRSTWIZARDNAVITABINDEX
iButtonWidth = self.iButtonWidth
iButtonHeight = 14
iCurStep = 0
iDialogHeight = self.xDialogModel.Height
iDialogWidth = self.xDialogModel.Width
iHelpPosX = 8
iBtnPosY = iDialogHeight - iButtonHeight - 6
iCancelPosX = iDialogWidth - self.iButtonWidth - 6
iFinishPosX = iCancelPosX - 6 - self.iButtonWidth
iNextPosX = iFinishPosX - 6 - self.iButtonWidth
iBackPosX = iNextPosX - 3 - self.iButtonWidth
self.insertControlModel(
"com.sun.star.awt.UnoControlFixedLineModel",
"lnNaviSep",
(PropertyNames.PROPERTY_HEIGHT, "Orientation",
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_WIDTH),
(1, 0, 0, iDialogHeight - 26, iCurStep, iDialogWidth))
self.insertControlModel(
"com.sun.star.awt.UnoControlFixedLineModel",
"lnRoadSep",
(PropertyNames.PROPERTY_HEIGHT,
"Orientation",
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_WIDTH),
(iBtnPosY - 6, 1, 85, 0, iCurStep, 1))
propNames = (PropertyNames.PROPERTY_ENABLED,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
"PushButtonType",
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.xDialogModel.HelpURL = HelpIds.getHelpIdString(self.__hid)
self.insertButton("btnWizardHelp",
WizardDialog.__HELP_ACTION_PERFORMED,
(PropertyNames.PROPERTY_ENABLED,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
"PushButtonType",
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(True, iButtonHeight,
strings.RID_COMMON_START_15,
iHelpPosX, iBtnPosY,
uno.Any("short",HELP), iCurStep,
uno.Any("short",(curtabindex + 1)), iButtonWidth), self)
self.insertButton("btnWizardBack",
WizardDialog.__BACK_ACTION_PERFORMED, propNames,
(False, iButtonHeight, HelpIds.getHelpIdString(self.__hid + 2),
strings.RID_COMMON_START_13,
iBackPosX, iBtnPosY, uno.Any("short",STANDARD), iCurStep,
uno.Any("short",(curtabindex + 1)), iButtonWidth), self)
self.insertButton("btnWizardNext",
WizardDialog.__NEXT_ACTION_PERFORMED, propNames,
(True, iButtonHeight, HelpIds.getHelpIdString(self.__hid + 3),
strings.RID_COMMON_START_14,
iNextPosX, iBtnPosY, uno.Any("short",STANDARD), iCurStep,
uno.Any("short",(curtabindex + 1)), iButtonWidth), self)
self.insertButton("btnWizardFinish",
WizardDialog.__FINISH_ACTION_PERFORMED, propNames,
(True, iButtonHeight, HelpIds.getHelpIdString(self.__hid + 4),
strings.RID_COMMON_START_12,
iFinishPosX, iBtnPosY, uno.Any("short",STANDARD),
iCurStep,
uno.Any("short",(curtabindex + 1)),
iButtonWidth), self)
self.insertButton("btnWizardCancel",
WizardDialog.__CANCEL_ACTION_PERFORMED, propNames,
(True, iButtonHeight, HelpIds.getHelpIdString(self.__hid + 5),
strings.RID_COMMON_START_11,
iCancelPosX, iBtnPosY, uno.Any("short",STANDARD), iCurStep,
uno.Any("short",(curtabindex + 1)),
iButtonWidth), self)
self.xDialogModel.btnWizardNext.DefaultButton = True
except Exception:
traceback.print_exc()
def insertRoadMapItems(self, items, enabled):
for index, item in enumerate(items):
try:
oRoadmapItem = self.oRoadmap.createInstance()
oRoadmapItem.Label = item
oRoadmapItem.Enabled = enabled[index]
oRoadmapItem.ID = index + 1
self.oRoadmap.insertByIndex(index, oRoadmapItem)
except Exception:
traceback.print_exc()
def enableBackButton(self, enabled):
self.xDialogModel.btnWizardBack.Enabled = enabled
def enableNextButton(self, enabled):
self.xDialogModel.btnWizardNext.Enabled = enabled
def enableFinishButton(self, enabled):
self.xDialogModel.btnWizardFinish.Enabled = enabled
def isStepEnabled(self, _nStep):
try:
xRoadmapItem = self.getRoadmapItemByID(_nStep)
# Todo: In this case an exception should be thrown
if xRoadmapItem is None:
return False
bIsEnabled = bool(xRoadmapItem.Enabled)
return bIsEnabled
except Exception:
traceback.print_exc()
return False
def gotoPreviousAvailableStep(self):
try:
if self.nNewStep > 1:
self.nOldStep = self.nNewStep
self.nNewStep -= 1
while self.nNewStep > 0:
bIsEnabled = self.isStepEnabled(self.nNewStep)
if bIsEnabled:
break;
self.nNewStep -= 1
if (self.nNewStep == 0):
self.nNewStep = self.nOldStep
self.switchToStep()
except Exception:
traceback.print_exc()
def getNextAvailableStep(self):
if self.isRoadmapComplete():
i = self.nNewStep + 1
while i <= self.nMaxStep:
if self.isStepEnabled(i):
return i
i += 1
return -1
def gotoNextAvailableStep(self):
try:
self.nOldStep = self.nNewStep
self.nNewStep = self.getNextAvailableStep()
if self.nNewStep > -1:
self.switchToStep()
except Exception:
traceback.print_exc()
@abstractmethod
def finishWizard(self):
pass
def finishWizard_1(self):
'''This function will call
if the finish button is pressed on the UI'''
try:
self.enableFinishButton(False)
success = False
try:
success = self.finishWizard()
finally:
if not success:
self.enableFinishButton(True)
if success:
self.removeTerminateListener()
except Exception:
traceback.print_exc()
def getCurrentStep(self):
try:
return int(self.xDialogModel.Step)
except Exception:
traceback.print_exc()
return -1
def cancelWizard(self):
#can be overwritten by extending class
self.xUnoDialog.endExecute()
def removeTerminateListener(self):
if self.bTerminateListenermustberemoved:
Desktop.getDesktop(self.xMSF).removeTerminateListener(self.terminateListener)
self.bTerminateListenermustberemoved = False
'''
called by the cancel button and
by the window hidden event.
if this method was not called before,
perform a cancel.
'''
def cancelWizard_1(self):
try:
self.cancelWizard()
self.removeTerminateListener()
except Exception:
traceback.print_exc()
def windowHidden(self):
self.cancelWizard_1()
def queryTermination(self):
self.activate()
raise TerminationVetoException()
def disposing(self, arg0):
self.cancelWizard_1()
def optCreateFromTemplateItemChanged(self):
self.bEditTemplate = False
def optMakeChangesItemChanged(self):
self.bEditTemplate = True

View File

@@ -0,0 +1,125 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import unohelper
from com.sun.star.awt import XActionListener
class ActionListenerProcAdapter( unohelper.Base, XActionListener ):
def __init__(self, oProcToCall):
self.oProcToCall = oProcToCall
def actionPerformed( self, oActionEvent ):
if callable( self.oProcToCall ):
self.oProcToCall()
def disposing(self, Event):
# TODO: Implement ?
pass
from com.sun.star.awt import XItemListener
class ItemListenerProcAdapter( unohelper.Base, XItemListener ):
def __init__(self, oProcToCall):
self.oProcToCall = oProcToCall
def itemStateChanged( self, oItemEvent ):
if callable( self.oProcToCall ):
try:
self.oProcToCall()
except:
self.oProcToCall(oItemEvent)
def disposing(self, Event):
# TODO: Implement ?
pass
from com.sun.star.awt import XTextListener
class TextListenerProcAdapter( unohelper.Base, XTextListener ):
def __init__(self, oProcToCall):
self.oProcToCall = oProcToCall
def textChanged( self, oTextEvent ):
if callable( self.oProcToCall ):
self.oProcToCall()
def disposing(self, Event):
# TODO: Implement ?
pass
from com.sun.star.frame import XTerminateListener
class TerminateListenerProcAdapter( unohelper.Base, XTerminateListener ):
def __init__(self, oProcToCall):
self.oProcToCall = oProcToCall
def queryTermination(self, TerminateEvent):
if callable( self.oProcToCall ):
self.oProcToCall()
from com.sun.star.awt import XWindowListener
class WindowListenerProcAdapter( unohelper.Base, XWindowListener ):
def __init__(self, oProcToCall):
self.oProcToCall = oProcToCall
def windowShown(self, TerminateEvent):
if callable( self.oProcToCall ):
self.oProcToCall()
def windowHidden(self, Event):
# TODO: Implement ?
pass
def windowResized(self, Event):
# TODO: Implement ?
pass
def windowMoved(self, Event):
# TODO: Implement ?
pass
def disposing(self, Event):
# TODO: Implement ?
pass
from com.sun.star.awt import XAdjustmentListener
class AdjustmentListenerProcAdapter( unohelper.Base, XAdjustmentListener ):
def __init__(self, oProcToCall):
self.oProcToCall = oProcToCall
def adjustmentValueChanged(self, TerminateEvent):
if callable( self.oProcToCall ):
self.oProcToCall()
from com.sun.star.awt import XFocusListener
class FocusListenerProcAdapter( unohelper.Base, XFocusListener ):
def __init__( self, oProcToCall):
self.oProcToCall = oProcToCall
def focusGained(self, FocusEvent):
if callable( self.oProcToCall ):
self.oProcToCall(FocusEvent)
from com.sun.star.awt import XKeyListener
class KeyListenerProcAdapter( unohelper.Base, XKeyListener ):
def __init__(self, oProcToCall):
self.oProcToCall = oProcToCall
def keyPressed(self, KeyEvent):
if callable( self.oProcToCall ):
self.oProcToCall(KeyEvent)
def disposing(self, Event):
# TODO: Implement ?
pass

View File

@@ -0,0 +1,117 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
import uno
from abc import ABCMeta, abstractmethod
from com.sun.star.util import Date
from com.sun.star.util import Time
from datetime import datetime
'''
DataAware objects are used to live-synchronize UI and DataModel/DataObject.
It is used as listener on UI events, to keep the DataObject up to date.
This class, as a base abstract class, sets a frame of functionality,
delegating the data Object get/set methods to a Value object,
and leaving the UI get/set methods abstract.
Note that event listening is *not* a part of this model.
the updateData() or updateUI() methods should be programmatically called.
in child classes, the updateData() will be bound to UI event calls.
<br><br>
This class holds references to a Data Object and a Value object.
The Value object "knows" how to get and set a value from the
Data Object.
'''
class DataAware(object):
__metaclass__ = ABCMeta
'''
creates a DataAware object for the given data object and Value object.
@param dataObject_
@param value_
'''
def __init__(self, dataObject_, field_):
self._dataObject = dataObject_
self._field = field_
'''
sets the given value to the UI control
@param newValue the value to set to the ui control.
'''
@abstractmethod
def setToUI (self,newValue):
pass
'''
gets the current value from the UI control.
@return the current value from the UI control.
'''
@abstractmethod
def getFromUI (self):
pass
'''
updates the UI control according to the
current state of the data object.
'''
def updateUI(self):
try:
data = getattr(self._dataObject, self._field)
except Exception:
data = uno.invoke(self._dataObject, "get" + self._field, ())
ui = self.getFromUI()
if data is not ui:
try:
self.setToUI(data)
except Exception:
traceback.print_exc()
'''
updates the DataObject according to
the current state of the UI control.
'''
def updateData(self):
useUno = False
try:
try:
data = getattr(self._dataObject, self._field)
except Exception:
useUno = True
data = uno.invoke(self._dataObject, "get" + self._field, ())
ui = self.getFromUI()
if data is not ui:
if isinstance(ui,Date):
d = datetime(ui.Year, ui.Month, ui.Day)
ui = d.strftime('%d/%m/%y')
elif isinstance(ui,Time):
t = datetime(1, 1, 1, ui.Hours, ui.Minutes)
ui = t.strftime('%H:%M')
if useUno:
uno.invoke(self._dataObject, "set" + self._field, (ui,))
else:
if isinstance(ui,tuple):
#Listbox Element
ui = ui[0]
setattr(self._dataObject, self._field, ui)
except Exception:
traceback.print_exc()

View File

@@ -0,0 +1,27 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
class EventListenerList(object):
def __init__(self):
self.list = []
def add(self, listener):
self.list.append(listener)
def remove(self, listener):
self.list.remove(listener)

View File

@@ -0,0 +1,67 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from abc import abstractmethod
from .ListDataListener import ListDataListener
class ListModelBinder(ListDataListener):
def __init__(self, unoListBox, listModel_):
self.unoList = unoListBox
self.unoListModel = unoListBox.Model
self.listModel = None
self.setListModel(listModel_)
self.renderer = self.Renderer()
def setListModel(self, newListModel):
if self.listModel is not None:
self.listModel.removeListDataListener(self)
self.listModel = newListModel
self.listModel.addListDataListener(self)
def update(self, i):
self.remove(i, i)
self.insert(i)
def remove(self, i1, i2):
self.unoList.removeItems(i1, i2 - i1 + 1)
def insert(self, i):
self.unoList.addItem(self.getItemString(i), i)
def getItemString(self, i):
return self.getItemString1(self.listModel.getElementAt(i))
def getItemString1(self, item):
return self.renderer.render(item)
def getSelectedItems(self):
return self.unoListModel.SelectedItems
class Renderer:
@abstractmethod
def render(self, item):
if (item is None):
return ""
elif (isinstance(item, int)):
return str(item)
else:
return item.toString()

View File

@@ -0,0 +1,48 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from .CommonListener import ItemListenerProcAdapter
from .DataAware import DataAware
class RadioDataAware(DataAware):
def __init__(self, data, value, radioButtons):
super(RadioDataAware,self).__init__(data, value)
self.radioButtons = radioButtons
def setToUI(self, value):
selected = int(value)
if selected == -1:
for i in self.radioButtons:
i.State = False
else:
self.radioButtons[selected].State = True
def getFromUI(self):
for index, workwith in enumerate(self.radioButtons):
if workwith.State:
return index
return -1
@classmethod
def attachRadioButtons(self, data, prop, buttons, field):
da = RadioDataAware(data, prop, buttons)
method = getattr(da,"updateData")
for i in da.radioButtons:
i.addItemListener(ItemListenerProcAdapter(method))
return da

View File

@@ -0,0 +1,76 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
import traceback
from .TaskEvent import TaskEvent
class Task:
successful = 0
failed = 0
maximum = 0
taskName = ""
listeners = []
subtaskName = ""
def __init__(self, taskName_, subtaskName_, max_):
self.taskName = taskName_
self.subtaskName = subtaskName_
self.maximum = max_
def start(self):
self.fireTaskStarted()
def fail(self):
self.fireTaskFailed()
def getMax(self):
return self.maximum
def setMax(self, max_):
self.maximum = max_
self.fireTaskStatusChanged()
def advance(self, success_):
if success_:
self.successful += 1
print ("Success :", self.successful)
else:
self.failed += 1
print ("Failed :", self.failed)
self.fireTaskStatusChanged()
if (self.failed + self.successful == self.maximum):
self.fireTaskFinished()
def fireTaskStatusChanged(self):
te = TaskEvent(self, TaskEvent.TASK_STATUS_CHANGED)
for i in range(len(self.listeners)):
self.listeners[i].taskStatusChanged(te)
def fireTaskStarted(self):
te = TaskEvent(self, TaskEvent.TASK_STARTED)
for i in range(len(self.listeners)):
self.listeners[i].taskStarted(te)
def fireTaskFailed(self):
te = TaskEvent(self, TaskEvent.TASK_FAILED)
for i in range(len(self.listeners)):
self.listeners[i].taskFinished(te)
def fireTaskFinished(self):
te = TaskEvent(self, TaskEvent.TASK_FINISHED)
for i in range(len(self.listeners)):
self.listeners[i].taskFinished(te)

View File

@@ -0,0 +1,34 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
class TaskEvent:
TASK_STARTED = 1
TASK_FINISHED = 2
TASK_STATUS_CHANGED = 3
SUBTASK_NAME_CHANGED = 4
TASK_FAILED = 5
taskType = 0
source = None
#general constructor-
# @param source
# @param type_
def __init__(self, source_, type_):
#super(TaskEvent, self).__init__(source)
self.taskType = type_
self.source = source_

View File

@@ -0,0 +1,35 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from abc import abstractmethod
from com.sun.star.script import EventListener
class TaskListener(EventListener):
@abstractmethod
def taskStarted(self, te):
pass
@abstractmethod
def taskFinished(self, te):
pass
# is called when the status of the task has advanced.
# @param te
@abstractmethod
def taskStatusChanged(self, te):
pass

View File

@@ -0,0 +1,104 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
from .CommonListener import ItemListenerProcAdapter, TextListenerProcAdapter
from .DataAware import DataAware, datetime, Date, Time
from ...common.PropertyNames import PropertyNames
'''
This class supports simple cases where a UI control can
be directly synchronized with a data property.
Such controls are: the different text controls
(synchronizing the "Text" , "Value", "Date", "Time" property),
Checkbox controls, Dropdown listbox controls (synchronizing the
SelectedItems[] property.
For those controls, static convenience methods are offered, to simplify use.
'''
class UnoDataAware(DataAware):
def __init__(self, dataObject, field, unoObject_, unoPropName_, isShort=False):
super(UnoDataAware,self).__init__(dataObject, field)
self.unoControl = unoObject_
self.unoModel = self.unoControl.Model
self.unoPropName = unoPropName_
self.isShort = isShort
def setToUI(self, value):
if (isinstance(value, list)):
value = tuple(value)
elif self.isShort:
value = uno.Any("[]short", (value,))
if value:
if(hasattr(self.unoModel, self.unoPropName)):
if self.unoPropName == "Date":
d = datetime.strptime(value, '%d/%m/%y')
value = Date(d.day, d.month, d.year)
elif self.unoPropName == "Time":
t = datetime.strptime(value, '%H:%M')
value = Time(0, 0, t.minute, t.hour, False)
setattr(self.unoModel, self.unoPropName, value)
else:
uno.invoke(self.unoModel, "set" + self.unoPropName, (value,))
def getFromUI(self):
return getattr(self.unoModel, self.unoPropName)
@classmethod
def __attachTextControl(
self, data, prop, unoText, unoProperty, field, value):
uda = UnoDataAware(data, prop, unoText, unoProperty)
method = getattr(uda,"updateData")
unoText.addTextListener(TextListenerProcAdapter(method))
return uda
@classmethod
def attachEditControl(self, data, prop, unoControl, field):
return self.__attachTextControl(
data, prop, unoControl, "Text", field, "")
@classmethod
def attachDateControl(self, data, prop, unoControl, field):
return self.__attachTextControl(
data, prop, unoControl, "Date", field, 0)
@classmethod
def attachTimeControl(self, data, prop, unoControl, field):
return self.__attachTextControl(
data, prop, unoControl, "Time", field, 0)
@classmethod
def attachNumericControl(self, data, prop, unoControl, field):
return self.__attachTextControl(
data, prop, unoControl, "Value", field, float(0))
@classmethod
def attachCheckBox(
self, data, prop, checkBox, field):
uda = UnoDataAware(data, prop, checkBox, PropertyNames.PROPERTY_STATE)
method = getattr(uda,"updateData")
checkBox.addItemListener(ItemListenerProcAdapter(method))
return uda
@classmethod
def attachListBox(self, data, prop, listBox, field):
uda = UnoDataAware(data, prop, listBox, "SelectedItems", True)
method = getattr(uda,"updateData")
listBox.addItemListener(ItemListenerProcAdapter(method))
return uda