diff options
Diffstat (limited to 'wizards/com/sun/star')
204 files changed, 46486 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/README b/wizards/com/sun/star/wizards/README new file mode 100644 index 0000000000..9ee2840048 --- /dev/null +++ b/wizards/com/sun/star/wizards/README @@ -0,0 +1,18 @@ +To call a wizard remotely you need to: + +-> For testing on core: + export URE_BOOTSTRAP="file:///home/'USER'/libreoffice-core/instdir/program/fundamentalrc" + export PYTHONPATH=/home/'USER'/libreoffice-core/instdir/program + #and run LibreOffice in listening mode: + ./soffice --"accept=socket,host=localhost,port=2002;urp;" + +-> For testing on installed LibreOffice: + export URE_BOOTSTRAP="file:///usr/lib/libreoffice/program/fundamentalrc" + export PYTHONPATH=/usr/lib/libreoffice/program + #and run LibreOffice in listening mode: + soffice --"accept=socket,host=localhost,port=2002;urp;" + +-> Launch the wizard from wizards parent folder: + python3.3 + from wizards.[Wizard's folder].CallWizard import CallWizard + CallWizard.callRemote() diff --git a/wizards/com/sun/star/wizards/__init__.py b/wizards/com/sun/star/wizards/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/__init__.py diff --git a/wizards/com/sun/star/wizards/agenda/AgendaDocument.py b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py new file mode 100644 index 0000000000..b96fe44cf1 --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/AgendaDocument.py @@ -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 >xxx< 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)) diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.py new file mode 100644 index 0000000000..991b05f045 --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.py @@ -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)) diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.py new file mode 100644 index 0000000000..e4370a416b --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.py @@ -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) diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py new file mode 100644 index 0000000000..372dad0551 --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py @@ -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 diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py new file mode 100644 index 0000000000..9d42e6317f --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.py @@ -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) diff --git a/wizards/com/sun/star/wizards/agenda/CGAgenda.py b/wizards/com/sun/star/wizards/agenda/CGAgenda.py new file mode 100644 index 0000000000..ee8435ba1c --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/CGAgenda.py @@ -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) diff --git a/wizards/com/sun/star/wizards/agenda/CGTopic.py b/wizards/com/sun/star/wizards/agenda/CGTopic.py new file mode 100644 index 0000000000..e99f770b24 --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/CGTopic.py @@ -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 diff --git a/wizards/com/sun/star/wizards/agenda/CallWizard.py b/wizards/com/sun/star/wizards/agenda/CallWizard.py new file mode 100644 index 0000000000..2b784e2fe2 --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/CallWizard.py @@ -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: diff --git a/wizards/com/sun/star/wizards/agenda/TemplateConsts.py b/wizards/com/sun/star/wizards/agenda/TemplateConsts.py new file mode 100644 index 0000000000..2593c2ce34 --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/TemplateConsts.py @@ -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>" diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.py b/wizards/com/sun/star/wizards/agenda/TopicsControl.py new file mode 100644 index 0000000000..6e269f6bf2 --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/TopicsControl.py @@ -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) diff --git a/wizards/com/sun/star/wizards/agenda/__init__.py b/wizards/com/sun/star/wizards/agenda/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/__init__.py diff --git a/wizards/com/sun/star/wizards/agenda/agenda.component b/wizards/com/sun/star/wizards/agenda/agenda.component new file mode 100644 index 0000000000..5778ae32fe --- /dev/null +++ b/wizards/com/sun/star/wizards/agenda/agenda.component @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . + --> +<component loader="com.sun.star.loader.Python" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.wizards.agenda.CallWizard"> + <service name="com.sun.star.task.Job"/> + </implementation> +</component> diff --git a/wizards/com/sun/star/wizards/common/ConfigGroup.py b/wizards/com/sun/star/wizards/common/ConfigGroup.py new file mode 100644 index 0000000000..200d4ef9d1 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/ConfigGroup.py @@ -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 diff --git a/wizards/com/sun/star/wizards/common/ConfigSet.py b/wizards/com/sun/star/wizards/common/ConfigSet.py new file mode 100644 index 0000000000..d4cc7e4886 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/ConfigSet.py @@ -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) diff --git a/wizards/com/sun/star/wizards/common/Configuration.java b/wizards/com/sun/star/wizards/common/Configuration.java new file mode 100644 index 0000000000..c206a4014b --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Configuration.java @@ -0,0 +1,201 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.beans.*; +import com.sun.star.container.*; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.Locale; + +/** + * This class gives access to the OO configuration API. + * <p>It contains 4 get and 4 set convenience methods for getting and settings properties + * in the configuration.</p> + * <p>For the get methods, two parameters must be given: name and parent, where name is the + * name of the property, parent is a HierarchyElement (::com::sun::star::configuration::HierarchyElement)</p> + * <p>The get and set methods support hierarchical property names like "options/gridX". </p> + * <p>NOTE: not yet supported, but sometime later, + * If you will omit the "parent" parameter, then the "name" parameter must be in hierarchy form from + * the root of the registry.</p> + */ +public abstract class Configuration +{ + + public static Object getConfigurationRoot(XMultiServiceFactory xmsf, String sPath, boolean updateable) throws com.sun.star.uno.Exception + { + + Object oConfigProvider; + oConfigProvider = xmsf.createInstance("com.sun.star.configuration.ConfigurationProvider"); + XMultiServiceFactory confMsf = UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider); + + final String sView = updateable ? "com.sun.star.configuration.ConfigurationUpdateAccess" : "com.sun.star.configuration.ConfigurationAccess"; + + Object args[] = new Object[1]; + + PropertyValue aPathArgument = new PropertyValue(); + aPathArgument.Name = "nodepath"; + aPathArgument.Value = sPath; + + args[0] = aPathArgument; + + return confMsf.createInstanceWithArguments(sView, args); + } + + public static String getProductName(XMultiServiceFactory xMSF) + { + try + { + Object oProdNameAccess = getConfigurationRoot(xMSF, "org.openoffice.Setup/Product", false); + return (String) Helper.getUnoObjectbyName(oProdNameAccess, "ooName"); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + private static String getLocaleString(XMultiServiceFactory xMSF, String root, String key) + { + String sLocale = PropertyNames.EMPTY_STRING; + try + { + Object oMasterKey = getConfigurationRoot(xMSF, root, false); + sLocale = (String) Helper.getUnoObjectbyName(oMasterKey, key); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + if (sLocale.length() == 0 && (!key.equals("Locale") || !root.equals("org.openoffice.System/L10N/"))) + { + return getLocaleString(xMSF, "org.openoffice.System/L10N/", "Locale"); + } + return sLocale; + } + + private static Locale getLocale(XMultiServiceFactory xMSF, String root, String key) + { + Locale aLocLocale = new Locale(); + String sLocale = getLocaleString(xMSF, root, key); + String[] sLocaleList = JavaTools.ArrayoutofString(sLocale, "-"); + aLocLocale.Language = sLocaleList[0]; + if (sLocaleList.length > 1) + { + aLocLocale.Country = sLocaleList[1]; + } + return aLocLocale; + } + + public static Locale getLocale(XMultiServiceFactory xMSF) + { + return getLocale(xMSF, "org.openoffice.Setup/L10N/", "ooSetupSystemLocale"); + } + + public static Locale getUILocale(XMultiServiceFactory xMSF) + { + return getLocale(xMSF, "org.openoffice.Setup/L10N/", "ooLocale"); + } + + public static String[] getNodeDisplayNames(XNameAccess _xNameAccessNode) + { + return getNodeChildNames(_xNameAccessNode, PropertyNames.PROPERTY_NAME); + } + + public static String[] getNodeChildNames(XNameAccess xNameAccessNode, String _schildname) + { + String[] snames = null; + try + { + snames = xNameAccessNode.getElementNames(); + String[] sdisplaynames = new String[snames.length]; + for (int i = 0; i < snames.length; i++) + { + Object oContent = Helper.getUnoPropertyValue(xNameAccessNode.getByName(snames[i]), _schildname); + if (!AnyConverter.isVoid(oContent)) + { + sdisplaynames[i] = (String) Helper.getUnoPropertyValue(xNameAccessNode.getByName(snames[i]), _schildname); + } + else + { + sdisplaynames[i] = snames[i]; + } + } + return sdisplaynames; + } + catch (Exception e) + { + e.printStackTrace(System.err); + return snames; + } + } + + public static XNameAccess getChildNodebyIndex(XNameAccess _xNameAccess, int _index) throws com.sun.star.uno.Exception + { + String[] snames = _xNameAccess.getElementNames(); + Object oNode = _xNameAccess.getByName(snames[_index]); + return UnoRuntime.queryInterface(XNameAccess.class, oNode); + } + + public static XNameAccess getChildNodebyName(XNameAccess _xNameAccessNode, String _SubNodeName) + { + try + { + if (_xNameAccessNode.hasByName(_SubNodeName)) + { + return UnoRuntime.queryInterface(XNameAccess.class, _xNameAccessNode.getByName(_SubNodeName)); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return null; + } + + public static XNameAccess getChildNodebyDisplayName(XMultiServiceFactory _xMSF, Locale _aLocale, XNameAccess _xNameAccessNode, String _displayname, String _nodename, int _nmaxcharcount) + { + String[] snames = null; + try + { + snames = _xNameAccessNode.getElementNames(); + for (int i = 0; i < snames.length; i++) + { + String curdisplayname = (String) Helper.getUnoPropertyValue(_xNameAccessNode.getByName(snames[i]), _nodename); + if ((_nmaxcharcount > 0) && (_nmaxcharcount < curdisplayname.length())) + { + curdisplayname = curdisplayname.substring(0, _nmaxcharcount); + } + curdisplayname = Desktop.removeSpecialCharacters(_xMSF, _aLocale, curdisplayname); + + if (curdisplayname.equals(_displayname)) + { + return UnoRuntime.queryInterface(XNameAccess.class, _xNameAccessNode.getByName(snames[i])); + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return null; + } +} diff --git a/wizards/com/sun/star/wizards/common/Configuration.py b/wizards/com/sun/star/wizards/common/Configuration.py new file mode 100644 index 0000000000..91274e0b28 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Configuration.py @@ -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) diff --git a/wizards/com/sun/star/wizards/common/DebugHelper.java b/wizards/com/sun/star/wizards/common/DebugHelper.java new file mode 100644 index 0000000000..6f172a2dc0 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/DebugHelper.java @@ -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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.uno.Exception; + +public class DebugHelper +{ + + + public static void exception(Exception ex) throws java.lang.Exception + { +// throw new UnsupportedOperationException("Not supported yet."); + } + + public static void writeInfo(String msg) + { +// throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/wizards/com/sun/star/wizards/common/Desktop.java b/wizards/com/sun/star/wizards/common/Desktop.java new file mode 100644 index 0000000000..b19d1f3759 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Desktop.java @@ -0,0 +1,286 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.util.XURLTransformer; +import com.sun.star.lang.Locale; +import com.sun.star.bridge.XUnoUrlResolver; +import com.sun.star.comp.helper.Bootstrap; +import com.sun.star.container.XHierarchicalNameAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.*; +import com.sun.star.i18n.KParseType; +import com.sun.star.i18n.ParseResult; +import com.sun.star.i18n.XCharacterClassification; + +public class Desktop +{ + + public static XDesktop getDesktop(XMultiServiceFactory xMSF) + { + com.sun.star.uno.XInterface xInterface = null; + XDesktop xDesktop = null; + if (xMSF != null) + { + try + { + xInterface = (com.sun.star.uno.XInterface) xMSF.createInstance("com.sun.star.frame.Desktop"); + xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + else + { + System.out.println("Can't create a desktop. null pointer !"); + } + return xDesktop; + } + + public static XFrame getActiveFrame(XMultiServiceFactory xMSF) + { + XDesktop xDesktop = getDesktop(xMSF); + XFramesSupplier xFrameSuppl = UnoRuntime.queryInterface(XFramesSupplier.class, xDesktop); + return xFrameSuppl.getActiveFrame(); + } + + private static XDispatch getDispatcher(XFrame xFrame, String _stargetframe, com.sun.star.util.URL oURL) + { + try + { + com.sun.star.util.URL[] oURLArray = new com.sun.star.util.URL[1]; + oURLArray[0] = oURL; + XDispatchProvider xDispatchProvider = UnoRuntime.queryInterface(XDispatchProvider.class, xFrame); + return xDispatchProvider.queryDispatch(oURLArray[0], _stargetframe, FrameSearchFlag.ALL); // "_self" + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return null; + } + + private static com.sun.star.util.URL getDispatchURL(XMultiServiceFactory xMSF, String _sURL) throws com.sun.star.uno.Exception + { + Object oTransformer = xMSF.createInstance("com.sun.star.util.URLTransformer"); + XURLTransformer xTransformer = UnoRuntime.queryInterface(XURLTransformer.class, oTransformer); + com.sun.star.util.URL[] oURL = new com.sun.star.util.URL[1]; + oURL[0] = new com.sun.star.util.URL(); + oURL[0].Complete = _sURL; + xTransformer.parseStrict(oURL); + return oURL[0]; + } + + private static void dispatchURL(XMultiServiceFactory xMSF, String sURL, XFrame xFrame, String _stargetframe) throws com.sun.star.uno.Exception + { + com.sun.star.util.URL oURL = getDispatchURL(xMSF, sURL); + XDispatch xDispatch = getDispatcher(xFrame, _stargetframe, oURL); + dispatchURL(xDispatch, oURL); + } + + public static void dispatchURL(XMultiServiceFactory xMSF, String sURL, XFrame xFrame) throws com.sun.star.uno.Exception + { + dispatchURL(xMSF, sURL, xFrame, PropertyNames.EMPTY_STRING); + } + + private static void dispatchURL(XDispatch _xDispatch, com.sun.star.util.URL oURL) + { + PropertyValue[] oArg = new PropertyValue[0]; + _xDispatch.dispatch(oURL, oArg); + } + + private static XMultiComponentFactory getMultiComponentFactory() throws com.sun.star.uno.Exception, RuntimeException, java.lang.Exception + { + XComponentContext xcomponentcontext = Bootstrap.createInitialComponentContext(null); + // initial serviceManager + return xcomponentcontext.getServiceManager(); + } + + public static XMultiServiceFactory connect(String connectStr) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException, Exception + { + XMultiComponentFactory componentFactory = getMultiComponentFactory(); + Object xUrlResolver = componentFactory.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver", null ); + XUnoUrlResolver urlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, xUrlResolver); + return UnoRuntime.queryInterface(XMultiServiceFactory.class, urlResolver.resolve( connectStr ) ); + } + + public static String getIncrementSuffix(XNameAccess xElementContainer, String ElementName) + { + boolean bElementexists = true; + int i = 1; + String sIncSuffix = PropertyNames.EMPTY_STRING; + String BaseName = ElementName; + while (bElementexists) + { + bElementexists = xElementContainer.hasByName(ElementName); + if (bElementexists) + { + i += 1; + ElementName = BaseName + Integer.toString(i); + } + } + if (i > 1) + { + sIncSuffix = Integer.toString(i); + } + return sIncSuffix; + } + + private static String getIncrementSuffix(XHierarchicalNameAccess xElementContainer, String ElementName) + { + boolean bElementexists = true; + int i = 1; + String sIncSuffix = PropertyNames.EMPTY_STRING; + String BaseName = ElementName; + while (bElementexists) + { + bElementexists = xElementContainer.hasByHierarchicalName(ElementName); + if (bElementexists) + { + i += 1; + ElementName = BaseName + Integer.toString(i); + } + } + if (i > 1) + { + sIncSuffix = Integer.toString(i); + } + return sIncSuffix; + } + + private static int checkforfirstSpecialCharacter(XMultiServiceFactory _xMSF, String _sString, Locale _aLocale) + { + try + { + int nStartFlags = com.sun.star.i18n.KParseTokens.ANY_LETTER_OR_NUMBER + com.sun.star.i18n.KParseTokens.ASC_UNDERSCORE; + Object ocharservice = _xMSF.createInstance("com.sun.star.i18n.CharacterClassification"); + XCharacterClassification xCharacterClassification = UnoRuntime.queryInterface(XCharacterClassification.class, ocharservice); + ParseResult aResult = xCharacterClassification.parsePredefinedToken(KParseType.IDENTNAME, _sString, 0, _aLocale, nStartFlags, PropertyNames.EMPTY_STRING, nStartFlags, PropertyNames.SPACE); + return aResult.EndPos; + } + catch (Exception e) + { + e.printStackTrace(System.err); + return -1; + } + } + + public static String removeSpecialCharacters(XMultiServiceFactory _xMSF, Locale _aLocale, String _sname) + { + String snewname = _sname; + int i = 0; + while (i < snewname.length()) + { + i = Desktop.checkforfirstSpecialCharacter(_xMSF, snewname, _aLocale); + if (i < snewname.length()) + { + String sspecialchar = snewname.substring(i, i + 1); + snewname = JavaTools.replaceSubString(snewname, PropertyNames.EMPTY_STRING, sspecialchar); + } + } + return snewname; + } + + /** + * Checks if the passed Element Name already exists in the ElementContainer. If yes it appends a + * suffix to make it unique + * @return a unique Name ready to be added to the container. + */ + public static String getUniqueName(XNameAccess xElementContainer, String sElementName) + { + String sIncSuffix = getIncrementSuffix(xElementContainer, sElementName); + return sElementName + sIncSuffix; + } + + /** + * Checks if the passed Element Name already exists in the ElementContainer. If yes it appends a + * suffix to make it unique + * @return a unique Name ready to be added to the container. + */ + public static String getUniqueName(XHierarchicalNameAccess xElementContainer, String sElementName) + { + String sIncSuffix = getIncrementSuffix(xElementContainer, sElementName); + return sElementName + sIncSuffix; + } + + /** + * Checks if the passed Element Name already exists in the list. If yes it appends a + * suffix to make it unique. + * @return a unique Name not being in the passed list. + */ + public static String getUniqueName(String[] _slist, String _sElementName, String _sSuffixSeparator) + { + if (_slist == null || _slist.length == 0) + { + return _sElementName; + } + String scompname = _sElementName; + int a = 2; + while (true) + { + for (int i = 0; i < _slist.length; i++) + { + if (JavaTools.FieldInList(_slist, scompname) == -1) + { + return scompname; + } + } + scompname = _sElementName + _sSuffixSeparator + a++; + } + } + + + + private static String getTemplatePath(XMultiServiceFactory _xMSF) + { + try + { + return FileAccess.getOfficePath(_xMSF, "Template", "share", "/wizard"); + } + catch (NoValidPathException nopathexception) + { + } + return PropertyNames.EMPTY_STRING; + } + + + + public static String getBitmapPath(XMultiServiceFactory _xMSF) + { + try + { + return FileAccess.combinePaths(_xMSF, getTemplatePath(_xMSF), "/../wizard/bitmap"); + } + catch (NoValidPathException nopathexception) + { + } + return PropertyNames.EMPTY_STRING; + } + + + + + +} diff --git a/wizards/com/sun/star/wizards/common/Desktop.py b/wizards/com/sun/star/wizards/common/Desktop.py new file mode 100644 index 0000000000..99c9d60d83 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Desktop.py @@ -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 + diff --git a/wizards/com/sun/star/wizards/common/FileAccess.java b/wizards/com/sun/star/wizards/common/FileAccess.java new file mode 100644 index 0000000000..4e8d520a52 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/FileAccess.java @@ -0,0 +1,594 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.Locale; +import com.sun.star.uno.Exception; +import com.sun.star.util.XMacroExpander; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Vector; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XTextInputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lib.util.StringHelper; +import com.sun.star.ucb.CommandAbortedException; +import com.sun.star.ucb.XFileIdentifierConverter; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.ucb.XSimpleFileAccess2; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.beans.PropertyValue; +import com.sun.star.document.XDocumentProperties; + +/** + * 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. + */ +public class FileAccess +{ + + private static String deleteLastSlashfromUrl(String _sPath) + { + if (_sPath.endsWith("/")) + { + return _sPath.substring(0, _sPath.length() - 1); + } + else + { + return _sPath; + } + } + + /** + * Further information on arguments value see in OO Developer Guide, + * chapter 6.2.7 + * @return the respective path of the office application. A probable following "/" at the end is trimmed. + */ + public static String getOfficePath(XMultiServiceFactory xMSF, String sPath) + { + try + { + String ResultPath = PropertyNames.EMPTY_STRING; + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings"); + ResultPath = com.sun.star.uno.AnyConverter.toString(Helper.getUnoPropertyValue(xInterface, sPath)); + ResultPath = deleteLastSlashfromUrl(ResultPath); + return ResultPath; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return PropertyNames.EMPTY_STRING; + } + } + + /** + * Further information on arguments value see in OO Developer Guide, + * chapter 6.2.7 + * @param sType use "share" or "user". Set to PropertyNames.EMPTY_STRING if not needed eg for the WorkPath; + * In the return Officepath a possible slash at the end is cut off + */ + public static String getOfficePath(XMultiServiceFactory xMSF, String sPath, String sType, String sSearchDir) throws NoValidPathException + { + //This method currently only works with sPath="Template" + + String ResultPath = PropertyNames.EMPTY_STRING; + + String Template_writable = PropertyNames.EMPTY_STRING; + String[] Template_internal; + String[] Template_user; + + boolean bexists = false; + try + { + XInterface xPathInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings"); + XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xPathInterface); + String WritePath = PropertyNames.EMPTY_STRING; + String[] ReadPaths = null; + XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface); + + Template_writable = (String) xPropertySet.getPropertyValue(sPath + "_writable"); + Template_internal = (String[]) xPropertySet.getPropertyValue(sPath + "_internal"); + Template_user = (String[]) xPropertySet.getPropertyValue(sPath + "_user"); + int iNumEntries = Template_user.length + Template_internal.length + 1; + ReadPaths = new String[iNumEntries]; + int t = 0; + for (int i = 0; i < Template_internal.length; i++) + { + ReadPaths[t] = Template_internal[i]; + t++; + } + for (int i = 0; i < Template_user.length; i++) + { + ReadPaths[t] = Template_user[i]; + t++; + } + ReadPaths[t] = Template_writable; + WritePath = Template_writable; + + if (sType.equalsIgnoreCase("user")) + { + ResultPath = WritePath; + bexists = true; + } + else + { + //find right path using the search sub path + for (int i = 0; i < ReadPaths.length; i++) + { + String tmpPath = ReadPaths[i] + sSearchDir; + if (xSimpleFileAccess.exists(tmpPath)) + { + ResultPath = ReadPaths[i]; + bexists = true; + break; + } + } + } + ResultPath = deleteLastSlashfromUrl(ResultPath); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + ResultPath = PropertyNames.EMPTY_STRING; + } + if (!bexists) + { + throw new NoValidPathException(xMSF, PropertyNames.EMPTY_STRING); + } + return ResultPath; + } + + public static ArrayList<String> getOfficePaths(XMultiServiceFactory xMSF, String _sPath) + { + //This method currently only works with sPath="Template" + + ArrayList<String> aPathList = new ArrayList<String>(); + String Template_writable = PropertyNames.EMPTY_STRING; + String[] Template_internal; + String[] Template_user; + + try + { + XInterface xPathInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings"); + XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xPathInterface); + Template_writable = (String) xPropertySet.getPropertyValue(_sPath + "_writable"); + Template_internal = (String[]) xPropertySet.getPropertyValue(_sPath + "_internal"); + Template_user = (String[]) xPropertySet.getPropertyValue(_sPath + "_user"); + + for (int i = 0; i < Template_internal.length; i++) + { + String sPath = Template_internal[i]; + if (sPath.toLowerCase().startsWith("vnd.sun.star.expand:")) + { + String sPathToExpand = URLDecoder.decode(StringHelper.replace( + sPath.substring("vnd.sun.star.expand:".length()), + '+', "%2B"), "UTF-8"); + + XMacroExpander xExpander = Helper.getMacroExpander(xMSF); + sPath = xExpander.expandMacros(sPathToExpand); + } + + // if there exists a language in the directory, we try to add the right language + sPath = checkIfLanguagePathExists(xMSF, sPath); + + aPathList.add(sPath); + } + aPathList.addAll(Arrays.asList(Template_user)); + aPathList.add(Template_writable); + // There was a bug here, because we have to search through the whole list of paths + } + catch (java.lang.Exception exception) + { + exception.printStackTrace(System.err); + } + return aPathList; + } + + private static String checkIfLanguagePathExists(XMultiServiceFactory _xMSF, String _sPath) + { + try + { + Object defaults = _xMSF.createInstance("com.sun.star.text.Defaults"); + Locale aLocale = (Locale) Helper.getUnoStructValue(defaults, "CharLocale"); + if (aLocale == null) + { + aLocale = new com.sun.star.lang.Locale(); + aLocale.Country = java.util.Locale.getDefault().getCountry(); + aLocale.Language = java.util.Locale.getDefault().getLanguage(); + aLocale.Variant = java.util.Locale.getDefault().getVariant(); + } + + String sLanguage = aLocale.Language; + String sCountry = aLocale.Country; + String sVariant = aLocale.Variant; + + // de-DE-Bayrisch + StringBuffer aLocaleAll = new StringBuffer(); + aLocaleAll.append(sLanguage).append('-').append(sCountry).append('-').append(sVariant); + String sPath = _sPath + "/" + aLocaleAll.toString(); + + XInterface xInterface = (XInterface) _xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + // de-DE + StringBuffer aLocaleLang_Country = new StringBuffer(); + aLocaleLang_Country.append(sLanguage).append('-').append(sCountry); + sPath = _sPath + "/" + aLocaleLang_Country.toString(); + + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + // de + StringBuffer aLocaleLang = new StringBuffer(); + aLocaleLang.append(sLanguage); + sPath = _sPath + "/" + aLocaleLang.toString(); + + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + // the absolute default is en-US or en + sPath = _sPath + "/en-US"; + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + sPath = _sPath + "/en"; + if (xSimpleFileAccess.exists(sPath)) + { + return sPath; + } + + } + catch (com.sun.star.uno.Exception e) + { + } + + return _sPath; + } + + public static void combinePaths(XMultiServiceFactory xMSF, ArrayList<String> _aFirstPath, String _sSecondPath) + { + for (int i = 0; i < _aFirstPath.size(); ++i) + { + String sOnePath = _aFirstPath.get(i); + sOnePath = addPath(sOnePath, _sSecondPath); + if (isPathValid(xMSF, sOnePath)) + { + _aFirstPath.add(i, sOnePath); + _aFirstPath.remove(i + 1); + } + else + { + _aFirstPath.remove(i); + --i; + } + } + } + + public static boolean isPathValid(XMultiServiceFactory xMSF, String _sPath) + { + boolean bExists = false; + try + { + XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface); + bExists = xSimpleFileAccess.exists(_sPath); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + return bExists; + } + + public static String combinePaths(XMultiServiceFactory xMSF, String _sFirstPath, String _sSecondPath) throws NoValidPathException + { + boolean bexists = false; + String ReturnPath = PropertyNames.EMPTY_STRING; + try + { + XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface); + ReturnPath = _sFirstPath + _sSecondPath; + bexists = xSimpleFileAccess.exists(ReturnPath); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return PropertyNames.EMPTY_STRING; + } + if (!bexists) + { + throw new NoValidPathException(xMSF, PropertyNames.EMPTY_STRING); + } + return ReturnPath; + } + + /** + * We search in all given path for a given file + */ + private static String addPath(String _sPath, String _sPath2) + { + String sNewPath; + if (!_sPath.endsWith("/")) + { + _sPath += "/"; + } + if (_sPath2.startsWith("/")) + { + _sPath2 = _sPath2.substring(1); + } + sNewPath = _sPath + _sPath2; + return sNewPath; + } + + public static String getPathFromList(XMultiServiceFactory xMSF, ArrayList<String> _aList, String _sFile) + { + String sFoundFile = PropertyNames.EMPTY_STRING; + try + { + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + + for (int i = 0; i < _aList.size(); i++) + { + String sPath = _aList.get(i); + sPath = addPath(sPath, _sFile); + if (xSimpleFileAccess.exists(sPath)) + { + sFoundFile = sPath; + } + } + } + catch (com.sun.star.uno.Exception e) + { + } + return sFoundFile; + } + + public static String[][] getFolderTitles(com.sun.star.lang.XMultiServiceFactory xMSF, String _sStartFilterName, ArrayList<String> FolderNames) + throws NoValidPathException + { + return getFolderTitles(xMSF, _sStartFilterName, FolderNames, PropertyNames.EMPTY_STRING); + } + + private static String getTitle(XMultiServiceFactory xMSF, String _sFile) + { + String sTitle = PropertyNames.EMPTY_STRING; + try + { + XInterface xDocInterface = (XInterface) xMSF.createInstance("com.sun.star.document.DocumentProperties"); + XDocumentProperties xDocProps = UnoRuntime.queryInterface(XDocumentProperties.class, xDocInterface); + PropertyValue[] noArgs = { }; + xDocProps.loadFromMedium(_sFile, noArgs); + sTitle = xDocProps.getTitle(); + } + catch (Exception e) + { + } + return sTitle; + } + + public static String[][] getFolderTitles(com.sun.star.lang.XMultiServiceFactory xMSF, String _sStartFilterName, ArrayList<String> FolderName, String _sEndFilterName) + throws NoValidPathException + { + String[][] LocLayoutFiles = new String[2][]; + if (FolderName.isEmpty()) + { + throw new NoValidPathException(null, "Path not given."); + } + ArrayList<String> TitleVector = new ArrayList<String>(); + ArrayList<String> URLVector = new ArrayList<String>(); + + com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = null; + try + { + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + xSimpleFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + } + catch (com.sun.star.uno.Exception e) + { + throw new NoValidPathException(null, "Internal error.", e); + } + + for (int j = 0; j < FolderName.size(); j++) + { + String sFolderName = FolderName.get(j); + + try + { + String[] nameList = xSimpleFileAccess.getFolderContents(sFolderName, false); + _sStartFilterName = _sStartFilterName == null || _sStartFilterName.equals(PropertyNames.EMPTY_STRING) ? null : _sStartFilterName + "-"; + + String fileName = PropertyNames.EMPTY_STRING; + for (int i = 0; i < nameList.length; i++) + { + fileName = getFilename(nameList[i]); + String sTitle; + + if (_sStartFilterName == null || fileName.startsWith(_sStartFilterName)) + { + if (_sEndFilterName.equals(PropertyNames.EMPTY_STRING)) + { + sTitle = getTitle(xMSF, nameList[i]); + } + else if (fileName.endsWith(_sEndFilterName)) + { + fileName = fileName.replaceAll(_sEndFilterName + "$", PropertyNames.EMPTY_STRING); + sTitle = fileName; + } + else + { + // no or wrong (start|end) filter + continue; + } + URLVector.add(nameList[i]); + TitleVector.add(sTitle); + } + } + } + catch (com.sun.star.ucb.CommandAbortedException exception) + { + exception.printStackTrace(System.err); + } + catch (com.sun.star.uno.Exception e) + { + } + } + + String[] LocNameList = new String[URLVector.size()]; + String[] LocTitleList = new String[TitleVector.size()]; + + // LLA: we have to check if this works + URLVector.toArray(LocNameList); + TitleVector.toArray(LocTitleList); + + LocLayoutFiles[1] = LocNameList; + LocLayoutFiles[0] = LocTitleList; + + JavaTools.bubblesortList(LocLayoutFiles); + + return LocLayoutFiles; + } + private XSimpleFileAccess2 fileAccess; + + public FileAccess(XMultiServiceFactory xmsf) throws com.sun.star.uno.Exception + { + //get a simple file access... + Object fa = xmsf.createInstance("com.sun.star.ucb.SimpleFileAccess"); + fileAccess = UnoRuntime.queryInterface(XSimpleFileAccess2.class, fa); + //get the file identifier converter + Object fcv = xmsf.createInstance("com.sun.star.ucb.FileContentProvider"); + UnoRuntime.queryInterface(XFileIdentifierConverter.class, fcv); + } + + /** + * @return the extension of the given filename. + */ + private static String getExtension(String filename) + { + int p = filename.indexOf('.'); + if (p == -1) + { + return PropertyNames.EMPTY_STRING; + } + else + { + do + { + filename = filename.substring(p + 1); + } + while ((p = filename.indexOf('.')) > -1); + } + return filename; + } + + /** + * @param def what to return in case of an exception + * @return true if the given file exists or not. + * if an exception occurs, returns the default value. + */ + public boolean exists(String filename, boolean def) + { + try + { + return fileAccess.exists(filename); + } + catch (CommandAbortedException e) + { + } + catch (Exception e) + { + } + + return def; + } + + public static String getFilename(String path) + { + return getFilename(path, "/"); + } + + private static String getFilename(String path, String pathSeparator) + { + String[] s = JavaTools.ArrayoutofString(path, pathSeparator); + return s[s.length - 1]; + } + + public static String getBasename(String path, String pathSeparator) + { + String filename = getFilename(path, pathSeparator); + String sExtension = getExtension(filename); + return filename.substring(0, filename.length() - (sExtension.length() + 1)); + } + + public static String[] getDataFromTextFile(XMultiServiceFactory _xMSF, String _filepath) + { + String[] sFileData = null; + try + { + Vector<String> oDataVector = new Vector<String>(); + Object oSimpleFileAccess = _xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, oSimpleFileAccess); + if (xSimpleFileAccess.exists(_filepath)) + { + XInputStream xInputStream = xSimpleFileAccess.openFileRead(_filepath); + Object oTextInputStream = _xMSF.createInstance("com.sun.star.io.TextInputStream"); + XTextInputStream xTextInputStream = UnoRuntime.queryInterface(XTextInputStream.class, oTextInputStream); + XActiveDataSink xActiveDataSink = UnoRuntime.queryInterface(XActiveDataSink.class, oTextInputStream); + xActiveDataSink.setInputStream(xInputStream); + while (!xTextInputStream.isEOF()) + { + oDataVector.addElement( xTextInputStream.readLine()); + } + xTextInputStream.closeInput(); + sFileData = new String[oDataVector.size()]; + oDataVector.toArray(sFileData); + + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return sFileData; + } + +} diff --git a/wizards/com/sun/star/wizards/common/FileAccess.py b/wizards/com/sun/star/wizards/common/FileAccess.py new file mode 100644 index 0000000000..c58f6d4b42 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/FileAccess.py @@ -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)) diff --git a/wizards/com/sun/star/wizards/common/HelpIds.java b/wizards/com/sun/star/wizards/common/HelpIds.java new file mode 100644 index 0000000000..2c1ae4fc7d --- /dev/null +++ b/wizards/com/sun/star/wizards/common/HelpIds.java @@ -0,0 +1,1040 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +public class HelpIds +{ + private static String array1[] = new String[] + { + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID0_HELP", // HID:34201 + "HID:WIZARDS_HID0_NEXT", // HID:34202 + "HID:WIZARDS_HID0_PREV", // HID:34203 + "HID:WIZARDS_HID0_CREATE", // HID:34204 + "HID:WIZARDS_HID0_CANCEL", // HID:34205 + "HID:WIZARDS_HID0_STATUS_DIALOG", // HID:34206 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID2_BTN_DOC_UP", // HID:34213 + "HID:WIZARDS_HID2_BTN_DOC_DOWN", // HID:34214 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID2_STATUS_ADD_DOCS", // HID:34219 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG10", // HID:34229 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG11", // HID:34230 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG12", // HID:34231 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG13", // HID:34232 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG14", // HID:34233 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG15", // HID:34234 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_BG_BTN_OK", // HID:34293 + "HID:WIZARDS_HID_BG_BTN_CANCEL", // HID:34294 + "HID:WIZARDS_HID_BG_BTN_BACK", // HID:34295 + "HID:WIZARDS_HID_BG_BTN_FW", // HID:34296 + "HID:WIZARDS_HID_BG_BTN_IMG1", // HID:34297 + "HID:WIZARDS_HID_BG_BTN_IMG2", // HID:34298 + "HID:WIZARDS_HID_BG_BTN_IMG3", // HID:34299 + "HID:WIZARDS_HID_BG_BTN_IMG4", // HID:34300 + "HID:WIZARDS_HID_BG_BTN_IMG5", // HID:34301 + "HID:WIZARDS_HID_BG_BTN_IMG6", // HID:34302 + "HID:WIZARDS_HID_BG_BTN_IMG7", // HID:34303 + "HID:WIZARDS_HID_BG_BTN_IMG8", // HID:34304 + "HID:WIZARDS_HID_BG_BTN_IMG9", // HID:34305 + "HID:WIZARDS_HID_BG_BTN_IMG10", // HID:34306 + "HID:WIZARDS_HID_BG_BTN_IMG11", // HID:34307 + "HID:WIZARDS_HID_BG_BTN_IMG12", // HID:34308 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGREPORT_DIALOG", // HID:34320 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGREPORT_0_CMDPREV", // HID:34322 + "HID:WIZARDS_HID_DLGREPORT_0_CMDNEXT", // HID:34323 + "HID:WIZARDS_HID_DLGREPORT_0_CMDFINISH", // HID:34324 + "HID:WIZARDS_HID_DLGREPORT_0_CMDCANCEL", // HID:34325 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGREPORT_1_LBTABLES", // HID:34330 + "HID:WIZARDS_HID_DLGREPORT_1_FIELDSAVAILABLE", // HID:34331 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVESELECTED", // HID:34332 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEALL", // HID:34333 + "HID:WIZARDS_HID_DLGREPORT_1_CMDREMOVESELECTED", // HID:34334 + "HID:WIZARDS_HID_DLGREPORT_1_CMDREMOVEALL", // HID:34335 + "HID:WIZARDS_HID_DLGREPORT_1_FIELDSSELECTED", // HID:34336 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEUP", // HID:34337 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEDOWN", // HID:34338 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGREPORT_2_GROUPING", // HID:34340 + "HID:WIZARDS_HID_DLGREPORT_2_CMDGROUP", // HID:34341 + PropertyNames.EMPTY_STRING, // HID:34342 empty, no moveall button + "HID:WIZARDS_HID_DLGREPORT_2_CMDUNGROUP", // HID:34343 + PropertyNames.EMPTY_STRING, // HID:34344 empty, no removeall button + "HID:WIZARDS_HID_DLGREPORT_2_PREGROUPINGDEST", // HID:34345 + "HID:WIZARDS_HID_DLGREPORT_2_CMDMOVEUPGROUP", // HID:34346 + "HID:WIZARDS_HID_DLGREPORT_2_CMDMOVEDOWNGROUP", // HID:34347 + "HID:WIZARDS_HID_DLGREPORT_3_SORT1", // HID:34348 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND1", // HID:34349 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND1", // HID:34350 + "HID:WIZARDS_HID_DLGREPORT_3_SORT2", // HID:34351 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND2", // HID:34352 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND2", // HID:34353 + "HID:WIZARDS_HID_DLGREPORT_3_SORT3", // HID:34354 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND3", // HID:34355 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND3", // HID:34356 + "HID:WIZARDS_HID_DLGREPORT_3_SORT4", // HID:34357 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND4", // HID:34358 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND4", // HID:34359 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGREPORT_4_TITLE", // HID:34362 + "HID:WIZARDS_HID_DLGREPORT_4_DATALAYOUT", // HID:34363 + "HID:WIZARDS_HID_DLGREPORT_4_PAGELAYOUT", // HID:34364 + "HID:WIZARDS_HID_DLGREPORT_4_LANDSCAPE", // HID:34365 + "HID:WIZARDS_HID_DLGREPORT_4_PORTRAIT", // HID:34366 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGREPORT_5_OPTDYNTEMPLATE", // HID:34370 + "HID:WIZARDS_HID_DLGREPORT_5_OPTSTATDOCUMENT", // HID:34371 + "HID:WIZARDS_HID_DLGREPORT_5_TXTTEMPLATEPATH", // HID:34372 + "HID:WIZARDS_HID_DLGREPORT_5_CMDTEMPLATEPATH", // HID:34373 + "HID:WIZARDS_HID_DLGREPORT_5_OPTEDITTEMPLATE", // HID:34374 + "HID:WIZARDS_HID_DLGREPORT_5_OPTUSETEMPLATE", // HID:34375 + "HID:WIZARDS_HID_DLGREPORT_5_TXTDOCUMENTPATH", // HID:34376 + "HID:WIZARDS_HID_DLGREPORT_5_CMDDOCUMENTPATH", // HID:34377 + "HID:WIZARDS_HID_DLGREPORT_5_CHKLINKTODB", // HID:34378 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_1", // HID:34381 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_2", // HID:34382 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_3", // HID:34383 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_4", // HID:34384 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_5", // HID:34385 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_6", // HID:34386 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_7", // HID:34387 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_DIALOG", // HID:34400 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_CMDPREV", // HID:34402 + "HID:WIZARDS_HID_DLGFORM_CMDNEXT", // HID:34403 + "HID:WIZARDS_HID_DLGFORM_CMDFINISH", // HID:34404 + "HID:WIZARDS_HID_DLGFORM_CMDCANCEL", // HID:34405 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_MASTER_LBTABLES", // HID:34411 + "HID:WIZARDS_HID_DLGFORM_MASTER_FIELDSAVAILABLE", // HID:34412 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVESELECTED", // HID:34413 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEALL", // HID:34414 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDREMOVESELECTED", // HID:34415 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDREMOVEALL", // HID:34416 + "HID:WIZARDS_HID_DLGFORM_MASTER_FIELDSSELECTED", // HID:34417 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEUP", // HID:34418 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEDOWN", // HID:34419 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_CHKCREATESUBFORM", // HID:34421 + "HID:WIZARDS_HID_DLGFORM_OPTONEXISTINGRELATION", // HID:34422 + "HID:WIZARDS_HID_DLGFORM_OPTSELECTMANUALLY", // HID:34423 + "HID:WIZARDS_HID_DLGFORM_lstRELATIONS", // HID:34424 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_SUB_LBTABLES", // HID:34431 + "HID:WIZARDS_HID_DLGFORM_SUB_FIELDSAVAILABLE", // HID:34432 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVESELECTED", // HID:34433 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEALL", // HID:34434 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDREMOVESELECTED", // HID:34435 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDREMOVEALL", // HID:34436 + "HID:WIZARDS_HID_DLGFORM_SUB_FIELDSSELECTED", // HID:34437 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEUP", // HID:34438 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEDOWN", // HID:34439 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK1", // HID:34441 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK1", // HID:34442 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK2", // HID:34443 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK2", // HID:34444 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK3", // HID:34445 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK3", // HID:34446 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK4", // HID:34447 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK4", // HID:34448 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_CMDALIGNLEFT", // HID:34451 + "HID:WIZARDS_HID_DLGFORM_CMDALIGNRIGHT", // HID:34452 + "HID:WIZARDS_HID_DLGFORM_CMDLEFTLABELED", // HID:34453 + "HID:WIZARDS_HID_DLGFORM_CMDTOPLABELED", // HID:34454 + "HID:WIZARDS_HID_DLGFORM_CMDTABLESTYLE", // HID:34455 + "HID:WIZARDS_HID_DLGFORM_CMDTOPJUSTIFIED", // HID:34456 + "HID:WIZARDS_HID_DLGFORM_CMDLEFTLABELED2", // HID:34457 + "HID:WIZARDS_HID_DLGFORM_CMDTOPLABELED2", // HID:34458 + "HID:WIZARDS_HID_DLGFORM_CMDTABLESTYLE2", // HID:34459 + "HID:WIZARDS_HID_DLGFORM_CMDTOPJUSTIFIED2", // HID:34460 + "HID:WIZARDS_HID_DLGFORM_OPTNEWDATAONLY", // HID:34461 + "HID:WIZARDS_HID_DLGFORM_OPTDISPLAYALLDATA", // HID:34462 + "HID:WIZARDS_HID_DLGFORM_CHKNOMODIFICATION", // HID:34463 + "HID:WIZARDS_HID_DLGFORM_CHKNODELETION", // HID:34464 + "HID:WIZARDS_HID_DLGFORM_CHKNOADDITION", // HID:34465 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_LSTSTYLES", // HID:34471 + "HID:WIZARDS_HID_DLGFORM_CMDNOBORDER", // HID:34472 + "HID:WIZARDS_HID_DLGFORM_CMD3DBORDER", // HID:34473 + "HID:WIZARDS_HID_DLGFORM_CMDSIMPLEBORDER", // HID:34474 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGFORM_TXTPATH", // HID:34481 + "HID:WIZARDS_HID_DLGFORM_OPTWORKWITHFORM", // HID:34482 + "HID:WIZARDS_HID_DLGFORM_OPTMODIFYFORM", // HID:34483 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGNEWSLTR_DIALOG", // HID:34500 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTSTANDARDLAYOUT", // HID:34501 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTPARTYLAYOUT", // HID:34502 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTBROCHURELAYOUT", // HID:34503 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTSINGLESIDED", // HID:34504 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTDOUBLESIDED", // HID:34505 + "HID:WIZARDS_HID_DLGNEWSLTR_CMDGOON", // HID:34506 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_SELLBUY", // HID:34520 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTSTOCKID_SELLBUY", // HID:34521 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTQUANTITY", // HID:34522 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTRATE", // HID:34523 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTDATE", // HID:34524 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTCOMMISSION", // HID:34525 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTFIX", // HID:34526 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTMINIMUM", // HID:34527 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_SELLBUY", // HID:34528 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_SELLBUY", // HID:34529 + "HID:WIZARDS_HID_DLGDEPOT_1_LSTSELLSTOCKS", // HID:34530 + "HID:WIZARDS_HID_DLGDEPOT_2_LSTBUYSTOCKS", // HID:34531 + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_SPLIT", // HID:34532 + "HID:WIZARDS_HID_DLGDEPOT_0_LSTSTOCKNAMES", // HID:34533 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTSTOCKID_SPLIT", // HID:34534 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_SPLIT", // HID:34535 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_SPLIT", // HID:34536 + "HID:WIZARDS_HID_DLGDEPOT_1_OPTPERSHARE", // HID:34537 + "HID:WIZARDS_HID_DLGDEPOT_1_OPTTOTAL", // HID:34538 + "HID:WIZARDS_HID_DLGDEPOT_1_TXTDIVIDEND", // HID:34539 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTOLDRATE", // HID:34540 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTNEWRATE", // HID:34541 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTDATE", // HID:34542 + "HID:WIZARDS_HID_DLGDEPOT_3_TXTSTARTDATE", // HID:34543 + "HID:WIZARDS_HID_DLGDEPOT_3_TXTENDDATE", // HID:34544 + "HID:WIZARDS_HID_DLGDEPOT_3_OPTDAILY", // HID:34545 + "HID:WIZARDS_HID_DLGDEPOT_3_OPTWEEKLY", // HID:34546 + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_HISTORY", // HID:34547 + "HID:WIZARDS_HID_DLGDEPOT_LSTMARKETS", // HID:34548 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_HISTORY", // HID:34549 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_HISTORY", // HID:34550 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGIMPORT_DIALOG", // HID:34570 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDHELP", // HID:34571 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDCANCEL", // HID:34572 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDPREV", // HID:34573 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDNEXT", // HID:34574 + "HID:WIZARDS_HID_DLGIMPORT_0_OPTSODOCUMENTS", // HID:34575 + "HID:WIZARDS_HID_DLGIMPORT_0_OPTMSDOCUMENTS", // HID:34576 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKLOGFILE", // HID:34577 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKWORD", // HID:34578 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKEXCEL", // HID:34579 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKPOWERPOINT", // HID:34580 + "HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATE", // HID:34581 + "HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATERECURSE", // HID:34582 + "HID:WIZARDS_HID_DLGIMPORT_2_LBTEMPLATEPATH", // HID:34583 + "HID:WIZARDS_HID_DLGIMPORT_2_EDTEMPLATEPATH", // HID:34584 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT", // HID:34585 + "HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENT", // HID:34586 + "HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENTRECURSE", // HID:34587 + "HID:WIZARDS_HID_DLGIMPORT_2_LBDOCUMENTPATH", // HID:34588 + "HID:WIZARDS_HID_DLGIMPORT_2_EDDOCUMENTPATH", // HID:34589 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT", // HID:34590 + "HID:WIZARDS_HID_DLGIMPORT_2_LBEXPORTDOCUMENTPATH", // HID:34591 + "HID:WIZARDS_HID_DLGIMPORT_2_EDEXPORTDOCUMENTPATH", // HID:34592 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDEXPORTPATHSELECT", // HID:34593 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGIMPORT_3_TBSUMMARY", // HID:34595 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKWRITER", // HID:34596 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKCALC", // HID:34597 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKIMPRESS", // HID:34598 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKMATHGLOBAL", // HID:34599 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT2", // HID:34600 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT2", // HID:34601 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGCORRESPONDENCE_DIALOG", // HID:34630 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_CANCEL", // HID:34631 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA1", // HID:34632 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA2", // HID:34633 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_AGENDAOKAY", // HID:34634 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER1", // HID:34635 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER2", // HID:34636 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_LETTEROKAY", // HID:34637 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGSTYLES_DIALOG", // HID:34650 + "HID:WIZARDS_HID_DLGSTYLES_LISTBOX", // HID:34651 + "HID:WIZARDS_HID_DLGSTYLES_CANCEL", // HID:34652 + "HID:WIZARDS_HID_DLGSTYLES_OKAY", // HID:34653 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGCONVERT_DIALOG", // HID:34660 + "HID:WIZARDS_HID_DLGCONVERT_CHECKBOX1", // HID:34661 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON1", // HID:34662 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON2", // HID:34663 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON3", // HID:34664 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON4", // HID:34665 + "HID:WIZARDS_HID_DLGCONVERT_LISTBOX1", // HID:34666 + "HID:WIZARDS_HID_DLGCONVERT_OBFILE", // HID:34667 + "HID:WIZARDS_HID_DLGCONVERT_OBDIR", // HID:34668 + "HID:WIZARDS_HID_DLGCONVERT_COMBOBOX1", // HID:34669 + "HID:WIZARDS_HID_DLGCONVERT_TBSOURCE", // HID:34670 + "HID:WIZARDS_HID_DLGCONVERT_CHECKRECURSIVE", // HID:34671 + "HID:WIZARDS_HID_DLGCONVERT_TBTARGET", // HID:34672 + "HID:WIZARDS_HID_DLGCONVERT_CBCANCEL", // HID:34673 + "HID:WIZARDS_HID_DLGCONVERT_CBHELP", // HID:34674 + "HID:WIZARDS_HID_DLGCONVERT_CBBACK", // HID:34675 + "HID:WIZARDS_HID_DLGCONVERT_CBGOON", // HID:34676 + "HID:WIZARDS_HID_DLGCONVERT_CBSOURCEOPEN", // HID:34677 + "HID:WIZARDS_HID_DLGCONVERT_CBTARGETOPEN", // HID:34678 + "HID:WIZARDS_HID_DLGCONVERT_CHKPROTECT", // HID:34679 + "HID:WIZARDS_HID_DLGCONVERT_CHKTEXTDOCUMENTS", // HID:34680 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGPASSWORD_CMDGOON", // HID:34690 + "HID:WIZARDS_HID_DLGPASSWORD_CMDCANCEL", // HID:34691 + "HID:WIZARDS_HID_DLGPASSWORD_CMDHELP", // HID:34692 + "HID:WIZARDS_HID_DLGPASSWORD_TXTPASSWORD", // HID:34693 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGHOLIDAYCAL_DIALOG", // HID:34700 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_PREVIEW", // HID:34701 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_OPYEAR", // HID:34702 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_OPMONTH", // HID:34703 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_EDYEAR", // HID:34704 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_EDMONTH", // HID:34705 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_SPINYEAR", // HID:34706 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_SPINMONTH", // HID:34707 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_CMBSTATE", // HID:34708 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_LBOWNDATA", // HID:34709 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CMDINSERT", // HID:34710 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CMDDELETE", // HID:34711 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENT", // HID:34712 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CHKEVENT", // HID:34713 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTDAY", // HID:34714 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTDAY", // HID:34715 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTMONTH", // HID:34716 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTMONTH", // HID:34717 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTYEAR", // HID:34718 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTYEAR", // HID:34719 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDOWNDATA", // HID:34720 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDCANCEL", // HID:34721 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDOK" // HID:34722 + }; + private static String array2[] = new String[] + { + "HID:WIZARDS_HID_LTRWIZ_OPTBUSINESSLETTER", // HID:40769 + "HID:WIZARDS_HID_LTRWIZ_OPTPRIVOFFICIALLETTER", // HID:40770 + "HID:WIZARDS_HID_LTRWIZ_OPTPRIVATELETTER", // HID:40771 + "HID:WIZARDS_HID_LTRWIZ_LSTBUSINESSSTYLE", // HID:40772 + "HID:WIZARDS_HID_LTRWIZ_CHKBUSINESSPAPER", // HID:40773 + "HID:WIZARDS_HID_LTRWIZ_LSTPRIVOFFICIALSTYLE", // HID:40774 + "HID:WIZARDS_HID_LTRWIZ_LSTPRIVATESTYLE", // HID:40775 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERCOMPANYLOGO", // HID:40776 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOHEIGHT", // HID:40777 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOX", // HID:40778 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOWIDTH", // HID:40779 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOY", // HID:40780 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERCOMPANYADDRESS", // HID:40781 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSHEIGHT", // HID:40782 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSX", // HID:40783 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSWIDTH", // HID:40784 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSY", // HID:40785 + "HID:WIZARDS_HID_LTRWIZ_CHKCOMPANYRECEIVER", // HID:40786 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERFOOTER", // HID:40787 + "HID:WIZARDS_HID_LTRWIZ_NUMFOOTERHEIGHT", // HID:40788 + "HID:WIZARDS_HID_LTRWIZ_LSTLETTERNORM", // HID:40789 + "HID:WIZARDS_HID_LTRWIZ_CHKUSELOGO", // HID:40790 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEADDRESSRECEIVER", // HID:40791 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESIGNS", // HID:40792 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESUBJECT", // HID:40793 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESALUTATION", // HID:40794 + "HID:WIZARDS_HID_LTRWIZ_LSTSALUTATION", // HID:40795 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEBENDMARKS", // HID:40796 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEGREETING", // HID:40797 + "HID:WIZARDS_HID_LTRWIZ_LSTGREETING", // HID:40798 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEFOOTER", // HID:40799 + "HID:WIZARDS_HID_LTRWIZ_OPTSENDERPLACEHOLDER", // HID:40800 + "HID:WIZARDS_HID_LTRWIZ_OPTSENDERDEFINE", // HID:40801 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERNAME", // HID:40802 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERSTREET", // HID:40803 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERPOSTCODE", // HID:40804 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERSTATE_TEXT", // HID:40805 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERCITY", // HID:40806 + "HID:WIZARDS_HID_LTRWIZ_OPTRECEIVERPLACEHOLDER", // HID:40807 + "HID:WIZARDS_HID_LTRWIZ_OPTRECEIVERDATABASE", // HID:40808 + "HID:WIZARDS_HID_LTRWIZ_TXTFOOTER", // HID:40809 + "HID:WIZARDS_HID_LTRWIZ_CHKFOOTERNEXTPAGES", // HID:40810 + "HID:WIZARDS_HID_LTRWIZ_CHKFOOTERPAGENUMBERS", // HID:40811 + "HID:WIZARDS_HID_LTRWIZ_TXTTEMPLATENAME", // HID:40812 + "HID:WIZARDS_HID_LTRWIZ_OPTCREATELETTER", // HID:40813 + "HID:WIZARDS_HID_LTRWIZ_OPTMAKECHANGES", // HID:40814 + "HID:WIZARDS_HID_LTRWIZ_TXTPATH", // HID:40815 + "HID:WIZARDS_HID_LTRWIZ_CMDPATH", // HID:40816 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_LTRWIZARD", // HID:40820 + "HID:WIZARDS_HID_LTRWIZARD_HELP", // HID:40821 + "HID:WIZARDS_HID_LTRWIZARD_BACK", // HID:40822 + "HID:WIZARDS_HID_LTRWIZARD_NEXT", // HID:40823 + "HID:WIZARDS_HID_LTRWIZARD_CREATE", // HID:40824 + "HID:WIZARDS_HID_LTRWIZARD_CANCEL", // HID:40825 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD_LSTTABLES", // HID:40850 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDS", // HID:40851 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVESELECTED", // HID:40852 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEALL", // HID:40853 + "HID:WIZARDS_HID_QUERYWIZARD_CMDREMOVESELECTED", // HID:40854 + "HID:WIZARDS_HID_QUERYWIZARD_CMDREMOVEALL", // HID:40855 + "HID:WIZARDS_HID_QUERYWIZARD_LSTSELFIELDS", // HID:40856 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEUP", // HID:40857 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEDOWN", // HID:40858 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD_SORT1", // HID:40865 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND1", // HID:40866 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND1", // HID:40867 + "HID:WIZARDS_HID_QUERYWIZARD_SORT2", // HID:40868 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND2", // HID:40869 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND2", // HID:40870 + "HID:WIZARDS_HID_QUERYWIZARD_SORT3", // HID:40871 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND3", // HID:40872 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND3", // HID:40873 + "HID:WIZARDS_HID_QUERYWIZARD_SORT4", // HID:40874 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND4", // HID:40875 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND4", // HID:40876 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD_OPTMATCHALL", // HID:40878 + "HID:WIZARDS_HID_QUERYWIZARD_OPTMATCHANY", // HID:40879 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_1", // HID:40880 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_1", // HID:40881 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_1", // HID:40882 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_2", // HID:40883 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_2", // HID:40884 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_2", // HID:40885 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_3", // HID:40886 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_3", // HID:40887 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_3", // HID:40888 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD_OPTAGGREGATEDETAILQUERY", // HID:40895 + "HID:WIZARDS_HID_QUERYWIZARD_OPTAGGREGATESUMMARYQUERY", // HID:40896 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_1", // HID:40897 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_1", // HID:40898 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_2", // HID:40899 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_2", // HID:40900 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_3", // HID:40901 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_3", // HID:40902 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_4", // HID:40903 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_4", // HID:40904 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_5", // HID:40905 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_5", // HID:40906 + "HID:WIZARDS_HID_QUERYWIZARD_BTNAGGREGATEPLUS", // HID:40907 + "HID:WIZARDS_HID_QUERYWIZARD_BTNAGGREGATEMINUS", // HID:40908 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDS", // HID:40915 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVESELECTED", // HID:40916 + PropertyNames.EMPTY_STRING, // HID:40917 empty, no moveall button + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERREMOVESELECTED", // HID:40918 + PropertyNames.EMPTY_STRING, // HID:40919 empty no removeall button + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERSELFIELDS", // HID:40920 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVEUP", // HID:409121 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVEDOWN", // HID:40922 + "HID:WIZARDS_HID_QUERYWIZARD_OPTGROUPMATCHALL", // HID:40923 + "HID:WIZARDS_HID_QUERYWIZARD_OPTGROUPMATCHANY", // HID:40924 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_1", // HID:40925 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_1", // HID:40926 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_1", // HID:40927 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_2", // HID:40928 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_2", // HID:40929 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_2", // HID:40930 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_3", // HID:40931 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_3", // HID:40932 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_3", // HID:40933 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_1", // HID:40940 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_2", // HID:40941 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_3", // HID:40942 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_4", // HID:40943 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_5", // HID:40944 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_6", // HID:40945 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_7", // HID:40946 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD_TXTQUERYTITLE", // HID:40955 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDISPLAYQUERY", // HID:40956 + "HID:WIZARDS_HID_QUERYWIZARD_OPTMODIFYQUERY", // HID:40957 + "HID:WIZARDS_HID_QUERYWIZARD_TXTSUMMARY", // HID:40958 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD", // HID:40970 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_QUERYWIZARD_BACK", // HID:40972 + "HID:WIZARDS_HID_QUERYWIZARD_NEXT", // HID:40973 + "HID:WIZARDS_HID_QUERYWIZARD_CREATE", // HID:40974 + "HID:WIZARDS_HID_QUERYWIZARD_CANCEL", // HID:40975 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_IS_BTN_OK", // HID:41003 + "HID:WIZARDS_HID_IS_BTN_CANCEL", // HID:41004 + "HID:WIZARDS_HID_IS_BTN_IMG1", // HID:41005 + "HID:WIZARDS_HID_IS_BTN_IMG2", // HID:41006 + "HID:WIZARDS_HID_IS_BTN_IMG3", // HID:41007 + "HID:WIZARDS_HID_IS_BTN_IMG4", // HID:41008 + "HID:WIZARDS_HID_IS_BTN_IMG5", // HID:41009 + "HID:WIZARDS_HID_IS_BTN_IMG6", // HID:41010 + "HID:WIZARDS_HID_IS_BTN_IMG7", // HID:41011 + "HID:WIZARDS_HID_IS_BTN_IMG8", // HID:41012 + "HID:WIZARDS_HID_IS_BTN_IMG9", // HID:41013 + "HID:WIZARDS_HID_IS_BTN_IMG10", // HID:41014 + "HID:WIZARDS_HID_IS_BTN_IMG11", // HID:41015 + "HID:WIZARDS_HID_IS_BTN_IMG12", // HID:41016 + "HID:WIZARDS_HID_IS_BTN_IMG13", // HID:41017 + "HID:WIZARDS_HID_IS_BTN_IMG14", // HID:41018 + "HID:WIZARDS_HID_IS_BTN_IMG15", // HID:41019 + "HID:WIZARDS_HID_IS_BTN_IMG16", // HID:41020 + "HID:WIZARDS_HID_IS_BTN_IMG17", // HID:41021 + "HID:WIZARDS_HID_IS_BTN_IMG18", // HID:41022 + "HID:WIZARDS_HID_IS_BTN_IMG19", // HID:41023 + "HID:WIZARDS_HID_IS_BTN_IMG20", // HID:41024 + "HID:WIZARDS_HID_IS_BTN_IMG21", // HID:41025 + "HID:WIZARDS_HID_IS_BTN_IMG22", // HID:41026 + "HID:WIZARDS_HID_IS_BTN_IMG23", // HID:41027 + "HID:WIZARDS_HID_IS_BTN_IMG24", // HID:41028 + "HID:WIZARDS_HID_IS_BTN_IMG25", // HID:41029 + "HID:WIZARDS_HID_IS_BTN_IMG26", // HID:41030 + "HID:WIZARDS_HID_IS_BTN_IMG27", // HID:41031 + "HID:WIZARDS_HID_IS_BTN_IMG28", // HID:41032 + "HID:WIZARDS_HID_IS_BTN_IMG29", // HID:41033 + "HID:WIZARDS_HID_IS_BTN_IMG30", // HID:41034 + "HID:WIZARDS_HID_IS_BTN_IMG31", // HID:41035 + "HID:WIZARDS_HID_IS_BTN_IMG32", // HID:41036 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_FTP_OK", // HID:41047 + "HID:WIZARDS_HID_FTP_CANCEL", // HID:41048 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_AGWIZ", // HID:41051 + "HID:WIZARDS_HID_AGWIZ_HELP", // HID:41052 + "HID:WIZARDS_HID_AGWIZ_NEXT", // HID:41053 + "HID:WIZARDS_HID_AGWIZ_PREV", // HID:41054 + "HID:WIZARDS_HID_AGWIZ_CREATE", // HID:41055 + "HID:WIZARDS_HID_AGWIZ_CANCEL", // HID:41056 + "HID:WIZARDS_HID_AGWIZ_1_LIST_PAGEDESIGN", // HID:41057 + "HID:WIZARDS_HID_AGWIZ_1_CHK_MINUTES", // HID:41058 + "HID:WIZARDS_HID_AGWIZ_2_TXT_TIME", // HID:41059 + "HID:WIZARDS_HID_AGWIZ_2_TXT_DATE", // HID:41060 + "HID:WIZARDS_HID_AGWIZ_2_TXT_TITLE", // HID:41061 + "HID:WIZARDS_HID_AGWIZ_2_TXT_LOCATION", // HID:41062 + "HID:WIZARDS_HID_AGWIZ_3_CHK_MEETING_TYPE", // HID:41063 + "HID:WIZARDS_HID_AGWIZ_3_CHK_READ", // HID:41064 + "HID:WIZARDS_HID_AGWIZ_3_CHK_BRING", // HID:41065 + "HID:WIZARDS_HID_AGWIZ_3_CHK_NOTES", // HID:41066 + "HID:WIZARDS_HID_AGWIZ_4_CHK_CALLED_BY", // HID:41067 + "HID:WIZARDS_HID_AGWIZ_4_CHK_FACILITATOR", // HID:41068 + "HID:WIZARDS_HID_AGWIZ_4_CHK_NOTETAKER", // HID:41069 + "HID:WIZARDS_HID_AGWIZ_4_CHK_TIMEKEEPER", // HID:41070 + "HID:WIZARDS_HID_AGWIZ_4_CHK_ATTENDEES", // HID:41071 + "HID:WIZARDS_HID_AGWIZ_4_CHK_OBSERVERS", // HID:41072 + "HID:WIZARDS_HID_AGWIZ_4_CHK_RESOURCEPERSONS", // HID:41073 + "HID:WIZARDS_HID_AGWIZ_6_TXT_TEMPLATENAME", // HID:41074 + "HID:WIZARDS_HID_AGWIZ_6_TXT_TEMPLATEPATH", // HID:41075 + "HID:WIZARDS_HID_AGWIZ_6_BTN_TEMPLATEPATH", // HID:41076 + "HID:WIZARDS_HID_AGWIZ_6_OPT_CREATEAGENDA", // HID:41077 + "HID:WIZARDS_HID_AGWIZ_6_OPT_MAKECHANGES", // HID:41078 + "HID:WIZARDS_HID_AGWIZ_5_BTN_INSERT", // HID:41079 + "HID:WIZARDS_HID_AGWIZ_5_BTN_REMOVE", // HID:41080 + "HID:WIZARDS_HID_AGWIZ_5_BTN_UP", // HID:41081 + "HID:WIZARDS_HID_AGWIZ_5_BTN_DOWN", // HID:41082 + "HID:WIZARDS_HID_AGWIZ_5_SCROLL_BAR", // HID:41083 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_1", // HID:41084 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_1", // HID:41085 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_1", // HID:41086 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_2", // HID:41087 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_2", // HID:41088 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_2", // HID:41089 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_3", // HID:41090 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_3", // HID:41091 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_3", // HID:41092 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_4", // HID:41093 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_4", // HID:41094 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_4", // HID:41095 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_5", // HID:41096 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_5", // HID:41097 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_5", // HID:41098 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_FAXWIZ_OPTBUSINESSFAX", // HID:41120 + "HID:WIZARDS_HID_FAXWIZ_LSTBUSINESSSTYLE", // HID:41121 + "HID:WIZARDS_HID_FAXWIZ_OPTPRIVATEFAX", // HID:41122 + "HID:WIZARDS_HID_LSTPRIVATESTYLE", // HID:41123 + "HID:WIZARDS_HID_IMAGECONTROL3", // HID:41124 + "HID:WIZARDS_HID_CHKUSELOGO", // HID:41125 + "HID:WIZARDS_HID_CHKUSEDATE", // HID:41126 + "HID:WIZARDS_HID_CHKUSECOMMUNICATIONTYPE", // HID:41127 + "HID:WIZARDS_HID_LSTCOMMUNICATIONTYPE", // HID:41128 + "HID:WIZARDS_HID_CHKUSESUBJECT", // HID:41129 + "HID:WIZARDS_HID_CHKUSESALUTATION", // HID:41130 + "HID:WIZARDS_HID_LSTSALUTATION", // HID:41131 + "HID:WIZARDS_HID_CHKUSEGREETING", // HID:41132 + "HID:WIZARDS_HID_LSTGREETING", // HID:41133 + "HID:WIZARDS_HID_CHKUSEFOOTER", // HID:41134 + "HID:WIZARDS_HID_OPTSENDERPLACEHOLDER", // HID:41135 + "HID:WIZARDS_HID_OPTSENDERDEFINE", // HID:41136 + "HID:WIZARDS_HID_TXTSENDERNAME", // HID:41137 + "HID:WIZARDS_HID_TXTSENDERSTREET", // HID:41138 + "HID:WIZARDS_HID_TXTSENDERPOSTCODE", // HID:41139 + "HID:WIZARDS_HID_TXTSENDERSTATE", // HID:41140 + "HID:WIZARDS_HID_TXTSENDERCITY", // HID:41141 + "HID:WIZARDS_HID_TXTSENDERFAX", // HID:41142 + "HID:WIZARDS_HID_OPTRECEIVERPLACEHOLDER", // HID:41143 + "HID:WIZARDS_HID_OPTRECEIVERDATABASE", // HID:41144 + "HID:WIZARDS_HID_TXTFOOTER", // HID:41145 + "HID:WIZARDS_HID_CHKFOOTERNEXTPAGES", // HID:41146 + "HID:WIZARDS_HID_CHKFOOTERPAGENUMBERS", // HID:41147 + "HID:WIZARDS_HID_TXTTEMPLATENAME", // HID:41148 + "HID:WIZARDS_HID_FILETEMPLATEPATH", // HID:41149 + "HID:WIZARDS_HID_OPTCREATEFAX", // HID:41150 + "HID:WIZARDS_HID_OPTMAKECHANGES", // HID:41151 + "HID:WIZARDS_HID_IMAGECONTROL2", // HID:41152 + "HID:WIZARDS_HID_FAXWIZ_TXTPATH", // HID:41153 + "HID:WIZARDS_HID_FAXWIZ_CMDPATH", // HID:41154 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_FAXWIZARD", // HID:41180 + "HID:WIZARDS_HID_FAXWIZARD_HELP", // HID:41181 + "HID:WIZARDS_HID_FAXWIZARD_BACK", // HID:41182 + "HID:WIZARDS_HID_FAXWIZARD_NEXT", // HID:41183 + "HID:WIZARDS_HID_FAXWIZARD_CREATE", // HID:41184 + "HID:WIZARDS_HID_FAXWIZARD_CANCEL", // HID:41185 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGTABLE_DIALOG", // HID:41200 + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGTABLE_CMDPREV", // HID:41202 + "HID:WIZARDS_HID_DLGTABLE_CMDNEXT", // HID:41203 + "HID:WIZARDS_HID_DLGTABLE_CMDFINISH", // HID:41204 + "HID:WIZARDS_HID_DLGTABLE_CMDCANCEL", // HID:41205 + "HID:WIZARDS_HID_DLGTABLE_OPTBUSINESS", // HID:41206 + "HID:WIZARDS_HID_DLGTABLE_OPTPRIVATE", // HID:41207 + "HID:WIZARDS_HID_DLGTABLE_LBTABLES", // HID:41208 + "HID:WIZARDS_HID_DLGTABLE_FIELDSAVAILABLE", // HID:41209 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVESELECTED", // HID:41210 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEALL", // HID:41211 + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVESELECTED", // HID:41212 + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVEALL", // HID:41213 + "HID:WIZARDS_HID_DLGTABLE_FIELDSSELECTED", // HID:41214 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEUP", // HID:41215 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEDOWN", // HID:41216 + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + PropertyNames.EMPTY_STRING, + "HID:WIZARDS_HID_DLGTABLE_LB_SELFIELDNAMES", // HID:41220 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDUP", // HID:41221 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDDOWN", // HID:41222 + "HID:WIZARDS_HID_DLGTABLE_CMDMINUS", // HID:41223 + "HID:WIZARDS_HID_DLGTABLE_CMDPLUS", // HID:41224 + "HID:WIZARDS_HID_DLGTABLE_COLNAME", // HID:41225 + "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER", // HID:41226 + "HID:WIZARDS_HID_DLGTABLE_CHK_USEPRIMEKEY", // HID:41227 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_AUTOMATIC", // HID:41228 + "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE_AUTOMATIC", // HID:41229 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SINGLE", // HID:41230 + "HID:WIZARDS_HID_DLGTABLE_LB_PK_FIELDNAME", // HID:41231 + "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE", // HID:41232 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SEVERAL", // HID:41233 + "HID:WIZARDS_HID_DLGTABLE_FIELDS_PK_AVAILABLE", // HID:41234 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVE_PK_SELECTED", // HID:41235 + PropertyNames.EMPTY_STRING, // HID:41236 empty, no moveall button + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVE_PK_SELECTED", // HID:41237 + PropertyNames.EMPTY_STRING, // HID:41238 empty, no removeall button + "HID:WIZARDS_HID_DLGTABLE_FIELDS_PK_SELECTED", // HID:41239 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEUP_PK_SELECTED", // HID:41240 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEDOWN_PK_SELECTED", // HID:41241 + "HID:WIZARDS_HID_DLGTABLE_TXT_NAME", // HID:41242 + "HID:WIZARDS_HID_DLGTABLE_OPT_MODIFYTABLE", // HID:41243 + "HID:WIZARDS_HID_DLGTABLE_OPT_WORKWITHTABLE", // HID:41244 + "HID:WIZARDS_HID_DLGTABLE_OPT_STARTFORMWIZARD", // HID:41245 + "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", // HID:41246 + "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA" // HID:41247 + }; + + public static String getHelpIdString( int nHelpId ) + { + if ( nHelpId >= 34200 && nHelpId <= 34722 ) + return array1[ nHelpId - 34200 ]; + else if ( nHelpId >= 40769 && nHelpId <= 41245 ) + return array2[ nHelpId - 40769 ]; + else + return ""; + } +} diff --git a/wizards/com/sun/star/wizards/common/HelpIds.py b/wizards/com/sun/star/wizards/common/HelpIds.py new file mode 100644 index 0000000000..971fc149c5 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/HelpIds.py @@ -0,0 +1,1028 @@ +# +# 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 HelpIds: + array1 = [ + "HID:WIZARDS_HID0_HELP", # HID:34201 + "HID:WIZARDS_HID0_NEXT", # HID:34202 + "HID:WIZARDS_HID0_PREV", # HID:34203 + "HID:WIZARDS_HID0_CREATE", # HID:34204 + "HID:WIZARDS_HID0_CANCEL", # HID:34205 + "HID:WIZARDS_HID0_STATUS_DIALOG", # HID:34206 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID2_BTN_DOC_UP", # HID:34213 + "HID:WIZARDS_HID2_BTN_DOC_DOWN", # HID:34214 + "", + "", + "", + "", + "HID:WIZARDS_HID2_STATUS_ADD_DOCS", # HID:34219 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG10", # HID:34229 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG11", # HID:34230 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG12", # HID:34231 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG13", # HID:34232 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG14", # HID:34233 + "HID:WIZARDS_HID3_IL_LAYOUTS_IMG15", # HID:34234 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_BG_BTN_OK", # HID:34293 + "HID:WIZARDS_HID_BG_BTN_CANCEL", # HID:34294 + "HID:WIZARDS_HID_BG_BTN_BACK", # HID:34295 + "HID:WIZARDS_HID_BG_BTN_FW", # HID:34296 + "HID:WIZARDS_HID_BG_BTN_IMG1", # HID:34297 + "HID:WIZARDS_HID_BG_BTN_IMG2", # HID:34298 + "HID:WIZARDS_HID_BG_BTN_IMG3", # HID:34299 + "HID:WIZARDS_HID_BG_BTN_IMG4", # HID:34300 + "HID:WIZARDS_HID_BG_BTN_IMG5", # HID:34301 + "HID:WIZARDS_HID_BG_BTN_IMG6", # HID:34302 + "HID:WIZARDS_HID_BG_BTN_IMG7", # HID:34303 + "HID:WIZARDS_HID_BG_BTN_IMG8", # HID:34304 + "HID:WIZARDS_HID_BG_BTN_IMG9", # HID:34305 + "HID:WIZARDS_HID_BG_BTN_IMG10", # HID:34306 + "HID:WIZARDS_HID_BG_BTN_IMG11", # HID:34307 + "HID:WIZARDS_HID_BG_BTN_IMG12", # HID:34308 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGREPORT_DIALOG", # HID:34320 + "", + "HID:WIZARDS_HID_DLGREPORT_0_CMDPREV", # HID:34322 + "HID:WIZARDS_HID_DLGREPORT_0_CMDNEXT", # HID:34323 + "HID:WIZARDS_HID_DLGREPORT_0_CMDFINISH", # HID:34324 + "HID:WIZARDS_HID_DLGREPORT_0_CMDCANCEL", # HID:34325 + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGREPORT_1_LBTABLES", # HID:34330 + "HID:WIZARDS_HID_DLGREPORT_1_FIELDSAVAILABLE", # HID:34331 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVESELECTED", # HID:34332 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEALL", # HID:34333 + "HID:WIZARDS_HID_DLGREPORT_1_CMDREMOVESELECTED", # HID:34334 + "HID:WIZARDS_HID_DLGREPORT_1_CMDREMOVEALL", # HID:34335 + "HID:WIZARDS_HID_DLGREPORT_1_FIELDSSELECTED", # HID:34336 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEUP", # HID:34337 + "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEDOWN", # HID:34338 + "", + "HID:WIZARDS_HID_DLGREPORT_2_GROUPING", # HID:34340 + "HID:WIZARDS_HID_DLGREPORT_2_CMDGROUP", # HID:34341 + "HID:WIZARDS_HID_DLGREPORT_2_CMDUNGROUP", # HID:34342 + "HID:WIZARDS_HID_DLGREPORT_2_PREGROUPINGDEST", # HID:34343 + "HID:WIZARDS_HID_DLGREPORT_2_CMDMOVEUPGROUP", # HID:34344 + "HID:WIZARDS_HID_DLGREPORT_2_CMDMOVEDOWNGROUP", # HID:34345 + "HID:WIZARDS_HID_DLGREPORT_3_SORT1", # HID:34346 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND1", # HID:34347 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND1", # HID:34348 + "HID:WIZARDS_HID_DLGREPORT_3_SORT2", # HID:34349 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND2", # HID:34350 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND2", # HID:34351 + "HID:WIZARDS_HID_DLGREPORT_3_SORT3", # HID:34352 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND3", # HID:34353 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND3", # HID:34354 + "HID:WIZARDS_HID_DLGREPORT_3_SORT4", # HID:34355 + "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND4", # HID:34356 + "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND4", # HID:34357 + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGREPORT_4_TITLE", # HID:34362 + "HID:WIZARDS_HID_DLGREPORT_4_DATALAYOUT", # HID:34363 + "HID:WIZARDS_HID_DLGREPORT_4_PAGELAYOUT", # HID:34364 + "HID:WIZARDS_HID_DLGREPORT_4_LANDSCAPE", # HID:34365 + "HID:WIZARDS_HID_DLGREPORT_4_PORTRAIT", # HID:34366 + "", + "", + "", + "HID:WIZARDS_HID_DLGREPORT_5_OPTDYNTEMPLATE", # HID:34370 + "HID:WIZARDS_HID_DLGREPORT_5_OPTSTATDOCUMENT", # HID:34371 + "HID:WIZARDS_HID_DLGREPORT_5_TXTTEMPLATEPATH", # HID:34372 + "HID:WIZARDS_HID_DLGREPORT_5_CMDTEMPLATEPATH", # HID:34373 + "HID:WIZARDS_HID_DLGREPORT_5_OPTEDITTEMPLATE", # HID:34374 + "HID:WIZARDS_HID_DLGREPORT_5_OPTUSETEMPLATE", # HID:34375 + "HID:WIZARDS_HID_DLGREPORT_5_TXTDOCUMENTPATH", # HID:34376 + "HID:WIZARDS_HID_DLGREPORT_5_CMDDOCUMENTPATH", # HID:34377 + "HID:WIZARDS_HID_DLGREPORT_5_CHKLINKTODB", # HID:34378 + "", + "", + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_1", # HID:34381 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_2", # HID:34382 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_3", # HID:34383 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_4", # HID:34384 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_5", # HID:34385 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_6", # HID:34386 + "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_7", # HID:34387 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_DIALOG", # HID:34400 + "", + "HID:WIZARDS_HID_DLGFORM_CMDPREV", # HID:34402 + "HID:WIZARDS_HID_DLGFORM_CMDNEXT", # HID:34403 + "HID:WIZARDS_HID_DLGFORM_CMDFINISH", # HID:34404 + "HID:WIZARDS_HID_DLGFORM_CMDCANCEL", # HID:34405 + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_MASTER_LBTABLES", # HID:34411 + "HID:WIZARDS_HID_DLGFORM_MASTER_FIELDSAVAILABLE", # HID:34412 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVESELECTED", # HID:34413 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEALL", # HID:34414 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDREMOVESELECTED", # HID:34415 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDREMOVEALL", # HID:34416 + "HID:WIZARDS_HID_DLGFORM_MASTER_FIELDSSELECTED", # HID:34417 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEUP", # HID:34418 + "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEDOWN", # HID:34419 + "", + "HID:WIZARDS_HID_DLGFORM_CHKCREATESUBFORM", # HID:34421 + "HID:WIZARDS_HID_DLGFORM_OPTONEXISTINGRELATION", # HID:34422 + "HID:WIZARDS_HID_DLGFORM_OPTSELECTMANUALLY", # HID:34423 + "HID:WIZARDS_HID_DLGFORM_lstRELATIONS", # HID:34424 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_SUB_LBTABLES", # HID:34431 + "HID:WIZARDS_HID_DLGFORM_SUB_FIELDSAVAILABLE", # HID:34432 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVESELECTED", # HID:34433 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEALL", # HID:34434 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDREMOVESELECTED", # HID:34435 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDREMOVEALL", # HID:34436 + "HID:WIZARDS_HID_DLGFORM_SUB_FIELDSSELECTED", # HID:34437 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEUP", # HID:34438 + "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEDOWN", # HID:34439 + "", + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK1", # HID:34441 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK1", # HID:34442 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK2", # HID:34443 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK2", # HID:34444 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK3", # HID:34446 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK4", # HID:34447 + "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK4", # HID:34448 + "", + "", + "HID:WIZARDS_HID_DLGFORM_CMDALIGNLEFT", # HID:34451 + "HID:WIZARDS_HID_DLGFORM_CMDALIGNRIGHT", # HID:34452 + "HID:WIZARDS_HID_DLGFORM_CMDLEFTLABELED", # HID:34453 + "HID:WIZARDS_HID_DLGFORM_CMDTOPLABELED", # HID:34454 + "HID:WIZARDS_HID_DLGFORM_CMDTABLESTYLE", # HID:34455 + "HID:WIZARDS_HID_DLGFORM_CMDTOPJUSTIFIED", # HID:34456 + "HID:WIZARDS_HID_DLGFORM_CMDLEFTLABELED2", # HID:34457 + "HID:WIZARDS_HID_DLGFORM_CMDTOPLABELED2", # HID:34458 + "HID:WIZARDS_HID_DLGFORM_CMDTABLESTYLE2", # HID:34459 + "HID:WIZARDS_HID_DLGFORM_CMDTOPJUSTIFIED2", # HID:34460 + "HID:WIZARDS_HID_DLGFORM_OPTNEWDATAONLY", # HID:34461 + "HID:WIZARDS_HID_DLGFORM_OPTDISPLAYALLDATA", # HID:34462 + "HID:WIZARDS_HID_DLGFORM_CHKNOMODIFICATION", # HID:34463 + "HID:WIZARDS_HID_DLGFORM_CHKNODELETION", # HID:34464 + "HID:WIZARDS_HID_DLGFORM_CHKNOADDITION", # HID:34465 + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_LSTSTYLES", # HID:34471 + "HID:WIZARDS_HID_DLGFORM_CMDNOBORDER", # HID:34472 + "HID:WIZARDS_HID_DLGFORM_CMD3DBORDER", # HID:34473 + "HID:WIZARDS_HID_DLGFORM_CMDSIMPLEBORDER", # HID:34474 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGFORM_TXTPATH", # HID:34481 + "HID:WIZARDS_HID_DLGFORM_OPTWORKWITHFORM", # HID:34482 + "HID:WIZARDS_HID_DLGFORM_OPTMODIFYFORM", # HID:34483 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGNEWSLTR_DIALOG", # HID:34500 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTSTANDARDLAYOUT", # HID:34501 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTPARTYLAYOUT", # HID:34502 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTBROCHURELAYOUT", # HID:34503 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTSINGLESIDED", # HID:34504 + "HID:WIZARDS_HID_DLGNEWSLTR_OPTDOUBLESIDED", # HID:34505 + "HID:WIZARDS_HID_DLGNEWSLTR_CMDGOON", # HID:34506 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_SELLBUY", # HID:34520 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTSTOCKID_SELLBUY", # HID:34521 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTQUANTITY", # HID:34522 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTRATE", # HID:34523 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTDATE", # HID:34524 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTCOMMISSION", # HID:34525 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTFIX", # HID:34526 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTMINIMUM", # HID:34527 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_SELLBUY", # HID:34528 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_SELLBUY", # HID:34529 + "HID:WIZARDS_HID_DLGDEPOT_1_LSTSELLSTOCKS", # HID:34530 + "HID:WIZARDS_HID_DLGDEPOT_2_LSTBUYSTOCKS", # HID:34531 + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_SPLIT", # HID:34532 + "HID:WIZARDS_HID_DLGDEPOT_0_LSTSTOCKNAMES", # HID:34533 + "HID:WIZARDS_HID_DLGDEPOT_0_TXTSTOCKID_SPLIT", # HID:34534 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_SPLIT", # HID:34535 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_SPLIT", # HID:34536 + "HID:WIZARDS_HID_DLGDEPOT_1_OPTPERSHARE", # HID:34537 + "HID:WIZARDS_HID_DLGDEPOT_1_OPTTOTAL", # HID:34538 + "HID:WIZARDS_HID_DLGDEPOT_1_TXTDIVIDEND", # HID:34539 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTOLDRATE", # HID:34540 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTNEWRATE", # HID:34541 + "HID:WIZARDS_HID_DLGDEPOT_2_TXTDATE", # HID:34542 + "HID:WIZARDS_HID_DLGDEPOT_3_TXTSTARTDATE", # HID:34543 + "HID:WIZARDS_HID_DLGDEPOT_3_TXTENDDATE", # HID:34544 + "HID:WIZARDS_HID_DLGDEPOT_3_OPTDAILY", # HID:34545 + "HID:WIZARDS_HID_DLGDEPOT_3_OPTWEEKLY", # HID:34546 + "HID:WIZARDS_HID_DLGDEPOT_DIALOG_HISTORY", # HID:34547 + "HID:WIZARDS_HID_DLGDEPOT_LSTMARKETS", # HID:34548 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_HISTORY", # HID:34549 + "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_HISTORY", # HID:34550 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGIMPORT_DIALOG", # HID:34570 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDHELP", # HID:34571 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDCANCEL", # HID:34572 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDPREV", # HID:34573 + "HID:WIZARDS_HID_DLGIMPORT_0_CMDNEXT", # HID:34574 + "HID:WIZARDS_HID_DLGIMPORT_0_OPTSODOCUMENTS", # HID:34575 + "HID:WIZARDS_HID_DLGIMPORT_0_OPTMSDOCUMENTS", # HID:34576 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKLOGFILE", # HID:34577 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKWORD", # HID:34578 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKEXCEL", # HID:34579 + "HID:WIZARDS_HID_DLGIMPORT_2_CHKPOWERPOINT", # HID:34580 + "HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATE", # HID:34581 + "HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATERECURSE", # HID:34582 + "HID:WIZARDS_HID_DLGIMPORT_2_LBTEMPLATEPATH", # HID:34583 + "HID:WIZARDS_HID_DLGIMPORT_2_EDTEMPLATEPATH", # HID:34584 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT", # HID:34585 + "HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENT", # HID:34586 + "HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENTRECURSE", # HID:34587 + "HID:WIZARDS_HID_DLGIMPORT_2_LBDOCUMENTPATH", # HID:34588 + "HID:WIZARDS_HID_DLGIMPORT_2_EDDOCUMENTPATH", # HID:34589 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT", # HID:34590 + "HID:WIZARDS_HID_DLGIMPORT_2_LBEXPORTDOCUMENTPATH", # HID:34591 + "HID:WIZARDS_HID_DLGIMPORT_2_EDEXPORTDOCUMENTPATH", # HID:34592 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDEXPORTPATHSELECT", # HID:34593 + "", + "HID:WIZARDS_HID_DLGIMPORT_3_TBSUMMARY", # HID:34595 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKWRITER", # HID:34596 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKCALC", # HID:34597 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKIMPRESS", # HID:34598 + "HID:WIZARDS_HID_DLGIMPORT_0_CHKMATHGLOBAL", # HID:34599 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT2", # HID:34600 + "HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT2", # HID:34601 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGCORRESPONDENCE_DIALOG", # HID:34630 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_CANCEL", # HID:34631 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA1", # HID:34632 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA2", # HID:34633 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_AGENDAOKAY", # HID:34634 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER1", # HID:34635 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER2", # HID:34636 + "HID:WIZARDS_HID_DLGCORRESPONDENCE_LETTEROKAY", # HID:34637 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGSTYLES_DIALOG", # HID:34650 + "HID:WIZARDS_HID_DLGSTYLES_LISTBOX", # HID:34651 + "HID:WIZARDS_HID_DLGSTYLES_CANCEL", # HID:34652 + "HID:WIZARDS_HID_DLGSTYLES_OKAY", # HID:34653 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGCONVERT_DIALOG", # HID:34660 + "HID:WIZARDS_HID_DLGCONVERT_CHECKBOX1", # HID:34661 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON1", # HID:34662 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON2", # HID:34663 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON3", # HID:34664 + "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON4", # HID:34665 + "HID:WIZARDS_HID_DLGCONVERT_LISTBOX1", # HID:34666 + "HID:WIZARDS_HID_DLGCONVERT_OBFILE", # HID:34667 + "HID:WIZARDS_HID_DLGCONVERT_OBDIR", # HID:34668 + "HID:WIZARDS_HID_DLGCONVERT_COMBOBOX1", # HID:34669 + "HID:WIZARDS_HID_DLGCONVERT_TBSOURCE", # HID:34670 + "HID:WIZARDS_HID_DLGCONVERT_CHECKRECURSIVE", # HID:34671 + "HID:WIZARDS_HID_DLGCONVERT_TBTARGET", # HID:34672 + "HID:WIZARDS_HID_DLGCONVERT_CBCANCEL", # HID:34673 + "HID:WIZARDS_HID_DLGCONVERT_CBHELP", # HID:34674 + "HID:WIZARDS_HID_DLGCONVERT_CBBACK", # HID:34675 + "HID:WIZARDS_HID_DLGCONVERT_CBGOON", # HID:34676 + "HID:WIZARDS_HID_DLGCONVERT_CBSOURCEOPEN", # HID:34677 + "HID:WIZARDS_HID_DLGCONVERT_CBTARGETOPEN", # HID:34678 + "HID:WIZARDS_HID_DLGCONVERT_CHKPROTECT", # HID:34679 + "HID:WIZARDS_HID_DLGCONVERT_CHKTEXTDOCUMENTS", # HID:34680 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGPASSWORD_CMDGOON", # HID:34690 + "HID:WIZARDS_HID_DLGPASSWORD_CMDCANCEL", # HID:34691 + "HID:WIZARDS_HID_DLGPASSWORD_CMDHELP", # HID:34692 + "HID:WIZARDS_HID_DLGPASSWORD_TXTPASSWORD", # HID:34693 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGHOLIDAYCAL_DIALOG", # HID:34700 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_PREVIEW", # HID:34701 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_OPYEAR", # HID:34702 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_OPMONTH", # HID:34703 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_EDYEAR", # HID:34704 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_EDMONTH", # HID:34705 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_SPINYEAR", # HID:34706 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_SPINMONTH", # HID:34707 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_CMBSTATE", # HID:34708 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_LBOWNDATA", # HID:34709 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CMDINSERT", # HID:34710 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CMDDELETE", # HID:34711 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENT", # HID:34712 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CHKEVENT", # HID:34713 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTDAY", # HID:34714 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTDAY", # HID:34715 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTMONTH", # HID:34716 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTMONTH", # HID:34717 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTYEAR", # HID:34718 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTYEAR", # HID:34719 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDOWNDATA", # HID:34720 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDCANCEL", # HID:34721 + "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDOK" # HID:34722 + ] + array2 = ["HID:WIZARDS_HID_LTRWIZ_OPTBUSINESSLETTER", # HID:40769 + "HID:WIZARDS_HID_LTRWIZ_OPTPRIVOFFICIALLETTER", # HID:40770 + "HID:WIZARDS_HID_LTRWIZ_OPTPRIVATELETTER", # HID:40771 + "HID:WIZARDS_HID_LTRWIZ_LSTBUSINESSSTYLE", # HID:40772 + "HID:WIZARDS_HID_LTRWIZ_CHKBUSINESSPAPER", # HID:40773 + "HID:WIZARDS_HID_LTRWIZ_LSTPRIVOFFICIALSTYLE", # HID:40774 + "HID:WIZARDS_HID_LTRWIZ_LSTPRIVATESTYLE", # HID:40775 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERCOMPANYLOGO", # HID:40776 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOHEIGHT", # HID:40777 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOX", # HID:40778 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOWIDTH", # HID:40779 + "HID:WIZARDS_HID_LTRWIZ_NUMLOGOY", # HID:40780 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERCOMPANYADDRESS", # HID:40781 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSHEIGHT", # HID:40782 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSX", # HID:40783 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSWIDTH", # HID:40784 + "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSY", # HID:40785 + "HID:WIZARDS_HID_LTRWIZ_CHKCOMPANYRECEIVER", # HID:40786 + "HID:WIZARDS_HID_LTRWIZ_CHKPAPERFOOTER", # HID:40787 + "HID:WIZARDS_HID_LTRWIZ_NUMFOOTERHEIGHT", # HID:40788 + "HID:WIZARDS_HID_LTRWIZ_LSTLETTERNORM", # HID:40789 + "HID:WIZARDS_HID_LTRWIZ_CHKUSELOGO", # HID:40790 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEADDRESSRECEIVER", # HID:40791 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESIGNS", # HID:40792 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESUBJECT", # HID:40793 + "HID:WIZARDS_HID_LTRWIZ_CHKUSESALUTATION", # HID:40794 + "HID:WIZARDS_HID_LTRWIZ_LSTSALUTATION", # HID:40795 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEBENDMARKS", # HID:40796 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEGREETING", # HID:40797 + "HID:WIZARDS_HID_LTRWIZ_LSTGREETING", # HID:40798 + "HID:WIZARDS_HID_LTRWIZ_CHKUSEFOOTER", # HID:40799 + "HID:WIZARDS_HID_LTRWIZ_OPTSENDERPLACEHOLDER", # HID:40800 + "HID:WIZARDS_HID_LTRWIZ_OPTSENDERDEFINE", # HID:40801 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERNAME", # HID:40802 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERSTREET", # HID:40803 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERPOSTCODE", # HID:40804 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERSTATE_TEXT", # HID:40805 + "HID:WIZARDS_HID_LTRWIZ_TXTSENDERCITY", # HID:40806 + "HID:WIZARDS_HID_LTRWIZ_OPTRECEIVERPLACEHOLDER", # HID:40807 + "HID:WIZARDS_HID_LTRWIZ_OPTRECEIVERDATABASE", # HID:40808 + "HID:WIZARDS_HID_LTRWIZ_TXTFOOTER", # HID:40809 + "HID:WIZARDS_HID_LTRWIZ_CHKFOOTERNEXTPAGES", # HID:40810 + "HID:WIZARDS_HID_LTRWIZ_CHKFOOTERPAGENUMBERS", # HID:40811 + "HID:WIZARDS_HID_LTRWIZ_TXTTEMPLATENAME", # HID:40812 + "HID:WIZARDS_HID_LTRWIZ_OPTCREATELETTER", # HID:40813 + "HID:WIZARDS_HID_LTRWIZ_OPTMAKECHANGES", # HID:40814 + "HID:WIZARDS_HID_LTRWIZ_TXTPATH", # HID:40815 + "HID:WIZARDS_HID_LTRWIZ_CMDPATH", # HID:40816 + "", + "", + "", + "HID:WIZARDS_HID_LTRWIZARD", # HID:40820 + "HID:WIZARDS_HID_LTRWIZARD_HELP", # HID:40821 + "HID:WIZARDS_HID_LTRWIZARD_BACK", # HID:40822 + "HID:WIZARDS_HID_LTRWIZARD_NEXT", # HID:40823 + "HID:WIZARDS_HID_LTRWIZARD_CREATE", # HID:40824 + "HID:WIZARDS_HID_LTRWIZARD_CANCEL", # HID:40825 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_LSTTABLES", # HID:40850 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDS", # HID:40851 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVESELECTED", # HID:40852 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEALL", # HID:40853 + "HID:WIZARDS_HID_QUERYWIZARD_CMDREMOVESELECTED", # HID:40854 + "HID:WIZARDS_HID_QUERYWIZARD_CMDREMOVEALL", # HID:40855 + "HID:WIZARDS_HID_QUERYWIZARD_LSTSELFIELDS", # HID:40856 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEUP", # HID:40857 + "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEDOWN", # HID:40858 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_SORT1", # HID:40865 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND1", # HID:40866 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND1", # HID:40867 + "HID:WIZARDS_HID_QUERYWIZARD_SORT2", # HID:40868 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND2", # HID:40869 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND2", # HID:40870 + "HID:WIZARDS_HID_QUERYWIZARD_SORT3", # HID:40871 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND3", # HID:40872 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND3", # HID:40873 + "HID:WIZARDS_HID_QUERYWIZARD_SORT4", # HID:40874 + "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND4", # HID:40875 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND4", # HID:40876 + "", + "HID:WIZARDS_HID_QUERYWIZARD_OPTMATCHALL", # HID:40878 + "HID:WIZARDS_HID_QUERYWIZARD_OPTMATCHANY", # HID:40879 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_1", # HID:40880 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_1", # HID:40881 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_1", # HID:40882 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_2", # HID:40883 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_2", # HID:40884 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_2", # HID:40885 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_3", # HID:40886 + "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_3", # HID:40887 + "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_3", # HID:40888 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_OPTAGGREGATEDETAILQUERY", # HID:40895 + "HID:WIZARDS_HID_QUERYWIZARD_OPTAGGREGATESUMMARYQUERY", # HID:40896 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_1", # HID:40897 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_1", # HID:40898 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_2", # HID:40899 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_2", # HID:40900 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_3", # HID:40901 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_3", # HID:40902 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_4", # HID:40903 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_4", # HID:40904 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_5", # HID:40905 + "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_5", # HID:40906 + "HID:WIZARDS_HID_QUERYWIZARD_BTNAGGREGATEPLUS", # HID:40907 + "HID:WIZARDS_HID_QUERYWIZARD_BTNAGGREGATEMINUS", # HID:40908 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDS", # HID:40915 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVESELECTED", # HID:40916 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERREMOVESELECTED", # HID:40917 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERSELFIELDS", # HID:40918 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVEUP", # HID:40919 + "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVEDOWN", # HID:40920 + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_OPTGROUPMATCHALL", # HID:40923 + "HID:WIZARDS_HID_QUERYWIZARD_OPTGROUPMATCHANY", # HID:40924 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_1", # HID:40925 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_1", # HID:40926 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_1", # HID:40927 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_2", # HID:40928 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_2", # HID:40929 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_2", # HID:40930 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_3", # HID:40931 + "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_3", # HID:40932 + "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_3", # HID:40933 + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_1", # HID:40940 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_2", # HID:40941 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_3", # HID:40942 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_4", # HID:40943 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_5", # HID:40944 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_6", # HID:40945 + "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_7", # HID:40946 + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD_TXTQUERYTITLE", # HID:40955 + "HID:WIZARDS_HID_QUERYWIZARD_OPTDISPLAYQUERY", # HID:40956 + "HID:WIZARDS_HID_QUERYWIZARD_OPTMODIFYQUERY", # HID:40957 + "HID:WIZARDS_HID_QUERYWIZARD_TXTSUMMARY", # HID:40958 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_QUERYWIZARD", # HID:40970 + "", + "HID:WIZARDS_HID_QUERYWIZARD_BACK", # HID:40972 + "HID:WIZARDS_HID_QUERYWIZARD_NEXT", # HID:40973 + "HID:WIZARDS_HID_QUERYWIZARD_CREATE", # HID:40974 + "HID:WIZARDS_HID_QUERYWIZARD_CANCEL", # HID:40975 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_IS_BTN_OK", # HID:41003 + "HID:WIZARDS_HID_IS_BTN_CANCEL", # HID:41004 + "HID:WIZARDS_HID_IS_BTN_IMG1", # HID:41005 + "HID:WIZARDS_HID_IS_BTN_IMG2", # HID:41006 + "HID:WIZARDS_HID_IS_BTN_IMG3", # HID:41007 + "HID:WIZARDS_HID_IS_BTN_IMG4", # HID:41008 + "HID:WIZARDS_HID_IS_BTN_IMG5", # HID:41009 + "HID:WIZARDS_HID_IS_BTN_IMG6", # HID:41010 + "HID:WIZARDS_HID_IS_BTN_IMG7", # HID:41011 + "HID:WIZARDS_HID_IS_BTN_IMG8", # HID:41012 + "HID:WIZARDS_HID_IS_BTN_IMG9", # HID:41013 + "HID:WIZARDS_HID_IS_BTN_IMG10", # HID:41014 + "HID:WIZARDS_HID_IS_BTN_IMG11", # HID:41015 + "HID:WIZARDS_HID_IS_BTN_IMG12", # HID:41016 + "HID:WIZARDS_HID_IS_BTN_IMG13", # HID:41017 + "HID:WIZARDS_HID_IS_BTN_IMG14", # HID:41018 + "HID:WIZARDS_HID_IS_BTN_IMG15", # HID:41019 + "HID:WIZARDS_HID_IS_BTN_IMG16", # HID:41020 + "HID:WIZARDS_HID_IS_BTN_IMG17", # HID:41021 + "HID:WIZARDS_HID_IS_BTN_IMG18", # HID:41022 + "HID:WIZARDS_HID_IS_BTN_IMG19", # HID:41023 + "HID:WIZARDS_HID_IS_BTN_IMG20", # HID:41024 + "HID:WIZARDS_HID_IS_BTN_IMG21", # HID:41025 + "HID:WIZARDS_HID_IS_BTN_IMG22", # HID:41026 + "HID:WIZARDS_HID_IS_BTN_IMG23", # HID:41027 + "HID:WIZARDS_HID_IS_BTN_IMG24", # HID:41028 + "HID:WIZARDS_HID_IS_BTN_IMG25", # HID:41029 + "HID:WIZARDS_HID_IS_BTN_IMG26", # HID:41030 + "HID:WIZARDS_HID_IS_BTN_IMG27", # HID:41031 + "HID:WIZARDS_HID_IS_BTN_IMG28", # HID:41032 + "HID:WIZARDS_HID_IS_BTN_IMG29", # HID:41033 + "HID:WIZARDS_HID_IS_BTN_IMG30", # HID:41034 + "HID:WIZARDS_HID_IS_BTN_IMG31", # HID:41035 + "HID:WIZARDS_HID_IS_BTN_IMG32", # HID:41036 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_FTP_OK", # HID:41047 + "HID:WIZARDS_HID_FTP_CANCEL", # HID:41048 + "", + "", + "HID:WIZARDS_HID_AGWIZ", # HID:41051 + "HID:WIZARDS_HID_AGWIZ_HELP", # HID:41052 + "HID:WIZARDS_HID_AGWIZ_NEXT", # HID:41053 + "HID:WIZARDS_HID_AGWIZ_PREV", # HID:41054 + "HID:WIZARDS_HID_AGWIZ_CREATE", # HID:41055 + "HID:WIZARDS_HID_AGWIZ_CANCEL", # HID:41056 + "HID:WIZARDS_HID_AGWIZ_1_LIST_PAGEDESIGN", # HID:41057 + "HID:WIZARDS_HID_AGWIZ_1_CHK_MINUTES", # HID:41058 + "HID:WIZARDS_HID_AGWIZ_2_TXT_TIME", # HID:41059 + "HID:WIZARDS_HID_AGWIZ_2_TXT_DATE", # HID:41060 + "HID:WIZARDS_HID_AGWIZ_2_TXT_TITLE", # HID:41061 + "HID:WIZARDS_HID_AGWIZ_2_TXT_LOCATION", # HID:41062 + "HID:WIZARDS_HID_AGWIZ_3_CHK_MEETING_TYPE", # HID:41063 + "HID:WIZARDS_HID_AGWIZ_3_CHK_READ", # HID:41064 + "HID:WIZARDS_HID_AGWIZ_3_CHK_BRING", # HID:41065 + "HID:WIZARDS_HID_AGWIZ_3_CHK_NOTES", # HID:41066 + "HID:WIZARDS_HID_AGWIZ_4_CHK_CALLED_BY", # HID:41067 + "HID:WIZARDS_HID_AGWIZ_4_CHK_FACILITATOR", # HID:41068 + "HID:WIZARDS_HID_AGWIZ_4_CHK_NOTETAKER", # HID:41069 + "HID:WIZARDS_HID_AGWIZ_4_CHK_TIMEKEEPER", # HID:41070 + "HID:WIZARDS_HID_AGWIZ_4_CHK_ATTENDEES", # HID:41071 + "HID:WIZARDS_HID_AGWIZ_4_CHK_OBSERVERS", # HID:41072 + "HID:WIZARDS_HID_AGWIZ_4_CHK_RESOURCEPERSONS", # HID:41073 + "HID:WIZARDS_HID_AGWIZ_6_TXT_TEMPLATENAME", # HID:41074 + "HID:WIZARDS_HID_AGWIZ_6_TXT_TEMPLATEPATH", # HID:41075 + "HID:WIZARDS_HID_AGWIZ_6_BTN_TEMPLATEPATH", # HID:41076 + "HID:WIZARDS_HID_AGWIZ_6_OPT_CREATEAGENDA", # HID:41077 + "HID:WIZARDS_HID_AGWIZ_6_OPT_MAKECHANGES", # HID:41078 + "HID:WIZARDS_HID_AGWIZ_5_BTN_INSERT", # HID:41079 + "HID:WIZARDS_HID_AGWIZ_5_BTN_REMOVE", # HID:41080 + "HID:WIZARDS_HID_AGWIZ_5_BTN_UP", # HID:41081 + "HID:WIZARDS_HID_AGWIZ_5_BTN_DOWN", # HID:41082 + "HID:WIZARDS_HID_AGWIZ_5_SCROLL_BAR", # HID:41083 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_1", # HID:41084 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_1", # HID:41085 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_1", # HID:41086 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_2", # HID:41087 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_2", # HID:41088 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_2", # HID:41089 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_3", # HID:41090 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_3", # HID:41091 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_3", # HID:41092 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_4", # HID:41093 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_4", # HID:41094 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_4", # HID:41095 + "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_5", # HID:41096 + "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_5", # HID:41097 + "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_5", # HID:41098 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_FAXWIZ_OPTBUSINESSFAX", # HID:41120 + "HID:WIZARDS_HID_FAXWIZ_LSTBUSINESSSTYLE", # HID:41121 + "HID:WIZARDS_HID_FAXWIZ_OPTPRIVATEFAX", # HID:41122 + "HID:WIZARDS_HID_LSTPRIVATESTYLE", # HID:41123 + "HID:WIZARDS_HID_IMAGECONTROL3", # HID:41124 + "HID:WIZARDS_HID_CHKUSELOGO", # HID:41125 + "HID:WIZARDS_HID_CHKUSEDATE", # HID:41126 + "HID:WIZARDS_HID_CHKUSECOMMUNICATIONTYPE", # HID:41127 + "HID:WIZARDS_HID_LSTCOMMUNICATIONTYPE", # HID:41128 + "HID:WIZARDS_HID_CHKUSESUBJECT", # HID:41129 + "HID:WIZARDS_HID_CHKUSESALUTATION", # HID:41130 + "HID:WIZARDS_HID_LSTSALUTATION", # HID:41131 + "HID:WIZARDS_HID_CHKUSEGREETING", # HID:41132 + "HID:WIZARDS_HID_LSTGREETING", # HID:41133 + "HID:WIZARDS_HID_CHKUSEFOOTER", # HID:41134 + "HID:WIZARDS_HID_OPTSENDERPLACEHOLDER", # HID:41135 + "HID:WIZARDS_HID_OPTSENDERDEFINE", # HID:41136 + "HID:WIZARDS_HID_TXTSENDERNAME", # HID:41137 + "HID:WIZARDS_HID_TXTSENDERSTREET", # HID:41138 + "HID:WIZARDS_HID_TXTSENDERPOSTCODE", # HID:41139 + "HID:WIZARDS_HID_TXTSENDERSTATE", # HID:41140 + "HID:WIZARDS_HID_TXTSENDERCITY", # HID:41141 + "HID:WIZARDS_HID_TXTSENDERFAX", # HID:41142 + "HID:WIZARDS_HID_OPTRECEIVERPLACEHOLDER", # HID:41143 + "HID:WIZARDS_HID_OPTRECEIVERDATABASE", # HID:41144 + "HID:WIZARDS_HID_TXTFOOTER", # HID:41145 + "HID:WIZARDS_HID_CHKFOOTERNEXTPAGES", # HID:41146 + "HID:WIZARDS_HID_CHKFOOTERPAGENUMBERS", # HID:41147 + "HID:WIZARDS_HID_TXTTEMPLATENAME", # HID:41148 + "HID:WIZARDS_HID_FILETEMPLATEPATH", # HID:41149 + "HID:WIZARDS_HID_OPTCREATEFAX", # HID:41150 + "HID:WIZARDS_HID_OPTMAKECHANGES", # HID:41151 + "HID:WIZARDS_HID_IMAGECONTROL2", # HID:41152 + "HID:WIZARDS_HID_FAXWIZ_TXTPATH", # HID:41153 + "HID:WIZARDS_HID_FAXWIZ_CMDPATH", # HID:41154 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_FAXWIZARD", # HID:41180 + "HID:WIZARDS_HID_FAXWIZARD_HELP", # HID:41181 + "HID:WIZARDS_HID_FAXWIZARD_BACK", # HID:41182 + "HID:WIZARDS_HID_FAXWIZARD_NEXT", # HID:41183 + "HID:WIZARDS_HID_FAXWIZARD_CREATE", # HID:41184 + "HID:WIZARDS_HID_FAXWIZARD_CANCEL", # HID:41185 + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "HID:WIZARDS_HID_DLGTABLE_DIALOG", # HID:41200 + "", + "HID:WIZARDS_HID_DLGTABLE_CMDPREV", # HID:41202 + "HID:WIZARDS_HID_DLGTABLE_CMDNEXT", # HID:41203 + "HID:WIZARDS_HID_DLGTABLE_CMDFINISH", # HID:41204 + "HID:WIZARDS_HID_DLGTABLE_CMDCANCEL", # HID:41205 + "HID:WIZARDS_HID_DLGTABLE_OPTBUSINESS", # HID:41206 + "HID:WIZARDS_HID_DLGTABLE_OPTPRIVATE", # HID:41207 + "HID:WIZARDS_HID_DLGTABLE_LBTABLES", # HID:41208 + "HID:WIZARDS_HID_DLGTABLE_FIELDSAVAILABLE", # HID:41209 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVESELECTED", # HID:41210 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEALL", # HID:41211 + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVESELECTED", # HID:41212 + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVEALL", # HID:41213 + "HID:WIZARDS_HID_DLGTABLE_FIELDSSELECTED", # HID:41214 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEUP", # HID:41215 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEDOWN", # HID:41216 + "", + "", + "", + "HID:WIZARDS_HID_DLGTABLE_LB_SELFIELDNAMES", # HID:41220 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDUP", # HID:41221 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDDOWN", # HID:41222 + "HID:WIZARDS_HID_DLGTABLE_CMDMINUS", # HID:41223 + "HID:WIZARDS_HID_DLGTABLE_CMDPLUS", # HID:41224 + "HID:WIZARDS_HID_DLGTABLE_COLNAME", # HID:41225 + "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER", # HID:41226 + "HID:WIZARDS_HID_DLGTABLE_CHK_USEPRIMEKEY", # HID:41227 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_AUTOMATIC", # HID:41228 + "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE_AUTOMATIC", # HID:41229 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SINGLE", # HID:41230 + "HID:WIZARDS_HID_DLGTABLE_LB_PK_FIELDNAME", # HID:41231 + "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE", # HID:41232 + "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SEVERAL", # HID:41233 + "HID:WIZARDS_HID_DLGTABLE_FIELDS_PK_AVAILABLE", # HID:41234 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVE_PK_SELECTED", # HID:41235 + "HID:WIZARDS_HID_DLGTABLE_CMDREMOVE_PK_SELECTED", # HID:41236 + "HID:WIZARDS_HID_DLGTABLE_FIELDS_PK_SELECTED", # HID:41237 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEUP_PK_SELECTED", # HID:41238 + "HID:WIZARDS_HID_DLGTABLE_CMDMOVEDOWN_PK_SELECTED", # HID:41239 + "HID:WIZARDS_HID_DLGTABLE_TXT_NAME", # HID:41240 + "HID:WIZARDS_HID_DLGTABLE_OPT_MODIFYTABLE", # HID:41241 + "HID:WIZARDS_HID_DLGTABLE_OPT_WORKWITHTABLE", # HID:41242 + "HID:WIZARDS_HID_DLGTABLE_OPT_STARTFORMWIZARD", # HID:41243 + "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", # HID:41244 + "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA" # HID:41245 + ] + + @classmethod + def getHelpIdString(self, nHelpId): + if nHelpId >= 34200 and nHelpId <= 34722: + return HelpIds.array1[nHelpId - 34200] + elif nHelpId >= 40769 and nHelpId <= 41245: + return HelpIds.array2[nHelpId - 40769] + else: + return None diff --git a/wizards/com/sun/star/wizards/common/Helper.java b/wizards/com/sun/star/wizards/common/Helper.java new file mode 100644 index 0000000000..efb0a970a9 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Helper.java @@ -0,0 +1,239 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.uno.XComponentContext; +import com.sun.star.util.XMacroExpander; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.RuntimeException; +import com.sun.star.uno.UnoRuntime; + +public class Helper +{ + + public static long convertUnoDatetoInteger(com.sun.star.util.Date DateValue) + { + java.util.Calendar oCal = java.util.Calendar.getInstance(); + oCal.set(DateValue.Year, DateValue.Month, DateValue.Day); + java.util.Date dTime = oCal.getTime(); + long lTime = dTime.getTime(); + return lTime / (3600 * 24000); + } + + public static void setUnoPropertyValue(Object oUnoObject, String PropertyName, Object PropertyValue) + { + try + { + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + if (xPSet.getPropertySetInfo().hasPropertyByName(PropertyName)) + { + xPSet.setPropertyValue(PropertyName, PropertyValue); + } + else + { + throw new java.lang.IllegalArgumentException("No Such Property: '" + PropertyName + "'"); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public static Object getUnoObjectbyName(Object oUnoObject, String ElementName) + { + try + { + com.sun.star.container.XNameAccess xName = UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class, oUnoObject); + if (xName.hasByName(ElementName)) + { + return xName.getByName(ElementName); + } + else + { + throw new RuntimeException(); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + + + public static Object getUnoPropertyValue(Object oUnoObject, String PropertyName, java.lang.Class<?> xClass) + { + try + { + if (oUnoObject != null) + { + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + Object oObject = xPSet.getPropertyValue(PropertyName); + if (AnyConverter.isVoid(oObject)) + { + return null; + } + else + { + return com.sun.star.uno.AnyConverter.toObject(new com.sun.star.uno.Type(xClass), oObject); + } + } + return null; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + + + + + public static Object getUnoPropertyValue(Object oUnoObject, String PropertyName) + { + try + { + if (oUnoObject != null) + { + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + return xPSet.getPropertyValue(PropertyName); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + return null; + } + + public static Object getUnoArrayPropertyValue(Object oUnoObject, String PropertyName) + { + try + { + if (oUnoObject != null) + { + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + Object oObject = xPSet.getPropertyValue(PropertyName); + if (AnyConverter.isArray(oObject)) + { + return getArrayValue(oObject); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + return null; + } + + public static Object getUnoStructValue(Object oUnoObject, String PropertyName) + { + try + { + if (oUnoObject != null) + { + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oUnoObject); + if (xPSet.getPropertySetInfo().hasPropertyByName(PropertyName)) + { + return xPSet.getPropertyValue(PropertyName); + } + } + return null; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public static void setUnoPropertyValues(Object oUnoObject, String[] PropertyNames, Object[] PropertyValues) + { + try + { + com.sun.star.beans.XMultiPropertySet xMultiPSetLst = UnoRuntime.queryInterface(com.sun.star.beans.XMultiPropertySet.class, oUnoObject); + if (xMultiPSetLst != null) + { + xMultiPSetLst.setPropertyValues(PropertyNames, PropertyValues); + } + else + { + for (int i = 0; i < PropertyNames.length; i++) + { + setUnoPropertyValue(oUnoObject, PropertyNames[i], PropertyValues[i]); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + /** + * checks if the value of an object that represents an array is null. + * check beforehand if the Object is really an array with "AnyConverter.IsArray(oObject) + * @param oValue the parameter that has to represent an object + * @return a null reference if the array is empty + */ + private static Object getArrayValue(Object oValue) + { + try + { + Object oPropList = com.sun.star.uno.AnyConverter.toArray(oValue); + int nlen = java.lang.reflect.Array.getLength(oPropList); + if (nlen == 0) + { + return null; + } + else + { + return oPropList; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public static XComponentContext getComponentContext(XMultiServiceFactory _xMSF) + { + // Get the path to the extension and try to add the path to the class loader + final XPropertySet xProps = UnoRuntime.queryInterface(XPropertySet.class, _xMSF); + final PropertySetHelper aHelper = new PropertySetHelper(xProps); + final Object aDefaultContext = aHelper.getPropertyValueAsObject("DefaultContext"); + return UnoRuntime.queryInterface(XComponentContext.class, aDefaultContext); + } + + public static XMacroExpander getMacroExpander(XMultiServiceFactory _xMSF) + { + final XComponentContext xComponentContext = getComponentContext(_xMSF); + final Object aSingleton = xComponentContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander"); + return UnoRuntime.queryInterface(XMacroExpander.class, aSingleton); + } +} diff --git a/wizards/com/sun/star/wizards/common/IRenderer.java b/wizards/com/sun/star/wizards/common/IRenderer.java new file mode 100644 index 0000000000..c704ed6f49 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/IRenderer.java @@ -0,0 +1,30 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +/** + * A General interface which gives a string + * that represents the rendered argument object. + * Can be used to reference resources, internationalizartion + * a.s.o + */ +public interface IRenderer +{ + + String render(Object object); +} diff --git a/wizards/com/sun/star/wizards/common/IRenderer.py b/wizards/com/sun/star/wizards/common/IRenderer.py new file mode 100644 index 0000000000..6086665f4d --- /dev/null +++ b/wizards/com/sun/star/wizards/common/IRenderer.py @@ -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 diff --git a/wizards/com/sun/star/wizards/common/InvalidQueryException.java b/wizards/com/sun/star/wizards/common/InvalidQueryException.java new file mode 100644 index 0000000000..a4ac8f90a1 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/InvalidQueryException.java @@ -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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.lang.XMultiServiceFactory; + +public class InvalidQueryException extends java.lang.Throwable +{ + // TODO don't show messages in Exceptions + public InvalidQueryException(XMultiServiceFactory xMSF, String sCommand) + { + SystemDialog.showErrorBox(xMSF, "RID_REPORT_65", "<STATEMENT>", sCommand); // Querycreationnotpossible + } + // TODO don't show messages in Exceptions + public InvalidQueryException(XMultiServiceFactory xMSF, String sCommand, Throwable cause) + { + super(cause); + SystemDialog.showErrorBox(xMSF, "RID_REPORT_65", "<STATEMENT>", sCommand); // Querycreationnotpossible + } +} diff --git a/wizards/com/sun/star/wizards/common/JavaTools.java b/wizards/com/sun/star/wizards/common/JavaTools.java new file mode 100644 index 0000000000..65bb3f6448 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/JavaTools.java @@ -0,0 +1,538 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.beans.PropertyValue; +import java.util.*; +import java.io.File; + +import com.sun.star.lib.util.UrlToFileMapper; +import java.net.MalformedURLException; +import java.net.URL; + +public class JavaTools +{ + + public static String[] ArrayOutOfMultiDimArray(String _sMultiDimArray[][], int _index) + { + String[] sRetArray = null; + if (_sMultiDimArray != null) + { + sRetArray = new String[_sMultiDimArray.length]; + for (int i = 0; i < _sMultiDimArray.length; i++) + { + sRetArray[i] = _sMultiDimArray[i][_index]; + } + } + return sRetArray; + } + + /**converts a list of Integer values included in an Integer vector to a list of int values + */ + public static int[] IntegerTointList(java.util.List<Integer> _aIntegerVector) + { + int[] nintValues = null; + if (_aIntegerVector.size() > 0) { + int i = 0; + nintValues = new int[_aIntegerVector.size()]; + for (Integer nIntegerValue : _aIntegerVector) { + nintValues[i++] = nIntegerValue.intValue(); + } + } + return nintValues; + } + + /**converts a list of Boolean values included in a Boolean vector to a list of boolean values + */ + public static boolean[] BooleanTobooleanList(java.util.List<Boolean> _aBooleanVector) + { + boolean[] bbooleanValues = null; + if (_aBooleanVector.size() > 0) { + int i = 0; + bbooleanValues = new boolean[_aBooleanVector.size()]; + for (Boolean bBooleanValue : _aBooleanVector) { + bbooleanValues[i++] = bBooleanValue.booleanValue(); + } + } + return bbooleanValues; + } + + public static String getlongestArrayItem(String[] StringArray) + { + String sLongestItem = PropertyNames.EMPTY_STRING; + int iCurLength; + int iOldLength = 0; + for (String str : StringArray) + { + iCurLength = str.length(); + if (iCurLength > iOldLength) + { + iOldLength = iCurLength; + sLongestItem = str; + } + } + return sLongestItem; + } + + public static String ArraytoString(String[] LocArray) + { + StringBuilder ResultString = new StringBuilder(PropertyNames.EMPTY_STRING); + boolean bActive = false; + for (String str : LocArray) { + if (bActive) { + ResultString.append(PropertyNames.SEMI_COLON); + } else { + bActive = true; + } + ResultString.append(str); + } + return ResultString.toString(); + } + + /** + * @return the index of the field that contains the string 'SearchString' or '-1' if not it is + * not contained within the array + */ + public static int FieldInList(String[] SearchList, String SearchString) { + int retvalue = -1; + for (int i = 0; i < SearchList.length; i++) { + if (SearchList[i].equals(SearchString)) { + retvalue = i; + break; + } + } + return retvalue; + } + + public static int FieldInTable(String[][] SearchList, String SearchString) + { + int retvalue = -1; + if (SearchList != null) { + int FieldLen = SearchList.length; + if (FieldLen > 0) { + for (int i = 0; i < FieldLen; i++) { + if (SearchList[i][0] != null && SearchList[i][0].equals(SearchString)) { + retvalue = i; + break; + } + } + } + } + return retvalue; + } + + public static int FieldInIntTable(int[][] SearchList, int SearchValue) + { + int retvalue = -1; + for (int i = 0; i < SearchList.length; i++) + { + if (SearchList[i][0] == SearchValue) + { + retvalue = i; + break; + } + } + return retvalue; + } + + public static int FieldInIntTable(int[] SearchList, int SearchValue, int _startindex) + { + int retvalue = -1; + for (int i = _startindex; i < SearchList.length; i++) + { + if (SearchList[i] == SearchValue) + { + retvalue = i; + break; + } + } + return retvalue; + } + + public static int FieldInIntTable(int[] SearchList, int SearchValue) + { + return FieldInIntTable(SearchList, SearchValue, 0); + } + + public static int getArraylength(Object[] MyArray) + { + int FieldCount = 0; + if (MyArray != null) + { + FieldCount = MyArray.length; + } + return FieldCount; + } + + /** + * This function bubble sorts an array of with 2 dimensions. + * The default sorting order is the first dimension + * Only if sort2ndValue is True the second dimension is the relevant for the sorting order + */ + public static String[][] bubblesortList(String[][] SortList) + { + String DisplayDummy; + int SortCount = SortList[0].length; + int DimCount = SortList.length; + for (int s = 0; s < SortCount; s++) + { + for (int t = 0; t < SortCount - s - 1; t++) + { + if (SortList[0][t].compareTo(SortList[0][t + 1]) > 0) + { + for (int k = 0; k < DimCount; k++) + { + DisplayDummy = SortList[k][t]; + SortList[k][t] = SortList[k][t + 1]; + SortList[k][t + 1] = DisplayDummy; + } + } + } + } + return SortList; + } + + public static String[] ArrayoutofString(String MainString, String Token) + { + String[] StringArray; + if (!MainString.equals(PropertyNames.EMPTY_STRING)) + { + ArrayList<String> StringVector = new ArrayList<String>(); + int iIndex; + do + { + iIndex = MainString.indexOf(Token); + if (iIndex < 0) + { + StringVector.add(MainString); + } + else + { + StringVector.add(MainString.substring(0, iIndex)); + MainString = MainString.substring(iIndex + 1, MainString.length()); + } + } + while (iIndex >= 0); + int FieldCount = StringVector.size(); + StringArray = new String[FieldCount]; + StringVector.toArray(StringArray); + } + else + { + StringArray = new String[0]; + } + return StringArray; + } + + public static String replaceSubString(String MainString, String NewSubString, String OldSubString) + { + try + { + int NewIndex = 0; + int OldIndex = 0; + int NewSubLen = NewSubString.length(); + int OldSubLen = OldSubString.length(); + while (NewIndex != -1) + { + NewIndex = MainString.indexOf(OldSubString, OldIndex); + if (NewIndex != -1) + { + MainString = MainString.substring(0, NewIndex) + NewSubString + MainString.substring(NewIndex + OldSubLen); + OldIndex = NewIndex + NewSubLen; + } + } + return MainString; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public static String convertfromURLNotation(String _sURLPath) + { + String sPath = PropertyNames.EMPTY_STRING; + try + { + URL oJavaURL = new URL(_sURLPath); + File oFile = UrlToFileMapper.mapUrlToFile(oJavaURL); + sPath = oFile.getAbsolutePath(); + } + catch (MalformedURLException e) + { + e.printStackTrace(System.err); + } + return sPath; + } + + public static String[] removeOutdatedFields(String[] baselist, String[] _complist) + { + String[] retarray = new String[] + { + }; + if ((baselist != null) && (_complist != null)) + { + ArrayList<String> retvector = new ArrayList<String>(); + for (int i = 0; i < baselist.length; i++) + { + if (FieldInList(_complist, baselist[i]) > -1) + { + retvector.add(baselist[i]); + // here you could call the method of a defined interface to notify the calling method + } + } + retarray = new String[retvector.size()]; + retvector.toArray(retarray); + } + return retarray; + } + + public static String[][] removeOutdatedFields(String[][] baselist, String[] _complist, int _compindex) + { + String[][] retarray = new String[][] {}; + if ((baselist != null) && (_complist != null)) + { + if (baselist.length > 0) + { + ArrayList<String[]> retvector = new ArrayList<String[]>(); + for (int i = 0; i < baselist.length; i++) + { + String sValue = baselist[i][_compindex]; + if (FieldInList(_complist, sValue) != -1) + { + retvector.add(baselist[i]); + // here you could call the method of a defined interface to notify the calling method + } + } + retarray = new String[retvector.size()][2]; + retvector.toArray(retarray); + } + } + return retarray; + } + + public static String[][] removeOutdatedFields(String[][] baselist, String[] _complist) + { + return removeOutdatedFields(baselist, _complist, 0); + } + + public static PropertyValue[][] removeOutdatedFields(PropertyValue[][] baselist, String[] _complist) + { + if ((baselist != null) && (_complist != null)) + { + ArrayList<PropertyValue[]> firstdimvector = new ArrayList<PropertyValue[]>(); + for (int n = 0; n < baselist.length; n++) + { + ArrayList<PropertyValue> secdimvector = new ArrayList<PropertyValue>(); + for (int m = 0; m < baselist[n].length; m++) + { + if (FieldInList(_complist, baselist[n][m].Name) > -1) + { + secdimvector.add(baselist[n][m]); + } + } + if (!secdimvector.isEmpty()) + { + PropertyValue[] internalArray = new PropertyValue[secdimvector.size()]; + secdimvector.toArray(internalArray); + firstdimvector.add(internalArray); + } + } + PropertyValue[][] retarray = new PropertyValue[firstdimvector.size()][]; + return firstdimvector.toArray(retarray); + } + return new PropertyValue[][] + { + }; + } + + /** + * searches a multidimensional array for duplicate fields. According to the following example + * SlaveFieldName1 ;SlaveFieldName2; SlaveFieldName3 + * MasterFieldName1;MasterFieldName2;MasterFieldName3 + * The entries SlaveFieldNameX and MasterFieldNameX are grouped together and then the created groups are compared + * If a group is duplicate the entry of the second group is returned. + */ + public static int getDuplicateFieldIndex(String[][] _scomplist) + { + int retvalue = -1; + if (_scomplist.length > 0) + { + int fieldcount = _scomplist[0].length; + String[] sDescList = new String[fieldcount]; + for (int m = 0; m < fieldcount; m++) + { + for (int n = 0; n < _scomplist.length; n++) + { + if (n == 0) + { + sDescList[m] = ""; + } + sDescList[m] += _scomplist[n][m]; + } + } + return getDuplicateFieldIndex(sDescList); + } + return retvalue; + } + + /** + * not tested!!!!! + */ + public static int getDuplicateFieldIndex(String[] scomplist) + { + for (int n = 0; n < scomplist.length; n++) + { + String scurvalue = scomplist[n]; + for (int m = n; m < scomplist.length; m++) + { + if (m != n) + { + if (scurvalue.equals(scomplist[m])) + { + return m; + } + } + } + } + return -1; + } + + public static int getDuplicateFieldIndex(String[] _scomplist, String _fieldname) + { + int iduplicate = 0; + for (int n = 0; n < _scomplist.length; n++) + { + if (_scomplist[n].equals(_fieldname)) + { + iduplicate++; + if (iduplicate == 2) + { + return n; + } + } + } + return -1; + } + + private static boolean isEqual(PropertyValue firstPropValue, PropertyValue secPropValue) + { + if (!firstPropValue.Name.equals(secPropValue.Name)) + { + return false; + //TODO replace 'equals' with AnyConverter.getType(firstpropValue).equals(secPropValue) to check content and Type + } + if (!firstPropValue.Value.equals(secPropValue.Value)) + { + return false; + } + return (firstPropValue.Handle == secPropValue.Handle); + } + + public static int[] getDuplicateFieldIndex(PropertyValue[][] ocomplist) + { + for (int n = 0; n < ocomplist.length; n++) + { + PropertyValue[] ocurValue = ocomplist[n]; + for (int m = n; m < ocurValue.length; m++) + { + PropertyValue odetValue = ocurValue[m]; + for (int s = 0; s < ocurValue.length; s++) + { + if (s != m) + { + if (isEqual(odetValue, ocurValue[s])) + { + return new int[] + { + n, s + }; + } + } + } + } + } + return new int[] + { + -1, -1 + }; + } + + public static String getSuffixNumber(String _sbasestring) + { + int suffixcharcount = 0; + for (int i = _sbasestring.length() - 1; i >= 0; i--) + { + char b = _sbasestring.charAt(i); + if ((b >= '0') && (b <= '9')) + { + suffixcharcount++; + } + else + { + break; + } + } + int istart = _sbasestring.length() - suffixcharcount; + return _sbasestring.substring(istart, _sbasestring.length()); + } + + public static String[] removefromList(String[] _sbaselist, String[] _sdellist) { + ArrayList<String> tempbaselist = new ArrayList<String>(); + for (String _sbase : _sbaselist) { + if (FieldInList(_sdellist, _sbase) == -1) { + tempbaselist.add(_sbase); + } + } + String[] sretlist = new String[tempbaselist.size()]; + tempbaselist.toArray(sretlist); + return sretlist; + } + + /** + * compares two strings. If one of them is empty and the other one is null it also returns true + */ + public static boolean isSame(String sFirstString, String sSecondString) + { + boolean bissame = false; + if (sFirstString == null) + { + if (sSecondString != null) + { + bissame = sSecondString.equals(PropertyNames.EMPTY_STRING); + } + else + { + bissame = true; + } + } + else + { + if (sFirstString.equals(PropertyNames.EMPTY_STRING)) + { + bissame = (sSecondString == null); + } + else if (sSecondString != null) + { + bissame = sFirstString.equals(sSecondString); + } + } + return bissame; + } +} diff --git a/wizards/com/sun/star/wizards/common/ListModel.py b/wizards/com/sun/star/wizards/common/ListModel.py new file mode 100644 index 0000000000..e0eaf5de3c --- /dev/null +++ b/wizards/com/sun/star/wizards/common/ListModel.py @@ -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 diff --git a/wizards/com/sun/star/wizards/common/MANIFEST.MF b/wizards/com/sun/star/wizards/common/MANIFEST.MF new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/MANIFEST.MF diff --git a/wizards/com/sun/star/wizards/common/NamedValueCollection.java b/wizards/com/sun/star/wizards/common/NamedValueCollection.java new file mode 100644 index 0000000000..32cc0cd80d --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NamedValueCollection.java @@ -0,0 +1,79 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.common; + +import com.sun.star.beans.PropertyState; +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +public class NamedValueCollection +{ + final private HashMap< String, Object > m_values = new HashMap< String, Object >(); + + public NamedValueCollection() + { + } + + public NamedValueCollection( final PropertyValue[] i_values ) + { + for ( int i = 0; i < i_values.length; ++i ) + m_values.put( i_values[i].Name, i_values[i].Value ); + } + + public final void put( final String i_name, final Object i_value ) + { + m_values.put( i_name, i_value ); + } + + + + public final < T extends XInterface > T queryOrDefault( final String i_key, final T i_default, Class<T> i_interfaceClass ) + { + if ( m_values.containsKey( i_key ) ) + { + final Object value = m_values.get( i_key ); + return UnoRuntime.queryInterface( i_interfaceClass, value ); + } + return i_default; + } + + public final PropertyValue[] getPropertyValues() + { + PropertyValue[] values = new PropertyValue[ m_values.size() ]; + + Iterator< Entry< String, Object > > iter = m_values.entrySet().iterator(); + int i = 0; + while ( iter.hasNext() ) + { + Entry< String, Object > entry = iter.next(); + values[i++] = new PropertyValue( + entry.getKey(), + 0, + entry.getValue(), + PropertyState.DIRECT_VALUE + ); + } + + return values; + } +} diff --git a/wizards/com/sun/star/wizards/common/NoValidPathException.java b/wizards/com/sun/star/wizards/common/NoValidPathException.java new file mode 100644 index 0000000000..3dd465953b --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NoValidPathException.java @@ -0,0 +1,44 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.common; + +import com.sun.star.lang.XMultiServiceFactory; + +public class NoValidPathException extends Exception +{ + public NoValidPathException(XMultiServiceFactory xMSF, String _sText) + { + super(_sText); + // TODO: NEVER open a dialog in an exception + if (xMSF != null) + { + SystemDialog.showErrorBox(xMSF, "RID_COMMON_21"); // OfficePathnotavailable + } + } + + public NoValidPathException(XMultiServiceFactory xMSF, String _sText, Throwable cause) + { + super(_sText, cause); + // TODO: NEVER open a dialog in an exception + if (xMSF != null) + { + SystemDialog.showErrorBox(xMSF, "RID_COMMON_21"); // OfficePathnotavailable + } + } +} diff --git a/wizards/com/sun/star/wizards/common/NoValidPathException.py b/wizards/com/sun/star/wizards/common/NoValidPathException.py new file mode 100644 index 0000000000..565f67fefc --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NoValidPathException.py @@ -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 + diff --git a/wizards/com/sun/star/wizards/common/NumberFormatter.java b/wizards/com/sun/star/wizards/common/NumberFormatter.java new file mode 100644 index 0000000000..b2220e1cca --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NumberFormatter.java @@ -0,0 +1,266 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.common; + +import java.util.Date; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.Locale; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.NumberFormat; +import com.sun.star.util.XNumberFormatTypes; +import com.sun.star.util.XNumberFormats; +import com.sun.star.util.XNumberFormatsSupplier; +import com.sun.star.util.XNumberFormatter; + + +public class NumberFormatter +{ + + private int iDateFormatKey = -1; + private int iDateTimeFormatKey = -1; + private int iNumberFormatKey = -1; + private int iTextFormatKey = -1; + private int iTimeFormatKey = -1; + private int iLogicalFormatKey = -1; + private long lDateCorrection; + private XNumberFormatter xNumberFormatter; + private XNumberFormats xNumberFormats; + private XNumberFormatTypes xNumberFormatTypes; + private XPropertySet xNumberFormatSettings; + private final Locale aLocale; + static private final Locale enLocale = new Locale( "en", "US", "" ); + + + public NumberFormatter(XMultiServiceFactory _xMSF, XNumberFormatsSupplier _xNumberFormatsSupplier, Locale _aLocale) throws Exception + { + aLocale = _aLocale; + Object oNumberFormatter = _xMSF.createInstance("com.sun.star.util.NumberFormatter"); + xNumberFormats = _xNumberFormatsSupplier.getNumberFormats(); + xNumberFormatSettings = _xNumberFormatsSupplier.getNumberFormatSettings(); + xNumberFormatter = UnoRuntime.queryInterface(XNumberFormatter.class, oNumberFormatter); + xNumberFormatter.attachNumberFormatsSupplier(_xNumberFormatsSupplier); + xNumberFormatTypes = UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats); + + } + + public NumberFormatter(XNumberFormatsSupplier _xNumberFormatsSupplier, Locale _aLocale) throws Exception + { + aLocale = _aLocale; + xNumberFormats = _xNumberFormatsSupplier.getNumberFormats(); + xNumberFormatSettings = _xNumberFormatsSupplier.getNumberFormatSettings(); + xNumberFormatTypes = UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats); + } + + + public double convertStringToNumber(int _nkey, String _sString)throws Exception + { + return xNumberFormatter.convertStringToNumber(_nkey, _sString); + } + + + /** + * @param dateCorrection The lDateCorrection to set. + */ + public void setNullDateCorrection(long dateCorrection) + { + lDateCorrection = dateCorrection; + } + + + public int defineNumberFormat(String _FormatString) + { + try + { + int NewFormatKey = xNumberFormats.queryKey(_FormatString, aLocale, true); + if (NewFormatKey == -1) + { + NewFormatKey = xNumberFormats.addNewConverted(_FormatString, enLocale, aLocale); + } + return NewFormatKey; + } + catch (Exception e) + { + e.printStackTrace(System.err); + return -1; + } + } + + + /** + * returns a numberformat for a FormatString. + */ + private int defineNumberFormat(String _FormatString, Locale _aLocale) + { + try + { + int NewFormatKey = xNumberFormats.queryKey(_FormatString, _aLocale, true); + if (NewFormatKey == -1) + { + NewFormatKey = xNumberFormats.addNew(_FormatString, _aLocale); + } + return NewFormatKey; + } + catch (Exception e) + { + e.printStackTrace(System.err); + return -1; + } + } + + + + public void setNumberFormat(XInterface _xFormatObject, int _FormatKey, NumberFormatter _oNumberFormatter) + { + try + { + XPropertySet xNumberFormat = _oNumberFormatter.xNumberFormats.getByKey(_FormatKey); + String FormatString = AnyConverter.toString(Helper.getUnoPropertyValue(xNumberFormat, "FormatString")); + Locale oLocale = (Locale) Helper.getUnoPropertyValue(xNumberFormat, "Locale"); + int NewFormatKey = defineNumberFormat(FormatString, oLocale); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, _xFormatObject); + if (xPSet.getPropertySetInfo().hasPropertyByName("FormatsSupplier")) + { + xPSet.setPropertyValue("FormatsSupplier", _oNumberFormatter.xNumberFormatter.getNumberFormatsSupplier()); + } + if (xPSet.getPropertySetInfo().hasPropertyByName("NumberFormat")) + { + xPSet.setPropertyValue("NumberFormat", Integer.valueOf(NewFormatKey)); + } + else if (xPSet.getPropertySetInfo().hasPropertyByName("FormatKey")) + { + xPSet.setPropertyValue("FormatKey", Integer.valueOf(NewFormatKey)); + } + else + { + // TODO: throws an exception in a try catch environment, very helpful? + throw new Exception(); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + + public long getNullDateCorrection() + { + com.sun.star.util.Date dNullDate = (com.sun.star.util.Date) Helper.getUnoStructValue(this.xNumberFormatSettings, "NullDate"); + long lNullDate = Helper.convertUnoDatetoInteger(dNullDate); + java.util.Calendar oCal = java.util.Calendar.getInstance(); + oCal.set(1900, 1, 1); + Date dTime = oCal.getTime(); + long lTime = dTime.getTime(); + long lDBNullDate = lTime / (3600 * 24000); + lDateCorrection = lDBNullDate - lNullDate; + return lDateCorrection; + } + + + public int setBooleanReportDisplayNumberFormat() + { + String FormatString = "[=1]" + '"' + (char)9745 + '"' + ";[=0]" + '"' + (char)58480 + '"' + ";0"; + iLogicalFormatKey = xNumberFormats.queryKey(FormatString, aLocale, true); + try + { + if (iLogicalFormatKey == -1) + { + iLogicalFormatKey = xNumberFormats.addNew(FormatString, aLocale); + } + } + catch (Exception e) + { //MalformedNumberFormat + e.printStackTrace(); + iLogicalFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.LOGICAL, aLocale); + } + return iLogicalFormatKey; + } + + + /** + * @return Returns the iDateFormatKey. + */ + public int getDateFormatKey() + { + if (iDateFormatKey == -1) + { + iDateFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.DATE, aLocale); + } + return iDateFormatKey; + } + /** + * @return Returns the iDateTimeFormatKey. + */ + public int getDateTimeFormatKey() + { + if (iDateTimeFormatKey == -1) + { + iDateTimeFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.DATETIME, aLocale); + } + return iDateTimeFormatKey; + } + /** + * @return Returns the iLogicalFormatKey. + */ + public int getLogicalFormatKey() + { + if (iLogicalFormatKey == -1) + { + iLogicalFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.LOGICAL, aLocale); + } + return iLogicalFormatKey; + } + /** + * @return Returns the iNumberFormatKey. + */ + public int getNumberFormatKey() + { + if (iNumberFormatKey == -1) + { + iNumberFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.NUMBER, aLocale); + } + return iNumberFormatKey; + } + /** + * @return Returns the iTextFormatKey. + */ + public int getTextFormatKey() + { + if (iTextFormatKey == -1) + { + iTextFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.TEXT, aLocale); + } + return iTextFormatKey; + } + /** + * @return Returns the iTimeFormatKey. + */ + public int getTimeFormatKey() + { + if (iTimeFormatKey == -1) + { + iTimeFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.TIME, aLocale); + } + return iTimeFormatKey; + } +} diff --git a/wizards/com/sun/star/wizards/common/NumberFormatter.py b/wizards/com/sun/star/wizards/common/NumberFormatter.py new file mode 100644 index 0000000000..54d84c9fc7 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NumberFormatter.py @@ -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) + diff --git a/wizards/com/sun/star/wizards/common/NumericalHelper.java b/wizards/com/sun/star/wizards/common/NumericalHelper.java new file mode 100644 index 0000000000..8a3ef43b21 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NumericalHelper.java @@ -0,0 +1,353 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.TypeClass; + +/** + * A class for helping with all kinds of numerical conversions. + * Optional or named parameters in SO are of the Object type in Java. + * These objects must be converted to the right simple value type. + * Unfortunately, StarBasic does not know the original desired type, + * and a value that should be a "Float" is delivered as "Byte". This class + * handles the conversions of these types.<br> + * This class does not log warnings (or throws Exceptions) when the precision + * of a value is lost. + */ +public class NumericalHelper +{ + + private static final int BYTE_TYPE = 0; + private static final int SHORT_TYPE = 1; + private static final int INT_TYPE = 2; + private static final int LONG_TYPE = 3; + private static final int FLOAT_TYPE = 4; + private static final int DOUBLE_TYPE = 5; + private static final int CHAR_TYPE = 6; + private static final int STRING_TYPE = -1; + private static final int BOOLEAN_TYPE = -2; + private static final int SEQUENCE_TYPE = -3; + + /** + * private c'tor to prevent instantiation + */ + private NumericalHelper() + { + // private c'tor, so no one can instantiate + } + + + + /** + * get an int value from the object + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static int toInt(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + int retValue = 0; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = getByte(aTypeObject); + break; + case CHAR_TYPE: + retValue = getChar(aTypeObject); + break; + case SHORT_TYPE: + retValue = getShort(aTypeObject); + break; + case INT_TYPE: + retValue = getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = (int) getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = (int) getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = (int) getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + retValue = Integer.parseInt((String) aTypeObject.aValue); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException(e, + "Cannot convert to int: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? -1 : 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get a double value from the object + * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted + */ + public static double toDouble(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + double retValue = 0.0; + TypeObject aTypeObject = getTypeObject(aValue); + switch (aTypeObject.iType) + { + case BYTE_TYPE: + retValue = getByte(aTypeObject); + break; + case CHAR_TYPE: + retValue = getChar(aTypeObject); + break; + case SHORT_TYPE: + retValue = getShort(aTypeObject); + break; + case INT_TYPE: + retValue = getInt(aTypeObject); + break; + case LONG_TYPE: + retValue = getLong(aTypeObject); + break; + case FLOAT_TYPE: + retValue = getFloat(aTypeObject); + break; + case DOUBLE_TYPE: + retValue = getDouble(aTypeObject); + break; + case STRING_TYPE: + try + { + retValue = Float.parseFloat((String) aTypeObject.aValue); + } + catch (java.lang.NumberFormatException e) + { + throw new com.sun.star.lang.IllegalArgumentException(e, + "Cannot convert to short: " + aTypeObject.aValue); + } + break; + case BOOLEAN_TYPE: + retValue = getBool(aTypeObject) ? (double) -1 : (double) 0; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return retValue; + } + + /** + * get the type object from the given object + * @param aValue an object representing a (numerical) value; can also be an 'any' + * @return a type object: the object together with the its type information + * @throws com.sun.star.lang.IllegalArgumentException if the object is unknown + */ + private static TypeObject getTypeObject(Object aValue) + throws com.sun.star.lang.IllegalArgumentException + { + TypeObject aTypeObject = new TypeObject(); + if (aValue == null || AnyConverter.isVoid(aValue)) + { + throw new com.sun.star.lang.IllegalArgumentException("Cannot convert a null object."); + } + int type = AnyConverter.getType(aValue).getTypeClass().getValue(); + switch (type) + { + case TypeClass.CHAR_value: + aTypeObject.iType = CHAR_TYPE; + aTypeObject.aValue = Character.valueOf(AnyConverter.toChar(aValue)); + break; + case TypeClass.BYTE_value: + aTypeObject.iType = BYTE_TYPE; + aTypeObject.aValue = Byte.valueOf(AnyConverter.toByte(aValue)); + break; + case TypeClass.SHORT_value: + aTypeObject.iType = SHORT_TYPE; + aTypeObject.aValue = Short.valueOf(AnyConverter.toShort(aValue)); + break; + case TypeClass.LONG_value: + aTypeObject.iType = INT_TYPE; + aTypeObject.aValue = Integer.valueOf(AnyConverter.toInt(aValue)); + break; + case TypeClass.HYPER_value: + aTypeObject.iType = LONG_TYPE; + aTypeObject.aValue = Long.valueOf(AnyConverter.toLong(aValue)); + break; + case TypeClass.FLOAT_value: + aTypeObject.iType = FLOAT_TYPE; + aTypeObject.aValue = Float.valueOf(AnyConverter.toFloat(aValue)); + break; + case TypeClass.DOUBLE_value: + aTypeObject.iType = DOUBLE_TYPE; + aTypeObject.aValue = Double.valueOf(AnyConverter.toDouble(aValue)); + break; + case TypeClass.STRING_value: + aTypeObject.iType = STRING_TYPE; + aTypeObject.aValue = AnyConverter.toString(aValue); + break; + case TypeClass.BOOLEAN_value: + aTypeObject.iType = BOOLEAN_TYPE; + aTypeObject.aValue = Boolean.valueOf(AnyConverter.toBoolean(aValue)); + break; + case TypeClass.SEQUENCE_value: + aTypeObject.iType = SEQUENCE_TYPE; + aTypeObject.aValue = aValue; + break; + default: + throw new com.sun.star.lang.IllegalArgumentException( + "Cannot convert this type: " + aValue.getClass().getName()); + } + return aTypeObject; + } + + /** + * get the simple byte type + */ + private static byte getByte(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != BYTE_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a byte type."); + } + return ((Byte) typeObject.aValue).byteValue(); + } + + /** + * get the simple char type + */ + private static char getChar(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != CHAR_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a char type."); + } + return ((Character) typeObject.aValue).charValue(); + } + + /** + * get the simple short type + */ + private static short getShort(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != SHORT_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a short type."); + } + return ((Short) typeObject.aValue).shortValue(); + } + + /** + * get the simple int type + * @param typeObject + * @return + * @throws com.sun.star.lang.IllegalArgumentException + */ + private static int getInt(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != INT_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not an int type."); + } + return ((Integer) typeObject.aValue).intValue(); + } + + /** + * get the simple float type + * @throws com.sun.star.lang.IllegalArgumentException + */ + private static float getFloat(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != FLOAT_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a float type."); + } + return ((Float) typeObject.aValue).floatValue(); + } + + /** + * get the simple double type + */ + private static double getDouble(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != DOUBLE_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a double type."); + } + return ((Double) typeObject.aValue).doubleValue(); + } + + /** + * get the simple long type + */ + private static long getLong(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != LONG_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a long type."); + } + return ((Long) typeObject.aValue).longValue(); + } + + /** + * get the simple boolean type + */ + private static boolean getBool(TypeObject typeObject) + throws com.sun.star.lang.IllegalArgumentException + { + if (typeObject.iType != BOOLEAN_TYPE) + { + throw new com.sun.star.lang.IllegalArgumentException( + "Given argument is not a boolean type."); + } + return ((Boolean) typeObject.aValue).booleanValue(); + } + + /** + * a class to contain a type and a value for easier conversions + */ + private static class TypeObject + { + + public int iType; + public Object aValue; + } + +} diff --git a/wizards/com/sun/star/wizards/common/ParaStyled.java b/wizards/com/sun/star/wizards/common/ParaStyled.java new file mode 100644 index 0000000000..6046571b7d --- /dev/null +++ b/wizards/com/sun/star/wizards/common/ParaStyled.java @@ -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 . + */ + +package com.sun.star.wizards.common; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.text.*; + +class ParaStyled +{ + + private String paraStyle; + + ParaStyled(String paraStyle_) + { + paraStyle = paraStyle_; + } + + private void format(Object textRange) + { + XText o; + o = UnoRuntime.queryInterface(XText.class, textRange); + if (o == null) + { + o = UnoRuntime.queryInterface(XTextRange.class, textRange).getText(); + } + XTextRange xtr = UnoRuntime.queryInterface(XTextRange.class, textRange); + XTextCursor cursor = o.createTextCursorByRange(xtr); + + Helper.setUnoPropertyValue(cursor, "ParaStyleName", paraStyle); + } + + public void write(Object textRange) + { + format(textRange); + } +} + diff --git a/wizards/com/sun/star/wizards/common/PlaceholderTextElement.java b/wizards/com/sun/star/wizards/common/PlaceholderTextElement.java new file mode 100644 index 0000000000..72778d5edc --- /dev/null +++ b/wizards/com/sun/star/wizards/common/PlaceholderTextElement.java @@ -0,0 +1,81 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.common; + +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.*; + +public class PlaceholderTextElement extends TextElement +{ + + private String hint; + private String placeHolderText; + private XMultiServiceFactory xmsf; + + public PlaceholderTextElement(XTextRange textRange, String placeHolderText_, String hint_, XMultiServiceFactory xmsf_) + { + super(textRange); + placeHolderText = placeHolderText_; + hint = hint_; + xmsf = xmsf_; + } + + @Override + public void write(Object textRange) + { + super.write(textRange); + if (text.equals(PropertyNames.EMPTY_STRING)) + { + XTextRange xTextRange = UnoRuntime.queryInterface(XTextRange.class, textRange); + try + { + XTextContent xTextContent = createPlaceHolder(xmsf, placeHolderText, hint); + xTextRange.getText().insertTextContent(xTextRange.getStart(), xTextContent, true); + } + catch (com.sun.star.lang.IllegalArgumentException ex) + { + ex.printStackTrace(); + } + } + } + + private static XTextContent createPlaceHolder(XMultiServiceFactory xmsf, String ph, String hint) + { + Object placeHolder; + try + { + placeHolder = xmsf.createInstance("com.sun.star.text.TextField.JumpEdit"); + } + catch (Exception ex) + { + ex.printStackTrace(); + return null; + } + Helper.setUnoPropertyValue(placeHolder, "PlaceHolder", ph); + Helper.setUnoPropertyValue(placeHolder, "Hint", hint); + Helper.setUnoPropertyValue(placeHolder, "PlaceHolderType", Short.valueOf(PlaceholderType.TEXT)); + return UnoRuntime.queryInterface(XTextContent.class, placeHolder); + + } + +} + + diff --git a/wizards/com/sun/star/wizards/common/Properties.java b/wizards/com/sun/star/wizards/common/Properties.java new file mode 100644 index 0000000000..2056921d36 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Properties.java @@ -0,0 +1,85 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.beans.PropertyValue; +import java.util.*; + +/** + * 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. + */ +public class Properties extends HashMap<String,Object> +{ + + public static Object getPropertyValue(PropertyValue[] props, String propName) + { + for (int i = 0; i < props.length; i++) + { + if (propName.equals(props[i].Name)) + { + return props[i].Value; + } + } + throw new IllegalArgumentException("Property '" + propName + "' not found."); + } + + public static boolean hasPropertyValue(PropertyValue[] props, String propName) + { + for (int i = 0; i < props.length; i++) + { + if (propName.equals(props[i].Name)) + { + return true; + } + } + return false; + } + + public static PropertyValue createProperty(String name, Object value) + { + PropertyValue pv = new PropertyValue(); + pv.Name = name; + pv.Value = value; + return pv; + } + + public static PropertyValue createProperty(String name, Object value, int handle) + { + PropertyValue pv = createProperty(name, value); + pv.Handle = handle; + return pv; + } + + public static PropertyValue[] convertToPropertyValueArray(Object[] _oObjectArray) + { + PropertyValue[] retproperties = null; + if (_oObjectArray != null && _oObjectArray.length > 0) + { + retproperties = new PropertyValue[_oObjectArray.length]; + for (int i = 0; i < _oObjectArray.length; i++) + { + retproperties[i] = (PropertyValue) _oObjectArray[i]; + } + } + return retproperties; + } +} diff --git a/wizards/com/sun/star/wizards/common/Properties.py b/wizards/com/sun/star/wizards/common/Properties.py new file mode 100644 index 0000000000..974856af6a --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Properties.py @@ -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) diff --git a/wizards/com/sun/star/wizards/common/PropertyNames.java b/wizards/com/sun/star/wizards/common/PropertyNames.java new file mode 100644 index 0000000000..5e5df5c879 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/PropertyNames.java @@ -0,0 +1,57 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +public class PropertyNames +{ + + public static String PROPERTY_DEFAULT_VALUE = "DefaultValue"; + public static String PROPERTY_IS_NULLABLE = "IsNullable"; + public static String PROPERTY_INPUT_REQUIRED = "InputRequired"; + public static String PROPERTY_ENABLED = "Enabled"; + public static String PROPERTY_HEIGHT = "Height"; + public static String PROPERTY_HELPURL = "HelpURL"; + public static String PROPERTY_POSITION_X = "PositionX"; + public static String PROPERTY_POSITION_Y = "PositionY"; + public static String PROPERTY_LABEL = "Label"; + public static String PROPERTY_MULTILINE = "MultiLine"; + public static String PROPERTY_NAME = "Name"; + public static String PROPERTY_STEP = "Step"; + public static String PROPERTY_WIDTH = "Width"; + public static String PROPERTY_TABINDEX = "TabIndex"; + public static String PROPERTY_STATE = "State"; + public static String PROPERTY_IMAGEURL = "ImageURL"; + public static String PROPERTY_TITLE = "Title"; + public static String PROPERTY_BORDER = "Border"; + public static String PROPERTY_MOVEABLE = "Moveable"; + public static String PROPERTY_ALIGN = "Align"; + public static String COMMAND = "Command"; + public static String COMMAND_TYPE = "CommandType"; + public static String SELECTED_ITEMS = "SelectedItems"; + public static String URL = "URL"; + public static String ACTIVE_CONNECTION = "ActiveConnection"; + public static String ASC = "ASC"; + public static String SEMI_COLON = ";"; + public static String EMPTY_STRING = ""; + public static String START = "start"; + public static String ORIENTATION = "Orientation"; + public static String READ_ONLY = "ReadOnly"; + public static String SPACE = " "; + public static String STRING_ITEM_LIST = "StringItemList"; + public static String FONT_DESCRIPTOR = "FontDescriptor"; +} diff --git a/wizards/com/sun/star/wizards/common/PropertyNames.py b/wizards/com/sun/star/wizards/common/PropertyNames.py new file mode 100644 index 0000000000..a78c08d29e --- /dev/null +++ b/wizards/com/sun/star/wizards/common/PropertyNames.py @@ -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" diff --git a/wizards/com/sun/star/wizards/common/PropertySetHelper.java b/wizards/com/sun/star/wizards/common/PropertySetHelper.java new file mode 100644 index 0000000000..7de45668eb --- /dev/null +++ b/wizards/com/sun/star/wizards/common/PropertySetHelper.java @@ -0,0 +1,257 @@ +/* + * 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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.beans.XPropertySet; +import com.sun.star.uno.AnyConverter; +import java.util.HashMap; + +public class PropertySetHelper +{ + + private XPropertySet m_xPropertySet; + private HashMap<String, Object> m_aHashMap; + + public PropertySetHelper(Object _aObj) + { + if (_aObj == null) + { + return; + } + m_xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _aObj); + } + + private HashMap<String, Object> getHashMap() + { + if (m_aHashMap == null) + { + m_aHashMap = new HashMap<String, Object>(); + } + return m_aHashMap; + } + + /** + set a property, don't throw any exceptions, they will only write down as a hint in the helper debug output + @param _sName name of the property to set + @param _aValue property value as object + */ + public void setPropertyValueDontThrow(String _sName, Object _aValue) + { + try + { + setPropertyValue(_sName, _aValue); + } + catch (Exception e) + { + DebugHelper.writeInfo("Don't throw the exception with property name(" + _sName + " ) : " + e.getMessage()); + } + } + + /** + set a property, + @param _sName name of the property to set + @param _aValue property value as object + */ + private void setPropertyValue(String _sName, Object _aValue) throws java.lang.Exception + { + if (m_xPropertySet != null) + { + try + { + m_xPropertySet.setPropertyValue(_sName, _aValue); + } + // Exceptions are not from interest + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + DebugHelper.exception(e); + } + catch (com.sun.star.beans.PropertyVetoException e) + { + DebugHelper.writeInfo(e.getMessage()); + DebugHelper.exception(e); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + DebugHelper.exception(e); + } + } + else + { + getHashMap().put(_sName, _aValue); + } + } + + /** + get a property and convert it to a int value + @param _sName the string name of the property + @param _nDefault if an error occur, return this value + @return the int value of the property + */ + public int getPropertyValueAsInteger(String _sName, int _nDefault) + { + Object aObject = null; + int nValue = _nDefault; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + if (aObject != null) + { + try + { + nValue = NumericalHelper.toInt(aObject); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo("can't convert an object to integer."); + } + } + return nValue; + } + + + + /** + get a property and convert it to a double value + @param _sName the string name of the property + @param _nDefault if an error occur, return this value + @return the int value of the property + */ + public double getPropertyValueAsDouble(String _sName, double _nDefault) + { + Object aObject = null; + double nValue = _nDefault; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + if (aObject == null && getHashMap().containsKey(_sName)) + { + aObject = getHashMap().get(_sName); + } + if (aObject != null) + { + try + { + nValue = NumericalHelper.toDouble(aObject); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo("can't convert an object to integer."); + } + } + return nValue; + } + + + + /** + get a property and convert it to a string value + @param _sName the string name of the property + @param _sDefault if an error occur, return this value + @return the string value of the property + */ + public String getPropertyValueAsString(String _sName, String _sDefault) + { + Object aObject = null; + String sValue = _sDefault; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + if (aObject != null) + { + try + { + sValue = AnyConverter.toString(aObject); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + DebugHelper.writeInfo("can't convert an object to string."); + } + } + return sValue; + } + + /** + get a property and don't convert it + @param _sName the string name of the property + @return the object value of the property without any conversion + */ + public Object getPropertyValueAsObject(String _sName) + { + Object aObject = null; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + DebugHelper.writeInfo(e.getMessage()); + } + } + return aObject; + } + +} diff --git a/wizards/com/sun/star/wizards/common/Resource.java b/wizards/com/sun/star/wizards/common/Resource.java new file mode 100644 index 0000000000..0da8f97566 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/Resource.java @@ -0,0 +1,68 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.common; + +import com.sun.star.beans.PropertyState; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.configuration.theDefaultProvider; +import com.sun.star.lang.Locale; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.resource.StringResourceWithLocation; +import com.sun.star.resource.XStringResourceWithLocation; +import com.sun.star.util.XMacroExpander; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; + +public final class Resource +{ + private XStringResourceWithLocation m_xStrResource; + + /** + * <p>Load the resource bundle that contains the resource {@code String} + * values.</p> + */ + public Resource(XMultiServiceFactory xMSF) { + XComponentContext xContext = Helper.getComponentContext(xMSF); + XMacroExpander xExpander = Helper.getMacroExpander(xMSF); + String sPath = xExpander.expandMacros("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/wizards/"); + Locale locale = Configuration.getUILocale(xMSF); + m_xStrResource = StringResourceWithLocation.create(xContext, sPath, true, locale, "resources", "", null); + } + + /** + * This method returns the corresponding {@code String} given the key. + * + * @param key Key string for getting the message {@code String}. + * @return Message {@code String} corresponding to the key. + */ + public String getResText(String key) { + return m_xStrResource.resolveString(key); + } + + public static void showCommonResourceError(XMultiServiceFactory xMSF) + { + String ProductName = Configuration.getProductName(xMSF); + String sError = "The files required could not be found.\nPlease start the %PRODUCTNAME Setup and choose 'Repair'."; + sError = JavaTools.replaceSubString(sError, ProductName, "%PRODUCTNAME"); + SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sError); + } +} diff --git a/wizards/com/sun/star/wizards/common/SystemDialog.java b/wizards/com/sun/star/wizards/common/SystemDialog.java new file mode 100644 index 0000000000..73be87b5aa --- /dev/null +++ b/wizards/com/sun/star/wizards/common/SystemDialog.java @@ -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 . + */ +package com.sun.star.wizards.common; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.XComponent; +import com.sun.star.frame.XFrame; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XMessageBox; + +public class SystemDialog +{ + + public static int showErrorBox(XMultiServiceFactory xMSF, String ResID, String AddTag, String AddString) + { + Resource oResource; + String ProductName = Configuration.getProductName(xMSF); + oResource = new Resource(xMSF); + String sErrorMessage = oResource.getResText(ResID); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, ProductName, "%PRODUCTNAME"); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, String.valueOf((char) 13), "<BR>"); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, AddString, AddTag); + return SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sErrorMessage); + } + + public static int showErrorBox(XMultiServiceFactory xMSF, String ResID) + { + Resource oResource; + String ProductName = Configuration.getProductName(xMSF); + oResource = new Resource(xMSF); + String sErrorMessage = oResource.getResText(ResID); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, ProductName, "%PRODUCTNAME"); + sErrorMessage = JavaTools.replaceSubString(sErrorMessage, String.valueOf((char) 13), "<BR>"); + return showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.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 ;-) + */ + public static int showMessageBox(XMultiServiceFactory xMSF, String windowServiceName, int windowAttribute, String MessageText) + { + + short iMessage = 0; + try + { + if (MessageText == null) + { + return 0; + } + XFrame xFrame = Desktop.getActiveFrame(xMSF); + XWindowPeer xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xFrame.getComponentWindow()); + return showMessageBox(xMSF, xWindowPeer, windowServiceName, windowAttribute, MessageText); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + return iMessage; + } + + /** + * just like the other showMessageBox(...) method, but receives a + * peer argument to use to create the message box. + */ + public static int showMessageBox(XMultiServiceFactory xMSF, XWindowPeer peer, String windowServiceName, int windowAttribute, String MessageText) + { + // If the peer is null we try to get one from the desktop... + if (peer == null) + { + return showMessageBox(xMSF, windowServiceName, windowAttribute, MessageText); + } + short iMessage = 0; + try + { + XInterface xAWTToolkit = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit"); + XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, xAWTToolkit); + com.sun.star.awt.WindowDescriptor oDescriptor = new com.sun.star.awt.WindowDescriptor(); + oDescriptor.WindowServiceName = windowServiceName; + oDescriptor.Parent = peer; + oDescriptor.Type = com.sun.star.awt.WindowClass.MODALTOP; + oDescriptor.WindowAttributes = windowAttribute; + XWindowPeer xMsgPeer = xToolkit.createWindow(oDescriptor); + XMessageBox xMsgbox = UnoRuntime.queryInterface(XMessageBox.class, xMsgPeer); + XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, xMsgbox); + xMsgbox.setMessageText(MessageText); + iMessage = xMsgbox.execute(); + xComponent.dispose(); + } + catch (Exception e) + { + // TODO Auto-generated catch block + e.printStackTrace(System.err); + } + return iMessage; + } + +} diff --git a/wizards/com/sun/star/wizards/common/SystemDialog.py b/wizards/com/sun/star/wizards/common/SystemDialog.py new file mode 100644 index 0000000000..4120292130 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/SystemDialog.py @@ -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 diff --git a/wizards/com/sun/star/wizards/common/TextElement.java b/wizards/com/sun/star/wizards/common/TextElement.java new file mode 100644 index 0000000000..a8ee641e1d --- /dev/null +++ b/wizards/com/sun/star/wizards/common/TextElement.java @@ -0,0 +1,54 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.common; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.text.*; + +public class TextElement extends ParaStyled +{ + + String text; + + TextElement(XTextRange range) + { + this(range.getString(), (String) Helper.getUnoPropertyValue(range.getStart(), "ParaStyleName")); + } + + private TextElement(String text_, String paraStyle_) + { + super(paraStyle_); + text = text_; + } + + @Override + public void write(Object textRange) + { + UnoRuntime.queryInterface(XTextRange.class, textRange).setString(text); + if (!text.equals(PropertyNames.EMPTY_STRING)) + { + super.write(textRange); + } + } + + public void setText(String inputText) + { + text = inputText; + } +} diff --git a/wizards/com/sun/star/wizards/common/UCB.py b/wizards/com/sun/star/wizards/common/UCB.py new file mode 100644 index 0000000000..1e52e48613 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/UCB.py @@ -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 + diff --git a/wizards/com/sun/star/wizards/common/__init__.py b/wizards/com/sun/star/wizards/common/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/common/__init__.py diff --git a/wizards/com/sun/star/wizards/common/strings.hrc b/wizards/com/sun/star/wizards/common/strings.hrc new file mode 100644 index 0000000000..d176df485b --- /dev/null +++ b/wizards/com/sun/star/wizards/common/strings.hrc @@ -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: diff --git a/wizards/com/sun/star/wizards/db/BlindtextCreator.java b/wizards/com/sun/star/wizards/db/BlindtextCreator.java new file mode 100644 index 0000000000..0d79f457d6 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/BlindtextCreator.java @@ -0,0 +1,100 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; + +public class BlindtextCreator +{ + + private static final String BlindText = + "Ut wisi enim ad minim veniam, quis nostrud exerci tation " + "ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor " + "in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at " + "vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore " + "te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy " + "nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, " + "quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. " + "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum " + "dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent " + "luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis " + "eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum."; + + public static String adjustBlindTextlength(String FieldTitle, int FieldWidth, boolean bIsCurLandscape, boolean bIsGroupTable, String[] _RecordFieldNames) + { + String BlindTextString = PropertyNames.EMPTY_STRING; + if (bIsGroupTable) + { + return getBlindTextString(FieldTitle, FieldWidth); + } + int MaxFieldCount = getMaxFieldCount(bIsCurLandscape); + if (_RecordFieldNames.length <= 2 * MaxFieldCount) + { + if (_RecordFieldNames.length <= MaxFieldCount) + { + BlindTextString = getBlindTextString(FieldTitle, FieldWidth); + } + else + { + BlindTextString = getBlindTextString(FieldTitle, (int) (0.5 * FieldWidth)); + } + } + else + { + BlindTextString = getBlindTextString(FieldTitle, (int) 1.1 * FieldTitle.length()); + } + return BlindTextString; + } + + public static String getBlindTextString(String FieldTitle, int MaxWidth) + { + String[] BlindTextArray = JavaTools.ArrayoutofString(BlindText, PropertyNames.SPACE); + String PartBlindText = BlindTextArray[0]; + String NewPartBlindText; + int MaxHeaderWidth; + int Titlelength = (int) 1.1 * FieldTitle.length(); // We assume that the TableHeading is bold + + if (Titlelength > PartBlindText.length()) + { + MaxHeaderWidth = Titlelength; + } + else + { + MaxHeaderWidth = PartBlindText.length(); + } + if (MaxHeaderWidth > MaxWidth) + { + MaxWidth = MaxHeaderWidth; + } + int i = 1; + do + { + NewPartBlindText = PartBlindText + PropertyNames.SPACE + BlindTextArray[i]; + if (NewPartBlindText.length() < MaxWidth) + { + PartBlindText = NewPartBlindText; + i += 1; + } + } + while (NewPartBlindText.length() < MaxWidth); + return PartBlindText; + } + + private static int getMaxFieldCount(boolean bIsCurLandscape) + { + if (bIsCurLandscape) + { + return 5; + } + else + { + return 3; + } + } +} diff --git a/wizards/com/sun/star/wizards/db/ColumnPropertySet.java b/wizards/com/sun/star/wizards/db/ColumnPropertySet.java new file mode 100644 index 0000000000..484dbf62fa --- /dev/null +++ b/wizards/com/sun/star/wizards/db/ColumnPropertySet.java @@ -0,0 +1,159 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.sdbc.DataType; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; + +public class ColumnPropertySet +{ + + private TypeInspector oTypeInspector; + public XPropertySet xPropertySet; + private int nType; + private String sTypeName = PropertyNames.EMPTY_STRING; + + public ColumnPropertySet(TypeInspector _oTypeInspector, XPropertySet _xPropertySet) + { + xPropertySet = _xPropertySet; + oTypeInspector = _oTypeInspector; + } + + private void assignPropertyValues(String _sNewName, PropertyValue[] _aNewColPropertyValues, boolean _bsetDefaultProperties) + { + try + { + nType = ((Integer) Properties.getPropertyValue(_aNewColPropertyValues, "Type")).intValue(); + nType = oTypeInspector.convertDataType(nType); + if (Properties.hasPropertyValue(_aNewColPropertyValues, "TypeName")) + { + sTypeName = (String) Properties.getPropertyValue(_aNewColPropertyValues, "TypeName"); + } + Integer precision = null; + if (Properties.hasPropertyValue(_aNewColPropertyValues, "Precision")) + { + precision = (Integer) Properties.getPropertyValue(_aNewColPropertyValues, "Precision"); + + } + if ((nType == DataType.VARCHAR) && (precision == null || precision.intValue() == 0)) + { + precision = 50; + } + if (precision != null) + { + xPropertySet.setPropertyValue("Precision", precision); + } + setType(sTypeName, precision); + for (int i = 0; i < _aNewColPropertyValues.length; i++) + { + String sPropName = _aNewColPropertyValues[i].Name; + if (_sNewName != null && sPropName.equals(PropertyNames.PROPERTY_NAME)) + { + xPropertySet.setPropertyValue(PropertyNames.PROPERTY_NAME, _sNewName); + } + else if (sPropName.equals("Precision")) + { + // do nothing, see above + } + else if ((!sPropName.equals("Type")) && (!sPropName.equals("TypeName"))) + { + Object oColValue = _aNewColPropertyValues[i].Value; + assignPropertyValue(sPropName, oColValue); + } + } + if (_bsetDefaultProperties) + { + assignPropertyValue("IsNullable", Integer.valueOf(oTypeInspector.isNullable(xPropertySet))); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + + } + + public void assignPropertyValues(PropertyValue[] _aNewColPropertyValues, boolean _bsetDefaultProperties) + { + assignPropertyValues(null /* don't change the name */, _aNewColPropertyValues, _bsetDefaultProperties); + } + + private void setType(String _sTypeName, Integer precision) + { + if (_sTypeName.equals(PropertyNames.EMPTY_STRING)) + { + sTypeName = oTypeInspector.getDefaultTypeName(nType, precision); + } + else + { + sTypeName = _sTypeName; + } + nType = oTypeInspector.getDataType(sTypeName); + assignPropertyValue("Type", Integer.valueOf(nType)); + assignPropertyValue("TypeName", sTypeName); + } + + private void assignPropertyValue(String _spropname, Object _oValue) + { + try + { + if (_spropname.equals("Type")) + { + nType = ((Integer) _oValue).intValue(); + xPropertySet.setPropertyValue("Type", Integer.valueOf(nType)); + } + else if (_spropname.equals(PropertyNames.PROPERTY_NAME)) + { + String sName = (String) _oValue; + if (!sName.equals(PropertyNames.EMPTY_STRING)) + { + xPropertySet.setPropertyValue(PropertyNames.PROPERTY_NAME, sName); + } + } + else if (_spropname.equals("Scale")) + { + int nScale = ((Integer) _oValue).intValue(); + nScale = oTypeInspector.getScale(xPropertySet); + xPropertySet.setPropertyValue("Scale", Integer.valueOf(nScale)); + } + else if (_spropname.equals("IsNullable")) + { + int nNullability = ((Integer) _oValue).intValue(); + nNullability = oTypeInspector.getNullability(xPropertySet, nNullability); + xPropertySet.setPropertyValue("IsNullable", Integer.valueOf(nNullability)); + } + else if (_spropname.equals("TypeName")) + { + String sTypeName = (String) _oValue; + xPropertySet.setPropertyValue("TypeName", sTypeName); + } + else + { + xPropertySet.setPropertyValue(_spropname, _oValue); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + +} diff --git a/wizards/com/sun/star/wizards/db/CommandMetaData.java b/wizards/com/sun/star/wizards/db/CommandMetaData.java new file mode 100644 index 0000000000..28180382f2 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/CommandMetaData.java @@ -0,0 +1,539 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.SQLException; +import com.sun.star.uno.AnyConverter; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class CommandMetaData extends DBMetaData +{ + + public Map<String, String> FieldTitleSet = new HashMap<String, String>(); + public String[] m_aAllFieldNames = new String[] + { + }; + public FieldColumn[] FieldColumns = new FieldColumn[] + { + }; + public String[] GroupFieldNames = new String[] + { + }; + private String[][] SortFieldNames = new String[][] + { + }; + private String[] RecordFieldNames = new String[] + { + }; + public String[][] AggregateFieldNames = new String[][] + { + }; + public String[] NumericFieldNames = new String[] + { + }; + public String[] NonAggregateFieldNames; + private int CommandType; + private String Command; + private String sIdentifierQuote = PropertyNames.EMPTY_STRING; + private boolean bCommandComposerAttributesalreadyRetrieved = false; + + public CommandMetaData(XMultiServiceFactory xMSF) + { + super(xMSF); + } + + public void initializeFieldColumns(String _CommandName, String[] _FieldNames) + { + this.setCommandName(_CommandName); + FieldColumns = new FieldColumn[_FieldNames.length]; + for (int i = 0; i < _FieldNames.length; i++) + { + FieldColumns[i] = new FieldColumn(this, _FieldNames[i], this.getCommandName(), false); + } + } + + public void initializeFieldColumns(String[] _FieldNames, XNameAccess _xColumns) + { + FieldColumns = new FieldColumn[_FieldNames.length]; + for (int i = 0; i < _FieldNames.length; i++) + { + FieldColumns[i] = new FieldColumn(this, _xColumns, _FieldNames[i]); + } + } + + public void initializeFieldColumns(String[] _FieldNames, String _CommandName) + { + this.setCommandName(_CommandName); + FieldColumns = new FieldColumn[_FieldNames.length]; + for (int i = 0; i < _FieldNames.length; i++) + { + FieldColumns[i] = new FieldColumn(this, _FieldNames[i], _CommandName, false); + if (FieldTitleSet != null && FieldTitleSet.containsKey(_FieldNames[i])) + { + FieldColumns[i].setFieldTitle(FieldTitleSet.get(_FieldNames[i])); + if (FieldColumns[i].getFieldTitle() == null) + { + FieldColumns[i].setFieldTitle(_FieldNames[i]); + FieldTitleSet.put(_FieldNames[i], _FieldNames[i]); + } + } + } + } + + public Map<String, String> getFieldTitleSet() + { + return FieldTitleSet; + } + + public XPropertySet getColumnObjectByFieldName(String _FieldName, boolean _bgetByDisplayName) + { + try + { + FieldColumn CurFieldColumn = null; + if (_bgetByDisplayName) + { + CurFieldColumn = this.getFieldColumnByDisplayName(_FieldName); + } + else + { + CurFieldColumn = this.getFieldColumnByFieldName(_FieldName); + } + String CurCommandName = CurFieldColumn.getCommandName(); + CommandObject oCommand = getTableByName(CurCommandName); + Object oColumn = oCommand.getColumns().getByName(CurFieldColumn.getFieldName()); + return UnoRuntime.queryInterface(XPropertySet.class, oColumn); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + // @SuppressWarnings("unchecked") + public void prependSortFieldNames(String[] _fieldnames) + { + ArrayList<String[]> aSortFields = new ArrayList<String[]>(); + for (int i = 0; i < _fieldnames.length; i++) + { + String[] sSortFieldName = new String[2]; + sSortFieldName[0] = _fieldnames[i]; + int index = JavaTools.FieldInTable(SortFieldNames, _fieldnames[i]); + if (index > -1) + { + sSortFieldName[1] = SortFieldNames[index][1]; + } + else + { + sSortFieldName[1] = PropertyNames.ASC; + } + aSortFields.add(sSortFieldName); + } + for (int i = 0; i < SortFieldNames.length; i++) + { + if (JavaTools.FieldInList(_fieldnames, SortFieldNames[i][0]) == -1) + { + aSortFields.add(SortFieldNames[i]); + } + } + SortFieldNames = new String[aSortFields.size()][2]; + aSortFields.toArray(SortFieldNames); + } + + public String[][] getSortFieldNames() + { + return SortFieldNames; + } + + public void setSortFieldNames(String[][] aNewListList) + { + SortFieldNames = aNewListList; + } + + public FieldColumn getFieldColumn(String _FieldName, String _CommandName) + { + for (int i = 0; i < FieldColumns.length; i++) + { + if (FieldColumns[i].getFieldName().equals(_FieldName) && FieldColumns[i].getCommandName().equals(_CommandName)) + { + return FieldColumns[i]; + } + } + return null; + } + + public FieldColumn getFieldColumnByFieldName(String _FieldName) + { + for (int i = 0; i < FieldColumns.length; i++) + { + String sFieldName = FieldColumns[i].getFieldName(); + if (sFieldName.equals(_FieldName)) + { + return FieldColumns[i]; + } + if (_FieldName.indexOf('.') == -1) + { + String sCompound = Command + "." + _FieldName; + if (sFieldName.equals(sCompound)) + { + return FieldColumns[i]; + } + } + } + throw new com.sun.star.uno.RuntimeException(); + } + + public FieldColumn getFieldColumnByDisplayName(String _DisplayName) + { + String identifierQuote = getIdentifierQuote(); + for (int i = 0; i < FieldColumns.length; i++) + { + String sDisplayName = FieldColumns[i].getDisplayFieldName(); + if (sDisplayName.equals(_DisplayName)) + { + return FieldColumns[i]; + } + if (_DisplayName.indexOf('.') == -1) + { + String sCompound = Command + "." + _DisplayName; + if (sDisplayName.equals(sCompound)) + { + return FieldColumns[i]; + } + } + String quotedName = new StringBuilder(CommandName.quoteName(FieldColumns[i].getCommandName(), identifierQuote)).append('.').append(CommandName.quoteName(FieldColumns[i].getFieldName(), identifierQuote)).toString(); + if (quotedName.equals(_DisplayName)) + { + return FieldColumns[i]; + } + } + throw new com.sun.star.uno.RuntimeException(); + } + + public FieldColumn getFieldColumnByTitle(String _FieldTitle) + { + for (int i = 0; i < FieldColumns.length; i++) + { + if (FieldColumns[i].getFieldTitle().equals(_FieldTitle)) + { + return FieldColumns[i]; + } + } + // throw new com.sun.star.uno.RuntimeException(); + // LLA: Group works with fields direct + for (int i = 0; i < FieldColumns.length; i++) + { + if (FieldColumns[i].getFieldName().equals(_FieldTitle)) + { + return FieldColumns[i]; + } + } + throw new com.sun.star.uno.RuntimeException(); + } + + public boolean getFieldNamesOfCommand(String _commandname, int _commandtype) + { + try + { + java.util.ArrayList<String> ResultFieldNames = new java.util.ArrayList<String>(10); + String[] FieldNames; + CommandObject oCommand = this.getCommandByName(_commandname, _commandtype); + FieldNames = oCommand.getColumns().getElementNames(); + if (FieldNames.length > 0) + { + for (int n = 0; n < FieldNames.length; n++) + { + final String sFieldName = FieldNames[n]; + Object oField = oCommand.getColumns().getByName(sFieldName); + int iType = AnyConverter.toInt(Helper.getUnoPropertyValue(oField, "Type")); + // BinaryFieldTypes are not included in the WidthList + if (JavaTools.FieldInIntTable(WidthList, iType) >= 0) + { + ResultFieldNames.add(sFieldName); + } + else if (JavaTools.FieldInIntTable(BinaryTypes, iType) >= 0) + { + ResultFieldNames.add(sFieldName); + } + } + m_aAllFieldNames = new String[ResultFieldNames.size()]; + m_aAllFieldNames = ResultFieldNames.toArray(m_aAllFieldNames); + return true; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + Resource oResource = new Resource(xMSF); + String sMsgNoFieldsFromCommand = oResource.getResText("RID_DB_COMMON_45"); + sMsgNoFieldsFromCommand = JavaTools.replaceSubString(sMsgNoFieldsFromCommand, _commandname, "%NAME"); + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgNoFieldsFromCommand); + return false; + } + + /** + * @return Returns the command. + */ + public String getCommandName() + { + return Command; + } + + /** + * @param _command The command to set. + */ + public void setCommandName(String _command) + { + Command = _command; + } + + /** + * @return Returns the commandType. + */ + public int getCommandType() + { + return CommandType; + } + + /** + * @param _commandType The commandType to set. + */ + public void setCommandType(int _commandType) + { + CommandType = _commandType; + } + + private boolean isnumeric(FieldColumn _oFieldColumn) + { + try + { + CommandObject oTable = super.getTableByName(_oFieldColumn.getCommandName()); + Object oField = oTable.getColumns().getByName(_oFieldColumn.getFieldName()); + int iType = AnyConverter.toInt(Helper.getUnoPropertyValue(oField, "Type")); + int ifound = java.util.Arrays.binarySearch(NumericTypes, iType); + if ((ifound < NumericTypes.length) && (ifound > 0)) + { + return (NumericTypes[ifound] == iType); + } + else + { + return false; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return false; + } + } + + public String[] setNumericFields() + { + try + { + ArrayList<String> numericfieldsvector = new java.util.ArrayList<String>(); + for (int i = 0; i < FieldColumns.length; i++) + { + if (isnumeric(FieldColumns[i])) + { + numericfieldsvector.add(FieldColumns[i].getDisplayFieldName()); + } + } + NumericFieldNames = new String[numericfieldsvector.size()]; + numericfieldsvector.toArray(NumericFieldNames); + return NumericFieldNames; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return new String[] + { + }; + } + } + + public String[] getFieldNames(String[] _sDisplayFieldNames, String _sCommandName) + { + ArrayList<String> sFieldNamesVector = new java.util.ArrayList<String>(); + for (int i = 0; i < FieldColumns.length; i++) + { + if (_sCommandName.equals(FieldColumns[i].getCommandName()) && JavaTools.FieldInList(_sDisplayFieldNames, FieldColumns[i].getDisplayFieldName()) > -1) + { + sFieldNamesVector.add(FieldColumns[i].getFieldName()); + } + } + String[] sFieldNames = new String[sFieldNamesVector.size()]; + sFieldNamesVector.toArray(sFieldNames); + return sFieldNames; + } + + public String[] getFieldNames() + { + String[] sFieldNames = new String[FieldColumns.length]; + for (int i = 0; i < FieldColumns.length; i++) + { + sFieldNames[i] = FieldColumns[i].getFieldName(); + } + return sFieldNames; + } + + public String[] getDisplayFieldNames() + { + String[] sDisplayFieldNames = new String[FieldColumns.length]; + for (int i = 0; i < FieldColumns.length; i++) + { + sDisplayFieldNames[i] = FieldColumns[i].getDisplayFieldName(); + } + return sDisplayFieldNames; + } + + public String[] setNonAggregateFieldNames() + { + try + { + ArrayList<String> nonaggregatefieldsvector = new java.util.ArrayList<String>(); + for (int i = 0; i < FieldColumns.length; i++) + { + if (JavaTools.FieldInTable(AggregateFieldNames, FieldColumns[i].getDisplayFieldName()) == -1) + { + nonaggregatefieldsvector.add(FieldColumns[i].getDisplayFieldName()); + } + } + NonAggregateFieldNames = new String[nonaggregatefieldsvector.size()]; + nonaggregatefieldsvector.toArray(NonAggregateFieldNames); + return NonAggregateFieldNames; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return new String[] + { + }; + } + } + + public String getFieldTitle(String FieldName) + { + String FieldTitle = FieldName; + if (this.FieldTitleSet != null) + { + FieldTitle = this.FieldTitleSet.get(FieldName); //FieldTitles[TitleIndex]; + if (FieldTitle == null) + { + return FieldName; + } + } + return FieldTitle; + } + + public void setFieldTitles(String[] sFieldTitles) + { + int nFieldColLength = FieldColumns.length; + for (int i = 0; i < sFieldTitles.length; i++) + { + if (i < nFieldColLength) + { + FieldColumns[i].setFieldTitle(sFieldTitles[i]); + } + + } + } + + public void setGroupFieldNames(String[] GroupFieldNames) + { + this.GroupFieldNames = GroupFieldNames; + } + + public String[] getGroupFieldNames() + { + return GroupFieldNames; + } + + public void createRecordFieldNames() + { + String CurFieldName; + int GroupFieldCount; + int TotFieldCount = FieldColumns.length; + GroupFieldCount = JavaTools.getArraylength(GroupFieldNames); + RecordFieldNames = new String[TotFieldCount - GroupFieldCount]; + + int a = 0; + for (int i = 0; i < TotFieldCount; i++) + { + CurFieldName = FieldColumns[i].getFieldName(); + if (JavaTools.FieldInList(GroupFieldNames, CurFieldName) < 0) + { + RecordFieldNames[a] = CurFieldName; + ++a; + } + } + } + + public void setRecordFieldNames(String[] _aNewList) + { + RecordFieldNames = _aNewList; + } + + public String[] getRecordFieldNames() + { + return RecordFieldNames; + } + + public String getRecordFieldName(int i) + { + return RecordFieldNames[i]; + } + + private void setCommandComposingAttributes() + { + try + { + xDBMetaData.getCatalogSeparator(); + sIdentifierQuote = xDBMetaData.getIdentifierQuoteString(); + bCommandComposerAttributesalreadyRetrieved = true; + } + catch (SQLException e) + { + e.printStackTrace(System.err); + } + } + + /** + * @return Returns the sIdentifierQuote. + */ + public String getIdentifierQuote() + { + if (!bCommandComposerAttributesalreadyRetrieved) + { + setCommandComposingAttributes(); + } + return sIdentifierQuote; + } +} diff --git a/wizards/com/sun/star/wizards/db/CommandName.java b/wizards/com/sun/star/wizards/db/CommandName.java new file mode 100644 index 0000000000..4768018ef3 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/CommandName.java @@ -0,0 +1,261 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.uno.Exception; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; + +public class CommandName +{ + + private CommandMetaData oCommandMetaData; + private String CatalogName = PropertyNames.EMPTY_STRING; + private String SchemaName = PropertyNames.EMPTY_STRING; + private String TableName = PropertyNames.EMPTY_STRING; + private String DisplayName = PropertyNames.EMPTY_STRING; + private String ComposedName = PropertyNames.EMPTY_STRING; + private String AliasName = PropertyNames.EMPTY_STRING; + private boolean bCatalogAtStart; + private String sCatalogSep; + private boolean baddQuotation = true; + + public CommandName(CommandMetaData _CommandMetaData, String _DisplayName) + { + oCommandMetaData = _CommandMetaData; + setComposedCommandName(_DisplayName); + } + + public CommandName(CommandMetaData _CommandMetaData, String _CatalogName, String _SchemaName, String _TableName, boolean _baddQuotation) + { + try + { + baddQuotation = _baddQuotation; + oCommandMetaData = _CommandMetaData; + if ((_CatalogName != null) && (oCommandMetaData.xDBMetaData.supportsCatalogsInTableDefinitions())) + { + if (!_CatalogName.equals(PropertyNames.EMPTY_STRING)) + { + CatalogName = _CatalogName; + } + } + if ((_SchemaName != null) && (oCommandMetaData.xDBMetaData.supportsSchemasInTableDefinitions())) + { + if (!_SchemaName.equals(PropertyNames.EMPTY_STRING)) + { + SchemaName = _SchemaName; + } + } + if (_TableName != null) + { + if (!_TableName.equals(PropertyNames.EMPTY_STRING)) + { + TableName = _TableName; + } + } + setComposedCommandName(); + } + catch (SQLException e) + { + e.printStackTrace(System.err); + } + } + + private void setComposedCommandName(String _DisplayName) + { + try + { + if (!setMetaDataAttributes()) + return; + + this.DisplayName = _DisplayName; + int iIndex; + if (oCommandMetaData.xDBMetaData.supportsCatalogsInDataManipulation()) + { // ...then Catalog also in TableName + iIndex = _DisplayName.indexOf(sCatalogSep); + if (iIndex >= 0) + { + if (bCatalogAtStart) + { + CatalogName = _DisplayName.substring(0, iIndex); + _DisplayName = _DisplayName.substring(iIndex + 1, _DisplayName.length()); + } + else + { + CatalogName = _DisplayName.substring(iIndex + 1, _DisplayName.length()); + _DisplayName = _DisplayName.substring(0, iIndex); + } + } + } + if (oCommandMetaData.xDBMetaData.supportsSchemasInDataManipulation()) + { + String[] NameList = JavaTools.ArrayoutofString(_DisplayName, "."); + if (NameList.length > 1) + { + SchemaName = NameList[0]; + TableName = NameList[1]; + } + else + { + TableName = _DisplayName; + } + } + else + { + TableName = _DisplayName; + } + setComposedCommandName(); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void setComposedCommandName() + { + if (this.setMetaDataAttributes()) + { + if (CatalogName != null) + { + if (!CatalogName.equals(PropertyNames.EMPTY_STRING)) + { + if (bCatalogAtStart) + { + ComposedName = quoteName(CatalogName) + sCatalogSep; + } + } + } + if (SchemaName != null) + { + if (!SchemaName.equals(PropertyNames.EMPTY_STRING)) + { + ComposedName += quoteName(SchemaName) + "."; + } + } + if (ComposedName.equals(PropertyNames.EMPTY_STRING)) + { + ComposedName = quoteName(TableName); + } + else + { + ComposedName += quoteName(TableName); + } + if ((!bCatalogAtStart) && (CatalogName != null)) + { + if (!CatalogName.equals(PropertyNames.EMPTY_STRING)) + { + ComposedName += sCatalogSep + quoteName(CatalogName); + } + } + } + } + + private boolean setMetaDataAttributes() + { + try + { + bCatalogAtStart = oCommandMetaData.xDBMetaData.isCatalogAtStart(); + sCatalogSep = oCommandMetaData.xDBMetaData.getCatalogSeparator(); + oCommandMetaData.xDBMetaData.getIdentifierQuoteString(); + return true; + } + catch (SQLException e) + { + e.printStackTrace(System.err); + return false; + } + } + + private String quoteName(String _sName) + { + if (baddQuotation) + { + return quoteName(_sName, this.oCommandMetaData.getIdentifierQuote()); + } + else + { + return _sName; + } + } + + public static String quoteName(String sName, String _sIdentifierQuote) + { + if (sName == null) + { + sName = PropertyNames.EMPTY_STRING; + } + return new StringBuilder(_sIdentifierQuote).append(sName).append(_sIdentifierQuote).toString(); + } + + public void setAliasName(String _AliasName) + { + AliasName = _AliasName; + } + + public String getAliasName() + { + return AliasName; + } + + /** + * @return Returns the catalogName. + */ + public String getCatalogName() + { + return CatalogName; + } + + /** + * @return Returns the composedName. + */ + public String getComposedName() + { + return ComposedName; + } + + /** + * @return Returns the displayName. + */ + public String getDisplayName() + { + return DisplayName; + } + + /** + * @return Returns the schemaName. + */ + public String getSchemaName() + { + return SchemaName; + } + + /** + * @return Returns the tableName. + */ + public String getTableName() + { + return TableName; + } + + public CommandMetaData getCommandMetaData() + { + return oCommandMetaData; + } +} diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java new file mode 100644 index 0000000000..1a720b0ac3 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -0,0 +1,1010 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XHierarchicalNameAccess; +import com.sun.star.container.XHierarchicalNameContainer; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.Locale; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XInitialization; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.sdb.XCompletedConnection; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.sdb.XFormDocumentsSupplier; +import com.sun.star.sdb.XOfficeDatabaseDocument; +import com.sun.star.sdb.XQueriesSupplier; +import com.sun.star.sdb.XQueryDefinitionsSupplier; +import com.sun.star.sdb.XReportDocumentsSupplier; +import com.sun.star.sdb.tools.XConnectionTools; +import com.sun.star.sdbc.DataType; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XDataSource; +import com.sun.star.sdbc.XDatabaseMetaData; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.task.XInteractionHandler; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.ui.dialogs.XExecutableDialog; +import com.sun.star.uno.Any; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.util.XNumberFormatsSupplier; +import com.sun.star.wizards.common.Configuration; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.NamedValueCollection; +import com.sun.star.wizards.common.NumberFormatter; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.common.SystemDialog; + +public class DBMetaData +{ + private XNameAccess xQueryNames; + public XDatabaseMetaData xDBMetaData; + private XDataSource m_dataSource; + private XPropertySet m_dataSourceSettings; + private XOfficeDatabaseDocument xModel; + private XPropertySet xDataSourcePropertySet; + private java.util.ArrayList<CommandObject> CommandObjects = new ArrayList<CommandObject>(1); + private Locale aLocale; + public String DataSourceName; + public com.sun.star.sdbc.XConnection DBConnection; + private com.sun.star.sdb.tools.XConnectionTools m_connectionTools; + public com.sun.star.lang.XMultiServiceFactory xMSF; + private XComponent xConnectionComponent; + + private XNameAccess xNameAccess; + private XInterface xDatabaseContext; + private XWindowPeer xWindowPeer; + private String[] TableNames = new String[] {}; + private String[] QueryNames = new String[] {}; + + protected int[][] WidthList; + protected static final int[] NumericTypes = { + DataType.TINYINT, // == -6; + DataType.BIGINT, // == -5 + DataType.NUMERIC, // == - 2 + DataType.DECIMAL, // == 3; + DataType.INTEGER, // == 4; + DataType.SMALLINT, // == 5; + DataType.FLOAT, // == 6; + DataType.REAL, // == 7; + DataType.DOUBLE, // == 8; + }; + protected static final int[] BinaryTypes = { //new int[12]; + DataType.BINARY, + DataType.VARBINARY, + DataType.LONGVARBINARY, + DataType.BLOB, + DataType.SQLNULL, + DataType.OBJECT, + DataType.DISTINCT, + DataType.STRUCT, + DataType.ARRAY, + DataType.CLOB, + DataType.REF + /* DataType.OTHER, */ + }; + + private int iMaxColumnsInSelect; + private int iMaxColumnNameLength = -1; + private int iMaxTableNameLength = -1; + private boolean bPasswordIsRequired; + private static final int NOLIMIT = 9999999; + private static final int INVALID = 9999999; + public TypeInspector oTypeInspector; + private NumberFormatter oNumberFormatter = null; + private long lDateCorrection = INVALID; + private boolean bdisposeConnection = false; + + public XPropertySet getDataSourcePropertySet() + { + return xDataSourcePropertySet; + } + + public DBMetaData(XMultiServiceFactory xMSF) + { + getInterfaces(xMSF); + InitializeWidthList(); + } + + public NumberFormatter getNumberFormatter() + { + if (oNumberFormatter == null) + { + try + { + XNumberFormatsSupplier xNumberFormatsSupplier = (XNumberFormatsSupplier) AnyConverter.toObject(XNumberFormatsSupplier.class, xDataSourcePropertySet.getPropertyValue("NumberFormatsSupplier")); + //TODO get the locale from the datasource + aLocale = Configuration.getLocale(xMSF); + oNumberFormatter = new NumberFormatter(xMSF, xNumberFormatsSupplier, aLocale); + lDateCorrection = oNumberFormatter.getNullDateCorrection(); + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + } + return oNumberFormatter; + } + + public long getNullDateCorrection() + { + if (lDateCorrection == INVALID) + { + if (oNumberFormatter == null) + { + oNumberFormatter = getNumberFormatter(); + } + lDateCorrection = oNumberFormatter.getNullDateCorrection(); + } + return lDateCorrection; + } + + private void getInterfaces(XMultiServiceFactory xMSF) + { + try + { + this.xMSF = xMSF; + xDatabaseContext = (XInterface) xMSF.createInstance("com.sun.star.sdb.DatabaseContext"); + xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xDatabaseContext ); + xNameAccess.getElementNames(); + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + } + + + + public boolean hasTableByName(String _stablename) + { + return getTableNamesAsNameAccess().hasByName(_stablename); + } + + public void setTableByName(String _tableName) + { + CommandObject oTableObject = new CommandObject(_tableName, com.sun.star.sdb.CommandType.TABLE); + this.CommandObjects.add(oTableObject); + } + + public CommandObject getTableByName(String _tablename) + { + return getCommandByName(_tablename, com.sun.star.sdb.CommandType.TABLE); + } + + public CommandObject getQueryByName(String _queryname) + { + return getCommandByName(_queryname, com.sun.star.sdb.CommandType.QUERY); + } + + public CommandObject getCommandByName(String _commandname, int _commandtype) + { + CommandObject oCommand = null; + for (int i = 0; i < CommandObjects.size(); i++) + { + oCommand = CommandObjects.get(i); + if ((oCommand.Name.equals(_commandname)) && (oCommand.CommandType == _commandtype)) + { + return oCommand; + } + } + if (oCommand == null) + { + oCommand = new CommandObject(_commandname, _commandtype); + CommandObjects.add(oCommand); + } + return oCommand; + } + + public void setQueryByName(String _QueryName) + { + CommandObject oQueryObject = new CommandObject(_QueryName, com.sun.star.sdb.CommandType.QUERY); + this.CommandObjects.add(oQueryObject); + } + + public class CommandObject + { + + private XNameAccess xColumns; + private XPropertySet xPropertySet; + private String Name; + private int CommandType; + + private CommandObject(String _CommandName, int _CommandType) + { + try + { + Object oCommand; + this.Name = _CommandName; + this.CommandType = _CommandType; + if (CommandType == com.sun.star.sdb.CommandType.TABLE) + { + oCommand = getTableNamesAsNameAccess().getByName(Name); + } + else + { + oCommand = getQueryNamesAsNameAccess().getByName(Name); + } + XColumnsSupplier xCommandCols = UnoRuntime.queryInterface( XColumnsSupplier.class, oCommand ); + xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oCommand ); +// TODO: Performance leak getColumns() take very long. + xColumns = UnoRuntime.queryInterface( XNameAccess.class, xCommandCols.getColumns() ); + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + } + public XNameAccess getColumns() + { + return xColumns; + } + public String getName() + { + return Name; + } + public XPropertySet getPropertySet() + { + return xPropertySet; + } + } + + public boolean hasEscapeProcessing(XPropertySet _xQueryPropertySet) + { + boolean bHasEscapeProcessing = false; + try + { + if (_xQueryPropertySet.getPropertySetInfo().hasPropertyByName("EscapeProcessing")) + { + bHasEscapeProcessing = AnyConverter.toBoolean(_xQueryPropertySet.getPropertyValue("EscapeProcessing")); + } + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + return bHasEscapeProcessing; + } + + private XNameAccess getQueryNamesAsNameAccess() + { + XQueriesSupplier xDBQueries = UnoRuntime.queryInterface( XQueriesSupplier.class, DBConnection ); + xQueryNames = xDBQueries.getQueries(); + return xQueryNames; + } + + public XNameAccess getTableNamesAsNameAccess() + { + XTablesSupplier xDBTables = UnoRuntime.queryInterface( XTablesSupplier.class, DBConnection ); + return xDBTables.getTables(); + } + + public String[] getQueryNames() + { + if (QueryNames != null && QueryNames.length > 0) + { + return QueryNames; + } + QueryNames = getQueryNamesAsNameAccess().getElementNames(); + return QueryNames; + } + + public String[] getTableNames() + { + if (TableNames != null && TableNames.length > 0) + { + return TableNames; + } + TableNames = getTableNamesAsNameAccess().getElementNames(); + return TableNames; + } + + private void InitializeWidthList() + { + WidthList = new int[17][2]; + WidthList[0][0] = DataType.BIT; // == -7; + WidthList[1][0] = DataType.BOOLEAN; // = 16 + WidthList[2][0] = DataType.TINYINT; // == -6; + WidthList[3][0] = DataType.BIGINT; // == -5; + WidthList[4][0] = DataType.LONGVARCHAR; // == -1; + WidthList[5][0] = DataType.CHAR; // == 1; + WidthList[6][0] = DataType.NUMERIC; // == 2; + WidthList[7][0] = DataType.DECIMAL; // == 3; [with fractional part] + WidthList[8][0] = DataType.INTEGER; // == 4; + WidthList[9][0] = DataType.SMALLINT; // == 5; + WidthList[10][0] = DataType.FLOAT; // == 6; + WidthList[11][0] = DataType.REAL; // == 7; + WidthList[12][0] = DataType.DOUBLE; // == 8; + WidthList[13][0] = DataType.VARCHAR; // == 12; + WidthList[14][0] = DataType.DATE; // == 91; + WidthList[15][0] = DataType.TIME; // == 92; + WidthList[16][0] = DataType.TIMESTAMP; // == 93; + // NumericTypes are all types where aggregate functions can be performed on. + // Similarly to a major competitor date/time/timestamp fields are not included + + + } + + public boolean isBinaryDataType(int _itype) + { + if (NumericTypes == null) + { + InitializeWidthList(); + } + return (JavaTools.FieldInIntTable(BinaryTypes, _itype) > -1); + } + + public int getMaxTablesInSelect() + { + try + { + int itablecount = xDBMetaData.getMaxTablesInSelect(); + if (itablecount == 0) + { + return DBMetaData.NOLIMIT; + } + else + { + return itablecount; + } + } + catch (SQLException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return - 1; + } + } + + public int getMaxColumnsInSelect() + { + return iMaxColumnsInSelect; + } + + private void setMaxColumnsInSelect() throws SQLException + { + iMaxColumnsInSelect = xDBMetaData.getMaxColumnsInSelect(); + if (iMaxColumnsInSelect == 0) + { + iMaxColumnsInSelect = DBMetaData.NOLIMIT; + } + } + + public int getMaxColumnsInTable() throws SQLException + { + int iMaxColumnsInTable = xDBMetaData.getMaxColumnsInTable(); + if (iMaxColumnsInTable == 0) + { + iMaxColumnsInTable = DBMetaData.NOLIMIT; + } + return iMaxColumnsInTable; + } + + private void getDataSourceObjects() throws Exception + { + try + { + xDBMetaData = DBConnection.getMetaData(); + getDataSourceInterfaces(); + setMaxColumnsInSelect(); + } + catch (SQLException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + } + + private void ensureDataSourceSettings() throws UnknownPropertyException, WrappedTargetException + { + if ( m_dataSourceSettings != null ) + return; + + XPropertySet dataSourceProperties = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() ); + m_dataSourceSettings = UnoRuntime.queryInterface( XPropertySet.class, dataSourceProperties.getPropertyValue( "Settings" ) ); + } + + public boolean isSQL92CheckEnabled() + { + boolean isSQL92CheckEnabled = false; + try + { + ensureDataSourceSettings(); + isSQL92CheckEnabled = AnyConverter.toBoolean( m_dataSourceSettings.getPropertyValue( "EnableSQL92Check" ) ); + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + return isSQL92CheckEnabled; + } + + public XDataSource getDataSource() + { + if (m_dataSource == null) + { + try + { + Object oDataSource = xNameAccess.getByName(DataSourceName); + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, oDataSource ); + } + catch (com.sun.star.container.NoSuchElementException e) + { + } + catch (com.sun.star.lang.WrappedTargetException e) + { + } + } + return m_dataSource; + } + + private void setDataSourceByName(String _DataSourceName) + { + try + { + this.DataSourceName = _DataSourceName; + getDataSourceInterfaces(); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, getDataSource() ); + if (xDocu != null) + { + xModel = xDocu.getDatabaseDocument(); + } + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + } + + private void getDataSourceInterfaces() throws Exception + { + xDataSourcePropertySet = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() ); + bPasswordIsRequired = ((Boolean) xDataSourcePropertySet.getPropertyValue("IsPasswordRequired")).booleanValue(); + } + + public boolean getConnection(PropertyValue[] curproperties) + { + try + { + XConnection xConnection = null; + if (Properties.hasPropertyValue(curproperties, PropertyNames.ACTIVE_CONNECTION)) + { + xConnection = UnoRuntime.queryInterface( XConnection.class, Properties.getPropertyValue( curproperties, PropertyNames.ACTIVE_CONNECTION ) ); + if (xConnection != null) + { + com.sun.star.container.XChild child = UnoRuntime.queryInterface( com.sun.star.container.XChild.class, xConnection ); + + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, child.getParent() ); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, m_dataSource ); + if (xDocu != null) + { + xModel = xDocu.getDatabaseDocument(); + } + XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, m_dataSource ); + if (xPSet != null) + { + DataSourceName = AnyConverter.toString(xPSet.getPropertyValue(PropertyNames.PROPERTY_NAME)); + } + return getConnection(xConnection); + } + else + { + bdisposeConnection = true; + } + } + else + { + bdisposeConnection = true; + } + if (Properties.hasPropertyValue(curproperties, "DataSourceName")) + { + String sDataSourceName = AnyConverter.toString(Properties.getPropertyValue(curproperties, "DataSourceName")); + return getConnection(sDataSourceName); + } + else if (Properties.hasPropertyValue(curproperties, "DataSource")) + { + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, Properties.getPropertyValue( curproperties, "DataSource" ) ); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, this.m_dataSource ); + if (xDocu != null) + { + xModel = xDocu.getDatabaseDocument(); + } + return getConnection(m_dataSource); + } + if (Properties.hasPropertyValue(curproperties, "DatabaseLocation")) + { + String sDataSourceName = AnyConverter.toString(Properties.getPropertyValue(curproperties, "DatabaseLocation")); + return getConnection(sDataSourceName); + } + } + catch (IllegalArgumentException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + catch (UnknownPropertyException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + catch (WrappedTargetException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + + return false; + } + + private boolean getConnection(String _DataSourceName) + { + setDataSourceByName(_DataSourceName); + return getConnection( getDataSource() ); + } + + private boolean getConnection(com.sun.star.sdbc.XConnection _DBConnection) + { + try + { + this.DBConnection = _DBConnection; + this.m_connectionTools = UnoRuntime.queryInterface( XConnectionTools.class, this.DBConnection ); + getDataSourceObjects(); + return true; + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return false; + } + } + + private boolean getConnection(XDataSource _dataSource) + { + Resource oResource = new Resource(xMSF); + try + { + int iMsg = 0; + boolean bgetConnection = false; + if (DBConnection != null) + { + xConnectionComponent.dispose(); + } + getDataSourceInterfaces(); + if (!bPasswordIsRequired) + { + DBConnection = _dataSource.getConnection(PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING); + bgetConnection = true; + } + else + { + XInteractionHandler xInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xMSF.createInstance("com.sun.star.task.InteractionHandler") ); + boolean bExitLoop = true; + do + { + XCompletedConnection xCompleted2 = UnoRuntime.queryInterface( XCompletedConnection.class, _dataSource ); + try + { + DBConnection = xCompleted2.connectWithCompletion( xInteractionHandler ); + bgetConnection = DBConnection != null; + if (!bgetConnection) + { + bExitLoop = true; + } + } + catch (Exception exception) + { + // Note: WindowAttributes from toolkit/source/awt/vclxtoolkit.cxx + String sMsgNoConnection = oResource.getResText("RID_DB_COMMON_14"); + iMsg = showMessageBox("QueryBox", VclWindowPeerAttribute.RETRY_CANCEL, sMsgNoConnection); + bExitLoop = iMsg == 0; + bgetConnection = false; + } + } + while (!bExitLoop); + } + if (!bgetConnection) + { + String sMsgConnectionImpossible = oResource.getResText("RID_DB_COMMON_35"); + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgConnectionImpossible); + } + else + { + xConnectionComponent = UnoRuntime.queryInterface( XComponent.class, DBConnection ); + m_connectionTools = UnoRuntime.queryInterface( XConnectionTools.class, DBConnection ); + getDataSourceObjects(); + } + return bgetConnection; + } + catch (Exception e) + { + String sMsgConnectionImpossible = oResource.getResText("RID_DB_COMMON_35"); + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgConnectionImpossible); + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return false; + } + } + + public int getMaxColumnNameLength() + { + try + { + if (iMaxColumnNameLength <= 0) + { + iMaxColumnNameLength = xDBMetaData.getMaxColumnNameLength(); + } + return iMaxColumnNameLength; + } + catch (SQLException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return 0; + } + } + + public int getMaxTableNameLength() + { + try + { + if (iMaxTableNameLength <= 0) + { + iMaxTableNameLength = xDBMetaData.getMaxTableNameLength(); + } + return iMaxTableNameLength; + } + catch (SQLException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return 0; + } + } + + public boolean supportsPrimaryKeys() + { + boolean supportsPrimaryKeys = false; + try + { + ensureDataSourceSettings(); + Any primaryKeySupport = (Any)m_dataSourceSettings.getPropertyValue( "PrimaryKeySupport" ); + if ( AnyConverter.isVoid( primaryKeySupport ) ) + supportsPrimaryKeys = supportsCoreSQLGrammar(); + else + supportsPrimaryKeys = AnyConverter.toBoolean( primaryKeySupport ); + } + catch ( Exception ex ) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, ex ); + } + return supportsPrimaryKeys; + } + + private boolean supportsCoreSQLGrammar() + { + try + { + return xDBMetaData.supportsCoreSQLGrammar(); + } + catch (SQLException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return false; + } + } + + public boolean supportsQueriesInFrom() throws SQLException + { + return m_connectionTools.getDataSourceMetaData().supportsQueriesInFrom(); + } + + public String suggestName( final int i_objectType, final String i_baseName ) throws IllegalArgumentException, SQLException + { + return m_connectionTools.getObjectNames().suggestName( i_objectType, i_baseName ); + } + + /** + * inserts a Query to a datasource; There is no validation if the queryname is already existing in the datasource + */ + public boolean createQuery(SQLQueryComposer _oSQLQueryComposer, String _QueryName) + { + try + { + XQueryDefinitionsSupplier xQueryDefinitionsSuppl = UnoRuntime.queryInterface( XQueryDefinitionsSupplier.class, m_dataSource ); + XNameAccess xQueryDefs = xQueryDefinitionsSuppl.getQueryDefinitions(); + XSingleServiceFactory xSSFQueryDefs = UnoRuntime.queryInterface( XSingleServiceFactory.class, xQueryDefs ); + Object oQuery = xSSFQueryDefs.createInstance(); //"com.sun.star.sdb.QueryDefinition" + XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, oQuery ); + + String s = _oSQLQueryComposer.m_xQueryAnalyzer.getQuery(); + xPSet.setPropertyValue(PropertyNames.COMMAND, s); + + XNameContainer xNameCont = UnoRuntime.queryInterface( XNameContainer.class, xQueryDefs ); + m_connectionTools.getObjectNames().checkNameForCreate(com.sun.star.sdb.CommandType.QUERY, _QueryName); + xNameCont.insertByName(_QueryName, oQuery); + return true; + } + catch (WrappedTargetException exception) + { + SQLException sqlError = null; + try + { + sqlError = (SQLException) exception.TargetException; + } + catch (ClassCastException castError) + { + } + + if (sqlError != null) + { + callSQLErrorMessageDialog(sqlError, null); + return false; + } + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, exception ); + } + catch (SQLException e) + { + callSQLErrorMessageDialog(e, null); + return false; + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + return false; + } + + public void dispose() + { + if ((DBConnection != null) && (this.bdisposeConnection)) + { + xConnectionComponent.dispose(); + } + } + + public XHierarchicalNameAccess getReportDocuments() + { + XReportDocumentsSupplier xReportDocumentSuppl = UnoRuntime.queryInterface( XReportDocumentsSupplier.class, this.xModel ); + xReportDocumentSuppl.getReportDocuments(); + return UnoRuntime.queryInterface( XHierarchicalNameAccess.class, xReportDocumentSuppl.getReportDocuments() ); + } + + public XHierarchicalNameAccess getFormDocuments() + { + XFormDocumentsSupplier xFormDocumentSuppl = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, xModel ); + return UnoRuntime.queryInterface( XHierarchicalNameAccess.class, xFormDocumentSuppl.getFormDocuments() ); + } + + public boolean hasFormDocumentByName(String _sFormName) + { + XFormDocumentsSupplier xFormDocumentSuppl = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, xModel ); + XNameAccess xFormNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xFormDocumentSuppl.getFormDocuments() ); + return xFormNameAccess.hasByName(_sFormName); + } + + public void addFormDocument(XComponent _xComponent) + { + XHierarchicalNameAccess _xFormDocNameAccess = getFormDocuments(); + addDatabaseDocument(_xComponent, _xFormDocNameAccess, false); + } + + public void addReportDocument(XComponent _xComponent, boolean _bcreatedynamicreport) + { + XHierarchicalNameAccess xReportDocNameAccess = getReportDocuments(); + addDatabaseDocument(_xComponent, xReportDocNameAccess, _bcreatedynamicreport); + } + + /** + * adds the passed document as a report or a form to the database. Afterwards the document is deleted. + * the document may not be open + * @param i_createTemplate describes the type of the document: "form" or "report" + */ + private void addDatabaseDocument(XComponent _xComponent, XHierarchicalNameAccess _xDocNameAccess, boolean i_createTemplate) + { + try + { + XModel xDocumentModel = UnoRuntime.queryInterface( XModel.class, _xComponent ); + String documentURL = xDocumentModel.getURL(); + String basename = FileAccess.getBasename(documentURL, "/"); + XCloseable xCloseable = UnoRuntime.queryInterface( XCloseable.class, _xComponent ); + xCloseable.close(false); + + NamedValueCollection creationArgs = new NamedValueCollection(); + creationArgs.put( PropertyNames.PROPERTY_NAME, basename ); + creationArgs.put( PropertyNames.URL, documentURL ); + creationArgs.put( "AsTemplate", i_createTemplate ); + XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, _xDocNameAccess ); + Object oDBDocument = xDocMSF.createInstanceWithArguments( "com.sun.star.sdb.DocumentDefinition", creationArgs.getPropertyValues() ); + XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocNameAccess ); + String sdocname = Desktop.getUniqueName(_xDocNameAccess, basename); + xHier.insertByHierarchicalName(sdocname, oDBDocument); + XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface ); + xSimpleFileAccess.kill(documentURL); + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + } + + public void createTypeInspector() throws SQLException + { + oTypeInspector = new TypeInspector(xDBMetaData.getTypeInfo()); + } + + public TypeInspector getDBDataTypeInspector() + { + return oTypeInspector; + } + + private String[] StringsFromResultSet(XResultSet _xResultSet, int _icol) + { + String[] sColValues = null; + if (_xResultSet == null) + return sColValues; + try + { + XRow xRow = UnoRuntime.queryInterface( XRow.class, _xResultSet ); + ArrayList<String> aColVector = new ArrayList<String>(); + while (_xResultSet.next()) + { + aColVector.add(xRow.getString(_icol)); + } + sColValues = new String[aColVector.size()]; + aColVector.toArray(sColValues); + } + catch (SQLException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + } + return sColValues; + } + + public String[] getCatalogNames() + { + try + { + XResultSet xResultSet = xDBMetaData.getCatalogs(); + return StringsFromResultSet(xResultSet, 1); + } + catch (SQLException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return null; + } + } + + public String[] getSchemaNames() + { + try + { + XResultSet xResultSet = xDBMetaData.getSchemas(); + return StringsFromResultSet(xResultSet, 1); + } + catch (SQLException e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return null; + } + } + + public boolean storeDatabaseDocumentToTempPath(XComponent _xcomponent, String _storename) + { + try + { + String storepath = FileAccess.getOfficePath(xMSF, "Temp") + "/" + _storename; + XStorable xStoreable = UnoRuntime.queryInterface( XStorable.class, _xcomponent ); + PropertyValue[] oStoreProperties = new PropertyValue[1]; + oStoreProperties[0] = Properties.createProperty("FilterName", "writer8"); + storepath += ".odt"; + xStoreable.storeAsURL(storepath, oStoreProperties); + return true; + } + catch (Exception e) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e ); + return false; + } + } + + public int showMessageBox(String windowServiceName, int windowAttribute, String MessageText) + { + if (getWindowPeer() != null) + { + return SystemDialog.showMessageBox(xMSF, xWindowPeer, windowServiceName, windowAttribute, MessageText); + } + else + { + return SystemDialog.showMessageBox(xMSF, windowServiceName, windowAttribute, MessageText); + } + } + + /** + * @return Returns the xWindowPeer. + */ + private XWindowPeer getWindowPeer() + { + return xWindowPeer; + } + + /** + * @param windowPeer The xWindowPeer to set. + * Should be called as soon as a Windowpeer of a wizard dialog is available + * The windowpeer is needed to call a Messagebox + */ + public void setWindowPeer(XWindowPeer windowPeer) + { + xWindowPeer = windowPeer; + } + + public void callSQLErrorMessageDialog(SQLException oSQLException, XWindow _xWindow) + { + try + { + Object oDialog = xMSF.createInstance("com.sun.star.sdb.ErrorMessageDialog"); + XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, oDialog ); + PropertyValue[] aPropertyValue = new PropertyValue[2]; + aPropertyValue[0] = Properties.createProperty("SQLException", oSQLException); + aPropertyValue[1] = Properties.createProperty("ParentWindow", _xWindow); + xInitialization.initialize(aPropertyValue); + XExecutableDialog xExecutableDialog = UnoRuntime.queryInterface( XExecutableDialog.class, oDialog ); + xExecutableDialog.execute(); + } + catch (com.sun.star.uno.Exception ex) + { + Logger.getLogger( getClass().getName() ).log( Level.SEVERE, "error calling the error dialog", ex ); + } + } + + public void finish() + { + xQueryNames = null; + xNameAccess = null; + xDatabaseContext = null; + xDBMetaData = null; + m_dataSource = null; + xModel = null; + xDataSourcePropertySet = null; + xWindowPeer = null; + DBConnection = null; + m_connectionTools = null; + xMSF = null; + xConnectionComponent = null; + CommandObjects = null; + } +} diff --git a/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java new file mode 100644 index 0000000000..013fb547ca --- /dev/null +++ b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java @@ -0,0 +1,170 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.db; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.frame.XController; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.sdbc.SQLException; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.NamedValueCollection; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.ui.WizardDialog; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * is a base class for a wizard creating a database object + */ +public abstract class DatabaseObjectWizard extends WizardDialog +{ + protected final PropertyValue[] m_wizardContext; + protected final XDatabaseDocumentUI m_docUI; + protected final XFrame m_frame; + + protected DatabaseObjectWizard( final XMultiServiceFactory i_orb, final int i_helpIDBase, final PropertyValue[] i_wizardContext ) + { + super( i_orb, i_helpIDBase ); + m_wizardContext = i_wizardContext; + + final NamedValueCollection wizardContext = new NamedValueCollection( m_wizardContext ); + m_docUI = wizardContext.queryOrDefault( "DocumentUI", (XDatabaseDocumentUI)null, XDatabaseDocumentUI.class ); + + if ( m_docUI != null ) + { + XController docController = UnoRuntime.queryInterface( XController.class, m_docUI ); + m_frame = docController.getFrame(); + } + else + { + XFrame parentFrame = wizardContext.queryOrDefault( "ParentFrame", (XFrame)null, XFrame.class ); + if ( parentFrame != null ) + m_frame = parentFrame; + else + m_frame = Desktop.getActiveFrame( xMSF ); + } + } + + protected final void loadSubComponent( final int i_type, final String i_name, final boolean i_forEditing ) + { + try + { + if ( m_docUI != null ) + m_docUI.loadComponent( i_type, i_name, i_forEditing ); + } + catch ( IllegalArgumentException ex ) + { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex ); + } + catch ( NoSuchElementException ex ) + { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex ); + } + catch ( SQLException ex ) + { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex ); + } + } + + public interface WizardFromCommandLineStarter + { + void start(XMultiServiceFactory factory, PropertyValue[] curproperties); + } + + protected static void executeWizardFromCommandLine( final String i_args[], WizardFromCommandLineStarter starter ) + { + final String settings[] = new String[] { null, null, null }; + final int IDX_PIPE_NAME = 0; + final int IDX_LOCATION = 1; + final int IDX_DSN = 2; + + // some simple parsing + boolean failure = false; + int settingsIndex = -1; + for ( int i=0; i<i_args.length; ++i ) + { + if ( settingsIndex >= 0 ) + { + settings[ settingsIndex ] = i_args[i]; + settingsIndex = -1; + continue; + } + + if ( i_args[i].equals( "--pipe-name" ) ) + { + settingsIndex = IDX_PIPE_NAME; + continue; + } + + if ( i_args[i].equals( "--database-location" ) ) + { + settingsIndex = IDX_LOCATION; + continue; + } + + if ( i_args[i].equals( "--data-source-name" ) ) + { + settingsIndex = IDX_DSN; + continue; + } + + failure = true; + } + + if ( settings[ IDX_PIPE_NAME ] == null ) + failure = true; + + if ( ( settings[ IDX_DSN ] == null ) && ( settings[ IDX_LOCATION ] == null ) ) + failure = true; + + if ( failure ) + { + System.err.println( "supported arguments: " ); + System.err.println( " --pipe-name <name> : specifies the name of the pipe to connect to the running OOo instance" ); + System.err.println( " --database-location <url> : specifies the URL of the database document to work with" ); + System.err.println( " --data-source-name <name> : specifies the name of the data source to work with" ); + return; + } + + final String ConnectStr = "uno:pipe,name=" + settings[IDX_PIPE_NAME] + ";urp;StarOffice.ServiceManager"; + try + { + final XMultiServiceFactory serviceFactory = Desktop.connect(ConnectStr); + if (serviceFactory != null) + { + PropertyValue[] curproperties = new PropertyValue[1]; + if ( settings[ IDX_LOCATION ] != null ) + curproperties[0] = Properties.createProperty( "DatabaseLocation", settings[ IDX_LOCATION ] ); + else + curproperties[0] = Properties.createProperty( "DataSourceName", settings[ IDX_DSN ] ); + + starter.start(serviceFactory, curproperties); + } + } + catch (java.lang.Exception jexception) + { + jexception.printStackTrace(System.err); + } + } +} diff --git a/wizards/com/sun/star/wizards/db/FieldColumn.java b/wizards/com/sun/star/wizards/db/FieldColumn.java new file mode 100644 index 0000000000..dd8b85a920 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/FieldColumn.java @@ -0,0 +1,403 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.sdbc.DataType; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.*; + +public class FieldColumn +{ + protected int ColIndex; + + private Object DefaultValue; + private String m_sFieldName; + private String m_sDisplayFieldName; + private String FieldTitle; + private String m_sCommandName; + private int m_nDBFormatKey; + private int m_nFieldType; + private XPropertySet m_xColPropertySet; + + // field meta data + private int FieldWidth; + private boolean bIsNumberFormat; + + private static boolean bFormatKeysInitialized = false; + private static int iDateFormatKey; + private static int iDateTimeFormatKey; + private static int iNumberFormatKey; + private static int iTextFormatKey; + private static int iTimeFormatKey; + private static int iLogicalFormatKey; + + private CommandMetaData m_aCommandMetaData; + + public FieldColumn(CommandMetaData oCommandMetaData, String _FieldName, String _CommandName, boolean _bInstantiateByDisplayName) + { + m_sCommandName = _CommandName; + if (_bInstantiateByDisplayName) + { + m_sDisplayFieldName = _FieldName; + m_sFieldName = getOnlyFieldName(_FieldName, _CommandName); + } + else + { + m_sFieldName = _FieldName; + m_sDisplayFieldName = composeDisplayFieldName(_CommandName, m_sFieldName); + } + FieldTitle = m_sFieldName; + m_aCommandMetaData = oCommandMetaData; + } + + public FieldColumn(CommandMetaData oCommandMetaData, XNameAccess _xColumns, String _FieldName) + { + m_sFieldName = _FieldName; +// FieldTitle = m_sFieldName; + m_sDisplayFieldName = m_sFieldName; + ColIndex = JavaTools.FieldInList(_xColumns.getElementNames(), m_sFieldName) + 1; + initializeFormatKeys(oCommandMetaData, _xColumns); + try + { + m_sCommandName = (String)m_xColPropertySet.getPropertyValue("TableName"); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + } + catch (com.sun.star.lang.WrappedTargetException e) + { + } + } + + public int getFieldType() + { + if (m_nFieldType == 0) + { + DBMetaData.CommandObject oTable = m_aCommandMetaData.getTableByName(m_sCommandName); + initializeFormatKeys(m_aCommandMetaData, oTable.getColumns()); + } + return m_nFieldType; + } + + public int getFieldWidth() + { + getFieldType(); // will collect meta data 'bout the column, if not already done so + return FieldWidth; + } + + public int getDBFormatKey() + { + getFieldType(); // will collect meta data 'bout the column, if not already done so + return m_nDBFormatKey; + } + + public boolean isNumberFormat() + { + getFieldType(); // will collect meta data 'bout the column, if not already done so + return bIsNumberFormat; + } + + /** + * Remove the pre name, we want the name after the 'dot' + * @param _DisplayFieldName + * @param _CommandName + * @return + */ + private String getOnlyFieldName(String _DisplayFieldName, String _CommandName) + { + return _DisplayFieldName.substring(_CommandName.length() + 1); + } + + public static String composeDisplayFieldName(String _sCommandName, String _sFieldName) + { + return _sCommandName + "." + _sFieldName; + } + + private void initializeFormatKeys(CommandMetaData oCommandMetaData, XNameAccess _xColumns) + { + try + { + if (!bFormatKeysInitialized) + { + final NumberFormatter aNumberFormatter = oCommandMetaData.getNumberFormatter(); + + iDateFormatKey = aNumberFormatter.getDateFormatKey(); + iDateTimeFormatKey = aNumberFormatter.getDateTimeFormatKey(); + iNumberFormatKey = aNumberFormatter.getNumberFormatKey(); + iTextFormatKey = aNumberFormatter.getTextFormatKey(); + iTimeFormatKey = aNumberFormatter.getTimeFormatKey(); + iLogicalFormatKey = aNumberFormatter.getLogicalFormatKey(); + bFormatKeysInitialized = true; + } + + m_xColPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _xColumns.getByName(m_sFieldName)); + ColIndex = JavaTools.FieldInList(_xColumns.getElementNames(), m_sFieldName) + 1; + m_nFieldType = AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Type")); + getTyperelatedFieldData(); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public XPropertySet getXColumnPropertySet() + { + getFieldType(); // will collect meta data 'bout the column, if not already done so + return m_xColPropertySet; + } + + public String getDisplayFieldName() + { + return m_sDisplayFieldName; + } + + public String getCommandName() + { + return m_sCommandName; + } + + public String getFieldName() + { + return m_sFieldName; + } + + public String getFieldTitle() + { + return FieldTitle; + } + + public void setFieldTitle(String _sTitle) + { + FieldTitle = _sTitle; + } + + + + public boolean isBoolean() + { + boolean bIsBoolean = false; + switch ( getFieldType() ) + { + case DataType.BIT: // == -7; + case DataType.BOOLEAN: + bIsBoolean = true; + break; + default: + bIsBoolean = false; + } + return bIsBoolean; + } + + private void getTyperelatedFieldData() + { + int StandardFormatKey = 0; + try + { + switch ( getFieldType() ) + { + case DataType.BIT: // == -7; + case DataType.BOOLEAN: + // Todo: Look if the defaultvalue has been set in the Datasource + StandardFormatKey = iLogicalFormatKey; + FieldWidth = 5; + bIsNumberFormat = true; + break; + + case DataType.TINYINT: // == -6; + case DataType.SMALLINT: // == 5; + StandardFormatKey = iNumberFormatKey; + FieldWidth = 5; + bIsNumberFormat = true; + break; + + case DataType.INTEGER: // == 4; + StandardFormatKey = iNumberFormatKey; + FieldWidth = 10; + bIsNumberFormat = true; + break; + + case DataType.BIGINT: // == -5; + StandardFormatKey = iNumberFormatKey; + FieldWidth = 15; + bIsNumberFormat = true; + break; + + case DataType.CHAR: // == 1; + StandardFormatKey = iTextFormatKey; + getTextFieldWidth(10); + bIsNumberFormat = false; + break; + + case DataType.VARCHAR: // == 12; + StandardFormatKey = iTextFormatKey; + getTextFieldWidth(30); + bIsNumberFormat = false; + break; + + case DataType.LONGVARCHAR: // == -1; + StandardFormatKey = iTextFormatKey; + getTextFieldWidth(60); + bIsNumberFormat = false; + break; + + case DataType.NUMERIC: // == 2; + StandardFormatKey = iNumberFormatKey; + FieldWidth = 20; + bIsNumberFormat = true; + break; + + case DataType.DECIMAL: // == 3; [with fractional part] + case DataType.FLOAT: // == 6; + case DataType.REAL: // == 7; + case DataType.DOUBLE: // == 8; + StandardFormatKey = iNumberFormatKey; + FieldWidth = 10 + AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Scale")) + 1; + bIsNumberFormat = true; + break; + + case DataType.DATE: // == 91; + StandardFormatKey = iDateFormatKey; + FieldWidth = 10; + bIsNumberFormat = true; + break; + + case DataType.TIME: // == 92; + StandardFormatKey = iTimeFormatKey; + FieldWidth = 10; + bIsNumberFormat = true; + break; + + case DataType.TIMESTAMP: // == 93; + StandardFormatKey = iDateTimeFormatKey; + FieldWidth = 20; + bIsNumberFormat = true; + break; + } + + Object oKey = m_xColPropertySet.getPropertyValue("FormatKey"); + if (AnyConverter.isVoid(oKey)) + { + m_nDBFormatKey = StandardFormatKey; + } + else + { + m_nDBFormatKey = AnyConverter.toInt(oKey); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + m_nDBFormatKey = StandardFormatKey; + } + } + + private void getTextFieldWidth(int iWidth) + { + try + { + FieldWidth = AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Precision")); + if (FieldWidth > 0) + { + if (FieldWidth > (2 * iWidth)) + { + FieldWidth = 2 * iWidth; + } + else if (FieldWidth == 0) + { + FieldWidth = iWidth; + } + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void initDefaultValue() + { + switch (getFieldType()) + { + case DataType.BIT: // == -7; + case DataType.BOOLEAN: + DefaultValue = Integer.valueOf("1"); + break; + + case DataType.TINYINT: // == -6; + DefaultValue = Integer.valueOf("98"); + break; + + case DataType.SMALLINT: // == 5; + DefaultValue = Integer.valueOf("987"); + break; + + case DataType.INTEGER: // == 4; + DefaultValue = Integer.valueOf("9876"); + break; + + case DataType.BIGINT: // == -5; + DefaultValue = Integer.valueOf("98765"); + break; + + case DataType.CHAR: // == 1; + DefaultValue = String.valueOf('x'); + break; + + case DataType.VARCHAR: // == 12; + case DataType.LONGVARCHAR: // == -1; + DefaultValue = BlindtextCreator.getBlindTextString(FieldTitle, FieldWidth); + break; + + case DataType.NUMERIC: // == 2; + case DataType.DECIMAL: // == 3; [with fractional part] + case DataType.FLOAT: // == 6; + case DataType.REAL: // == 7; + case DataType.DOUBLE: // == 8; + DefaultValue = Double.valueOf("9876.54"); + break; + + case DataType.DATE: // == 91; + DefaultValue = Double.valueOf("42510"); + break; + + case DataType.TIME: // == 92; + DefaultValue = Double.valueOf("10"); + break; + + case DataType.TIMESTAMP: // == 93; + DefaultValue = Double.valueOf("5454110"); + break; + + default: + break; + } + } + + public Object getDefaultValue() + { + if ( DefaultValue == null ) + initDefaultValue(); + return DefaultValue; + } + +} diff --git a/wizards/com/sun/star/wizards/db/MANIFEST.MF b/wizards/com/sun/star/wizards/db/MANIFEST.MF new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/MANIFEST.MF diff --git a/wizards/com/sun/star/wizards/db/QueryMetaData.java b/wizards/com/sun/star/wizards/db/QueryMetaData.java new file mode 100644 index 0000000000..abbc603675 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/QueryMetaData.java @@ -0,0 +1,244 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.beans.PropertyValue; + +import java.util.*; +import com.sun.star.wizards.common.*; + +public class QueryMetaData extends CommandMetaData +{ + + private SQLQueryComposer oSQLQueryComposer = null; + public String Command; + // Vector CommandNamesV; + private PropertyValue[][] m_aFilterConditions; /* = new PropertyValue[][] {}; */ + + public PropertyValue[][] GroupByFilterConditions = new PropertyValue[][] + { + }; + public int Type = QueryType.SODETAILQUERY; + + public interface QueryType + { + int SOSUMMARYQUERY = 0; + int SODETAILQUERY = 1; + } + + public QueryMetaData(XMultiServiceFactory _xMSF) + { + super(_xMSF); + } + + public void setFilterConditions(PropertyValue[][] _FilterConditions) + { + this.m_aFilterConditions = _FilterConditions; + } + + public PropertyValue[][] getFilterConditions() + { + if (m_aFilterConditions == null) + { + m_aFilterConditions = new PropertyValue[][] + { + }; + } + return m_aFilterConditions; + } + + public void setGroupByFilterConditions(PropertyValue[][] _GroupByFilterConditions) + { + this.GroupByFilterConditions = _GroupByFilterConditions; + } + + public PropertyValue[][] getGroupByFilterConditions() + { + return this.GroupByFilterConditions; + } + + public void addSeveralFieldColumns(String[] _FieldNames, String _sCommandName) + { + ArrayList<FieldColumn> oToBeAddedFieldColumns = new ArrayList<FieldColumn>(); + for (int i = 0; i < _FieldNames.length; i++) + { + FieldColumn oFieldColumn = getFieldColumn(_FieldNames[i], _sCommandName); + if (oFieldColumn == null) + { + oToBeAddedFieldColumns.add(new FieldColumn(this, _FieldNames[i], _sCommandName, false)); + } + } + if (oToBeAddedFieldColumns.size() > 0) + { + int nOldFieldCount = FieldColumns.length; + FieldColumn[] LocFieldColumns = new FieldColumn[nOldFieldCount + oToBeAddedFieldColumns.size()]; + System.arraycopy(FieldColumns, 0, LocFieldColumns, 0, nOldFieldCount); + for (int i = 0; i < oToBeAddedFieldColumns.size(); i++) + { + LocFieldColumns[nOldFieldCount + i] = oToBeAddedFieldColumns.get(i); + } + FieldColumns = LocFieldColumns; + } + } + + public void reorderFieldColumns(String[] _sDisplayFieldNames) + { + FieldColumn[] LocFieldColumns = new FieldColumn[FieldColumns.length]; + for (int i = 0; i < _sDisplayFieldNames.length; i++) + { + FieldColumn LocFieldColumn = this.getFieldColumnByDisplayName(_sDisplayFieldNames[i]); + LocFieldColumns[i] = LocFieldColumn; + } + System.arraycopy(LocFieldColumns, 0, FieldColumns, 0, LocFieldColumns.length); + } + + public void removeSeveralFieldColumnsByDisplayFieldName(String[] _DisplayFieldNames) + { + ArrayList<FieldColumn> oRemainingFieldColumns = new ArrayList<FieldColumn>(); + for (int n = 0; n < FieldColumns.length; n++) + { + String sDisplayFieldName = FieldColumns[n].getDisplayFieldName(); + if (JavaTools.FieldInList(_DisplayFieldNames, sDisplayFieldName) <= -1) + { + oRemainingFieldColumns.add(FieldColumns[n]); + } + } + FieldColumns = new FieldColumn[oRemainingFieldColumns.size()]; + oRemainingFieldColumns.toArray(FieldColumns); + } + + + + public String[] getIncludedCommandNames() + { + ArrayList<String> CommandNamesV = new ArrayList<String>(1); + for (int i = 0; i < FieldColumns.length; i++) + { + final FieldColumn CurQueryField = FieldColumns[i]; + final String CurCommandName = CurQueryField.getCommandName(); + if (!CommandNamesV.contains(CurCommandName)) + { + CommandNamesV.add(CurCommandName); + } + } + String[] sIncludedCommandNames = new String[CommandNamesV.size()]; + CommandNamesV.toArray(sIncludedCommandNames); + return sIncludedCommandNames; + } + + public static String[] getIncludedCommandNames(String[] _FieldNames) + { + ArrayList<String> CommandNames = new ArrayList<String>(1); + for (int i = 0; i < _FieldNames.length; i++) + { + String[] MetaList = JavaTools.ArrayoutofString(_FieldNames[i], "."); + if (MetaList.length > 1) + { + StringBuilder sb = new StringBuilder(PropertyNames.EMPTY_STRING); + for (int a = 0; a < MetaList.length - 1; a++) + { + sb.append(MetaList[a]); + } + String CurCommandName = sb.toString(); + if (!CommandNames.contains(CurCommandName)) + { + CommandNames.add(CurCommandName); + } + } + } + String[] sIncludedCommandNames = new String[CommandNames.size()]; + CommandNames.toArray(sIncludedCommandNames); + return sIncludedCommandNames; + } + + public void initializeFieldTitleSet() + { + try + { + if (FieldTitleSet == null) + { + FieldTitleSet = new HashMap<String, String>(); + } + String[] aCommandNames = getIncludedCommandNames(); + for (int i = 0; i < aCommandNames.length; i++) + { + String sCommandName = aCommandNames[i]; + CommandObject oTable = getTableByName(sCommandName); + String sTableName = oTable.getName(); + String[] LocFieldNames = oTable.getColumns().getElementNames(); + for (int a = 0; a < LocFieldNames.length; a++) + { + String sDisplayFieldName = FieldColumn.composeDisplayFieldName(sTableName, LocFieldNames[a]); + if (!FieldTitleSet.containsKey(sDisplayFieldName)) + { + FieldTitleSet.put(sDisplayFieldName, LocFieldNames[a]); + } + } + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public String[] getUniqueAggregateFieldNames() + { + ArrayList<String> UniqueAggregateFieldVector = new ArrayList<String>(); + for (int i = 0; i < AggregateFieldNames.length; i++) + { + if (!UniqueAggregateFieldVector.contains(AggregateFieldNames[i][0])) + { + UniqueAggregateFieldVector.add(AggregateFieldNames[i][0]); + } + } + return UniqueAggregateFieldVector.toArray(new String[UniqueAggregateFieldVector.size()]); + } + + public boolean hasNumericalFields() + { + for (int i = 0; i < FieldColumns.length; i++) + { + if (FieldColumns[i].isNumberFormat()) + { + return true; + } + } + return false; + } + + public int getAggregateIndex(String _DisplayFieldName) + { + int iAggregate = -1; + if (Type == QueryType.SOSUMMARYQUERY) + { + iAggregate = JavaTools.FieldInTable(AggregateFieldNames, _DisplayFieldName); + } + return iAggregate; + } + + public SQLQueryComposer getSQLQueryComposer() + { + if (oSQLQueryComposer == null) + { + oSQLQueryComposer = new SQLQueryComposer(this); + } + return oSQLQueryComposer; + } +} diff --git a/wizards/com/sun/star/wizards/db/RecordParser.java b/wizards/com/sun/star/wizards/db/RecordParser.java new file mode 100644 index 0000000000..e4295e4734 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/RecordParser.java @@ -0,0 +1,244 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sdbc.DataType; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.uno.Any; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.wizards.common.Helper; +import com.sun.star.sdb.XCompletedExecution; +import com.sun.star.wizards.common.InvalidQueryException; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.task.XInteractionHandler; +import com.sun.star.wizards.common.PropertyNames; + +public class RecordParser extends QueryMetaData +{ + + private XNameAccess xColumns; + private com.sun.star.sdbc.XRow xResultSetRow; + public XResultSet ResultSet; + private XInterface xRowSet; + private XCompletedExecution xExecute; + private XComponent xRowSetComponent; + private XInteractionHandler xInteraction; + public FieldColumn[] GroupFieldColumns; + public FieldColumn[] RecordFieldColumns; + + /** Creates a new instance of RecordParser */ + public RecordParser(XMultiServiceFactory _xMSF) + { + super(_xMSF); + getInterfaces(); + } + + private void getInterfaces() + { + try + { + xRowSet = (XInterface) xMSF.createInstance("com.sun.star.sdb.RowSet"); + UnoRuntime.queryInterface(XColumnsSupplier.class, xRowSet); + xRowSetComponent = UnoRuntime.queryInterface(XComponent.class, xRowSet); + xExecute = UnoRuntime.queryInterface(XCompletedExecution.class, xRowSet); + XInterface oInteraction = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler"); + xInteraction = UnoRuntime.queryInterface(XInteractionHandler.class, oInteraction); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private Object getColumnStringValue(int ColIndex) + { + try + { + com.sun.star.uno.Type CurType; + Object oAny; + String sValue = xResultSetRow.getString(ColIndex); //??? + CurType = new com.sun.star.uno.Type(String.class); + oAny = AnyConverter.toObject(CurType, sValue); + return oAny; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + private Object getColumnDoubleValue(int ColIndex, boolean bisDate) + { + try + { + Double DblValue; + if (bisDate) + { + DblValue = Double.valueOf(xResultSetRow.getDouble(ColIndex) + super.getNullDateCorrection()); + } + else + { + DblValue = Double.valueOf(xResultSetRow.getDouble(ColIndex)); + } + if (!xResultSetRow.wasNull()) + { + return DblValue; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + return Any.VOID; + } + + private Object getColumnValue(int ColIndex, int iType) + { + Object oAny = Any.VOID; + switch (iType) + { + case DataType.BIT: // == -7; + case DataType.BOOLEAN: + case DataType.TINYINT: // == -6; + case DataType.BIGINT: // == -5; + case DataType.NUMERIC: // == 2; + case DataType.INTEGER: // == 4; + case DataType.SMALLINT: // == 5; + case DataType.DECIMAL: // == 3; [with fractional part] + case DataType.FLOAT: // == 6; + case DataType.REAL: // == 7; + case DataType.DOUBLE: // == 8; + case DataType.TIME: // == 92; + oAny = getColumnDoubleValue(ColIndex, false); + break; + + case DataType.DATE: // == 91; + case DataType.TIMESTAMP: // == 93; + oAny = getColumnDoubleValue(ColIndex, true); + break; + case DataType.CHAR: // == 1; + case DataType.VARCHAR: // == 12; + case DataType.LONGVARCHAR: // == -1; + oAny = getColumnStringValue(ColIndex); + break; + + } + + // Is the index OK; increment? + return oAny; + } + + public boolean executeCommand(int _nCommandType) throws InvalidQueryException + { + try + { + Helper.setUnoPropertyValue(xRowSet, "DataSourceName", DataSourceName); + Helper.setUnoPropertyValue(xRowSet, PropertyNames.ACTIVE_CONNECTION, DBConnection); + Helper.setUnoPropertyValue(xRowSet, PropertyNames.COMMAND, Command); + Helper.setUnoPropertyValue(xRowSet, PropertyNames.COMMAND_TYPE, Integer.valueOf(_nCommandType)); // CommandType + xExecute.executeWithCompletion(xInteraction); + com.sun.star.sdb.XResultSetAccess xResultAccess = UnoRuntime.queryInterface(com.sun.star.sdb.XResultSetAccess.class, xRowSet); + ResultSet = xResultAccess.createResultSet(); + xResultSetRow = UnoRuntime.queryInterface(com.sun.star.sdbc.XRow.class, ResultSet); + XColumnsSupplier xDBCols = UnoRuntime.queryInterface(XColumnsSupplier.class, ResultSet); + xColumns = xDBCols.getColumns(); + setCommandType(_nCommandType); + return true; + } + catch (Exception exception) + { + throw new InvalidQueryException(xMSF, Command, exception); + } + } + + public boolean getFields(String[] _sFieldNames, boolean binitializeDBColumns) + { + try + { + if (binitializeDBColumns) + { + initializeFieldColumns(_sFieldNames, xColumns); + } + String[] AllQueryFieldNames = xColumns.getElementNames(); + for (int i = 0; i < FieldColumns.length; i++) + { + String sFieldName = FieldColumns[i].getFieldName(); + int nColIndex = JavaTools.FieldInList(AllQueryFieldNames, sFieldName) + 1; + FieldColumns[i].ColIndex = nColIndex; + if (nColIndex == -1) + { + throw new InvalidQueryException(xMSF, Command); + } + } + GroupFieldColumns = getFieldColumnList(GroupFieldNames); + RecordFieldColumns = getFieldColumnList(getRecordFieldNames()); + return true; + } + catch (InvalidQueryException queryexception) + { + queryexception.printStackTrace(System.err); + return false; + } + } + + private FieldColumn[] getFieldColumnList(String[] _FieldNames) + { + FieldColumn[] LocFieldColumns = new FieldColumn[_FieldNames.length]; + for (int i = 0; i < _FieldNames.length; i++) + { + LocFieldColumns[i] = super.getFieldColumnByFieldName(_FieldNames[i]); + } + return LocFieldColumns; + } + + public Object getGroupColumnValue(int ColIndex) + { + FieldColumn CurDBFieldColumn = this.GroupFieldColumns[ColIndex]; + return getColumnValue(CurDBFieldColumn.ColIndex, CurDBFieldColumn.getFieldType()); + } + + public boolean getcurrentRecordData(java.util.ArrayList<Object[]> DataVector) + { + Object[] RecordValueArray = new Object[RecordFieldColumns.length]; + for (int i = 0; i < RecordFieldColumns.length; i++) + { + FieldColumn CurDBFieldColumn = this.RecordFieldColumns[i]; + RecordValueArray[i] = getColumnValue(CurDBFieldColumn.ColIndex, CurDBFieldColumn.getFieldType()); //FinalColIndex + } + DataVector.add(RecordValueArray); + return true; + } + + @Override + public void dispose() + { + if (xRowSetComponent != null) + { + xRowSetComponent.dispose(); + } + super.dispose(); + } +} diff --git a/wizards/com/sun/star/wizards/db/RelationController.java b/wizards/com/sun/star/wizards/db/RelationController.java new file mode 100644 index 0000000000..0c77d92bb1 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/RelationController.java @@ -0,0 +1,145 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import java.util.ArrayList; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XRow; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; + +/** + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class RelationController extends CommandName +{ + + private static final int PKTABLE_CAT = 1; + private static final int PKTABLE_SCHEM = 2; + private static final int PKTABLE_NAME = 3; + private static final int PKCOLUMN_NAME = 4; + private static final int FKTABLE_CAT = 5; + private static final int FKTABLE_SCHEM = 6; + private static final int FKTABLE_NAME = 7; + private static final int FKCOLUMN_NAME = 8; + + public RelationController(CommandMetaData _CommandMetaData, String _DisplayName) + { + super(_CommandMetaData, _DisplayName); + } + + public String[] getExportedKeys() + { + String[] sReferencedTableNames = new String[] + { + }; + try + { + ArrayList<String> aReferencedTableVector = new ArrayList<String>(); + XResultSet xResultSet = super.getCommandMetaData().xDBMetaData.getExportedKeys(getCatalogName(this), getSchemaName(), getTableName()); + XRow xRow = UnoRuntime.queryInterface(XRow.class, xResultSet); + while (xResultSet.next()) + { + String sForeignCatalog = xRow.getString(FKTABLE_CAT); + String sForeignScheme = xRow.getString(FKTABLE_SCHEM); + String sForeignTableName = xRow.getString(FKTABLE_NAME); + CommandName oCommandName = new CommandName(getCommandMetaData(), sForeignCatalog, sForeignScheme, sForeignTableName, false); + aReferencedTableVector.add(oCommandName.getComposedName()); + } + sReferencedTableNames = new String[aReferencedTableVector.size()]; + aReferencedTableVector.toArray(sReferencedTableNames); + } + catch (SQLException e) + { + e.printStackTrace(System.err); + } + return sReferencedTableNames; + } + + private Object getCatalogName(CommandName _oCommandName) + { + String sLocCatalog = _oCommandName.getCatalogName(); + if (sLocCatalog.equals(PropertyNames.EMPTY_STRING)) + { + return null; + } + else + { + return sLocCatalog; + } + } + + public String[][] getImportedKeyColumns(String _sreferencedtablename) + { + String[][] sKeyColumnNames = new String[][] + { + }; + try + { + CommandName oLocCommandName = new CommandName(super.getCommandMetaData(), _sreferencedtablename); + XResultSet xResultSet = super.getCommandMetaData().xDBMetaData.getImportedKeys(getCatalogName(oLocCommandName), oLocCommandName.getSchemaName(), oLocCommandName.getTableName()); + XRow xRow = UnoRuntime.queryInterface(XRow.class, xResultSet); + boolean bleaveLoop = false; + ArrayList<String> aMasterFieldNamesVector = new ArrayList<String>(); + ArrayList<String> aSlaveFieldNamesVector = new ArrayList<String>(); + while (xResultSet.next() && !bleaveLoop) + { + String sPrimaryCatalog = null; + String sPrimarySchema = null; + if (super.getCommandMetaData().xDBMetaData.supportsCatalogsInDataManipulation()) + { + sPrimaryCatalog = xRow.getString(PKTABLE_CAT); + } + if (super.getCommandMetaData().xDBMetaData.supportsSchemasInDataManipulation()) + { + sPrimarySchema = xRow.getString(PKTABLE_SCHEM); + } + String sPrimaryTableName = xRow.getString(PKTABLE_NAME); + String sPrimaryColumnName = xRow.getString(PKCOLUMN_NAME); + String sForeignColumnName = xRow.getString(FKCOLUMN_NAME); + if (JavaTools.isSame(getTableName(), sPrimaryTableName)) + { + if (sPrimarySchema == null || JavaTools.isSame(getSchemaName(), sPrimarySchema)) + { + if (JavaTools.isSame(getCatalogName(), sPrimaryCatalog)) + { + aSlaveFieldNamesVector.add(sForeignColumnName); + aMasterFieldNamesVector.add(sPrimaryColumnName); + bleaveLoop = true; //Only one relation may exist between two tables... + } + } + + } + } + sKeyColumnNames = new String[2][aMasterFieldNamesVector.size()]; + sKeyColumnNames[0] = new String[aSlaveFieldNamesVector.size()]; + sKeyColumnNames[1] = new String[aMasterFieldNamesVector.size()]; + aSlaveFieldNamesVector.toArray(sKeyColumnNames[0]); + aMasterFieldNamesVector.toArray(sKeyColumnNames[1]); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return sKeyColumnNames; + } +} diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java new file mode 100644 index 0000000000..17bc953aff --- /dev/null +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -0,0 +1,436 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.beans.*; +import com.sun.star.container.XIndexAccess; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.sdb.XSingleSelectQueryAnalyzer; +import com.sun.star.ui.dialogs.XExecutableDialog; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.sdbc.SQLException; +import com.sun.star.lang.XInitialization; +import com.sun.star.awt.XWindow; +import com.sun.star.sdb.SQLFilterOperator; + +import com.sun.star.wizards.common.*; +import java.util.ArrayList; + +public class SQLQueryComposer +{ + + private QueryMetaData CurDBMetaData; + public XSingleSelectQueryAnalyzer m_xQueryAnalyzer; + private ArrayList<CommandName> composedCommandNames = new ArrayList<CommandName>(1); + private XSingleSelectQueryComposer m_queryComposer; + private XMultiServiceFactory xMSF; + private boolean bincludeGrouping = true; + + public SQLQueryComposer(QueryMetaData _CurDBMetaData) + { + try + { + setDBMetaData(_CurDBMetaData); + xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, CurDBMetaData.DBConnection); + final Object oQueryComposer = xMSF.createInstance("com.sun.star.sdb.SingleSelectQueryComposer"); + m_xQueryAnalyzer = UnoRuntime.queryInterface(XSingleSelectQueryAnalyzer.class, oQueryComposer); + m_queryComposer = UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, m_xQueryAnalyzer); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private boolean addtoSelectClause(String DisplayFieldName) throws SQLException + { + return !(bincludeGrouping && CurDBMetaData.xDBMetaData.supportsGroupByUnrelated() && CurDBMetaData.GroupFieldNames != null && JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, DisplayFieldName) > -1); + } + + public String getSelectClause(boolean _baddAliasFieldNames) throws SQLException + { + // getFromClause() must be called first to populate composedCommandNames, + // but it's idempotent, so let's call it now in case the caller didn't already: + getFromClause(); + + String sSelectBaseClause = "SELECT "; + StringBuilder sb = new StringBuilder(sSelectBaseClause); + for (int i = 0; i < CurDBMetaData.FieldColumns.length; i++) + { + if (addtoSelectClause(CurDBMetaData.FieldColumns[i].getDisplayFieldName())) + { + int iAggregate = CurDBMetaData.getAggregateIndex(CurDBMetaData.FieldColumns[i].getDisplayFieldName()); + if (iAggregate > -1) + { + sb.append(CurDBMetaData.AggregateFieldNames[iAggregate][1]).append("(").append(getComposedAliasDisplayName(CurDBMetaData.AggregateFieldNames[iAggregate][0])).append(")"); + if (_baddAliasFieldNames) + { + sb.append(getAliasFieldNameClause(CurDBMetaData.AggregateFieldNames[iAggregate][0])); + } + } + else + { + sb.append(getComposedAliasDisplayName(CurDBMetaData.FieldColumns[i].getDisplayFieldName())); + if (_baddAliasFieldNames) + { + sb.append(getAliasFieldNameClause(CurDBMetaData.FieldColumns[i].getDisplayFieldName())); + } + } + sb.append(", "); + } + } + String sSelectClause = sb.toString(); + // TODO: little bit unhandy version of remove the append 'comma' at the end + if (sSelectClause.equals(sSelectBaseClause)) + { + sSelectClause = sSelectClause.substring(0, sSelectClause.length() - 1); + } + else + { + sSelectClause = sSelectClause.substring(0, sSelectClause.length() - 2); + } + return sSelectClause; + } + + private String getAliasFieldNameClause(String _FieldName) + { + String FieldTitle = CurDBMetaData.getFieldTitle(_FieldName); + if (!FieldTitle.equals(_FieldName)) + { + return " AS " + CommandName.quoteName(FieldTitle, CurDBMetaData.getIdentifierQuote()); + } + else + { + return ""; + } + } + + + + public void prependSortingCriteria() throws SQLException + { + prependSortingCriteria(false); + } + + private void prependSortingCriteria(boolean _baddAliasFieldNames) throws SQLException + { + XIndexAccess xColumnIndexAccess = m_xQueryAnalyzer.getOrderColumns(); + m_queryComposer.setOrder(""); + for (int i = 0; i < CurDBMetaData.getSortFieldNames().length; i++) + { + appendSortingCriterion(i, _baddAliasFieldNames); + } + for (int i = 0; i < xColumnIndexAccess.getCount(); i++) + { + try + { + XPropertySet xColumnPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xColumnIndexAccess.getByIndex(i)); + String sName = (String) xColumnPropertySet.getPropertyValue(PropertyNames.PROPERTY_NAME); + if (JavaTools.FieldInTable(CurDBMetaData.getSortFieldNames(), sName) == -1) + { + boolean bascend = AnyConverter.toBoolean(xColumnPropertySet.getPropertyValue("IsAscending")); + m_queryComposer.appendOrderByColumn(xColumnPropertySet, bascend); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + } + + private void appendSortingCriterion(int _SortIndex, boolean _baddAliasFieldNames) throws SQLException + { + String sSortValue = CurDBMetaData.getSortFieldNames()[_SortIndex][0]; + XPropertySet xColumn = CurDBMetaData.getColumnObjectByFieldName(sSortValue, _baddAliasFieldNames); + + String sSort = "ASC"; + if(CurDBMetaData.getSortFieldNames()[_SortIndex].length > 1) + { + sSort = CurDBMetaData.getSortFieldNames()[_SortIndex][1]; + } + boolean bascend = !(sSort.equals("DESC")); + m_queryComposer.appendOrderByColumn(xColumn, bascend); + } + + private void appendSortingcriteria(boolean _baddAliasFieldNames) throws SQLException + { + m_queryComposer.setOrder(""); + for (int i = 0; i < CurDBMetaData.getSortFieldNames().length; i++) + { + String sSortValue = CurDBMetaData.getSortFieldNames()[i][0]; + int iAggregate = CurDBMetaData.getAggregateIndex(sSortValue); + if (iAggregate > -1) + { + String sOrder = m_xQueryAnalyzer.getOrder(); + if (sOrder.length() > 0) + { + sOrder += ", "; + } + sOrder += CurDBMetaData.AggregateFieldNames[iAggregate][1] + "(" + getComposedAliasDisplayName(CurDBMetaData.AggregateFieldNames[iAggregate][0]) + ")"; + sOrder += " " + CurDBMetaData.getSortFieldNames()[i][1]; + m_queryComposer.setOrder(sOrder); + } + else + { + appendSortingCriterion(i, _baddAliasFieldNames); + } + } + } + + private void appendGroupByColumns(boolean _baddAliasFieldNames) throws SQLException + { + for (int i = 0; i < CurDBMetaData.GroupFieldNames.length; i++) + { + XPropertySet xColumn = CurDBMetaData.getColumnObjectByFieldName(CurDBMetaData.GroupFieldNames[i], _baddAliasFieldNames); + m_queryComposer.appendGroupByColumn(xColumn); + } + } + + private void setDBMetaData(QueryMetaData _oDBMetaData) + { + this.CurDBMetaData = _oDBMetaData; + updateComposedCommandNames(); + } + + private PropertyValue[][] replaceConditionsByAlias(PropertyValue _filterconditions[][]) + { + for (int n = 0; n < _filterconditions.length; n++) + { + for (int m = 0; m < _filterconditions[n].length; m++) + { + final String aliasName = getComposedAliasFieldName(_filterconditions[n][m].Name); + _filterconditions[n][m].Name = aliasName; + } + } + return _filterconditions; + } + + public String getQuery() + { + return m_xQueryAnalyzer.getQuery(); + } + + private void updateComposedCommandNames() + { + composedCommandNames.clear(); + String[] sCommandNames = CurDBMetaData.getIncludedCommandNames(); + for (int i = 0; i < sCommandNames.length; i++) + { + CommandName curCommandName = new CommandName(CurDBMetaData, sCommandNames[i]); + curCommandName.setAliasName(getuniqueAliasName(curCommandName.getTableName())); + composedCommandNames.add(curCommandName); + } + } + + public StringBuilder getFromClause() throws SQLException + { + StringBuilder sFromClause = new StringBuilder("FROM"); + String[] sCommandNames = CurDBMetaData.getIncludedCommandNames(); + for (int i = 0; i < sCommandNames.length; i++) + { + CommandName curCommandName = getComposedCommandByDisplayName(sCommandNames[i]); + if (curCommandName == null) { + throw new SQLException("Error: CommandName unavailable"); + } + sFromClause.append(" ").append(curCommandName.getComposedName()).append(" ").append(quoteName(curCommandName.getAliasName())); + if (i < sCommandNames.length - 1) + { + sFromClause.append(", "); + } + } + return sFromClause; + } + + public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames) + { + return setQueryCommand(_xParentWindow, _bincludeGrouping, _baddAliasFieldNames, true); + } + + private boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery) + { + return setQueryCommand(_xParentWindow, _bincludeGrouping, _baddAliasFieldNames, addQuery, false); + } + + private boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery, boolean prependSortingCriteria) + { + try + { + bincludeGrouping = _bincludeGrouping; + if (addQuery) + { + StringBuilder fromClause = getFromClause(); + String sSelectClause = getSelectClause(_baddAliasFieldNames); + StringBuilder queryclause = new StringBuilder(sSelectClause).append(" ").append(fromClause); + m_xQueryAnalyzer.setQuery(queryclause.toString()); + if (CurDBMetaData.getFilterConditions() != null && CurDBMetaData.getFilterConditions().length > 0) + { + CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions())); + m_queryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions()); + } + } + if (_bincludeGrouping) + { + appendGroupByColumns(_baddAliasFieldNames); + if (CurDBMetaData.GroupByFilterConditions.length > 0) + { + m_queryComposer.setStructuredHavingClause(CurDBMetaData.GroupByFilterConditions); + } + } + if (prependSortingCriteria) + { + prependSortingCriteria(_baddAliasFieldNames); + } + else + { + appendSortingcriteria(_baddAliasFieldNames); + } + + return true; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + displaySQLErrorDialog(exception, _xParentWindow); + return false; + } + } + + private String getComposedAliasDisplayName(String _fieldname) + { + FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByDisplayName(_fieldname); + final String curCommandName = CurFieldColumn.getCommandName(); + final String curFieldName = CurFieldColumn.getFieldName(); + CommandName curComposedCommandName = getComposedCommandByDisplayName(curCommandName); + if (curComposedCommandName == null) + { + //return _fieldname; + if ( curCommandName.length() > 0 ) + return quoteName(curCommandName) + "." + quoteName(curFieldName); + else + return quoteName(curFieldName); + } + String curAliasName = curComposedCommandName.getAliasName(); + return quoteName(curAliasName) + "." + quoteName(curFieldName); + } + + private String getComposedAliasFieldName(String _fieldname) + { + FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByFieldName(_fieldname); + final String curCommandName = CurFieldColumn.getCommandName(); + final String curFieldName = CurFieldColumn.getFieldName(); + CommandName curComposedCommandName = getComposedCommandByDisplayName(curCommandName); + if (curComposedCommandName == null) + { + //return _fieldname; + if ( curCommandName.length() > 0 ) + return quoteName(curCommandName) + "." + quoteName(curFieldName); + else + return quoteName(curFieldName); + } + String curAliasName = curComposedCommandName.getAliasName(); + return quoteName(curAliasName) + "." + quoteName(curFieldName); + } + + private CommandName getComposedCommandByAliasName(String _AliasName) + { + if (composedCommandNames != null) + { + for (CommandName commandName : composedCommandNames) + { + if (commandName.getAliasName().equals(_AliasName)) + { + return commandName; + } + } + } + return null; + } + + private CommandName getComposedCommandByDisplayName(String _DisplayName) + { + if (composedCommandNames != null) + { + for (CommandName commandName : composedCommandNames) + { + if (commandName.getDisplayName().equals(_DisplayName)) + { + return commandName; + } + } + } + return null; + } + + private String getuniqueAliasName(String _TableName) + { + int a = 0; + String AliasName = ""; + boolean bAliasNameexists = true; + String locAliasName = _TableName; + while (bAliasNameexists) + { + bAliasNameexists = (getComposedCommandByAliasName(locAliasName) != null); + if (bAliasNameexists) + { + a++; + locAliasName = _TableName + "_" + a; + } + else + { + AliasName = locAliasName; + } + } + return AliasName; + } + + private String quoteName(String _sname) + { + return CommandName.quoteName(_sname, CurDBMetaData.getIdentifierQuote()); + } + + private void displaySQLErrorDialog(Exception _exception, XWindow _xParentWindow) + { + try + { + Object oErrorDialog = CurDBMetaData.xMSF.createInstance("com.sun.star.sdb.ErrorMessageDialog"); + XInitialization xInitialize = UnoRuntime.queryInterface(XInitialization.class, oErrorDialog); + XExecutableDialog xExecute = UnoRuntime.queryInterface(XExecutableDialog.class, oErrorDialog); + PropertyValue[] rDispatchArguments = new PropertyValue[3]; + rDispatchArguments[0] = Properties.createProperty(PropertyNames.PROPERTY_TITLE, Configuration.getProductName(CurDBMetaData.xMSF) + " Base"); + rDispatchArguments[1] = Properties.createProperty("ParentWindow", _xParentWindow); + rDispatchArguments[2] = Properties.createProperty("SQLException", _exception); + xInitialize.initialize(rDispatchArguments); + xExecute.execute(); + //TODO dispose??? + } + catch (Exception typeexception) + { + typeexception.printStackTrace(System.err); + } + } + + public XSingleSelectQueryComposer getQueryComposer() + { + return m_queryComposer; + } +} diff --git a/wizards/com/sun/star/wizards/db/TableDescriptor.java b/wizards/com/sun/star/wizards/db/TableDescriptor.java new file mode 100644 index 0000000000..fca2619892 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/TableDescriptor.java @@ -0,0 +1,809 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import java.util.ArrayList; + +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.ContainerEvent; +import com.sun.star.container.XContainer; +import com.sun.star.container.XContainerListener; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbcx.KeyType; +import com.sun.star.sdbcx.XAppend; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.sdbcx.XDataDescriptorFactory; +import com.sun.star.sdbcx.XDrop; +import com.sun.star.sdbcx.XKeysSupplier; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; + +public class TableDescriptor extends CommandMetaData implements XContainerListener +{ + + private XDataDescriptorFactory xTableDataDescriptorFactory; + private XPropertySet xPropTableDataDescriptor; + private XNameAccess xNameAccessColumns; + private XIndexAccess xIndexAccessKeys; + private XDataDescriptorFactory xColumnDataDescriptorFactory; + private XContainer xTableContainer; + private XAppend xTableAppend; + private XDrop xTableDrop; + private XAppend xKeyAppend; + private XDrop xKeyDrop; + private String[] sTableFilters = null; + private final ArrayList<ColumnDescriptor> columncontainer; + private final ArrayList<XPropertySet> keycolumncontainer; + private CommandName ComposedTableName; + private XAppend xKeyColAppend; + private XColumnsSupplier xKeyColumnSupplier; + private XPropertySet xKey; + private boolean bIDFieldisInserted = false; + private String IDFieldName = PropertyNames.EMPTY_STRING; + private final String sColumnAlreadyExistsMessage; + private final XWindow xWindow; + + public TableDescriptor(XMultiServiceFactory xMSF, XWindow _xWindow, String _sColumnAlreadyExistsMessage) + { + super(xMSF); + columncontainer = new ArrayList<ColumnDescriptor>(); + keycolumncontainer = new ArrayList<XPropertySet>(); + sColumnAlreadyExistsMessage = _sColumnAlreadyExistsMessage; + xWindow = _xWindow; + } + + private static class ColumnDescriptor + { + String Name; + XPropertySet xColPropertySet; + + public ColumnDescriptor(XPropertySet _xColPropertySet, String _Name) + { + Name = _Name; + xColPropertySet = _xColPropertySet; + } + } + + @Override + public boolean getConnection(PropertyValue[] _curPropertyValue) + { + if (super.getConnection(_curPropertyValue)) + { + xTableAppend = UnoRuntime.queryInterface( XAppend.class, getTableNamesAsNameAccess() ); + xTableDrop = UnoRuntime.queryInterface( XDrop.class, getTableNamesAsNameAccess() ); + xTableDataDescriptorFactory = UnoRuntime.queryInterface( XDataDescriptorFactory.class, getTableNamesAsNameAccess() ); + xPropTableDataDescriptor = xTableDataDescriptorFactory.createDataDescriptor(); + XColumnsSupplier xColumnsSupplier = UnoRuntime.queryInterface( XColumnsSupplier.class, xPropTableDataDescriptor ); + xNameAccessColumns = xColumnsSupplier.getColumns(); + xColumnDataDescriptorFactory = UnoRuntime.queryInterface( XDataDescriptorFactory.class, xNameAccessColumns ); + try + { + createTypeInspector(); + sTableFilters = (String[]) AnyConverter.toArray(getDataSourcePropertySet().getPropertyValue("TableFilter")); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return true; + } + else + { + return false; + } + } + + private void removePrimaryKeys() + { + if (keycolumncontainer.size() > 0) + { + for (int i = (keycolumncontainer.size() - 1); i >= 0; i--) + { + keycolumncontainer.remove(i); + } + } + } + + private boolean createPrimaryKeys(String[] _fieldnames, boolean _bAutoincrementation) + { + try + { + XKeysSupplier xKeySupplier = UnoRuntime.queryInterface(XKeysSupplier.class, xPropTableDataDescriptor); + xIndexAccessKeys = xKeySupplier.getKeys(); + XDataDescriptorFactory xKeyFac = UnoRuntime.queryInterface(XDataDescriptorFactory.class, xIndexAccessKeys); + xKeyDrop = UnoRuntime.queryInterface(XDrop.class, xIndexAccessKeys); + xKeyAppend = UnoRuntime.queryInterface(XAppend.class, xKeyFac); + xKey = xKeyFac.createDataDescriptor(); + xKey.setPropertyValue("Type", Integer.valueOf(KeyType.PRIMARY)); + xKeyColumnSupplier = UnoRuntime.queryInterface(XColumnsSupplier.class, xKey); + XDataDescriptorFactory xKeyColFac = UnoRuntime.queryInterface(XDataDescriptorFactory.class, xKeyColumnSupplier.getColumns()); + xKeyColAppend = UnoRuntime.queryInterface(XAppend.class, xKeyColFac); + removePrimaryKeys(); + for (int i = 0; i < _fieldnames.length; i++) + { + XPropertySet xKeyColPropertySet = xKeyColFac.createDataDescriptor(); + xKeyColPropertySet.setPropertyValue(PropertyNames.PROPERTY_NAME, _fieldnames[i]); + keycolumncontainer.add(xKeyColPropertySet); + XPropertySet xColPropertySet = null; + if (hasByName(_fieldnames[i])) + { + xColPropertySet = getByName(_fieldnames[i]); + } + else + { + xColPropertySet = addPrimaryKeyColumn(_fieldnames[i]); + } + xColPropertySet.setPropertyValue("IsNullable", Integer.valueOf(com.sun.star.sdbc.ColumnValue.NO_NULLS)); + if (_bAutoincrementation) + { + int nDataType = oTypeInspector.getAutoIncrementIndex(xColPropertySet); + if (nDataType != TypeInspector.INVALID) + { + if (xColPropertySet.getPropertySetInfo().hasPropertyByName("IsAutoIncrement")) + { + xColPropertySet.setPropertyValue("Type", Integer.valueOf(nDataType)); + xColPropertySet.setPropertyValue("IsAutoIncrement", Boolean.valueOf(_bAutoincrementation)); + } + } + } + modifyColumn(_fieldnames[i], xColPropertySet); + } + return true; + } + catch (UnknownPropertyException e) + { + e.printStackTrace(System.err); + } + catch (PropertyVetoException e) + { + e.printStackTrace(System.err); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + } + catch (WrappedTargetException e) + { + e.printStackTrace(System.err); + } + + return false; + } + + private boolean isColumnNameDuplicate(XNameAccess _xColumns, XPropertySet _xToBeAppendedPropertySet) + { + try + { + String sColumnName = AnyConverter.toString(_xToBeAppendedPropertySet.getPropertyValue(PropertyNames.PROPERTY_NAME)); + if (_xColumns.hasByName(sColumnName)) + { + String sMessage = JavaTools.replaceSubString(sColumnAlreadyExistsMessage, sColumnName, "%FIELDNAME"); + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMessage); + return true; + } + return false; + } + catch (Exception ex) + { + ex.printStackTrace(System.err); + return false; + } + } + + /** + * creates the table under the passed name + * @param _tablename is made unique if necessary + * @return true or false to indicate successful creation or not + */ + public boolean createTable(String _catalogname, String _schemaname, String _tablename) + { + boolean breturn = true; + try + { + XAppend xAppendColumns = UnoRuntime.queryInterface(XAppend.class, xNameAccessColumns); + for (int i = 0; i < columncontainer.size(); i++) + { + XPropertySet xColPropertySet = getByIndex(i); + if (xColPropertySet != null && !isColumnNameDuplicate(xNameAccessColumns, xColPropertySet)) + { + xAppendColumns.appendByDescriptor(xColPropertySet); //xColPropertySet.setPropertyValue("Type", 32423) + } + else + { + breturn = false; + } + } + if (breturn) + { + assignTableProperty(PropertyNames.PROPERTY_NAME, _tablename); + assignTableProperty("CatalogName", _catalogname); + assignTableProperty("SchemaName", _schemaname); + xTableContainer = UnoRuntime.queryInterface(XContainer.class, getTableNamesAsNameAccess()); + xTableContainer.addContainerListener(this); + if (keycolumncontainer.size() > 0) + { + for (int i = 0; i < keycolumncontainer.size(); i++) + { + XPropertySet xKeyColPropertySet = keycolumncontainer.get(i); + if (!isColumnNameDuplicate(xKeyColumnSupplier.getColumns(), xKeyColPropertySet)) + { + xKeyColAppend.appendByDescriptor(xKeyColPropertySet); + } + else + { + breturn = false; + } + } + if (breturn) + { + xKeyAppend.appendByDescriptor(xKey); + } + } + if (breturn) + { + // TODO: LLA: describe what is he doing here. + xTableAppend.appendByDescriptor(xPropTableDataDescriptor); + } + } + } + catch (SQLException oSQLException) + { + super.callSQLErrorMessageDialog(oSQLException, xWindow); + breturn = false; + } + catch (Exception e) + { + e.printStackTrace(System.err); + breturn = false; + } + if (!breturn) + { + removeAllColumnsFromDescriptor(_tablename); + this.removePrimaryKeys(); + } + return breturn; + } + + private boolean removeAllColumnsFromDescriptor(String _tablename) + { + try + { + xPropTableDataDescriptor.setPropertyValue(PropertyNames.PROPERTY_NAME, PropertyNames.EMPTY_STRING); + if ((xKeyDrop != null) && (xIndexAccessKeys != null)) + { + int icount = xIndexAccessKeys.getCount(); + if (icount > 0) + { + for (int i = xIndexAccessKeys.getCount() - 1; i >= 0; i--) + { + xKeyDrop.dropByIndex(i); + } + } + } + XDrop xColumnDrop = UnoRuntime.queryInterface(XDrop.class, xNameAccessColumns); + for (int i = xNameAccessColumns.getElementNames().length - 1; i >= 0; i--) + { + xColumnDrop.dropByIndex(i); + } + if (xTableDrop != null) + { + if (getTableNamesAsNameAccess().hasByName(_tablename)) + { + xTableDrop.dropByName(_tablename); + } + } + if (bIDFieldisInserted) + { + this.dropColumnbyName(this.IDFieldName); + bIDFieldisInserted = false; + } + return false; + } + catch (SQLException oSQLException) + { + super.callSQLErrorMessageDialog(oSQLException, xWindow); + } + catch (Exception e1) + { + e1.printStackTrace(System.err); + } + return false; + } + + public boolean createTable(String _catalogname, String _schemaname, String _tablename, String[] _keycolumnnames, boolean _bAutoincrementation) + { + if (createPrimaryKeys(_keycolumnnames, _bAutoincrementation)) + { + return createTable(_catalogname, _schemaname, _tablename); + } + return false; + } + + private void assignTableProperty(String _spropname, String _svalue) + { + if (_svalue != null && !_svalue.equals(PropertyNames.EMPTY_STRING)) + { + try + { + xPropTableDataDescriptor.setPropertyValue(_spropname, _svalue); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + } + + public boolean modifyColumnName(String _soldname, String _snewname) + { + try + { + return modifyColumn(_soldname, PropertyNames.PROPERTY_NAME, _snewname); + } + catch (Exception e) + { + e.printStackTrace(System.err); + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, e.getMessage()); + return false; + } + } + + private boolean modifyColumn(String _sname, String _spropname, Object _oValue) + { + try + { + if (this.columncontainer.size() > 0) + { + for (int i = 0; i < columncontainer.size(); i++) + { + ColumnDescriptor oColumnDescriptor = columncontainer.get(i); + if (oColumnDescriptor.Name.equals(_sname)) + { + oColumnDescriptor.xColPropertySet.setPropertyValue(_spropname, _oValue); + if (_spropname.equals(PropertyNames.PROPERTY_NAME)) + { + oColumnDescriptor.Name = (String) _oValue; + } + columncontainer.remove(i); + columncontainer.add(i, oColumnDescriptor); + return true; + } + } + } + } + catch (UnknownPropertyException e) + { + e.printStackTrace(System.err); + } + catch (PropertyVetoException e) + { + e.printStackTrace(System.err); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + } + catch (WrappedTargetException e) + { + e.printStackTrace(System.err); + } + return false; + } + + public boolean modifyColumn(String _sname, XPropertySet _xColPropertySet) + { + try + { + if (this.columncontainer.size() > 0) + { + for (int i = 0; i < columncontainer.size(); i++) + { + ColumnDescriptor oColumnDescriptor = columncontainer.get(i); + if (oColumnDescriptor.Name.equals(_sname)) + { + oColumnDescriptor.xColPropertySet = _xColPropertySet; + oColumnDescriptor.Name = (String) _xColPropertySet.getPropertyValue(PropertyNames.PROPERTY_NAME); + columncontainer.remove(i); + columncontainer.add(i, oColumnDescriptor); + return true; + } + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return false; + } + + public void dropColumnbyName(String _sname) + { + try + { + if (columncontainer.size() > 0) + { + for (int i = 0; i < columncontainer.size(); i++) + { + ColumnDescriptor oColumnDescriptor = columncontainer.get(i); + if (oColumnDescriptor != null) + { + if (oColumnDescriptor.Name.equals(_sname)) + { + columncontainer.remove(i); + } + } + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private String[] getColumnNames() + { + if (columncontainer.size() > 0) + { + try + { + String[] fieldnames = new String[columncontainer.size()]; + for (int i = 0; i < columncontainer.size(); i++) + { + ColumnDescriptor oColumnDescriptor = columncontainer.get(i); + fieldnames[i] = oColumnDescriptor.Name; + } + return fieldnames; + } + catch (RuntimeException e) + { + e.printStackTrace(System.err); + } + } + return new String[] + { + }; + } + + private boolean hasByName(String _fieldname) + { + try + { + if (columncontainer.size() > 0) + { + for (int i = 0; i < columncontainer.size(); i++) + { + ColumnDescriptor oColumnDescriptor = columncontainer.get(i); + if (oColumnDescriptor.Name.equals(_fieldname)) + { + return true; + } + } + } + } + catch (RuntimeException e) + { + e.printStackTrace(System.err); + } + return false; + } + + private ColumnDescriptor getColumnDescriptorByName(String _fieldname) + { + try + { + if (this.columncontainer.size() > 0) + { + for (int i = 0; i < columncontainer.size(); i++) + { + ColumnDescriptor oColumnDescriptor = columncontainer.get(i); + if (oColumnDescriptor.Name.equals(_fieldname)) + { + return oColumnDescriptor; + } + } + } + } + catch (RuntimeException e) + { + e.printStackTrace(System.err); + } + return null; + } + + public XPropertySet getByName(String _fieldname) + { + ColumnDescriptor oColumnDescriptor = getColumnDescriptorByName(_fieldname); + if (oColumnDescriptor != null) + { + return oColumnDescriptor.xColPropertySet; + } + else + { + return null; + } + } + + private XPropertySet getByIndex(int _index) + { + try + { + if (columncontainer.size() > _index) + { + ColumnDescriptor oColumnDescriptor = columncontainer.get(_index); + return oColumnDescriptor.xColPropertySet; + } + } + catch (RuntimeException e) + { + e.printStackTrace(System.err); + } + return null; + } + + public XPropertySet clonePropertySet(String _snewname, XPropertySet _xnewPropertySet) + { + XPropertySet xRetPropertySet = xColumnDataDescriptorFactory.createDataDescriptor(); + try + { + if (hasByName(_snewname)) + { + Object oColumn = getByName(_snewname); + XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, oColumn); + Property[] aColProperties = xPropertySet.getPropertySetInfo().getProperties(); + for (int i = 0; i < aColProperties.length; i++) + { + String sPropName = aColProperties[i].Name; + Object oColValue = _xnewPropertySet.getPropertyValue(sPropName); + xRetPropertySet.setPropertyValue(sPropName, oColValue); + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return xRetPropertySet; + } + + public boolean addColumn(PropertyValue[] _aNewPropertyValues) + { + try + { + String sname = (String) Properties.getPropertyValue(_aNewPropertyValues, PropertyNames.PROPERTY_NAME); + if (!hasByName(sname)) + { + ColumnPropertySet oPropertySet = new ColumnPropertySet(oTypeInspector, xColumnDataDescriptorFactory.createDataDescriptor()); + oPropertySet.assignPropertyValues(_aNewPropertyValues, true); + ColumnDescriptor oColumnDescriptor = new ColumnDescriptor(oPropertySet.xPropertySet, sname); + this.columncontainer.add(oColumnDescriptor); + return true; + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return false; + } + + public boolean moveColumn(int _nOldIndex, int _nNewIndex) + { + try + { + ColumnDescriptor oColumnDescriptor = this.columncontainer.get(_nOldIndex); + this.columncontainer.remove(_nOldIndex); + columncontainer.add(_nNewIndex, oColumnDescriptor); + return true; + } + catch (Exception e) + { + e.printStackTrace(System.err); + return false; + } + } + + + + private XPropertySet addPrimaryKeyColumn(String _columnname) + { + try + { + if (!hasByName(_columnname)) + { + try + { + XPropertySet xColPropertySet = xColumnDataDescriptorFactory.createDataDescriptor(); + IDFieldName = Desktop.getUniqueName(getColumnNames(), _columnname, PropertyNames.EMPTY_STRING); + xColPropertySet.setPropertyValue(PropertyNames.PROPERTY_NAME, IDFieldName); + + int nDataType = oTypeInspector.convertDataType(com.sun.star.sdbc.DataType.INTEGER); + xColPropertySet.setPropertyValue("Type", Integer.valueOf(nDataType)); + xColPropertySet.setPropertyValue("TypeName", oTypeInspector.getDefaultTypeName(nDataType, null)); + ColumnDescriptor oColumnDescriptor = new ColumnDescriptor(xColPropertySet, IDFieldName); + this.columncontainer.add(0, oColumnDescriptor); + this.bIDFieldisInserted = true; + return xColPropertySet; + } + catch (RuntimeException e1) + { + e1.printStackTrace(System.err); + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return null; + } + + public String[] getNonBinaryFieldNames() + { + ArrayList<String> NonBinaryFieldNameVector = new ArrayList<String>(); + try + { + for (int i = 0; i < columncontainer.size(); i++) + { + ColumnDescriptor oColumnDescriptor = columncontainer.get(i); + XPropertySet xColPropertySet = getByName(oColumnDescriptor.Name); + int itype; + try + { + itype = AnyConverter.toInt(xColPropertySet.getPropertyValue("Type")); + if (!isBinaryDataType(itype)) + { + NonBinaryFieldNameVector.add(oColumnDescriptor.Name); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + } + catch (RuntimeException e) + { + e.printStackTrace(System.err); + } + String[] sbinaryfieldnames = new String[NonBinaryFieldNameVector.size()]; + NonBinaryFieldNameVector.toArray(sbinaryfieldnames); + return sbinaryfieldnames; + } + + public String getComposedTableName(String _scatalogname, String _sschemaname, String _stablename) + { + ComposedTableName = new CommandName(this, _scatalogname, _sschemaname, _stablename, false); + return ComposedTableName.getComposedName(); + } + + public String getComposedTableName() + { + if (ComposedTableName != null) + { + return this.ComposedTableName.getComposedName(); + } + else + { + return null; + } + } + + /* (non-Javadoc) + * @see com.sun.star.container.XContainerListener#elementInserted(com.sun.star.container.ContainerEvent) + */ + public void elementInserted(ContainerEvent arg0) + { + try + { + XPropertySet xTablePropertySet = UnoRuntime.queryInterface(XPropertySet.class, arg0.Element); + String stablename = AnyConverter.toString(xTablePropertySet.getPropertyValue(PropertyNames.PROPERTY_NAME)); + String sschemaname = AnyConverter.toString(xPropTableDataDescriptor.getPropertyValue("SchemaName")); + String scatalogname = AnyConverter.toString(xPropTableDataDescriptor.getPropertyValue("CatalogName")); + ComposedTableName = new CommandName(this, scatalogname, sschemaname, stablename, false); + appendTableNameToFilter(ComposedTableName.getComposedName()); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + /* (non-Javadoc) + * @see com.sun.star.container.XContainerListener#elementRemoved(com.sun.star.container.ContainerEvent) + */ + public void elementRemoved(ContainerEvent arg0) + { + } + + /* (non-Javadoc) + * @see com.sun.star.container.XContainerListener#elementReplaced(com.sun.star.container.ContainerEvent) + */ + public void elementReplaced(ContainerEvent arg0) + { + } + + /* (non-Javadoc) + * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject) + */ + public void disposing(EventObject arg0) + { + } + + private boolean appendTableNameToFilter(String _scomposedtablename) + { + boolean bhastoinsert = true; + for (int i = 0; i < sTableFilters.length; i++) + { + if (sTableFilters[i].compareTo("%") > -1) + { + if (sTableFilters[i].endsWith("." + _scomposedtablename)) + { + bhastoinsert = false; + } + else if (sTableFilters[i].length() == 1) + { + bhastoinsert = false; + } + } + else if (sTableFilters[i].equals(_scomposedtablename)) + { + bhastoinsert = false; + } + if (!bhastoinsert) + { + break; + } + } + if (bhastoinsert) + { + String[] sNewTableFilters = new String[sTableFilters.length + 1]; + System.arraycopy(sTableFilters, 0, sNewTableFilters, 0, sTableFilters.length); + sNewTableFilters[sTableFilters.length] = _scomposedtablename; + sTableFilters = sNewTableFilters; + try + { + getDataSourcePropertySet().setPropertyValue("TableFilter", sTableFilters); + } + catch (Exception e) + { + e.printStackTrace(System.err); + bhastoinsert = false; + } + } + return bhastoinsert; + } +} + diff --git a/wizards/com/sun/star/wizards/db/TypeInspector.java b/wizards/com/sun/star/wizards/db/TypeInspector.java new file mode 100644 index 0000000000..831378e961 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/TypeInspector.java @@ -0,0 +1,367 @@ +/* + * 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 . + */ +package com.sun.star.wizards.db; + +import java.util.ArrayList; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.sdbc.ColumnValue; +import com.sun.star.sdbc.DataType; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XRow; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; + +public class TypeInspector +{ + + private String[] sDataTypeNames; + private int[] nDataTypeInfos; + private int[] nPrecisionInfos; + private int[] nNullableInfos; + private boolean[] bisAutoIncrementableInfos; + private int[] nMinScaleInfos; + private int[] nMaxScaleInfos; + private final int[] nNumericFallBackList = new int[] + { + DataType.INTEGER, DataType.FLOAT, DataType.REAL, DataType.DOUBLE, DataType.NUMERIC, DataType.DECIMAL + }; + static final int INVALID = 999999; + + public TypeInspector(XResultSet _xResultSet) + { + try + { + ArrayList<String> aTypeNameVector = new ArrayList<String>(); + ArrayList<Integer> aTypeVector = new ArrayList<Integer>(); + ArrayList<Integer> aNullableVector = new ArrayList<Integer>(); + ArrayList<Boolean> aAutoIncrementVector = new ArrayList<Boolean>(); + ArrayList<Integer> aPrecisionVector = new ArrayList<Integer>(); + ArrayList<Integer> aMinScaleVector = new ArrayList<Integer>(); + ArrayList<Integer> aMaxScaleVector = new ArrayList<Integer>(); + XRow xRow = UnoRuntime.queryInterface(XRow.class, _xResultSet); + while (_xResultSet.next()) + { + aTypeNameVector.add(xRow.getString(1)); + aTypeVector.add(Integer.valueOf(xRow.getShort(2))); + aPrecisionVector.add(Integer.valueOf(xRow.getInt(3))); + aNullableVector.add(Integer.valueOf(xRow.getShort(7))); + aAutoIncrementVector.add(Boolean.valueOf(xRow.getBoolean(12))); + aMinScaleVector.add(Integer.valueOf(xRow.getShort(14))); + aMaxScaleVector.add(Integer.valueOf(xRow.getShort(15))); + + } + sDataTypeNames = new String[aTypeNameVector.size()]; + aTypeNameVector.toArray(sDataTypeNames); + nDataTypeInfos = JavaTools.IntegerTointList(aTypeVector); + nNullableInfos = JavaTools.IntegerTointList(aNullableVector); + bisAutoIncrementableInfos = JavaTools.BooleanTobooleanList(aAutoIncrementVector); + nPrecisionInfos = JavaTools.IntegerTointList(aPrecisionVector); + nMinScaleInfos = JavaTools.IntegerTointList(aMinScaleVector); + nMaxScaleInfos = JavaTools.IntegerTointList(aMaxScaleVector); + } + catch (SQLException e) + { + e.printStackTrace(System.err); + } + } + + public int getScale(XPropertySet _xColPropertySet) + { + try + { + int i = getDataTypeIndex(_xColPropertySet, false); + int nScale = AnyConverter.toInt(_xColPropertySet.getPropertyValue("Scale")); + if (i == -1) + { + return nScale; + } + if (nScale > nMaxScaleInfos[i]) + { + return nMaxScaleInfos[i]; + } + else if (nScale < nMinScaleInfos[i]) + { + return nMinScaleInfos[i]; + } + else + { + return nScale; + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + return 0; + } + } + + public int getNullability(XPropertySet _xColPropertySet, int _nNullable) + { + int i = getDataTypeIndex(_xColPropertySet, false); + if (i == -1) + { + return ColumnValue.NO_NULLS; + } + if (_nNullable == ColumnValue.NULLABLE) + { + return nNullableInfos[i]; //probably nullability is not allowed + } + return _nNullable; + } + + + + public int isNullable(XPropertySet _xColPropertySet) + { + int i = getDataTypeIndex(_xColPropertySet, false); + if (i > -1) + { + return nNullableInfos[i]; + } + else + { + return ColumnValue.NO_NULLS; + } + } + + private int getDataTypeIndex(XPropertySet _xColPropertySet, boolean _bCheckNumericAttributes) + { + try + { + int nPrecision = -1; + int nScale = -1; + int nDataType = AnyConverter.toInt(_xColPropertySet.getPropertyValue("Type")); + String sTypeName = AnyConverter.toString(_xColPropertySet.getPropertyValue("TypeName")); + if (_bCheckNumericAttributes) + { + nPrecision = AnyConverter.toInt(_xColPropertySet.getPropertyValue("Precision")); + nScale = AnyConverter.toInt(_xColPropertySet.getPropertyValue("Scale")); + } + boolean bleaveloop = false; + int startindex = 0; + while (!bleaveloop) + { + int i = JavaTools.FieldInIntTable(nDataTypeInfos, nDataType, startindex); + startindex = i + 1; + bleaveloop = (i < 0); + if (!bleaveloop && sTypeName.equals(sDataTypeNames[i])) + { + if (_bCheckNumericAttributes) + { + if (nPrecision <= nPrecisionInfos[i] && (nScale >= nMinScaleInfos[i]) && (nScale <= nMinScaleInfos[i]) ) + { + return i; + } + } + else + { + return i; + } + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return -1; + } + + private boolean supportsDataType(int _curDataType) + { + return (JavaTools.FieldInIntTable(nDataTypeInfos, _curDataType) > -1); + } + + private int getLastConversionFallbackDataType() + { + if (supportsDataType(DataType.VARCHAR)) + { + return DataType.VARCHAR; + } + else + { + return DataType.LONGVARCHAR; + } + } + + /** + * an empty string is returned when no appropriate Typename can be found + * finds the first TypeName of the passed datatype. + */ + public String getDefaultTypeName(int _curDataType, Integer precision) + { + String ret = PropertyNames.EMPTY_STRING; + for (int i = 0; i < nDataTypeInfos.length; i++) + { + if (nDataTypeInfos[i] == _curDataType) + { + if (precision == null || nPrecisionInfos[i] >= precision.intValue()) + { + ret = sDataTypeNames[i]; // this fits best ! + break; + } + else if (ret.length() == 0) + { + // in case we don't find anything else, we at return a typename + // with the correct class + ret = sDataTypeNames[i]; + } + } + } + return ret; + } + + public int getDataType(String _sTypeName) + { + int i = JavaTools.FieldInList(sDataTypeNames, _sTypeName); + if (i > -1) + { + return nDataTypeInfos[i]; + } + else + { + return getLastConversionFallbackDataType(); + } + } + + public int convertDataType(int _curDataType) + { + int retDataType = _curDataType; + if (!supportsDataType(_curDataType)) + { + switch (_curDataType) + { + case DataType.BIT: + retDataType = convertDataType(DataType.BOOLEAN); + break; + case DataType.BOOLEAN: + retDataType = convertDataType(DataType.BIT); + break; + case DataType.TINYINT: + retDataType = convertDataType(DataType.SMALLINT); + break; + case DataType.SMALLINT: + retDataType = convertDataType(DataType.INTEGER); + break; + case DataType.INTEGER: + retDataType = convertDataType(DataType.FLOAT); + break; + case DataType.FLOAT: + retDataType = convertDataType(DataType.REAL); + break; + case DataType.DATE: + case DataType.TIME: + retDataType = convertDataType(DataType.TIMESTAMP); + break; + case DataType.TIMESTAMP: + case DataType.REAL: + case DataType.BIGINT: + retDataType = convertDataType(DataType.DOUBLE); + break; + case DataType.DOUBLE: + retDataType = convertDataType(DataType.NUMERIC); + break; + case DataType.NUMERIC: + retDataType = convertDataType(DataType.DECIMAL); + break; + case DataType.DECIMAL: + if (supportsDataType(DataType.DOUBLE)) + { + retDataType = convertDataType(DataType.DOUBLE); + } + else if (supportsDataType(DataType.NUMERIC)) + { + retDataType = DataType.NUMERIC; + } + else + { + retDataType = getLastConversionFallbackDataType(); + } + break; + case DataType.VARCHAR: + retDataType = getLastConversionFallbackDataType(); + break; + default: + retDataType = getLastConversionFallbackDataType(); + } + } + return retDataType; + } + + public int getAutoIncrementIndex(XPropertySet _xColPropertySet) + { + try + { + boolean bleaveloop = false; + int startindex = 0; + int curDataType = ((Integer) _xColPropertySet.getPropertyValue("Type")).intValue(); + while (!bleaveloop) + { + int i = JavaTools.FieldInIntTable(nDataTypeInfos, curDataType, startindex); + startindex = i + 1; + bleaveloop = (i == -1); + if (!bleaveloop && bisAutoIncrementableInfos[i]) + { + return nDataTypeInfos[i]; + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return INVALID; + + } + + public boolean isAutoIncrementable(XPropertySet _xColPropertySet) + { + return (getAutoIncrementIndex(_xColPropertySet) != INVALID); + } + + /** Do we have a datatype that supports AutoIncrementation? + */ + public boolean isAutoIncrementationSupported() + { + for (int n = 0; n < this.nNumericFallBackList.length; n++) + { + int nDataType = nNumericFallBackList[n]; + boolean bleaveloop = false; + int startindex = 0; + while (!bleaveloop) + { + int i = JavaTools.FieldInIntTable(nDataTypeInfos, nDataType, startindex); + bleaveloop = (i < 0); + if (!bleaveloop) + { + if (this.bisAutoIncrementableInfos[i]) + { + return true; + } + startindex = i + 1; + } + startindex = i + 1; + } + } + return false; + } +} diff --git a/wizards/com/sun/star/wizards/document/Control.java b/wizards/com/sun/star/wizards/document/Control.java new file mode 100644 index 0000000000..73f91b75e8 --- /dev/null +++ b/wizards/com/sun/star/wizards/document/Control.java @@ -0,0 +1,346 @@ +/* + * 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 . + */ +package com.sun.star.wizards.document; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XLayoutConstrains; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.wizards.common.*; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.AnyConverter; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.util.Date; +import com.sun.star.util.Time; + +public class Control extends Shape +{ + + XControlModel xControlModel; + private XControl xControl; + public XPropertySet xPropertySet; + XWindowPeer xWindowPeer; + private static final int SOMAXTEXTSIZE = 50; + private int icontroltype; + private XNameContainer xFormName; + private static final int IIMGFIELDWIDTH = 3000; + + public Control() + { + } + + public Control(FormHandler _oFormHandler, String _sServiceName, Point _aPoint) + { + super(_oFormHandler, _sServiceName, _aPoint, null); + } + + public Control(FormHandler _oFormHandler, XNameContainer _xFormName, int _icontroltype, String _FieldName, Point _aPoint, Size _aSize) + { + super(_oFormHandler, _aPoint, _aSize); + xFormName = _xFormName; + createControl(_icontroltype, null, _FieldName); + } + + public Control(FormHandler _oFormHandler, int _icontroltype, Point _aPoint, Size _aSize) + { + super(_oFormHandler, _aPoint, _aSize); + createControl(_icontroltype, null, null); + } + + private void createControl(int _icontroltype, XShapes _xGroupShapes, String _FieldName) + { + try + { + icontroltype = _icontroltype; + String sServiceName = oFormHandler.sModelServices[icontroltype]; + Object oControlModel = oFormHandler.xMSFDoc.createInstance(sServiceName); + xControlModel = UnoRuntime.queryInterface( XControlModel.class, oControlModel ); + xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oControlModel ); + + XPropertySetInfo xPSI = xPropertySet.getPropertySetInfo(); + if ( xPSI.hasPropertyByName( "MouseWheelBehavior" ) ) + xPropertySet.setPropertyValue( "MouseWheelBehavior", Short.valueOf( com.sun.star.awt.MouseWheelBehavior.SCROLL_DISABLED ) ); + + insertControlInContainer(_FieldName); + xControlShape.setControl(xControlModel); + if (_xGroupShapes == null) + { + oFormHandler.xDrawPage.add(xShape); + } + else + { + _xGroupShapes.add(xShape); + } + xControl = oFormHandler.xControlAccess.getControl(xControlModel); + UnoRuntime.queryInterface( XPropertySet.class, xControl ); + xWindowPeer = xControl.getPeer(); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private void insertControlInContainer(String _fieldname) + { + try + { + if (xFormName != null) + { + XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, xFormName); + String sControlName = Desktop.getUniqueName(xNameAccess, getControlName(_fieldname)); + xPropertySet.setPropertyValue(PropertyNames.PROPERTY_NAME, sControlName); + xFormName.insertByName(sControlName, xControlModel); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private String getControlName(String _fieldname) + { + String controlname = PropertyNames.EMPTY_STRING; + switch (getControlType()) + { + case FormHandler.SOLABEL: + controlname = "lbl" + _fieldname; + break; + case FormHandler.SOTEXTBOX: + controlname = "txt" + _fieldname; + break; + case FormHandler.SOCHECKBOX: + controlname = "chk" + _fieldname; + break; + case FormHandler.SODATECONTROL: + controlname = "dat" + _fieldname; + break; + case FormHandler.SOTIMECONTROL: + controlname = "tim" + _fieldname; + break; + case FormHandler.SONUMERICCONTROL: + controlname = "fmt" + _fieldname; + break; + case FormHandler.SOGRIDCONTROL: + controlname = "grd" + _fieldname; + break; + case FormHandler.SOIMAGECONTROL: + controlname = "img" + _fieldname; + break; + default: + controlname = "ctrl" + _fieldname; + } + return controlname; + } + + public int getPreferredWidth(String sText) + { + Size aPeerSize = getPreferredSize(sText); + return ((aPeerSize.Width + 10) * oFormHandler.getXPixelFactor()); + } + + public int getPreferredHeight(String sText) + { + Size aPeerSize = getPreferredSize(sText); + if (getControlType() == FormHandler.SOCHECKBOX) + { + return (aPeerSize.Height * oFormHandler.getXPixelFactor()); + } + else + { + return ((aPeerSize.Height + 2) * oFormHandler.getXPixelFactor()); + } + } + + public int getPreferredWidth() + { + if (getControlType() == FormHandler.SOIMAGECONTROL) + { + return IIMGFIELDWIDTH; + } + else + { + Size aPeerSize = getPeerSize(); + int nWidth; + if (aPeerSize == null) + nWidth = 0; + else + nWidth = aPeerSize.Width; + + // We increase the preferred Width a bit so that the control does not become too small + // when we change the border from "3D" to "Flat" + if (getControlType() == FormHandler.SOCHECKBOX) + { + return nWidth * oFormHandler.getXPixelFactor(); + } + else + { + return (nWidth * oFormHandler.getXPixelFactor()) + 200; + } + } + } + + public int getPreferredHeight() + { + if (getControlType() == FormHandler.SOIMAGECONTROL) + { + return 2000; + } + else + { + Size aPeerSize = getPeerSize(); + int nHeight; + if (aPeerSize == null) + nHeight = 0; + else + nHeight = aPeerSize.Height; + + // We increase the preferred Height a bit so that the control does not become too small + // when we change the border from "3D" to "Flat" + return ((nHeight + 1) * oFormHandler.getYPixelFactor()); + } + } + + private Size getPreferredSize(String sText) + { + try + { + if (xPropertySet.getPropertySetInfo().hasPropertyByName("Text")) + { + xPropertySet.setPropertyValue("Text", sText); + } + else if (xPropertySet.getPropertySetInfo().hasPropertyByName(PropertyNames.PROPERTY_LABEL)) + { + xPropertySet.setPropertyValue(PropertyNames.PROPERTY_LABEL, sText); + } + else + { + throw new IllegalArgumentException(); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return getPeer().getPreferredSize(); + } + + public void setPropertyValue(String _sPropertyName, Object _aPropertyValue) throws Exception + { + if (xPropertySet.getPropertySetInfo().hasPropertyByName(_sPropertyName)) + { + xPropertySet.setPropertyValue(_sPropertyName, _aPropertyValue); + } + } + + /** the peer should be retrieved every time before it is used because it + * might be disposed otherwise + */ + private XLayoutConstrains getPeer() + { + return UnoRuntime.queryInterface(XLayoutConstrains.class, xControl.getPeer()); + } + + private Size getPeerSize() + { + try + { + Size aPreferredSize = null; + double dblEffMax = 0; + if (xPropertySet.getPropertySetInfo().hasPropertyByName("EffectiveMax")) + { + if (xPropertySet.getPropertyValue("EffectiveMax") != com.sun.star.uno.Any.VOID) + { + dblEffMax = AnyConverter.toDouble(xPropertySet.getPropertyValue("EffectiveMax")); + } + if (dblEffMax == 0) + { + // This is relevant for decimal fields + xPropertySet.setPropertyValue("EffectiveValue", Double.valueOf(99999)); + } + else + { + xPropertySet.setPropertyValue("EffectiveValue", Double.valueOf(dblEffMax)); //Double.valueOf(100000.2)); + } + aPreferredSize = getPeer().getPreferredSize(); + xPropertySet.setPropertyValue("EffectiveValue", com.sun.star.uno.Any.VOID); + } + else if (getControlType() == FormHandler.SOCHECKBOX) + { + aPreferredSize = getPeer().getPreferredSize(); + } + else if (getControlType() == FormHandler.SODATECONTROL) + { + Date d = new Date(); + d.Day = 30; + d.Month = 12; + d.Year = 9999; + xPropertySet.setPropertyValue("Date", d); + aPreferredSize = getPeer().getPreferredSize(); + xPropertySet.setPropertyValue("Date", com.sun.star.uno.Any.VOID); + } + else if (getControlType() == FormHandler.SOTIMECONTROL) + { + Time t = new Time(); + t.NanoSeconds = 999999999; + t.Seconds = 59; + t.Minutes = 59; + t.Hours = 22; + xPropertySet.setPropertyValue("Time", t); + aPreferredSize = getPeer().getPreferredSize(); + xPropertySet.setPropertyValue("Time", com.sun.star.uno.Any.VOID); + } + else + { + String stext; + short iTextLength = AnyConverter.toShort(xPropertySet.getPropertyValue("MaxTextLen")); + if (iTextLength < SOMAXTEXTSIZE) + { + stext = FormHandler.SOSIZETEXT.substring(0, SOMAXTEXTSIZE); + } + else + { + stext = FormHandler.SOSIZETEXT.substring(0, iTextLength); + } + xPropertySet.setPropertyValue("Text", stext); + aPreferredSize = getPeer().getPreferredSize(); + xPropertySet.setPropertyValue("Text", PropertyNames.EMPTY_STRING); + } + return aPreferredSize; + } + catch (Exception e) + { + e.printStackTrace(System.err); + return null; + } + } + + public int getControlType() + { + return icontroltype; + } +} diff --git a/wizards/com/sun/star/wizards/document/DatabaseControl.java b/wizards/com/sun/star/wizards/document/DatabaseControl.java new file mode 100644 index 0000000000..fc756fa4c0 --- /dev/null +++ b/wizards/com/sun/star/wizards/document/DatabaseControl.java @@ -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 . + */ + +package com.sun.star.wizards.document; + +import com.sun.star.awt.Point; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.container.XNameContainer; +import com.sun.star.sdbc.DataType; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.FieldColumn; + +/** + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class DatabaseControl extends Control +{ + + private int m_nFieldType; + + public DatabaseControl(GridControl _oGridControl, FieldColumn _curfieldcolumn) + { + super(); + if (_curfieldcolumn.getFieldType() != DataType.TIMESTAMP) + { + createGridColumn(_oGridControl, _curfieldcolumn, _curfieldcolumn.getFieldType(), _curfieldcolumn.getFieldTitle()); + } + } + + public DatabaseControl(GridControl _oGridControl, FieldColumn _curfieldcolumn, int _fieldtype, String _columntitle) + { + super(); + createGridColumn(_oGridControl, _curfieldcolumn, _fieldtype, _columntitle); + } + + private int getFieldType() + { + return m_nFieldType; + } + + private void createGridColumn(GridControl _oGridControl, FieldColumn _curfieldcolumn, int _fieldtype, String _columntitle) + { + try + { + m_nFieldType = _fieldtype; + String sFieldName = _curfieldcolumn.getFieldName(); + String sUniqueName = Desktop.getUniqueName(_oGridControl.xNameAccess, sFieldName); + + String sGridColumnName = getGridColumnName(); + XPropertySet xPropColumn = _oGridControl.xGridColumnFactory.createColumn(sGridColumnName); + xPropColumn.setPropertyValue(PropertyNames.PROPERTY_NAME, sUniqueName); + boolean bHidden = false; + if (_fieldtype == DataType.LONGVARBINARY) //TODO CONTROLType abfragen!!!!!! + { + bHidden = true; + } + xPropColumn.setPropertyValue("Hidden", Boolean.valueOf(bHidden)); + xPropColumn.setPropertyValue("DataField", sFieldName); + xPropColumn.setPropertyValue(PropertyNames.PROPERTY_LABEL, _columntitle); + xPropColumn.setPropertyValue(PropertyNames.PROPERTY_WIDTH, 0); // Width of column is adjusted to Columname + + XPropertySetInfo xPSI = xPropColumn.getPropertySetInfo(); + if ( xPSI.hasPropertyByName( "MouseWheelBehavior" ) ) + xPropColumn.setPropertyValue( "MouseWheelBehavior", Short.valueOf( com.sun.star.awt.MouseWheelBehavior.SCROLL_DISABLED ) ); + + setNumericLimits(); + _oGridControl.xNameContainer.insertByName(sFieldName, xPropColumn); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public DatabaseControl(FormHandler _oFormHandler, String _sServiceName, Point _aPoint) + { + super(_oFormHandler, _sServiceName, _aPoint); + } + + public DatabaseControl(FormHandler _oFormHandler, XNameContainer _xFormName, String _curFieldName, int _fieldtype, Point _aPoint) + { + super(_oFormHandler, _xFormName, _oFormHandler.getControlType(_fieldtype), _curFieldName, _aPoint, null); + try + { + m_nFieldType = _fieldtype; + Helper.setUnoPropertyValue(xControlModel, "DataField", _curFieldName); + setNumericLimits(); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private String getGridColumnName() + { + for (int i = 0; i < FormHandler.oControlData.length; i++) + { + if (FormHandler.oControlData[i].DataType == getFieldType()) + { + return FormHandler.oControlData[i].GridColumnName; + } + } + return PropertyNames.EMPTY_STRING; + } + + public int getControlHeight() + { + if (getControlType() == FormHandler.SOIMAGECONTROL) + { + return oFormHandler.getControlReferenceHeight() * 4; + } + else + { + if (getFieldType() == DataType.LONGVARCHAR) + { + return oFormHandler.getControlReferenceHeight() * 4; + } + else if (getControlType() == FormHandler.SOCHECKBOX) + { + return super.getPreferredHeight(); + } + } + return oFormHandler.getControlReferenceHeight(); + } + + public int getControlWidth() + { + if (getControlType() == FormHandler.SOIMAGECONTROL) + { + return 2 * getControlHeight(); + } + if (getFieldType() == DataType.LONGVARCHAR) + { + return 2 * getControlHeight(); + } + else + { + return getPreferredWidth(); + } + } + + private void setNumericLimits() + { + try + { + if (getControlType() == FormHandler.SONUMERICCONTROL) + { + xPropertySet.setPropertyValue("TreatAsNumber", Boolean.TRUE); + switch (getFieldType()) + { + case DataType.BIGINT: + xPropertySet.setPropertyValue("EffectiveMax", Double.valueOf(Long.MAX_VALUE)); + xPropertySet.setPropertyValue("EffectiveMin", Double.valueOf(Long.MIN_VALUE)); + break; + case DataType.INTEGER: + xPropertySet.setPropertyValue("EffectiveMax", Double.valueOf(Integer.MAX_VALUE)); + xPropertySet.setPropertyValue("EffectiveMin", Double.valueOf(Integer.MIN_VALUE)); + break; + case DataType.SMALLINT: + xPropertySet.setPropertyValue("EffectiveMax", Double.valueOf(Short.MAX_VALUE)); + xPropertySet.setPropertyValue("EffectiveMin", Double.valueOf(Short.MIN_VALUE)); + break; + case DataType.TINYINT: + xPropertySet.setPropertyValue("EffectiveMax", Double.valueOf(Byte.MAX_VALUE)); + xPropertySet.setPropertyValue("EffectiveMin", Double.valueOf(Byte.MIN_VALUE)); + break; + case DataType.FLOAT: + case DataType.REAL: + case DataType.DOUBLE: + case DataType.DECIMAL: + case DataType.NUMERIC: + break; + } + } + else if (getControlType() == FormHandler.SOIMAGECONTROL) + { + xPropertySet.setPropertyValue("ScaleMode", com.sun.star.awt.ImageScaleMode.ISOTROPIC); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + /** + * @return + */ +} diff --git a/wizards/com/sun/star/wizards/document/FormHandler.java b/wizards/com/sun/star/wizards/document/FormHandler.java new file mode 100644 index 0000000000..6ff44ceb3a --- /dev/null +++ b/wizards/com/sun/star/wizards/document/FormHandler.java @@ -0,0 +1,447 @@ +/* + * 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 . + */ +package com.sun.star.wizards.document; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XChild; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.view.XControlAccess; +import com.sun.star.wizards.common.*; + +import com.sun.star.sdbc.DataType; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.XInterface; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPageSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapeGrouper; +import com.sun.star.drawing.XShapes; +import com.sun.star.form.XFormsSupplier; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.container.XNamed; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class FormHandler +{ + private static final String CHECKBOX = "CheckBox"; + private static final String DATEFIELD = "DateField"; + private static final String FORMATTEDFIELD = "FormattedField"; + private static final String TEXTFIELD = "TextField"; + private static final String TIMEFIELD = "TimeField"; + + private XFormsSupplier xFormsSupplier; + public XMultiServiceFactory xMSFDoc; + public XMultiServiceFactory xMSF; + public XDrawPage xDrawPage; + public String[] sModelServices = new String[8]; + public static ControlData[] oControlData; + + public static final int SOLABEL = 0; + public static final int SOTEXTBOX = 1; + public static final int SOCHECKBOX = 2; + public static final int SODATECONTROL = 3; + public static final int SOTIMECONTROL = 4; + public static final int SONUMERICCONTROL = 5; + public static final int SOGRIDCONTROL = 6; + public static final int SOIMAGECONTROL = 7; + public static final int SODATETIMECONTROL = 8; + public static String SOSIZETEXT = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."; + private int iXPixelFactor = -1; + private int iYPixelFactor = -1; + private int iXNirwanaPos = 50000; + private int iYNirwanaPos = 50000; + private int nLabelHeight = -1; + private int nDBRefHeight = -1; + private int BasicLabelDiffHeight = -1; + private XNameAccess xNamedForms; + XControlAccess xControlAccess; + XShapeGrouper xShapeGrouper; + + public static class ControlData + { + int DataType; + private int ControlType; + String GridColumnName; + } + + /** Creates a new instance of FormHandler */ + public FormHandler(XMultiServiceFactory _xMSF, XTextDocument xTextDocument) + { + this.xMSF = _xMSF; + XDrawPageSupplier xDrawPageSupplier = UnoRuntime.queryInterface(XDrawPageSupplier.class, xTextDocument); + xDrawPage = xDrawPageSupplier.getDrawPage(); + xFormsSupplier = UnoRuntime.queryInterface(XFormsSupplier.class, xDrawPage); + xShapeGrouper = UnoRuntime.queryInterface(XShapeGrouper.class, xDrawPage); + xControlAccess = UnoRuntime.queryInterface(XControlAccess.class, xTextDocument.getCurrentController()); + xMSFDoc = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + sModelServices[SOLABEL] = "com.sun.star.form.component.FixedText"; + sModelServices[SOTEXTBOX] = "com.sun.star.form.component.TextField"; + sModelServices[SOCHECKBOX] = "com.sun.star.form.component.CheckBox"; + sModelServices[SODATECONTROL] = "com.sun.star.form.component.DateField"; + sModelServices[SOTIMECONTROL] = "com.sun.star.form.component.TimeField"; + sModelServices[SONUMERICCONTROL] = "com.sun.star.form.component.FormattedField"; + sModelServices[SOGRIDCONTROL] = "com.sun.star.form.component.GridControl"; + sModelServices[SOIMAGECONTROL] = "com.sun.star.form.component.DatabaseImageControl"; + + oControlData = new ControlData[23]; + oControlData[0] = createControlData(DataType.BIT, SOCHECKBOX, CHECKBOX); + oControlData[1] = createControlData(DataType.BOOLEAN, SOCHECKBOX, CHECKBOX); + oControlData[2] = createControlData(DataType.TINYINT, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[3] = createControlData(DataType.SMALLINT, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[4] = createControlData(DataType.INTEGER, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[5] = createControlData(DataType.BIGINT, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[6] = createControlData(DataType.FLOAT, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[7] = createControlData(DataType.REAL, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[8] = createControlData(DataType.DOUBLE, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[9] = createControlData(DataType.NUMERIC, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[10] = createControlData(DataType.DECIMAL, SONUMERICCONTROL, FORMATTEDFIELD); + oControlData[11] = createControlData(DataType.CHAR, SOTEXTBOX, TEXTFIELD); + oControlData[12] = createControlData(DataType.VARCHAR, SOTEXTBOX, TEXTFIELD); + oControlData[13] = createControlData(DataType.LONGVARCHAR, SOTEXTBOX, TEXTFIELD); + oControlData[14] = createControlData(DataType.DATE, SODATECONTROL, DATEFIELD); + oControlData[15] = createControlData(DataType.TIME, SOTIMECONTROL, TIMEFIELD); + oControlData[16] = createControlData(DataType.TIMESTAMP, SODATECONTROL, TEXTFIELD); + oControlData[17] = createControlData(DataType.BINARY, SOIMAGECONTROL, TEXTFIELD); + oControlData[18] = createControlData(DataType.VARBINARY, SOIMAGECONTROL, TEXTFIELD); + oControlData[19] = createControlData(DataType.LONGVARBINARY, SOIMAGECONTROL, TEXTFIELD); + oControlData[20] = createControlData(DataType.BLOB, SOIMAGECONTROL, TEXTFIELD); + oControlData[21] = createControlData(DataType.CLOB, SOIMAGECONTROL, TEXTFIELD); + + oControlData[22] = createControlData(DataType.OTHER, SOIMAGECONTROL, TEXTFIELD); + } + + public int getControlType(int _fieldtype) + { + for (int i = 0; i < oControlData.length; i++) + { + if (oControlData[i].DataType == _fieldtype) + { + return oControlData[i].ControlType; + } + } + return -1; + } + + private void initializeBasicControlValues() + { + Control oLabelControl = new Control(this, SOLABEL, new Point(), new Size()); + XDevice xDevice = UnoRuntime.queryInterface(XDevice.class, oLabelControl.xWindowPeer); + iXPixelFactor = (int) (100000 / xDevice.getInfo().PixelPerMeterX); + iYPixelFactor = (int) (100000 / xDevice.getInfo().PixelPerMeterY); + + nLabelHeight = (oLabelControl.getPreferredHeight("The quick brown fox...") + 1); + Control oTextControl = new Control(this, SOTEXTBOX, new Point(), new Size()); + nDBRefHeight = (oTextControl.getPreferredHeight("The quick brown fox...") + 1); + BasicLabelDiffHeight = (nDBRefHeight - nLabelHeight) / 2; + xDrawPage.remove(oLabelControl.xShape); + xDrawPage.remove(oTextControl.xShape); + } + + private ControlData createControlData(int _datatype, int _controltype, String _gridcolumnname) + { + ControlData curControlData = new ControlData(); + curControlData.DataType = _datatype; + curControlData.ControlType = _controltype; + curControlData.GridColumnName = _gridcolumnname; + return curControlData; + } + + public XNameContainer getDocumentForms() + { + return xFormsSupplier.getForms(); + } + + public String getValueofHiddenControl(XNameAccess xNamedForm, String ControlName) + { + String value = ""; + try + { + if (xNamedForm.hasByName(ControlName)) + { + value = AnyConverter.toString(com.sun.star.wizards.common.Helper.getUnoPropertyValue(xNamedForm.getByName(ControlName), "HiddenValue")); + } + } + catch (Exception ex) + { + Logger.getLogger( FormHandler.class.getName() ).log( Level.SEVERE, null, ex ); + } + return value; + } + + public void insertHiddenControl(XNameAccess xNameAccess, XNameContainer xNamedForm, String ControlName, String ControlValue) + { + try + { + XInterface xHiddenControl; + if (xNameAccess.hasByName(ControlName)) + { + xHiddenControl = (XInterface) AnyConverter.toObject(new Type(XInterface.class), xNameAccess.getByName(ControlName)); + } + else + { + xHiddenControl = (XInterface) xMSFDoc.createInstance("com.sun.star.form.component.HiddenControl"); + xNamedForm.insertByName(ControlName, xHiddenControl); + } + Helper.setUnoPropertyValue(xHiddenControl, "HiddenValue", ControlValue); + } + catch (Exception ex) + { + Logger.getLogger(FormHandler.class.getName()).log(Level.SEVERE, null, ex); + } + } + + private boolean hasFormByName(String _FormName) + { + XNameContainer xNamedFormContainer = getDocumentForms(); + xNamedForms = UnoRuntime.queryInterface(XNameAccess.class, xNamedFormContainer); + return xNamedForms.hasByName(_FormName); + } + + public void removeControlsofForm(String _FormName) + { + try + { + for (int i = xDrawPage.getCount() - 1; i >= 0; i--) + { + if (belongsToForm(xDrawPage.getByIndex(i), _FormName)) + { + XShape xShape = UnoRuntime.queryInterface(XShape.class, xDrawPage.getByIndex(i)); + xDrawPage.remove(xShape); + } + } + } + catch (Exception e) + { + Logger.getLogger(FormHandler.class.getName()).log(Level.SEVERE, null, e); + } + } + + public void removeElement( XNameContainer _parentContainer, String _formName ) + { + try + { + _parentContainer.removeByName( _formName ); + } + catch ( WrappedTargetException e ) + { + Logger.getLogger(FormHandler.class.getName()).log(Level.SEVERE, null, e); + } + catch( final NoSuchElementException e ) + { + Logger.getLogger(FormHandler.class.getName()).log(Level.SEVERE, null, e); + } + } + + private boolean belongsToForm(Object _oDrawPageElement, String _FormName) + { + XServiceInfo xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, _oDrawPageElement); + while (xServiceInfo.supportsService("com.sun.star.drawing.GroupShape")) + { + XShapes xShapes = UnoRuntime.queryInterface(XShapes.class, _oDrawPageElement); + try + { + _oDrawPageElement = xShapes.getByIndex(0); + xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, _oDrawPageElement); + } + catch(final com.sun.star.uno.Exception e) + { + return false; + } + } + if (xServiceInfo.supportsService("com.sun.star.drawing.ControlShape")) + { + XControlShape xControlShape = UnoRuntime.queryInterface(XControlShape.class, _oDrawPageElement); + XControlModel xControlModel = xControlShape.getControl(); + xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, xControlShape.getControl()); + if (xServiceInfo.supportsService("com.sun.star.form.FormComponent")) + { + XChild xChild = UnoRuntime.queryInterface(XChild.class, xControlModel); + XNamed xNamed = UnoRuntime.queryInterface(XNamed.class, xChild.getParent()); + String sName = xNamed.getName(); + return _FormName.equals(sName); + } + } + return false; + } + + public XNameContainer insertFormbyName(String _FormName, XNameContainer _xNamedFormContainer) + { + try + { + Object oDBForm; + if (!hasFormByName(_FormName)) + { + oDBForm = xMSFDoc.createInstance("com.sun.star.form.component.Form"); + _xNamedFormContainer.insertByName(_FormName, oDBForm); + XNameContainer xNamedForm; + xNamedForm = UnoRuntime.queryInterface(XNameContainer.class, oDBForm); + return xNamedForm; + } + else + { + return getFormByName(_FormName); + } + } + catch (com.sun.star.uno.Exception e) + { + Logger.getLogger(FormHandler.class.getName()).log(Level.SEVERE, null, e); + return null; + } + } + + public XNameContainer insertFormbyName(String _FormName) + { + return insertFormbyName(_FormName, getDocumentForms()); + } + + private XNameContainer getFormByName(String _sname) + { + XNameContainer xNamedForm = null; + try + { + if (xNamedForms.hasByName(_sname)) + { + Object oDBForm = AnyConverter.toObject(new Type(XInterface.class), Helper.getUnoObjectbyName(xNamedForms, _sname)); + xNamedForm = UnoRuntime.queryInterface(XNameContainer.class, oDBForm); + } + } + catch (IllegalArgumentException e) + { + Logger.getLogger(FormHandler.class.getName()).log(Level.SEVERE, null, e); + } + return xNamedForm; + } + + public int getXPixelFactor() + { + if (iXPixelFactor == -1) + { + initializeBasicControlValues(); + } + return iXPixelFactor; + } + + public int getYPixelFactor() + { + if (iYPixelFactor == -1) + { + initializeBasicControlValues(); + } + return iYPixelFactor; + } + + // Note: as Shapes cannot be removed from the DrawPage without destroying + // the object we have to park them somewhere beyond the visible area of the page + public void moveShapesToNirwana(Control[] ControlList) + { + if (ControlList != null) + { + for (int i = 0; i < ControlList.length; i++) + { + if (ControlList[i] != null) + { + ControlList[i].setPosition(new Point(this.iXNirwanaPos, this.iYNirwanaPos)); + } + } + } + } + + /** + * By removing the shape the whole control is disposed too + * + */ + public void removeShape(XShape _xShape) + { + xDrawPage.remove(_xShape); + XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, _xShape); + xComponent.dispose(); + } + + public XShape groupShapesTogether(XMultiServiceFactory _xMSF, XShape _xLabelShape, XShape _xControlShape) + { + try + { + Object oGroupShape = _xMSF.createInstance("com.sun.star.drawing.ShapeCollection"); + XShapes xShapes = UnoRuntime.queryInterface(XShapes.class, oGroupShape); + xShapes.add(_xLabelShape); + xShapes.add(_xControlShape); + return this.xShapeGrouper.group(xShapes); + } + catch (Exception e) + { + Logger.getLogger(FormHandler.class.getName()).log(Level.SEVERE, null, e); + return null; + } + } + + public int getBasicLabelDiffHeight() + { + if (this.BasicLabelDiffHeight == -1) + { + initializeBasicControlValues(); + } + return BasicLabelDiffHeight; + } + + public int getControlReferenceHeight() + { + if (this.nDBRefHeight == -1) + { + initializeBasicControlValues(); + } + return nDBRefHeight; + } + + public int getLabelHeight() + { + if (this.nLabelHeight == -1) + { + initializeBasicControlValues(); + } + return nLabelHeight; + } + + public void setDrawObjectsCaptureMode(boolean _bCaptureObjects) + { + try + { + XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, this.xMSFDoc.createInstance("com.sun.star.text.DocumentSettings")); + xPropertySet.setPropertyValue("DoNotCaptureDrawObjsOnPage", Boolean.valueOf(!_bCaptureObjects)); + } + catch (Exception e) + { + Logger.getLogger(FormHandler.class.getName()).log(Level.SEVERE, null, e); + } + } +} diff --git a/wizards/com/sun/star/wizards/document/GridControl.java b/wizards/com/sun/star/wizards/document/GridControl.java new file mode 100644 index 0000000000..79f35de337 --- /dev/null +++ b/wizards/com/sun/star/wizards/document/GridControl.java @@ -0,0 +1,90 @@ +/* + * 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 . + */ +package com.sun.star.wizards.document; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControlModel; +import com.sun.star.beans.XPropertySet; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.db.FieldColumn; +import com.sun.star.sdbc.*; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.form.XGridColumnFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; + +public class GridControl extends Shape +{ + + public XNameContainer xNameContainer; + public XGridColumnFactory xGridColumnFactory; + public XPropertySet xPropertySet; + XNameAccess xNameAccess; + public XComponent xComponent; + + public GridControl(XMultiServiceFactory _xMSF, String _sname, FormHandler _oFormHandler, XNameContainer _xFormName, FieldColumn[] _fieldcolumns, Point _aPoint, Size _aSize) + { + super(_oFormHandler, _aPoint, _aSize); + try + { + Object oGridModel = oFormHandler.xMSFDoc.createInstance(oFormHandler.sModelServices[FormHandler.SOGRIDCONTROL]); + xNameContainer = UnoRuntime.queryInterface( XNameContainer.class, oGridModel ); + xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, oGridModel ); + _xFormName.insertByName(_sname, oGridModel); + XControlModel xControlModel = UnoRuntime.queryInterface( XControlModel.class, oGridModel ); + // test if the interface was available + if (xControlModel == null) { + throw new Exception( + "Error: GridModel does not export XControlModel interface"); + } + + if (xControlShape == null) { + throw new Exception( + "Error: GridModel does not have a XControlShape"); + } + + xControlShape.setControl(xControlModel); + xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oGridModel ); + oFormHandler.xDrawPage.add(xShape); + xGridColumnFactory = UnoRuntime.queryInterface( XGridColumnFactory.class, oGridModel ); + xComponent = UnoRuntime.queryInterface( XComponent.class, oGridModel ); + + for (int i = 0; i < _fieldcolumns.length; i++) + { + FieldColumn curfieldcolumn = _fieldcolumns[i]; + if (curfieldcolumn.getFieldType() == DataType.TIMESTAMP) + { + new TimeStampControl(new Resource(_xMSF), this, curfieldcolumn); + } + else + { + new DatabaseControl(this, curfieldcolumn); + } + } + + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } +} diff --git a/wizards/com/sun/star/wizards/document/OfficeDocument.java b/wizards/com/sun/star/wizards/document/OfficeDocument.java new file mode 100644 index 0000000000..1868c19891 --- /dev/null +++ b/wizards/com/sun/star/wizards/document/OfficeDocument.java @@ -0,0 +1,229 @@ +/* + * 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 . + */ +package com.sun.star.wizards.document; + +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.wizards.common.*; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.WindowAttribute; +import com.sun.star.awt.WindowDescriptor; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.PropertyValue; +import com.sun.star.sheet.XCellRangeData; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XFrames; +import com.sun.star.frame.XFramesSupplier; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XTerminateListener; +import com.sun.star.util.XCloseable; +import com.sun.star.util.XModifiable; + +public class OfficeDocument +{ + + public static void dispose(XMultiServiceFactory xMSF, XComponent xComponent) + { + try + { + if (xComponent != null) + { + XModifiable xModified = UnoRuntime.queryInterface(XModifiable.class, xComponent); + XModel xModel = UnoRuntime.queryInterface(XModel.class, xComponent); + XFrame xFrame = xModel.getCurrentController().getFrame(); + if (xModified.isModified()) + { + xModified.setModified(false); + } + Desktop.dispatchURL(xMSF, ".uno:CloseDoc", xFrame); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public static XFrame createNewFrame(XMultiServiceFactory xMSF, XTerminateListener listener) + { + return createNewFrame(xMSF, listener, "_blank"); + } + + private static XFrame createNewFrame(XMultiServiceFactory xMSF, XTerminateListener listener, String FrameName) + { + XFrame xFrame = null; + if (FrameName.equalsIgnoreCase("WIZARD_LIVE_PREVIEW")) + { + xFrame = createNewPreviewFrame(xMSF, listener); + } + else + { + XFrame xF = UnoRuntime.queryInterface(XFrame.class, Desktop.getDesktop(xMSF)); + xFrame = xF.findFrame(FrameName, 0); + if (listener != null) + { + XFramesSupplier xFS = UnoRuntime.queryInterface(XFramesSupplier.class, xF); + XFrames xFF = xFS.getFrames(); + xFF.remove(xFrame); + XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, xF); + xDesktop.addTerminateListener(listener); + } + } + return xFrame; + } + + private static XFrame createNewPreviewFrame(XMultiServiceFactory xMSF, XTerminateListener listener) + { + XFrame xFrame = null; + try + { + XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, xMSF.createInstance("com.sun.star.awt.Toolkit")); + + //describe the window and its properties + WindowDescriptor aDescriptor = new WindowDescriptor(); + aDescriptor.Type = com.sun.star.awt.WindowClass.TOP; + aDescriptor.WindowServiceName = "window"; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = null; + aDescriptor.Bounds = new Rectangle(10, 10, 640, 480); + aDescriptor.WindowAttributes = WindowAttribute.BORDER | + WindowAttribute.MOVEABLE | + WindowAttribute.SIZEABLE | + //WindowAttribute.CLOSEABLE | + VclWindowPeerAttribute.CLIPCHILDREN; + + //create a new blank container window + XWindowPeer xPeer = UnoRuntime.queryInterface(XWindowPeer.class, xToolkit.createWindow(aDescriptor)); + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xPeer); + + //define some further properties of the frame window + //if it's needed .-) + //xPeer->setBackground(...); + + //create new empty frame and set window on it + xFrame = UnoRuntime.queryInterface(XFrame.class, xMSF.createInstance("com.sun.star.frame.Frame")); + xFrame.initialize(xWindow); + + //from now this frame is usable ... + //and not part of the desktop tree. + //You are alone with him .-) + + if (listener != null) + { + Desktop.getDesktop(xMSF).addTerminateListener(listener); + } + } + catch (Exception e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return xFrame; + + } + + public static Object load(XInterface xInterface, String sURL, String sFrame, PropertyValue[] xValues) + { + Object oDocument = null; + com.sun.star.frame.XComponentLoader xComponentLoader = null; + try + { + xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, xInterface); + com.sun.star.lang.XComponent xComponent = xComponentLoader.loadComponentFromURL(sURL, sFrame, 0, xValues); + + XServiceInfo xComponentService = UnoRuntime.queryInterface(XServiceInfo.class, xComponent); + if (xComponentService.supportsService("com.sun.star.text.TextDocument")) + { + oDocument = UnoRuntime.queryInterface(XTextDocument.class, xComponent); //TODO: write if clauses for Calc, Impress and Draw + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + return oDocument; + } + + public static boolean close(XComponent xComponent) + { + boolean bState = false; + XModel xModel = UnoRuntime.queryInterface(XModel.class, xComponent); + + if (xModel != null) + { + XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, xModel); + + if (xCloseable != null) + { + try + { + xCloseable.close(true); + bState = true; + } + catch (com.sun.star.util.CloseVetoException exCloseVeto) + { + System.out.println("could not close doc"); + bState = false; + } + } + else + { + XComponent xDisposeable = UnoRuntime.queryInterface(XComponent.class, xModel); + xDisposeable.dispose(); + bState = true; + } + } + return bState; + } + + public static void ArraytoCellRange(Object[][] datalist, Object oTable, int xpos, int ypos) + { + try + { + int rowcount = datalist.length; + if (rowcount > 0) + { + int colcount = datalist[0].length; + if (colcount > 0) + { + XCellRange xCellRange = UnoRuntime.queryInterface(XCellRange.class, oTable); + XCellRange xNewRange = xCellRange.getCellRangeByPosition(xpos, ypos, (colcount + xpos) - 1, (rowcount + ypos) - 1); + XCellRangeData xDataArray = UnoRuntime.queryInterface(XCellRangeData.class, xNewRange); + xDataArray.setDataArray(datalist); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + +} diff --git a/wizards/com/sun/star/wizards/document/OfficeDocument.py b/wizards/com/sun/star/wizards/document/OfficeDocument.py new file mode 100644 index 0000000000..1483f902da --- /dev/null +++ b/wizards/com/sun/star/wizards/document/OfficeDocument.py @@ -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) diff --git a/wizards/com/sun/star/wizards/document/Shape.java b/wizards/com/sun/star/wizards/document/Shape.java new file mode 100644 index 0000000000..72c17d7f84 --- /dev/null +++ b/wizards/com/sun/star/wizards/document/Shape.java @@ -0,0 +1,131 @@ +/* + * 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 . + */ +package com.sun.star.wizards.document; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.text.TextContentAnchorType; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Helper; + +/** + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class Shape +{ + + public XShape xShape; + protected FormHandler oFormHandler; + public XServiceInfo xServiceInfo; + protected Point aPoint; + private Size aSize; + protected XControlShape xControlShape; + private XMultiServiceFactory xMSF; + XShapes xShapes; + + public Shape(FormHandler _oFormHandler, Point _aPoint, Size _aSize) + { + this.aPoint = _aPoint; + this.aSize = _aSize; + this.oFormHandler = _oFormHandler; + createShape("com.sun.star.drawing.ControlShape"); + } + + public Shape(FormHandler _oFormHandler, String _sServiceName, Point _aPoint, Size _aSize) + { + try + { + this.aPoint = _aPoint; + this.aSize = _aSize; + this.oFormHandler = _oFormHandler; + Object oShape = oFormHandler.xMSF.createInstance(_sServiceName); + xShapes = UnoRuntime.queryInterface(XShapes.class, oShape); + xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, oShape); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public Shape() + { + } + + private void createShape(String sServiceName) + { + try + { + xMSF = oFormHandler.xMSFDoc; + Object oShape = xMSF.createInstance(sServiceName); + xShape = UnoRuntime.queryInterface(XShape.class, oShape); + xShape.setPosition(aPoint); + if (aSize != null) + { + xShape.setSize(aSize); + } + else + { + xShape.setSize(new Size(1000, 100)); + } + Helper.setUnoPropertyValue(xShape, "AnchorType", TextContentAnchorType.AT_PARAGRAPH); + xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, xShape); + xControlShape = UnoRuntime.queryInterface(XControlShape.class, xShape); + + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public Size getSize() + { + return xShape.getSize(); + } + + public void setSize(Size _aSize) + { + try + { + xShape.setSize(_aSize); + } + catch (PropertyVetoException e) + { + e.printStackTrace(System.err); + } + } + + public Point getPosition() + { + return xShape.getPosition(); + } + + public void setPosition(Point _aPoint) + { + xShape.setPosition(_aPoint); + } +} diff --git a/wizards/com/sun/star/wizards/document/TimeStampControl.java b/wizards/com/sun/star/wizards/document/TimeStampControl.java new file mode 100644 index 0000000000..0ce10a33cc --- /dev/null +++ b/wizards/com/sun/star/wizards/document/TimeStampControl.java @@ -0,0 +1,111 @@ +/* + * 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 . + */ +package com.sun.star.wizards.document; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.beans.XPropertySet; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.db.FieldColumn; +import com.sun.star.wizards.ui.*; +import com.sun.star.sdbc.*; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShapes; + +public class TimeStampControl extends DatabaseControl +{ + + private DatabaseControl oDateControl; + private DatabaseControl oTimeControl; + private Resource oResource; + private int nDBWidth; + + public TimeStampControl(Resource _oResource, FormHandler _oFormHandler, XNameContainer _xFormName, String _curFieldName, Point _aPoint) + { + super(_oFormHandler, "com.sun.star.drawing.ShapeCollection", _aPoint); + oResource = _oResource; + oDateControl = new DatabaseControl(oFormHandler, _xFormName, _curFieldName, DataType.DATE, aPoint); + int nDBHeight = oDateControl.getControlHeight(); + int nDateWidth = oDateControl.getPreferredWidth(); + oDateControl.setSize(new Size(nDateWidth, nDBHeight)); + Point aTimePoint = new Point(aPoint.X + 10 + nDateWidth, aPoint.Y); + oTimeControl = new DatabaseControl(oFormHandler, _xFormName, _curFieldName, DataType.TIME, aTimePoint); + int nTimeWidth = oTimeControl.getPreferredWidth(); + oTimeControl.setSize(new Size(nTimeWidth, nDBHeight)); + nDBWidth = nDateWidth + nTimeWidth + 10; + xShapes.add(oDateControl.xShape); + xShapes.add(oTimeControl.xShape); + xShape = _oFormHandler.xShapeGrouper.group(xShapes); + xShapes = UnoRuntime.queryInterface(XShapes.class, xShape); + } + + public XPropertySet getControlofGroupShapeByIndex(int _i) + { + try + { + if (_i < xShapes.getCount()) + { + Object oControl = xShapes.getByIndex(_i); + XControlShape xControlShape = UnoRuntime.queryInterface(XControlShape.class, oControl); + return UnoRuntime.queryInterface(XPropertySet.class, xControlShape.getControl()); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return null; + } + + public TimeStampControl(Resource _oResource, GridControl _oGridControl, FieldColumn _curfieldcolumn) + { + super(_oGridControl, _curfieldcolumn); + oResource = _oResource; + String sDateAppendix = oResource.getResText("RID_FORM_88"); + String sTimeAppendix = oResource.getResText("RID_FORM_89"); + oDateControl = new DatabaseControl(_oGridControl, _curfieldcolumn, DataType.DATE, _curfieldcolumn.getFieldTitle() + PropertyNames.SPACE + sDateAppendix); + oTimeControl = new DatabaseControl(_oGridControl, _curfieldcolumn, DataType.TIME, _curfieldcolumn.getFieldTitle() + PropertyNames.SPACE + sTimeAppendix); + } + + @Override + public void setPropertyValue(String _sPropertyName, Object _aPropertyValue) throws Exception + { + oDateControl.setPropertyValue(_sPropertyName, _aPropertyValue); + oTimeControl.setPropertyValue(_sPropertyName, _aPropertyValue); + } + + @Override + public int getPreferredWidth() + { + return nDBWidth; + } + + @Override + public int getControlType() + { + return FormHandler.SODATETIMECONTROL; + } +} + + + + + diff --git a/wizards/com/sun/star/wizards/document/__init__.py b/wizards/com/sun/star/wizards/document/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/document/__init__.py diff --git a/wizards/com/sun/star/wizards/fax/CGFax.py b/wizards/com/sun/star/wizards/fax/CGFax.py new file mode 100644 index 0000000000..ff69cf134a --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/CGFax.py @@ -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() diff --git a/wizards/com/sun/star/wizards/fax/CGFaxWizard.py b/wizards/com/sun/star/wizards/fax/CGFaxWizard.py new file mode 100644 index 0000000000..30f211a84d --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/CGFaxWizard.py @@ -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() + diff --git a/wizards/com/sun/star/wizards/fax/CallWizard.py b/wizards/com/sun/star/wizards/fax/CallWizard.py new file mode 100644 index 0000000000..ca222132f9 --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/CallWizard.py @@ -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: diff --git a/wizards/com/sun/star/wizards/fax/FaxDocument.py b/wizards/com/sun/star/wizards/fax/FaxDocument.py new file mode 100644 index 0000000000..b695ffe55c --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/FaxDocument.py @@ -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() diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py new file mode 100644 index 0000000000..6c8d4a40fa --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py @@ -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)) diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogConst.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogConst.py new file mode 100644 index 0000000000..faececb1bd --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogConst.py @@ -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) diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py new file mode 100644 index 0000000000..72952dce27 --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py @@ -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 diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py new file mode 100644 index 0000000000..fa3254207c --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py @@ -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) diff --git a/wizards/com/sun/star/wizards/fax/__init__.py b/wizards/com/sun/star/wizards/fax/__init__.py new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/__init__.py @@ -0,0 +1 @@ + diff --git a/wizards/com/sun/star/wizards/fax/fax.component b/wizards/com/sun/star/wizards/fax/fax.component new file mode 100644 index 0000000000..abc871137f --- /dev/null +++ b/wizards/com/sun/star/wizards/fax/fax.component @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . +--> +<component loader="com.sun.star.loader.Python" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.wizards.fax.CallWizard"> + <service name="com.sun.star.task.Job"/> + </implementation> +</component> diff --git a/wizards/com/sun/star/wizards/form/CallFormWizard.java b/wizards/com/sun/star/wizards/form/CallFormWizard.java new file mode 100644 index 0000000000..297ce57754 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/CallFormWizard.java @@ -0,0 +1,170 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.Type; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; + +/** This class capsulates the class, that implements the minimal component, a + * factory for creating the service (<CODE>__getServiceFactory</CODE>). + */ +public class CallFormWizard +{ + + /** Gives a factory for creating the service. + * This method is called by the <code>JavaLoader</code> + * <p> + * @return Returns a <code>XSingleServiceFactory</code> for creating the component. + * @see com.sun.star.comp.loader.JavaLoader + * @param stringImplementationName The implementation name of the component. + * @param xMSF The service manager, who gives access to every known service. + * @param xregistrykey Makes structural information (except regarding tree structures) of a single + * registry key accessible. + */ + public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(String stringImplementationName, com.sun.star.lang.XMultiServiceFactory xMSF, com.sun.star.registry.XRegistryKey xregistrykey) + { + com.sun.star.lang.XSingleServiceFactory xsingleservicefactory = null; + if (stringImplementationName.equals(FormWizardImplementation.class.getName())) + { + xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(FormWizardImplementation.class, FormWizardImplementation.__serviceName, xMSF, xregistrykey); + } + return xsingleservicefactory; + } + + /** This class implements the component. At least the interfaces XServiceInfo, + * XTypeProvider, and XInitialization should be provided by the service. + */ + public static class FormWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.task.XJobExecutor + { + private PropertyValue[] m_wizardContext; + + /** The constructor of the inner class has a XMultiServiceFactory parameter. + * @param xmultiservicefactoryInitialization A special service factory + * could be introduced while initializing. + */ + public FormWizardImplementation(com.sun.star.lang.XMultiServiceFactory xmultiservicefactoryInitialization) + { + super(); + m_serviceFactory = xmultiservicefactoryInitialization; + } + + public void trigger(String sEvent) + { + try + { + if (sEvent.equals(PropertyNames.START)) + { + FormWizard CurFormWizard = new FormWizard( m_serviceFactory, m_wizardContext ); + CurFormWizard.start(); + } + } + catch (Exception exception) + { + System.err.println(exception); + } + System.gc(); + } + /** The service name, that must be used to get an instance of this service. + */ + private static final String __serviceName = "com.sun.star.wizards.form.CallFormWizard"; + /** The service manager, that gives access to all registered services. + */ + private final com.sun.star.lang.XMultiServiceFactory m_serviceFactory; + + /** This method is a member of the interface for initializing an object + * directly after its creation. + * @param object This array of arbitrary objects will be passed to the + * component after its creation. + * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be + * passed to the caller. + */ + public void initialize(Object[] object) throws com.sun.star.uno.Exception + { + m_wizardContext = Properties.convertToPropertyValueArray(object); + } + + /** This method returns an array of all supported service names. + * @return Array of supported service names. + */ + public java.lang.String[] getSupportedServiceNames() + { + String[] stringSupportedServiceNames = new String[] { __serviceName }; + + return stringSupportedServiceNames; + } + + /** This method returns true, if the given service will be + * supported by the component. + * @param stringService Service name. + * @return True, if the given service name will be supported. + */ + public boolean supportsService(String stringService) + { + boolean booleanSupportsService = false; + + if (stringService.equals(__serviceName)) + { + booleanSupportsService = true; + } + return booleanSupportsService; + } + + @Override + public byte[] getImplementationId() + { + return new byte[0]; + } + + /** Return the class name of the component. + * @return Class name of the component. + */ + public java.lang.String getImplementationName() + { + return FormWizardImplementation.class.getName(); + } + + /** Provides a sequence of all types (usually interface types) + * provided by the object. + * @return Sequence of all types (usually interface types) provided by the + * service. + */ + @Override + public Type[] getTypes() + { + Type[] typeReturn = + { + }; + + try + { + typeReturn = new Type[] + { + new Type(com.sun.star.task.XJobExecutor.class), new Type(com.sun.star.lang.XTypeProvider.class), new Type(com.sun.star.lang.XServiceInfo.class), new Type(com.sun.star.beans.XPropertySet.class), new Type(com.sun.star.beans.XFastPropertySet.class), new Type(com.sun.star.beans.XMultiPropertySet.class), new Type(com.sun.star.lang.XInitialization.class) + }; + } + catch (Exception exception) + { + System.err.println(exception); + } + + return typeReturn; + } + } +} diff --git a/wizards/com/sun/star/wizards/form/DataEntrySetter.java b/wizards/com/sun/star/wizards/form/DataEntrySetter.java new file mode 100644 index 0000000000..4b4a3e0cf9 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/DataEntrySetter.java @@ -0,0 +1,147 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.XCheckBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.beans.PropertyValue; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.WizardDialog; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; + +public class DataEntrySetter +{ + + private final XRadioButton optDisplayAllData; + private final XCheckBox chknomodification; + private final XCheckBox chknodeletion; + private final XCheckBox chknoaddition; + + public DataEntrySetter(WizardDialog CurUnoDialog) + { + short curtabindex = (short) (FormWizard.SODATA_PAGE * 100); + Integer IDataStep = Integer.valueOf(FormWizard.SODATA_PAGE); + String sNewDataOnly = CurUnoDialog.m_oResource.getResText("RID_FORM_44"); + String sDisplayAllData = CurUnoDialog.m_oResource.getResText("RID_FORM_46"); + String sNoModification = CurUnoDialog.m_oResource.getResText("RID_FORM_47"); // AllowUpdates + String sNoDeletion = CurUnoDialog.m_oResource.getResText("RID_FORM_48"); // AllowDeletes + String sNoAddition = CurUnoDialog.m_oResource.getResText("RID_FORM_49"); // AllowInserts + String sdontdisplayExistingData = CurUnoDialog.m_oResource.getResText("RID_FORM_45"); + + CurUnoDialog.insertRadioButton("optNewDataOnly", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleCheckBoxes(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTNEWDATAONLY", sNewDataOnly, 98, 25, IDataStep, Short.valueOf(curtabindex++), 195 + }); + + optDisplayAllData = CurUnoDialog.insertRadioButton("optDisplayAllData", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleCheckBoxes(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTDISPLAYALLDATA", sDisplayAllData, 98, 50, Short.valueOf((short) 1), IDataStep, Short.valueOf(curtabindex++), 197 + }); + chknomodification = CurUnoDialog.insertCheckBox("chknomodification", null, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNOMODIFICATION", sNoModification, 108, 62, Short.valueOf((short) 0), IDataStep, Short.valueOf(curtabindex++), 189 + }); + chknodeletion = CurUnoDialog.insertCheckBox("chknodeletion", null, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNODELETION", sNoDeletion, 108, 74, Short.valueOf((short) 0), IDataStep, Short.valueOf(curtabindex++), 189 + }); + chknoaddition = CurUnoDialog.insertCheckBox("chknoaddition", null, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNOADDITION", sNoAddition, 108, 86, Short.valueOf((short) 0), IDataStep, Short.valueOf(curtabindex++), 191 + }); + CurUnoDialog.insertLabel("lbldontdisplayExistingData", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, sdontdisplayExistingData, 108, 33, IDataStep, Short.valueOf(curtabindex++), 134 + }); + } + + public PropertyValue[] getFormProperties() + { + PropertyValue[] retProperties; + if (optDisplayAllData.getState()) + { + retProperties = new PropertyValue[3]; + boolean bAllowUpdates = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknomodification), PropertyNames.PROPERTY_STATE)).shortValue()) != 1; + boolean bAllowDeletes = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknodeletion), PropertyNames.PROPERTY_STATE)).shortValue()) != 1; + boolean bAllowInserts = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknoaddition), PropertyNames.PROPERTY_STATE)).shortValue()) != 1; + retProperties[0] = Properties.createProperty("AllowUpdates", Boolean.valueOf(bAllowUpdates)); + retProperties[1] = Properties.createProperty("AllowDeletes", Boolean.valueOf(bAllowDeletes)); + retProperties[2] = Properties.createProperty("AllowInserts", Boolean.valueOf(bAllowInserts)); + } + else + { + retProperties = new PropertyValue[1]; + retProperties[0] = Properties.createProperty("IgnoreResult", Boolean.TRUE); + } + return retProperties; + + } + + private void toggleCheckBoxes() + { + boolean bdisplayalldata = optDisplayAllData.getState(); + Helper.setUnoPropertyValue(UnoDialog.getModel(chknomodification), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdisplayalldata)); + Helper.setUnoPropertyValue(UnoDialog.getModel(chknodeletion), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdisplayalldata)); + Helper.setUnoPropertyValue(UnoDialog.getModel(chknoaddition), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdisplayalldata)); + } +} diff --git a/wizards/com/sun/star/wizards/form/FieldLinker.java b/wizards/com/sun/star/wizards/form/FieldLinker.java new file mode 100644 index 0000000000..74dc5707e1 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/FieldLinker.java @@ -0,0 +1,308 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XFixedText; +import com.sun.star.awt.XListBox; +import com.sun.star.uno.Exception; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.HelpIds; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.db.RelationController; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.WizardDialog; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.DBLimitedFieldSelection; +import com.sun.star.wizards.common.PropertyNames; + +public class FieldLinker extends DBLimitedFieldSelection +{ + + private XFixedText[] lblSlaveFields; + private XFixedText[] lblMasterFields; + private XListBox[] lstSlaveFields; + private XListBox[] lstMasterFields; + private int[] SOLINKLST = null; + private String[] sSlaveListHeader; + private String[] sMasterListHeader; //CurUnoDialog.m_oResource.getResText("RID_FORM_40"); + + public FieldLinker(WizardDialog _CurUnoDialog, int iStep, int iCompPosY, int _firsthelpid) + { + super(_CurUnoDialog, iStep, iCompPosY, _firsthelpid); + } + + @Override + protected void insertControlGroup(int i) + { + try + { + if (i == 0) + { + lblSlaveFields = new XFixedText[rowcount]; + lblMasterFields = new XFixedText[rowcount]; + lstSlaveFields = new XListBox[rowcount]; + lstMasterFields = new XListBox[rowcount]; + int SOFIRSTLINKLST = 0; + int SOSECLINKLST = 1; + int SOTHIRDLINKLST = 2; + int SOFOURTHLINKLST = 3; + sSlaveListHeader = new String[4]; //new String[rowcount];PropertyNames.EMPTY_STRING; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40); + sSlaveListHeader[0] = CurUnoDialog.m_oResource.getResText("RID_FORM_20"); + sSlaveListHeader[1] = CurUnoDialog.m_oResource.getResText("RID_FORM_21"); + sSlaveListHeader[2] = CurUnoDialog.m_oResource.getResText("RID_FORM_22"); + sSlaveListHeader[3] = CurUnoDialog.m_oResource.getResText("RID_FORM_23"); + sMasterListHeader = new String[4]; // new String[rowcount];PropertyNames.EMPTY_STRING; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40); + sMasterListHeader[0] = CurUnoDialog.m_oResource.getResText("RID_FORM_24"); + sMasterListHeader[1] = CurUnoDialog.m_oResource.getResText("RID_FORM_25"); + sMasterListHeader[2] = CurUnoDialog.m_oResource.getResText("RID_FORM_26"); + sMasterListHeader[3] = CurUnoDialog.m_oResource.getResText("RID_FORM_27"); + SOLINKLST = new int[] + { + SOFIRSTLINKLST, SOSECLINKLST, SOTHIRDLINKLST, SOFOURTHLINKLST + }; + } + String sSlaveHidString = HelpIds.getHelpIdString(FirstHelpIndex + (i * 2)); + String sMasterHidString = HelpIds.getHelpIdString(FirstHelpIndex + (i * 2) + 1); + boolean bDoEnable = (i < 2); + lblSlaveFields[i] = CurUnoDialog.insertLabel("lblSlaveFieldLink" + Integer.toString(i + 1), + new String[] + { + 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 + }, + new Object[] + { + Boolean.valueOf(bDoEnable), 8, sSlaveListHeader[i], 97, Integer.valueOf(iCurPosY), IStep, Short.valueOf(curtabindex++), 97 + }); + lstSlaveFields[i] = CurUnoDialog.insertListBox("lstSlaveFieldLink" + (i + 1), SOLINKLST[i], null, new ItemListenerImpl(), + new String[] + { + "Dropdown", + PropertyNames.PROPERTY_ENABLED, + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + "LineCount", + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, + Boolean.valueOf(bDoEnable), + UIConsts.INTEGER_12, + sSlaveHidString, + Short.valueOf(UnoDialog.getListBoxLineCount()), + 97, + Integer.valueOf(iCurPosY + 10), + IStep, + Short.valueOf(curtabindex++), + 97 + }); + + lblMasterFields[i] = CurUnoDialog.insertLabel("lblMasterFieldLink" + Integer.toString(i + 1), + new String[] + { + 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 + }, + new Object[] + { + Boolean.valueOf(bDoEnable), 8, sMasterListHeader[i], 206, Integer.valueOf(iCurPosY), IStep, Short.valueOf(curtabindex++), 97 + }); + + lstMasterFields[i] = CurUnoDialog.insertListBox("lstMasterFieldLink" + Integer.toString(i + 1), SOLINKLST[i], null, new ItemListenerImpl(), + new String[] + { + "Dropdown", + PropertyNames.PROPERTY_ENABLED, + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + "LineCount", + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, + Boolean.valueOf(bDoEnable), + UIConsts.INTEGER_12, + sMasterHidString, + Short.valueOf(UnoDialog.getListBoxLineCount()), + 206, + Integer.valueOf(iCurPosY + 10), + IStep, + Short.valueOf(curtabindex++), + 97 + }); + iCurPosY = iCurPosY + 38; + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + @Override + protected void enableNextControlRow(int curindex) + { + boolean bSlaveField = lstSlaveFields[curindex].getSelectedItemPos() > 0; + boolean bMasterField = lstMasterFields[curindex].getSelectedItemPos() > 0; + boolean bDoEnable = (bSlaveField && bMasterField); + if (!bDoEnable) + { + moveupSelectedItems(curindex, bDoEnable); + } + else + { + toggleControlRow(curindex + 1, true); + } + } + + @Override + protected int getMaxSelIndex() + { + int MaxSelIndex = -1; + for (int i = 0; i < rowcount; i++) + { + if ((lstSlaveFields[i].getSelectedItemPos() > 0) && (lstMasterFields[i].getSelectedItemPos() > 0)) + { + MaxSelIndex += 1; + } + } + return MaxSelIndex; + } + + @Override + protected void toggleControlRow(int i, boolean bDoEnable) + { + if (i < rowcount) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(lblSlaveFields[i]), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[i]), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(lblMasterFields[i]), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[i]), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable)); + if (!bDoEnable) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[i]), PropertyNames.SELECTED_ITEMS, new short[] { 0 }); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[i]), PropertyNames.SELECTED_ITEMS, new short[] { 0 }); + } + } + } + + @Override + protected void updateFromNextControlRow(int curindex) + { + short iNextMasterItemPos = lstMasterFields[curindex + 1].getSelectedItemPos(); + short iNextSlaveItemPos = lstSlaveFields[curindex + 1].getSelectedItemPos(); + + if ((iNextMasterItemPos != 0) && (iNextSlaveItemPos != 0)) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[curindex]), PropertyNames.SELECTED_ITEMS, new short[] {iNextMasterItemPos }); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[curindex]), PropertyNames.SELECTED_ITEMS, new short[] {iNextSlaveItemPos}); + + Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[curindex + 1]), PropertyNames.SELECTED_ITEMS, new short[] { 0 }); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[curindex + 1]), PropertyNames.SELECTED_ITEMS, new short[] { 0 }); + toggleControlRow(curindex, true); + } + } + + public void initialize(String[] _AllMasterFieldNames, String[] _AllSlaveFieldNames, String[][] _LinkFieldNames) + { + int SOMASTERINDEX = 1; + String[] MasterLinkNames = JavaTools.ArrayOutOfMultiDimArray(_LinkFieldNames, SOMASTERINDEX); + int SOSLAVEINDEX = 0; + String[] SlaveLinkNames = JavaTools.ArrayOutOfMultiDimArray(_LinkFieldNames, SOSLAVEINDEX); + String[] ViewMasterFieldNames = addNoneFieldItemToList(_AllMasterFieldNames); // add '-undefined-' + String[] ViewSlaveFieldNames = addNoneFieldItemToList(_AllSlaveFieldNames); + for (int i = 0; i < rowcount; i++) + { + super.initializeListBox(lstMasterFields[i], ViewMasterFieldNames, MasterLinkNames, i); + super.initializeListBox(lstSlaveFields[i], ViewSlaveFieldNames, SlaveLinkNames, i); + if (_LinkFieldNames != null) + { + toggleControlRow(i, (i <= _LinkFieldNames.length)); + } + else + { + toggleControlRow(i, i == 0); + } + } + } + + public String[][] getLinkFieldNames(RelationController _oRelationController, String _sReferencedTableName) + { + return _oRelationController.getImportedKeyColumns(_sReferencedTableName); + } + + /** + * @return the LinkFieldnames of the joins. When no LinkFieldNames were selected the returned Array is empty. + * When Joins were assigned duplicate a null value is returned + * + */ + public String[][] getLinkFieldNames() + { + int nSelectedIndex = getMaxSelIndex(); + String[][] LinkFieldNames = new String[2][nSelectedIndex + 1]; + for (int i = 0; i <= nSelectedIndex; i++) + { + LinkFieldNames[0][i] = lstSlaveFields[i].getSelectedItem(); + LinkFieldNames[1][i] = lstMasterFields[i].getSelectedItem(); + } + int iduplicate = JavaTools.getDuplicateFieldIndex(LinkFieldNames); + if (iduplicate != -1) + { + String sLinkFieldsAreDuplicate = CurUnoDialog.m_oResource.getResText("RID_FORM_19"); + String sLocLinkFieldsAreDuplicate = JavaTools.replaceSubString(sLinkFieldsAreDuplicate, LinkFieldNames[0][iduplicate], "<FIELDNAME1>"); + sLocLinkFieldsAreDuplicate = JavaTools.replaceSubString(sLocLinkFieldsAreDuplicate, LinkFieldNames[1][iduplicate], "<FIELDNAME2>"); + CurUnoDialog.setCurrentStep(FormWizard.SOFIELDLINKER_PAGE); + CurUnoDialog.enableNavigationButtons(true, true, true); + CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, sLocLinkFieldsAreDuplicate); + CurUnoDialog.setFocus("lstSlaveFieldLink" + (iduplicate + 1)); + return null; + } + return LinkFieldNames; + + } + + public void enable(boolean _bdoenable) + { + CurUnoDialog.setStepEnabled(IStep.intValue(), _bdoenable); + } + + private class ItemListenerImpl implements com.sun.star.awt.XItemListener + { + public void itemStateChanged(ItemEvent EventObject) + { + if (EventObject == null) { + return; + } + int ikey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); + enableNextControlRow(ikey); + } + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + } +} diff --git a/wizards/com/sun/star/wizards/form/Finalizer.java b/wizards/com/sun/star/wizards/form/Finalizer.java new file mode 100644 index 0000000000..1fa97b0ac5 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/Finalizer.java @@ -0,0 +1,133 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.XRadioButton; +import com.sun.star.awt.XTextComponent; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.ui.*; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; + +/** + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class Finalizer +{ + + private WizardDialog CurUnoDialog; + private XRadioButton optModifyForm; + private XTextComponent txtFormName; + private FormDocument oFormDocument; + + public Finalizer(WizardDialog _CurUnoDialog) + { + this.CurUnoDialog = _CurUnoDialog; + short curtabindex = (short) (FormWizard.SOSTORE_PAGE * 100); + + String slblFormName = CurUnoDialog.m_oResource.getResText("RID_FORM_50"); + String slblProceed = CurUnoDialog.m_oResource.getResText("RID_FORM_51"); + String sWorkWithForm = CurUnoDialog.m_oResource.getResText("RID_FORM_52"); + String sModifyForm = CurUnoDialog.m_oResource.getResText("RID_FORM_53"); + CurUnoDialog.insertLabel("lblFormName", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], slblFormName, 97, 25, UIConsts.INTEGERS[8], Short.valueOf(curtabindex++), 111 + }); + txtFormName = CurUnoDialog.insertTextField("txtFormName", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent event) { + toggleFinishButton(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGFORM_TXTPATH", 97, 35, UIConsts.INTEGERS[8], Short.valueOf((short) 82), PropertyNames.EMPTY_STRING, 185 + }); + CurUnoDialog.insertLabel("lblProceed", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], slblProceed, 97, 62, UIConsts.INTEGERS[8], Short.valueOf(curtabindex++), 185 + }); + CurUnoDialog.insertRadioButton("optWorkWithForm", null, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTWORKWITHFORM", sWorkWithForm, 101, 77, Short.valueOf((short) 1), UIConsts.INTEGERS[8], Short.valueOf(curtabindex++), 107 + }); + optModifyForm = CurUnoDialog.insertRadioButton("optModifyForm", null, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTMODIFYFORM", sModifyForm, 101, 89, UIConsts.INTEGERS[8], Short.valueOf(curtabindex++), 107 + }); + } + + public void initialize(String _formname, FormDocument _oFormDocument) + { + if (oFormDocument == null) + { + oFormDocument = _oFormDocument; + } + if (txtFormName.getText().length() == 0) + { + txtFormName.setText(Desktop.getUniqueName(_oFormDocument.oMainFormDBMetaData.getFormDocuments(), _formname)); + } + } + + private void toggleFinishButton() + { + CurUnoDialog.enableFinishButton(txtFormName.getText().length() > 0); + } + + public String getName() + { + return txtFormName.getText(); + } + + public boolean getOpenForEditing() + { + return optModifyForm.getState(); + } + + public boolean finish() + { + return oFormDocument.oMainFormDBMetaData.storeDatabaseDocumentToTempPath(this.oFormDocument.xComponent, getName()); + } +} diff --git a/wizards/com/sun/star/wizards/form/FormConfiguration.java b/wizards/com/sun/star/wizards/form/FormConfiguration.java new file mode 100644 index 0000000000..9f74c24379 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/FormConfiguration.java @@ -0,0 +1,246 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import com.sun.star.awt.ActionEvent; +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.XCheckBox; +import com.sun.star.awt.XFixedText; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.RelationController; +import com.sun.star.wizards.ui.CommandFieldSelection; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.WizardDialog; +import com.sun.star.wizards.ui.event.XActionListenerAdapter; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; + +/** + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class FormConfiguration +{ + + private WizardDialog CurUnoDialog; + private XRadioButton optOnExistingRelation; + private XCheckBox chkcreateSubForm; + private XRadioButton optSelectManually; + private XFixedText lblRelations; + private XListBox lstRelations; + private String[] sreferencedTables; + private CommandFieldSelection CurSubFormFieldSelection; + private boolean bsupportsRelations; + private RelationController oRelationController = null; + + public FormConfiguration(WizardDialog _CurUnoDialog) + { + this.CurUnoDialog = _CurUnoDialog; + short curtabindex = (short) (FormWizard.SOSUBFORM_PAGE * 100); + Integer ISubFormStep = Integer.valueOf(FormWizard.SOSUBFORM_PAGE); + String sOnExistingRelation = CurUnoDialog.m_oResource.getResText("RID_FORM_5"); + String sOnManualRelation = CurUnoDialog.m_oResource.getResText("RID_FORM_7"); + String sSelectManually = CurUnoDialog.m_oResource.getResText("RID_FORM_4"); + String sSelectRelation = CurUnoDialog.m_oResource.getResText("RID_FORM_8"); + String sSubFormDescription = CurUnoDialog.m_oResource.getResText("RID_FORM_3"); + + // CheckBox 'Add sub form' + chkcreateSubForm = CurUnoDialog.insertCheckBox("chkcreateSubForm", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubFormMode(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKCREATESUBFORM", sSelectManually, 97, 26, ISubFormStep, Short.valueOf(curtabindex++), 160 + }); + optOnExistingRelation = CurUnoDialog.insertRadioButton("optOnExistingRelation", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSteps(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + Boolean.FALSE, UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTONEXISTINGRELATION", sOnExistingRelation, 107, 43, ISubFormStep, Short.valueOf(curtabindex++), 160 + }); + optSelectManually = CurUnoDialog.insertRadioButton("optSelectManually", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSteps(); + } + }, + new String[] + { + PropertyNames.PROPERTY_ENABLED, 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 + }, + new Object[] + { + Boolean.FALSE, UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTSELECTMANUALLY", sOnManualRelation, 107, 99, Short.valueOf((short) 1), ISubFormStep, Short.valueOf(curtabindex++), 160 + }); + lblRelations = CurUnoDialog.insertLabel("lblSelectRelation", + new String[] + { + PropertyNames.PROPERTY_ENABLED, 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 + }, + new Object[] + { + Boolean.FALSE, 19, sSelectRelation, Boolean.TRUE, 119, 56, ISubFormStep, Short.valueOf(curtabindex++), 80 + }); + lstRelations = CurUnoDialog.insertListBox("lstrelations", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + onexistingRelationSelection(); + } + }, new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + onexistingRelationSelection(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + Boolean.FALSE, 37, "HID:WIZARDS_HID_DLGFORM_lstRELATIONS", 201, 55, ISubFormStep, Short.valueOf(curtabindex++), 103 + }); + CurUnoDialog.insertLabel("lblSubFormDescription", + new String[] + { + 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 + }, + new Object[] + { + 59, sSubFormDescription, Boolean.TRUE, 110, 120, ISubFormStep, Short.valueOf(curtabindex++), 190 + }); + CurUnoDialog.insertInfoImage(97, 120, ISubFormStep.intValue()); + } + + + public RelationController getRelationController() + { + return oRelationController; + } + + public boolean areexistingRelationsdefined() + { + return ((chkcreateSubForm.getState() == 1) && (optOnExistingRelation.getState())); + } + + private void toggleSubFormMode() + { + boolean bdoEnable = (this.chkcreateSubForm.getState() == 1); + Helper.setUnoPropertyValue(UnoDialog.getModel(optOnExistingRelation), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoEnable && bsupportsRelations)); + Helper.setUnoPropertyValue(UnoDialog.getModel(optSelectManually), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoEnable)); + toggleSteps(); + } + + public void initialize(CommandFieldSelection _CurSubFormFieldSelection, RelationController _oRelationController) + { + oRelationController = _oRelationController; + sreferencedTables = oRelationController.getExportedKeys(); + bsupportsRelations = (sreferencedTables.length > 0); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstRelations), PropertyNames.STRING_ITEM_LIST, sreferencedTables); + this.CurSubFormFieldSelection = _CurSubFormFieldSelection; + toggleRelationsListbox(); + Helper.setUnoPropertyValue(UnoDialog.getModel(optOnExistingRelation), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bsupportsRelations && (chkcreateSubForm.getState() == 1))); + } + + private void toggleSteps() + { + if (chkcreateSubForm.getState() == 1) + { + if (optOnExistingRelation.getState()) + { + onexistingRelationSelection(); + } + else if (optSelectManually.getState()) + { + CurUnoDialog.enablefromStep(FormWizard.SOFIELDLINKER_PAGE, (CurSubFormFieldSelection.getSelectedFieldNames().length > 0)); + CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, true); + } + } + else + { + CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, false); + CurUnoDialog.setStepEnabled(FormWizard.SOFIELDLINKER_PAGE, false); + CurUnoDialog.enablefromStep(FormWizard.SOCONTROL_PAGE, true); + } + toggleRelationsListbox(); + } + + public String getreferencedTableName() + { + if (areexistingRelationsdefined()) + { + short[] iselected = (short[]) Helper.getUnoArrayPropertyValue(UnoDialog.getModel(lstRelations), PropertyNames.SELECTED_ITEMS); + if (iselected != null && iselected.length > 0) + { + return sreferencedTables[iselected[0]]; + } + } + return PropertyNames.EMPTY_STRING; + } + + private void onexistingRelationSelection() + { + String scurreferencedTableName = getreferencedTableName(); + if (scurreferencedTableName.length() > 0) + { + if (CurSubFormFieldSelection.getSelectedCommandName().equals(scurreferencedTableName)) + { + CurUnoDialog.enablefromStep(FormWizard.SOSUBFORMFIELDS_PAGE, true); + CurUnoDialog.setStepEnabled(FormWizard.SOFIELDLINKER_PAGE, false); + return; + } + else + { + CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, true); + CurUnoDialog.enablefromStep(FormWizard.SOFIELDLINKER_PAGE, false); + return; + } + } + CurUnoDialog.enablefromStep(FormWizard.SOSUBFORMFIELDS_PAGE, false); + } + + private void toggleRelationsListbox() + { + boolean bdoenable = bsupportsRelations && this.optOnExistingRelation.getState() && (chkcreateSubForm.getState() == 1); + Helper.setUnoPropertyValue(UnoDialog.getModel(lblRelations), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoenable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstRelations), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoenable)); + } + + public boolean hasSubForm() + { + return (this.chkcreateSubForm.getState() == 1); + } +} diff --git a/wizards/com/sun/star/wizards/form/FormControlArranger.java b/wizards/com/sun/star/wizards/form/FormControlArranger.java new file mode 100644 index 0000000000..93becab456 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/FormControlArranger.java @@ -0,0 +1,675 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.ColumnValue; +import com.sun.star.sdbc.DataType; +import com.sun.star.task.XStatusIndicator; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.*; +import com.sun.star.wizards.document.Control; +import com.sun.star.wizards.document.DatabaseControl; +import com.sun.star.wizards.document.FormHandler; +import com.sun.star.wizards.document.Shape; +import com.sun.star.wizards.document.TimeStampControl; + +public class FormControlArranger +{ + + private static final String LABELCONTROL = "LabelControl"; + protected DatabaseControl[] DBControlList = null; + private final XNameContainer xFormName; + private final XMultiServiceFactory xMSF; + private Control[] LabelControlList = null; + private final XStatusIndicator xProgressBar; + private final FieldColumn[] FieldColumns; + // Control curLabelControl; + private int icurArrangement; + private boolean bIsFirstRun; + private boolean bIsVeryFirstRun; + private boolean bControlsareCreated; + private int cXOffset; + private int cYOffset; + private static final int cVertDistance = 200; + private static final int cHoriDistance = 300; + private static final int cLabelGap = 100; + private static final double CMAXREDUCTION = 0.7; + private final FormHandler oFormHandler; + private int iReduceWidth; + private int m_currentLabelPosX; + private int m_currentLabelPosY; + private int m_currentControlPosX; + private int m_currentControlPosY; + private int m_LabelHeight; + private int m_LabelWidth; + private int m_dbControlHeight; + private int m_dbControlWidth; + private int m_MaxLabelWidth; + private int nFormWidth; + private int nFormHeight; + private int m_currentMaxRowHeight; + private int nSecMaxRowY; + private int m_maxPositionX; + private int a; + private int StartA; + private int m_controlMaxPosY = 0; //the maximum YPosition of a DBControl in the form + private Short NBorderType = Short.valueOf((short) 1); //3-D Border + + public FormControlArranger(FormHandler _oFormHandler, XNameContainer _xFormName, CommandMetaData oDBMetaData, XStatusIndicator _xProgressBar, Point _StartPoint, Size _FormSize) + { + FieldColumns = oDBMetaData.FieldColumns; + xMSF = oDBMetaData.xMSF; + xFormName = _xFormName; + xProgressBar = _xProgressBar; + LabelControlList = new Control[FieldColumns.length]; + DBControlList = new DatabaseControl[FieldColumns.length]; + oFormHandler = _oFormHandler; + cXOffset = _StartPoint.X; + cYOffset = _StartPoint.Y; + setFormSize(_FormSize); + } + // Note: on all Controls except for the checkbox the Label has to be set + // a bit under the DBControl because its Height is also smaller + + private int getLabelDiffHeight(int _index) + { + final DatabaseControl curDBControl = DBControlList[_index]; + if (curDBControl != null && curDBControl.getControlType() == FormHandler.SOCHECKBOX) + { + return getCheckBoxDiffHeight(_index); + } + return oFormHandler.getBasicLabelDiffHeight(); + } + + public Control[] getLabelControlList() + { + return LabelControlList; + } + + private int getCheckBoxDiffHeight(int LastIndex) + { + if (LastIndex < DBControlList.length && DBControlList[LastIndex].getControlType() == FormHandler.SOCHECKBOX) + { + return (oFormHandler.getControlReferenceHeight() - DBControlList[LastIndex].getControlHeight()) / 2; + } + return 0; + } + + private boolean isReducable(int _index, int i_labelWidth, int i_dbControlWidth) + { + boolean bisreducable = false; + int ntype = FieldColumns[_index].getFieldType(); + switch (ntype) + { + case DataType.TINYINT: + case DataType.SMALLINT: + case DataType.INTEGER: + case DataType.FLOAT: + case DataType.DATE: + case DataType.TIME: + case DataType.TIMESTAMP: + case DataType.REAL: + case DataType.DOUBLE: + case DataType.NUMERIC: + case DataType.DECIMAL: + case DataType.BIT: + case DataType.BOOLEAN: + bisreducable = false; + break; + case DataType.VARCHAR: + short nTextLen; + try + { + nTextLen = AnyConverter.toShort(DBControlList[_index].xPropertySet.getPropertyValue("MaxTextLen")); + if ((nTextLen == 0) || (nTextLen > 20)) + { + bisreducable = true; + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + break; + case DataType.BIGINT: + bisreducable = true; + break; + default: + bisreducable = true; + } + if (bisreducable && i_labelWidth > 0.9 * CMAXREDUCTION * i_dbControlWidth) + { + bisreducable = false; + } + return bisreducable; + } + + private void checkJustifiedPosition(int a) + { + int nBaseWidth = nFormWidth + cXOffset; + int nLeftDist = m_maxPositionX - nBaseWidth; + int nRightDist = nBaseWidth - (DBControlList[a].getPosition().X - cHoriDistance); + if (nLeftDist < 0.5 * nRightDist) + { + // Fieldwidths in the line can be made smaller... + adjustLineWidth(StartA, a, nLeftDist, -1); + m_currentLabelPosY = m_currentMaxRowHeight + cVertDistance; + m_currentControlPosY = m_currentLabelPosY + m_LabelHeight; + m_currentLabelPosX = cXOffset; + m_currentControlPosX = cXOffset; + bIsFirstRun = true; + StartA = a + 1; + } + else + { + // FieldWidths in the line can be made wider... + if (m_currentControlPosY + m_dbControlHeight == m_currentMaxRowHeight) + { + // The last Control was the highest in the row + m_currentLabelPosY = nSecMaxRowY; + } + else + { + m_currentLabelPosY = m_currentMaxRowHeight; + } + m_currentLabelPosY += cVertDistance; + m_currentControlPosY = m_currentLabelPosY + m_LabelHeight; + m_currentControlPosX = cXOffset; + m_currentLabelPosX = cXOffset; + LabelControlList[a].setPosition(new Point(cXOffset, m_currentLabelPosY)); + DBControlList[a].setPosition(new Point(cXOffset, m_currentControlPosY)); + bIsFirstRun = true; + checkOuterPoints(m_currentControlPosX, m_dbControlWidth > m_LabelWidth ? m_dbControlWidth : m_LabelWidth, m_currentControlPosY, m_dbControlHeight, true); + m_currentLabelPosX = m_maxPositionX + cHoriDistance; + m_currentControlPosX = m_currentLabelPosX; + adjustLineWidth(StartA, a - 1, nRightDist, 1); + StartA = a; + } + } + + private int getCorrWidth(int StartIndex, int EndIndex, int nDist, int Widthfactor) + { + int ShapeCount; + if (Widthfactor > 0) + { + // shapes are made wide + ShapeCount = EndIndex - StartIndex + 1; + } + else + { + // shapes are made more narrow + ShapeCount = iReduceWidth; + } + if(ShapeCount == 0) + return 0; + else + return (nDist) / ShapeCount; + } + + /** + * + * @param StartIndex + * @param EndIndex + * @param nDist + * @param WidthFactor is either '+1' or '-1' and determines whether the control shapes widths are to be made smaller or larger + */ + private void adjustLineWidth(final int StartIndex, final int EndIndex, final int nDist, final int WidthFactor) + { + if(StartIndex <= EndIndex) + { + int CorrWidth = getCorrWidth(StartIndex, EndIndex, nDist, WidthFactor); + int iLocTCPosX = cXOffset; + for (int i = StartIndex; i <= EndIndex; i++) + { + int nControlBaseWidth = 0; + DatabaseControl dbControl = DBControlList[i]; + Control curLabelControl = LabelControlList[i]; + if (i != StartIndex) + { + curLabelControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y)); + dbControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y + m_LabelHeight)); + } + final Size labelSize = curLabelControl.getSize(); + Size controlSize = dbControl.getSize(); + if (((labelSize.Width > controlSize.Width)) && (WidthFactor > 0)) + { + nControlBaseWidth = labelSize.Width; + } + else + { + nControlBaseWidth = controlSize.Width; + } + if (FieldColumns[i].getFieldType() == DataType.TIMESTAMP) + { + TimeStampControl oDBTimeStampControl = (TimeStampControl) dbControl; + nControlBaseWidth = oDBTimeStampControl.getSize().Width; + } + if (WidthFactor > 0 || isReducable(i, labelSize.Width, controlSize.Width)) + { + controlSize.Width = nControlBaseWidth + WidthFactor * CorrWidth; + dbControl.setSize(controlSize); + controlSize = dbControl.getSize(); + } + + if (labelSize.Width > controlSize.Width) + { + iLocTCPosX += labelSize.Width; + } + else + { + iLocTCPosX += controlSize.Width; + } + iLocTCPosX += cHoriDistance; + } + } + if (WidthFactor > 0) + { + iReduceWidth = 1; + } + else + { + iReduceWidth = 0; + } + } + + private void checkOuterPoints(int i_nXPos, int i_nWidth, int i_nYPos, int i_nHeight, boolean i_bIsDBField) + { + if (icurArrangement == FormWizard.IN_BLOCK_TOP && i_bIsDBField) + { + // Only at DBControls you can measure the Value of nMaxRowY + if (bIsFirstRun) + { + m_currentMaxRowHeight = i_nYPos + i_nHeight; + nSecMaxRowY = m_currentMaxRowHeight; + } + else + { + int nRowY = i_nYPos + i_nHeight; + if (nRowY >= m_currentMaxRowHeight) + { + nSecMaxRowY = m_currentMaxRowHeight; + m_currentMaxRowHeight = nRowY; + } + } + } + // Find the outer right point + if (bIsFirstRun) + { + m_maxPositionX = i_nXPos + i_nWidth; + bIsFirstRun = false; + } + else + { + int nColRightX = i_nXPos + i_nWidth; + if (nColRightX > m_maxPositionX) + { + m_maxPositionX = nColRightX; + } + } + } + + public void positionControls(int _icurArrangement, Point _aStartPoint, short _iAlign, Short _NBorderType) + { + try + { + NBorderType = _NBorderType; + setStartPoint(_aStartPoint); + icurArrangement = _icurArrangement; + initializePosSizes(); + initializeControlColumn(-1); + bIsVeryFirstRun = true; + m_currentMaxRowHeight = 0; + nSecMaxRowY = 0; + m_maxPositionX = 0; + xProgressBar.start(PropertyNames.EMPTY_STRING, FieldColumns.length); + for (int i = 0; i < FieldColumns.length; i++) + { + try + { + insertLabel(i, _iAlign); + insertDBControl(i); + bIsVeryFirstRun = false; + DBControlList[i].setPropertyValue(LABELCONTROL, LabelControlList[i].xPropertySet); + resetPosSizes(i); + xProgressBar.setValue(i + 1); + } + catch (RuntimeException e) + { + } + } + xProgressBar.end(); + bControlsareCreated = true; + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public boolean areControlsexisting() + { + if (DBControlList != null) + { + if (DBControlList.length > 0) + { + return (DBControlList[0] != null); + } + } + return false; + } + + private void initializeControlColumn(int LastIndex) + { + bIsFirstRun = true; + StartA = LastIndex + 1; + a = 0; + } + + private void resetPosSizes(int LastIndex) + { + int nYRefPos = m_currentControlPosY; + switch (icurArrangement) + { + case FormWizard.COLUMNAR_LEFT: + m_currentControlPosY = m_currentControlPosY + m_dbControlHeight + cVertDistance + getCheckBoxDiffHeight(LastIndex); + nYRefPos = m_currentControlPosY; + if ((m_currentControlPosY > cYOffset + nFormHeight) || (LastIndex == (FieldColumns.length - 1))) + { + repositionColumnarLeftControls(LastIndex); + m_currentLabelPosX = m_maxPositionX + 2 * cHoriDistance; + m_currentControlPosX = m_currentLabelPosX + cLabelGap + m_MaxLabelWidth; + m_currentControlPosY = cYOffset; + nYRefPos = m_currentControlPosY; + initializeControlColumn(LastIndex); + } + else + { + /*a = a + 1;*/ + /* a += 1;*/ + ++a; + } + m_currentLabelPosY = m_currentControlPosY + getLabelDiffHeight(LastIndex); + if ((nYRefPos + m_dbControlHeight) > m_controlMaxPosY) + { + m_controlMaxPosY = nYRefPos + m_dbControlHeight; + } + + break; + case FormWizard.COLUMNAR_TOP: + m_currentLabelPosY = m_currentControlPosY + m_dbControlHeight + cVertDistance + getCheckBoxDiffHeight(LastIndex); + + if ((m_currentLabelPosY > cYOffset + nFormHeight) || (LastIndex == (FieldColumns.length - 1))) + { + m_currentControlPosX = m_maxPositionX + cHoriDistance; + m_currentLabelPosX = m_currentControlPosX; + nYRefPos = m_currentControlPosY; + m_currentControlPosY = cYOffset + m_LabelHeight + cVertDistance; + m_currentLabelPosY = cYOffset; + initializeControlColumn(LastIndex); + } + else + { + ++a; + } + if ((nYRefPos + m_dbControlHeight + cVertDistance) > m_controlMaxPosY) + { + m_controlMaxPosY = nYRefPos + m_dbControlHeight + cVertDistance; + } + break; + + case FormWizard.IN_BLOCK_TOP: + if (isReducable(a, m_LabelWidth, m_dbControlWidth)) + { + ++iReduceWidth; + } + if (m_maxPositionX > cXOffset + nFormWidth) + { + checkJustifiedPosition(a); + nYRefPos = m_currentControlPosY; + } + else + { + m_currentLabelPosX = m_maxPositionX + cHoriDistance; + } + if (a == FieldColumns.length - 1) + { + checkJustifiedPosition(a); + nYRefPos = m_currentControlPosY; + } + m_currentControlPosX = m_currentLabelPosX; + ++a; + if ((nYRefPos + m_dbControlHeight) > m_controlMaxPosY) + { + m_controlMaxPosY = nYRefPos + m_dbControlHeight; + } + break; + } + } + + private void repositionColumnarLeftControls(int LastIndex) + { + bIsFirstRun = true; + for (int i = StartA; i <= LastIndex; i++) + { + if (i == StartA) + { + m_currentLabelPosX = LabelControlList[i].getPosition().X; + m_currentControlPosX = m_currentLabelPosX + m_MaxLabelWidth + cHoriDistance; + } + LabelControlList[i].setSize(new Size(m_MaxLabelWidth, m_LabelHeight)); + resetDBShape(DBControlList[i], m_currentControlPosX); + checkOuterPoints(m_currentControlPosX, m_dbControlWidth, m_currentControlPosY, m_dbControlHeight, true); + } + } + + private void resetDBShape(Shape _curDBControl, int iXPos) + { + m_dbControlWidth = _curDBControl.getSize().Width; + m_dbControlHeight = _curDBControl.getSize().Height; + _curDBControl.setPosition(new Point(iXPos, _curDBControl.getPosition().Y)); + } + + private void initializePosSizes() + { + m_controlMaxPosY = 0; + m_currentLabelPosX = cXOffset; + m_LabelWidth = 2000; + m_dbControlWidth = 2000; + m_dbControlHeight = oFormHandler.getControlReferenceHeight(); + m_LabelHeight = oFormHandler.getLabelHeight(); + iReduceWidth = 0; + if (icurArrangement == FormWizard.COLUMNAR_LEFT) + { + m_currentLabelPosY = cYOffset + getLabelDiffHeight(0); + m_currentControlPosX = cXOffset + 3050; + m_currentControlPosY = cYOffset; + } + else + { + m_currentControlPosX = cXOffset; + m_currentLabelPosY = cYOffset; + } + } + + private void insertLabel(int i, int _iAlign) + { + try + { + Point aPoint = new Point(m_currentLabelPosX, m_currentLabelPosY); + Size aSize = new Size(m_LabelWidth, m_LabelHeight); + if (bControlsareCreated) + { + LabelControlList[i].setPosition(aPoint); + if (icurArrangement != FormWizard.COLUMNAR_LEFT) + { + m_LabelWidth = LabelControlList[i].getPreferredWidth(FieldColumns[i].getFieldTitle()); + aSize.Width = m_LabelWidth; + LabelControlList[i].setSize(aSize); + } + else + { + m_LabelWidth = LabelControlList[i].getSize().Width; + } + } + else + { + final String sFieldName = FieldColumns[i].getFieldName(); + LabelControlList[i] = new Control(oFormHandler, xFormName, FormHandler.SOLABEL, sFieldName, aPoint, aSize); + if (bIsVeryFirstRun && icurArrangement == FormWizard.COLUMNAR_TOP) + { + m_currentControlPosY = m_currentLabelPosY + m_LabelHeight; + } + final String sTitle = FieldColumns[i].getFieldTitle(); + m_LabelWidth = LabelControlList[i].getPreferredWidth(sTitle); + aSize.Width = m_LabelWidth; + LabelControlList[i].setSize(aSize); + } + Control curLabelControl = LabelControlList[i]; + if (icurArrangement == FormWizard.COLUMNAR_LEFT) + { + // Note This If Sequence must be called before retrieving the outer Points + if (bIsFirstRun) + { + m_MaxLabelWidth = m_LabelWidth; + bIsFirstRun = false; + } + else if (m_LabelWidth > m_MaxLabelWidth) + { + m_MaxLabelWidth = m_LabelWidth; + } + } + checkOuterPoints(m_currentLabelPosX, m_LabelWidth, m_currentLabelPosY, m_LabelHeight, false); + if ((icurArrangement == FormWizard.COLUMNAR_TOP) || (icurArrangement == FormWizard.IN_BLOCK_TOP)) + { + m_currentControlPosX = m_currentLabelPosX; + m_currentControlPosY = m_currentLabelPosY + m_LabelHeight; + curLabelControl.xPropertySet.setPropertyValue(PropertyNames.PROPERTY_ALIGN, Short.valueOf((short) com.sun.star.awt.TextAlign.LEFT)); + } + else + { + curLabelControl.xPropertySet.setPropertyValue(PropertyNames.PROPERTY_ALIGN, Short.valueOf((short) _iAlign)); + } + if (!bControlsareCreated) + { + curLabelControl.setSize(new Size(m_LabelWidth, m_LabelHeight)); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private void insertDBControl(int i) + { + try + { + String sFieldName = FieldColumns[i].getFieldName(); + int nFieldType = FieldColumns[i].getFieldType(); + boolean bFieldNullable = AnyConverter.toInt(FieldColumns[i].getXColumnPropertySet().getPropertyValue(PropertyNames.PROPERTY_IS_NULLABLE)) != ColumnValue.NO_NULLS; + boolean bFieldHasDefaultValue = !AnyConverter.toString(FieldColumns[i].getXColumnPropertySet().getPropertyValue(PropertyNames.PROPERTY_DEFAULT_VALUE)).isEmpty(); + + Point aPoint = new Point(m_currentControlPosX, m_currentControlPosY); + if (bControlsareCreated) + { + DBControlList[i].setPosition(aPoint); + } + else + { + if (nFieldType == DataType.TIMESTAMP) + { + DBControlList[i] = new TimeStampControl(new Resource(xMSF), oFormHandler, xFormName, sFieldName, aPoint); + } + else + { + DBControlList[i] = new DatabaseControl(oFormHandler, xFormName, sFieldName, nFieldType, aPoint); + if (DBControlList[i].getControlType() == FormHandler.SOCHECKBOX) + { + // Checkboxes have no Label near by + DBControlList[i].setPropertyValue(PropertyNames.PROPERTY_LABEL, PropertyNames.EMPTY_STRING); + } + } + } + DatabaseControl aDBControl = DBControlList[i]; + m_dbControlHeight = aDBControl.getControlHeight(); + m_dbControlWidth = aDBControl.getControlWidth(); + if (nFieldType != DataType.TIMESTAMP) + { + aDBControl.setSize(new Size(m_dbControlWidth, m_dbControlHeight)); + } + if (aDBControl.getControlType() == FormHandler.SOCHECKBOX) + { + m_currentControlPosY = m_currentControlPosY + /*(int)*/ ((oFormHandler.getControlReferenceHeight() - m_dbControlHeight) / 2); + aPoint = new Point(m_currentControlPosX, m_currentControlPosY); + aDBControl.setPosition(aPoint); + } + if (nFieldType == DataType.LONGVARCHAR) /* memo */ + { + Helper.setUnoPropertyValue(aDBControl.xPropertySet, PropertyNames.PROPERTY_MULTILINE, Boolean.TRUE); + } + checkOuterPoints(m_currentControlPosX, m_dbControlWidth, m_currentControlPosY, m_dbControlHeight, true); + aDBControl.setPropertyValue(PropertyNames.PROPERTY_BORDER, NBorderType); + aDBControl.setPropertyValue(PropertyNames.PROPERTY_INPUT_REQUIRED, !(bFieldNullable || bFieldHasDefaultValue)); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public int getFormHeight() + { + return m_controlMaxPosY - cYOffset; + } + + public int getEntryPointY() + { + if (icurArrangement == FormWizard.COLUMNAR_TOP) + { + Control curLabelControl2 = LabelControlList[0]; + return curLabelControl2.getPosition().Y; + } + else + { + DatabaseControl curDBControl2 = DBControlList[0]; + return curDBControl2.getPosition().Y; + } + } + + public void setStartPoint(Point _aPoint) + { + cXOffset = _aPoint.X; + cYOffset = _aPoint.Y; + } + + + + public void setFormSize(Size _FormSize) + { + nFormHeight = _FormSize.Height; + nFormWidth = _FormSize.Width; + } +} diff --git a/wizards/com/sun/star/wizards/form/FormDocument.java b/wizards/com/sun/star/wizards/form/FormDocument.java new file mode 100644 index 0000000000..af72449501 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/FormDocument.java @@ -0,0 +1,554 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import java.util.ArrayList; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.CommandMetaData; +import com.sun.star.wizards.document.Control; +import com.sun.star.wizards.document.DatabaseControl; +import com.sun.star.wizards.document.FormHandler; +import com.sun.star.wizards.document.GridControl; +import com.sun.star.wizards.text.TextDocument; +import com.sun.star.wizards.text.TextStyleHandler; +import com.sun.star.wizards.text.ViewHandler; + +public class FormDocument extends TextDocument +{ + protected ArrayList<ControlForm> oControlForms = new ArrayList<ControlForm>(); + protected CommandMetaData oMainFormDBMetaData; + protected CommandMetaData oSubFormDBMetaData; + protected String[][] LinkFieldNames; + + private FormHandler oFormHandler; + private XPropertySet xPropPageStyle; + private static final int SOFORMGAP = 2000; + private boolean bhasSubForm; + private UIControlArranger curUIControlArranger; + private StyleApplier curStyleApplier; + private int nPageWidth; + private int nPageHeight; + private int nFormWidth; + private int nFormHeight; + private Point aMainFormPoint; + private static final String SOMAINFORM = "MainForm"; + private static final String SOSUBFORM = "SubForm"; + + public FormDocument(XMultiServiceFactory xMSF) + { + super(xMSF, new TextDocument.ModuleIdentifier("com.sun.star.sdb.FormDesign"), true); + try + { + oFormHandler = new FormHandler(xMSF, xTextDocument); + oFormHandler.setDrawObjectsCaptureMode(false); + TextStyleHandler oTextStyleHandler = new TextStyleHandler(xTextDocument); + new ViewHandler(xTextDocument); + oMainFormDBMetaData = new CommandMetaData(xMSF);// , CharLocale); + oSubFormDBMetaData = new CommandMetaData(xMSF);// , CharLocale); + ViewHandler oViewHandler = new ViewHandler(xTextDocument); + TextStyleHandler oTextStyleSupplier = new TextStyleHandler(xTextDocument); + Helper.setUnoPropertyValue(xTextDocument, "ApplyFormDesignMode", Boolean.FALSE); + oViewHandler.setViewSetting("ShowTableBoundaries", Boolean.FALSE); + oViewHandler.setViewSetting("ShowOnlineLayout", Boolean.TRUE); + xPropPageStyle = oTextStyleSupplier.getStyleByName("PageStyles", "Standard"); + Size aSize = oTextStyleHandler.changePageAlignment(xPropPageStyle, true); + nPageWidth = aSize.Width; + nPageHeight = aSize.Height; + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public void addUIFormController(UIControlArranger _curUIControlArranger) + { + this.curUIControlArranger = _curUIControlArranger; + } + + public void addStyleApplier(StyleApplier _curStyleApplier) + { + this.curStyleApplier = _curStyleApplier; + } + + private String getDataSourceName() + { + return this.oMainFormDBMetaData.DataSourceName; + } + + private void adjustPageStyle() + { + try + { + int nMargin; + int totfieldcount = getMainFieldCount() + getSubFieldCount(); + if (totfieldcount > 30) + { + nMargin = 500; + } + else if (totfieldcount > 20) + { + nMargin = 750; + } + else + { + nMargin = 1000; + } + xPropPageStyle.setPropertyValue("RightMargin", Integer.valueOf(nMargin)); + xPropPageStyle.setPropertyValue("LeftMargin", Integer.valueOf(nMargin)); + xPropPageStyle.setPropertyValue("TopMargin", Integer.valueOf(nMargin)); + xPropPageStyle.setPropertyValue("BottomMargin", Integer.valueOf(nMargin)); + aMainFormPoint = new Point(nMargin, nMargin); + nFormWidth = (int) (0.8 * nPageWidth) - 2 * nMargin; + nFormHeight = (int) (0.65 * nPageHeight) - 2 * nMargin; + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public void initialize(boolean _baddParentForm, boolean _bShouldHaveSubForm, boolean _bModifySubForm, Short _NBorderType) + { + bhasSubForm = _bShouldHaveSubForm; + adjustPageStyle(); + if (_baddParentForm) + { + if (oControlForms.isEmpty()) + { + final ControlForm aMainControlForm = new ControlForm(this, SOMAINFORM, aMainFormPoint, getMainFormSize(FormWizard.AS_GRID)); + oControlForms.add(aMainControlForm); + } + else + { + oFormHandler.removeControlsofForm(SOMAINFORM); + oControlForms.get(0).oFormController = null; + } + oControlForms.get(0).initialize(curUIControlArranger.getSelectedArrangement(0), _NBorderType); + } + if (_bShouldHaveSubForm) + { + if (oControlForms.size() == 1) + { + adjustMainFormSize(_NBorderType); + final ControlForm aSubControlForm = new ControlForm(this, SOSUBFORM, getSubFormPoint(), getSubFormSize()); + oControlForms.add(aSubControlForm); + /* ((ControlForm) oControlForms.get(1))*/ + aSubControlForm.initialize(curUIControlArranger.getSelectedArrangement(1), _NBorderType); + } + else if (_bModifySubForm) + { + if (oControlForms.size() > 1) + { + oFormHandler.removeControlsofForm(SOSUBFORM); + oControlForms.get(1).oFormController = null; + oControlForms.get(1).initialize(curUIControlArranger.getSelectedArrangement(1), _NBorderType); + } + } + } + else + { + ControlForm aMainForm = oControlForms.get(0); + // WRONG if (oFormHandler.hasFormByName(SOSUBFORM)) + if (aMainForm.xFormContainer != null && aMainForm.xFormContainer.hasByName(SOSUBFORM)) + { + oFormHandler.removeControlsofForm(SOSUBFORM); + oFormHandler.removeElement( aMainForm.xFormContainer, SOSUBFORM ); + oControlForms.get(1).oFormController = null; + oControlForms.remove(1); + adjustMainFormSize(_NBorderType); + } + } + } + + private int getMainFieldCount() + { + return oMainFormDBMetaData.getFieldNames().length; + } + private int getSubFieldCount() + { + return oSubFormDBMetaData.getFieldNames().length; + } + + private Size getMainFormSize(int _curArrangement) + { + int nMainFormHeight = nFormHeight; + if (bhasSubForm) + { + if (_curArrangement == FormWizard.AS_GRID) + { + nMainFormHeight = (int) ((double) (nFormHeight - SOFORMGAP) / 2); + } + else + { + int nTotalFieldCount = getMainFieldCount() + getSubFieldCount(); + nMainFormHeight = (int) (((double) getMainFieldCount() / (double) nTotalFieldCount) * ((double) (nFormHeight - SOFORMGAP) / 2)); + } + } + return new Size(nFormWidth, nMainFormHeight); + } + + private Size getSubFormSize() + { + int nMainFormHeight = oControlForms.get(0).getActualFormHeight(); + return new Size(nFormWidth, nFormHeight - nMainFormHeight - SOFORMGAP); + } + + private Point getSubFormPoint() + { + ControlForm curMainControlForm = oControlForms.get(0); + return new Point(curMainControlForm.aStartPoint.X, + (curMainControlForm.aStartPoint.Y + curMainControlForm.getFormSize().Height + SOFORMGAP)); + } + + private void adjustMainFormSize(Short _NBorderType) + { + ControlForm oMainControlForm = oControlForms.get(0); + oMainControlForm.setFormSize(getMainFormSize(oMainControlForm.curArrangement)); + if (oMainControlForm.curArrangement == FormWizard.AS_GRID) + { + oMainControlForm.oGridControl.setSize(oMainControlForm.getFormSize()); + } + else + { + oMainControlForm.oFormController.positionControls(oMainControlForm.curArrangement, + oMainControlForm.aStartPoint, + curUIControlArranger.getAlignValue(), + _NBorderType); + } + } + + private void adjustSubFormPosSize(Short _NBorderType) + { + ControlForm oMainControlForm = oControlForms.get(0); + ControlForm oSubControlForm = oControlForms.get(1); + oSubControlForm.setFormSize(new Size(nFormWidth, nFormHeight - oMainControlForm.getFormSize().Height)); + if (oSubControlForm.curArrangement == FormWizard.AS_GRID) + { + Point aPoint = oSubControlForm.oGridControl.getPosition(); + int idiffheight = oSubControlForm.getEntryPointY() - oMainControlForm.getActualFormHeight() - oMainControlForm.aStartPoint.Y - SOFORMGAP; + oSubControlForm.setStartPoint(new Point(aPoint.X, (aPoint.Y - idiffheight))); + oSubControlForm.oGridControl.setPosition(oSubControlForm.aStartPoint); + oSubControlForm.oGridControl.setSize(getSubFormSize()); + } + else + { +// oSubControlForm.oFormController.adjustYPositions(_idiffheight); + oSubControlForm.setStartPoint(new Point(oSubControlForm.aStartPoint.X, oMainControlForm.getActualFormHeight() + oMainControlForm.aStartPoint.Y + SOFORMGAP)); + oSubControlForm.oFormController.positionControls(oSubControlForm.curArrangement, oSubControlForm.aStartPoint, curUIControlArranger.getAlignValue(), _NBorderType); + } + } + + private ControlForm getControlFormByName(String _sname) + { + for (int i = 0; i < oControlForms.size(); i++) + { + ControlForm curControlForm = oControlForms.get(i); + if (curControlForm.Name.equals(_sname)) + { + return curControlForm; + } + } + throw new IllegalArgumentException("Searching for control " + _sname + " failed"); + } + + public boolean finalizeForms(DataEntrySetter _curDataEntrySetter, FieldLinker _curFieldLinker, FormConfiguration _curFormConfiguration) + { + try + { + this.xTextDocument.lockControllers(); + PropertyValue[] aFormProperties = _curDataEntrySetter.getFormProperties(); + ControlForm oMasterControlForm = getControlFormByName(SOMAINFORM); + oMasterControlForm.setFormProperties(aFormProperties, oMainFormDBMetaData); + oMasterControlForm.finalizeControls(); + if (oMasterControlForm.xFormContainer.hasByName(SOSUBFORM)) + { + ControlForm oSubControlForm = getControlFormByName(SOSUBFORM); + oSubControlForm.setFormProperties(aFormProperties, oSubFormDBMetaData); + String sRefTableName = _curFormConfiguration.getreferencedTableName(); + if (sRefTableName.equals(PropertyNames.EMPTY_STRING)) + { + LinkFieldNames = _curFieldLinker.getLinkFieldNames(); + } + else + { + LinkFieldNames = _curFieldLinker.getLinkFieldNames(_curFormConfiguration.getRelationController(), sRefTableName); + } + if (LinkFieldNames != null && LinkFieldNames.length > 0) + { + oSubControlForm.xPropertySet.setPropertyValue("DetailFields", LinkFieldNames[0]); + oSubControlForm.xPropertySet.setPropertyValue("MasterFields", LinkFieldNames[1]); + oSubControlForm.finalizeControls(); + return true; + } + return false; + } + return true; + } + catch (Exception e) + { + e.printStackTrace(System.err); + return false; + } + finally + { + unlockallControllers(); + } + } + + public class ControlForm + { + + private XNameContainer xFormContainer; + GridControl oGridControl; + private FormControlArranger oFormController; + private int curArrangement; + private FormDocument oFormDocument; + private String Name; + private Point aStartPoint; + private Size aFormSize; + private CommandMetaData oDBMetaData; + private XPropertySet xPropertySet; + + public ControlForm(FormDocument _oFormDocument, String _sname, Point _astartPoint, Size _aFormSize) + { + aStartPoint = _astartPoint; + aFormSize = _aFormSize; + oFormDocument = _oFormDocument; + Name = _sname; + if (_sname.equals(SOSUBFORM)) + { + ControlForm oMainControlForm = oControlForms.get(0); + xFormContainer = oFormHandler.insertFormbyName(_sname, oMainControlForm.xFormContainer); + } + else + { + xFormContainer = oFormHandler.insertFormbyName(_sname); + } + xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xFormContainer); + if (_sname.equals(SOMAINFORM)) + { + oDBMetaData = oFormDocument.oMainFormDBMetaData; + } + else + { + oDBMetaData = oFormDocument.oSubFormDBMetaData; + } + } + + public void initialize(int _curArrangement, Short _NBorderType) + { + boolean adaptControlStyles = false; + xTextDocument.lockControllers(); + curArrangement = _curArrangement; + if (oGridControl != null) + { + oFormHandler.xDrawPage.remove(oGridControl.xShape); + oGridControl.xComponent.dispose(); + oGridControl = null; + } + if (oFormController == null) + { + oFormController = new FormControlArranger(oFormHandler, xFormContainer, oDBMetaData, xProgressBar, aStartPoint, aFormSize); + } + else + { + if (curArrangement == FormWizard.AS_GRID) + { + oFormHandler.moveShapesToNirwana(getLabelControls()); + oFormHandler.moveShapesToNirwana(getDatabaseControls()); + } + } + if (curArrangement == FormWizard.AS_GRID) + { + insertGridControl(_NBorderType); + adaptControlStyles = true; + } + else + { + adaptControlStyles = !oFormController.areControlsexisting(); + oFormController.positionControls(_curArrangement, aStartPoint, curUIControlArranger.getAlignValue(), _NBorderType); + } + if (adaptControlStyles) + { + curStyleApplier.applyStyle(true); + } + if ((Name.equals(SOMAINFORM)) && (oControlForms.size() > 1)) + { + ControlForm curSubControlForm = oControlForms.get(1); + if (curSubControlForm != null) + { + adjustSubFormPosSize(_NBorderType); + } + } + setFormSize(new Size(aFormSize.Width, getActualFormHeight())); + unlockallControllers(); + } + + public Control[] getLabelControls() + { + if (oFormController != null) + { + return oFormController.getLabelControlList(); + } + else + { + return null; + } + } + + private Size getFormSize() + { + return aFormSize; + } + + private void setFormSize(Size _aSize) + { + aFormSize = _aSize; + oFormController.setFormSize(aFormSize); + } + + private void setStartPoint(Point _aPoint) + { + aStartPoint = _aPoint; + if (oFormController != null) + { + oFormController.setStartPoint(_aPoint); + } + } + + private int getActualFormHeight() + { + if (curArrangement == FormWizard.AS_GRID) + { + return oGridControl.xShape.getSize().Height; + } + else + { + return oFormController.getFormHeight(); + } + } + + private int getEntryPointY() + { + if (curArrangement == FormWizard.AS_GRID) + { + return oGridControl.xShape.getPosition().Y; + } + else + { + return oFormController.getEntryPointY(); + } + } + + private void setFormProperties(PropertyValue[] _aPropertySetList, CommandMetaData _oDBMetaData) + { + try + { + xPropertySet.setPropertyValue("DataSourceName", getDataSourceName()); + xPropertySet.setPropertyValue(PropertyNames.COMMAND, _oDBMetaData.getCommandName()); + xPropertySet.setPropertyValue(PropertyNames.COMMAND_TYPE, Integer.valueOf(_oDBMetaData.getCommandType())); + for (int i = 0; i < _aPropertySetList.length; i++) + { + xPropertySet.setPropertyValue(_aPropertySetList[i].Name, _aPropertySetList[i].Value); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public DatabaseControl[] getDatabaseControls() + { + if (oFormController != null) + { + return oFormController.DBControlList; + } + else + { + return null; + } + } + + public GridControl getGridControl() + { + return oGridControl; + } + + public int getArrangemode() + { + return curArrangement; + } + + private void insertGridControl(Short _NBorderType) + { + try + { + curArrangement = FormWizard.AS_GRID; + if (Name.equals(SOMAINFORM)) + { + oGridControl = new GridControl(xMSF, Name + "_Grid", oFormHandler, xFormContainer, oDBMetaData.FieldColumns, aStartPoint, getMainFormSize(FormWizard.AS_GRID)); + } + else + { + oGridControl = new GridControl(xMSF, Name + "_Grid", oFormHandler, xFormContainer, oDBMetaData.FieldColumns, aStartPoint, getSubFormSize()); + } + oGridControl.xPropertySet.setPropertyValue(PropertyNames.PROPERTY_BORDER, _NBorderType); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private void finalizeControls() + { + Control[] oLabelControls = getLabelControls(); + Control[] oDBControls = getDatabaseControls(); + if (oLabelControls != null) + { + for (int i = 0; i < getLabelControls().length; i++) + { + if (curArrangement == FormWizard.AS_GRID) + { + if ((oLabelControls[i] != null) && (oDBControls[i] != null)) + { + oFormHandler.removeShape(oLabelControls[i].xShape); + oFormHandler.removeShape(oDBControls[i].xShape); + } + } + else + { + oFormHandler.groupShapesTogether(xMSF, oLabelControls[i].xShape, oDBControls[i].xShape); + } + } + } + } + } +} diff --git a/wizards/com/sun/star/wizards/form/FormWizard.java b/wizards/com/sun/star/wizards/form/FormWizard.java new file mode 100644 index 0000000000..4534d8ac5b --- /dev/null +++ b/wizards/com/sun/star/wizards/form/FormWizard.java @@ -0,0 +1,464 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.application.DatabaseObject; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.db.DatabaseObjectWizard; +import com.sun.star.wizards.db.RelationController; +import com.sun.star.wizards.document.OfficeDocument; +import com.sun.star.wizards.ui.CommandFieldSelection; +import com.sun.star.wizards.ui.UIConsts; + +public class FormWizard extends DatabaseObjectWizard +{ + + private CommandFieldSelection curDBCommandFieldSelection; + private FormConfiguration curFormConfiguration; + private CommandFieldSelection curSubFormFieldSelection; + private FormDocument curFormDocument; + private FieldLinker curFieldLinker; + private UIControlArranger curControlArranger; + private DataEntrySetter CurDataEntrySetter; + private StyleApplier curStyleApplier; + private Finalizer curFinalizer; + private static String slblFields; + private static String slblSelFields; + private String sShowBinaryFields = PropertyNames.EMPTY_STRING; + private String serrFormNameexists = PropertyNames.EMPTY_STRING; + private static final int SOMAIN_PAGE = 1; + public static final int SOSUBFORM_PAGE = 2; + public static final int SOSUBFORMFIELDS_PAGE = 3; + public static final int SOFIELDLINKER_PAGE = 4; + public static final int SOCONTROL_PAGE = 5; + public static final int SODATA_PAGE = 6; + public static final int SOSTYLE_PAGE = 7; + public static final int SOSTORE_PAGE = 8; + public static final int COLUMNAR_LEFT = 1; + public static final int COLUMNAR_TOP = 2; + public static final int AS_GRID = 3; + public static final int IN_BLOCK_TOP = 4; + private String slblTables; + private boolean m_openForEditing; + private boolean m_success = false; + private String FormName; + + public FormWizard(XMultiServiceFactory i_servicFactory, final PropertyValue[] i_wizardContext) + { + super(i_servicFactory, 34400, i_wizardContext); + super.addResourceHandler(); + Helper.setUnoPropertyValues(xDialogModel, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_MOVEABLE, PropertyNames.PROPERTY_NAME, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_TITLE, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 210, Boolean.TRUE, "DialogForm", 102, 41, 1, Short.valueOf((short) 0), m_oResource.getResText("RID_FORM_0"), 310 + }); + drawNaviBar(); + getFormResources(); + setRightPaneHeaders(m_oResource, "RID_FORM_", 90, 8); + } + + public static void main(String i_args[]) + { + executeWizardFromCommandLine( i_args, new WizardFromCommandLineStarter() { + public void start(XMultiServiceFactory factory, PropertyValue[] curproperties) { + FormWizard wizard = new FormWizard(factory, curproperties); + wizard.start(); + } + }); + } + + // @Override + @Override + protected void enterStep(int nOldStep, int nNewStep) + { + try + { + if ((nOldStep < SOCONTROL_PAGE) && (nNewStep >= SOCONTROL_PAGE)) + { + curFormDocument.initialize(curDBCommandFieldSelection.isModified(), curFormConfiguration.hasSubForm(), curSubFormFieldSelection.isModified(), getBorderType()); + curDBCommandFieldSelection.setModified(false); + curSubFormFieldSelection.setModified(false); + } + switch (nNewStep) + { + case SOMAIN_PAGE: + curDBCommandFieldSelection.setModified(false); + break; + case SOSUBFORM_PAGE: + { + final String sCommandName = curDBCommandFieldSelection.getSelectedCommandName(); + RelationController oRelationController = new RelationController(curFormDocument.oMainFormDBMetaData, sCommandName); + curFormConfiguration.initialize(curSubFormFieldSelection, oRelationController); + } + break; + case SOSUBFORMFIELDS_PAGE: + { + String sPreSelectedTableName = curFormConfiguration.getreferencedTableName(); + boolean bReadOnly = (sPreSelectedTableName.length() > 0); + if (sPreSelectedTableName.length() == 0) + { + final String sTableName = curSubFormFieldSelection.getSelectedCommandName(); + String[] aFieldNames = curSubFormFieldSelection.getSelectedFieldNames(); + curFormDocument.oSubFormDBMetaData.initializeFieldColumns(sTableName, aFieldNames); + } + else + { + curSubFormFieldSelection.preselectCommand(sPreSelectedTableName, bReadOnly); + } + } + break; + case SOFIELDLINKER_PAGE: + { + final String[] aMainFieldNames = curFormDocument.oMainFormDBMetaData.getFieldNames(); + final String[] aSubFieldNames = curFormDocument.oSubFormDBMetaData.getFieldNames(); + curFieldLinker.initialize(aMainFieldNames, aSubFieldNames, curFormDocument.LinkFieldNames); + } + break; + case SOCONTROL_PAGE: + curControlArranger.enableSubFormImageList(curFormConfiguration.hasSubForm()); + break; + case SODATA_PAGE: + break; + case SOSTYLE_PAGE: + break; + case SOSTORE_PAGE: + { + String sTableName = this.curDBCommandFieldSelection.getSelectedCommandName(); + this.curFinalizer.initialize(sTableName, curFormDocument); + } + break; + default: + break; + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + protected Short getBorderType() + { + return curStyleApplier.getBorderType(); + } + + // @Override + @Override + protected void leaveStep(int nOldStep, int nNewStep) + { + switch (nOldStep) + { + case SOMAIN_PAGE: + { + final String sTableName = curDBCommandFieldSelection.getSelectedCommandName(); + final String[] aFieldNames = curDBCommandFieldSelection.getSelectedFieldNames(); + curFormDocument.oMainFormDBMetaData.initializeFieldColumns(sTableName, aFieldNames); + + final String[] aMainFieldNames = curFormDocument.oMainFormDBMetaData.getFieldNames(); + curFormDocument.LinkFieldNames = JavaTools.removeOutdatedFields(curFormDocument.LinkFieldNames, aMainFieldNames, 1); + } + break; + case SOSUBFORM_PAGE: + break; + case SOSUBFORMFIELDS_PAGE: + { + final String sTableName = curSubFormFieldSelection.getSelectedCommandName(); + final String[] aFieldNames = curSubFormFieldSelection.getSelectedFieldNames(); + curFormDocument.oSubFormDBMetaData.initializeFieldColumns(sTableName, aFieldNames); + + final String[] aSubFieldNames = curFormDocument.oSubFormDBMetaData.getFieldNames(); + curFormDocument.LinkFieldNames = JavaTools.removeOutdatedFields(curFormDocument.LinkFieldNames, aSubFieldNames, 0); + } + break; + case SOFIELDLINKER_PAGE: + curFormDocument.LinkFieldNames = curFieldLinker.getLinkFieldNames(); + break; + case SOCONTROL_PAGE: + break; + case SODATA_PAGE: + break; + case SOSTYLE_PAGE: + break; + case SOSTORE_PAGE: + break; + default: + break; + } + } + + private void buildSteps() + { + curDBCommandFieldSelection = new CommandFieldSelection(this, curFormDocument.oMainFormDBMetaData, 92, slblFields, slblSelFields, slblTables, true, 34411); + curDBCommandFieldSelection.addFieldSelectionListener(new FieldSelectionListener()); + curFormDocument.xProgressBar.setValue(20); + // Label Help Text + insertLabel("lblBinaryHelpText", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 28, sShowBinaryFields, Boolean.TRUE, 95, 154, Integer.valueOf(SOMAIN_PAGE), 210 + }); + + curFormConfiguration = new FormConfiguration(this); + curFormDocument.xProgressBar.setValue(30); + + curSubFormFieldSelection = new CommandFieldSelection(this, curFormDocument.oSubFormDBMetaData, SOSUBFORMFIELDS_PAGE, 92, slblFields, slblSelFields, slblTables, true, 34431); + curSubFormFieldSelection.addFieldSelectionListener(new FieldSelectionListener()); + insertLabel("lblSubFormBinaryHelpText", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 28, sShowBinaryFields, Boolean.TRUE, 95, 154, Integer.valueOf(SOSUBFORMFIELDS_PAGE), 210 + }); + + curFormDocument.xProgressBar.setValue(40); + + curFieldLinker = new FieldLinker(this, SOFIELDLINKER_PAGE, 30, 34441); + curFormDocument.xProgressBar.setValue(50); + + curControlArranger = new UIControlArranger(this, curFormDocument); + curFormDocument.addUIFormController(curControlArranger); + curFormDocument.xProgressBar.setValue(60); + + CurDataEntrySetter = new DataEntrySetter(this); + curFormDocument.xProgressBar.setValue(70); + + curStyleApplier = new StyleApplier(this, curFormDocument); + curFormDocument.addStyleApplier(curStyleApplier); + curFormDocument.xProgressBar.setValue(80); + + curFinalizer = new Finalizer(this); + curFormDocument.xProgressBar.setValue(100); + + enableNavigationButtons(false, false, false); + curFormDocument.xProgressBar.end(); + } + + // @Override + @Override + public boolean finishWizard() + { + int ncurStep = getCurrentStep(); + if ((switchToStep(ncurStep, SOSTORE_PAGE)) || (ncurStep == SOSTORE_PAGE)) + { + this.curFinalizer.initialize(curDBCommandFieldSelection.getSelectedCommandName(), this.curFormDocument); + String sNewFormName = curFinalizer.getName(); + if (!curFormDocument.oMainFormDBMetaData.hasFormDocumentByName(sNewFormName)) + { + m_openForEditing = curFinalizer.getOpenForEditing(); + FormName = curFinalizer.getName(); + if (curFormDocument.finalizeForms(CurDataEntrySetter, curFieldLinker, curFormConfiguration)) + { + + if (curFinalizer.finish()) + { + m_success = true; + xDialog.endExecute(); + return true; + } + } + } + else + { + String smessage = JavaTools.replaceSubString(serrFormNameexists, sNewFormName, "%FORMNAME"); + showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage); + } + } + return false; + } + + // @Override + @Override + public void cancelWizard() + { + m_success = false; + xDialog.endExecute(); + } + + private void insertFormRelatedSteps() + { + addRoadmap(); + int i = 0; + i = insertRoadmapItem(0, true, m_oResource.getResText("RID_FORM_80"), SOMAIN_PAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_FORM_81"), SOSUBFORM_PAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_FORM_82"), SOSUBFORMFIELDS_PAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_FORM_83"), SOFIELDLINKER_PAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_FORM_84"), SOCONTROL_PAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_FORM_85"), SODATA_PAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_FORM_86"), SOSTYLE_PAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_FORM_87"), SOSTORE_PAGE); + setRoadmapInteractive(true); + setRoadmapComplete(true); + setCurrentRoadmapItemID((short) 1); + } + + public void start() + { + try + { + curFormDocument = new FormDocument(xMSF); + if (curFormDocument.oMainFormDBMetaData.getConnection(m_wizardContext)) + { + curFormDocument.oSubFormDBMetaData.getConnection(new PropertyValue[] + { + Properties.createProperty(PropertyNames.ACTIVE_CONNECTION, curFormDocument.oMainFormDBMetaData.DBConnection) + }); + curFormDocument.xProgressBar.setValue(20); + buildSteps(); + this.curDBCommandFieldSelection.preselectCommand(m_wizardContext, false); + XWindowPeer xWindowPeer2 = createWindowPeer(curFormDocument.xWindowPeer); + curFormDocument.oMainFormDBMetaData.setWindowPeer(xWindowPeer2); + insertFormRelatedSteps(); + short dialogReturn = executeDialog(curFormDocument.xFrame); + xComponent.dispose(); + if ((dialogReturn == 0) && m_success) + { + curFormDocument.oMainFormDBMetaData.addFormDocument(curFormDocument.xComponent); + loadSubComponent(DatabaseObject.FORM, FormName, m_openForEditing); + } + } + } + catch (java.lang.Exception jexception) + { + jexception.printStackTrace(System.err); + } + if ((!m_success) && (curFormDocument != null)) + { + OfficeDocument.close(curFormDocument.xComponent); + } + } + + private void getFormResources() + { + sShowBinaryFields = m_oResource.getResText("RID_FORM_2"); + slblTables = m_oResource.getResText("RID_FORM_6"); + slblFields = m_oResource.getResText("RID_FORM_12"); + slblSelFields = m_oResource.getResText("RID_FORM_1"); + serrFormNameexists = m_oResource.getResText("RID_FORM_98"); + } + + private class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener + { + + private int ID; + + // @Override + public void setID(String sIncSuffix) + { + ID = 1; + if (sIncSuffix != null) + { + if ((!sIncSuffix.equals(PropertyNames.EMPTY_STRING)) && (!sIncSuffix.equals("_"))) + { + String sID = JavaTools.ArrayoutofString(sIncSuffix, "_")[1]; + ID = Integer.parseInt(sID); + } + } + } + + // @Override + public void shiftFromLeftToRight(String[] SelItems, String[] NewItems) + { + if (ID == 1) + { + toggleMainFormSteps(); + } + else + { + toggleSubFormSteps(); + } + } + + // @Override + public void shiftFromRightToLeft(String[] SelItems, String[] NewItems) + { + // TODO When the ListFieldbox is refilled only fields of the current Command may be merged into the Listbox + if (ID == 1) + { + toggleMainFormSteps(); + } + else + { + toggleSubFormSteps(); + } + } + // @Override + + public void moveItemDown(String item) + { + } + + // @Override + public void moveItemUp(String item) + { + } + + private boolean toggleSubFormSteps() + { + curSubFormFieldSelection.setModified(true); + boolean benabled = curSubFormFieldSelection.getSelectedFieldNames().length > 0; + enablefromStep(SOFIELDLINKER_PAGE, benabled); + if (benabled) + curFieldLinker.enable(!curFormConfiguration.areexistingRelationsdefined()); + return benabled; + } + + private void toggleMainFormSteps() + { + curDBCommandFieldSelection.setModified(true); + boolean enabled = curDBCommandFieldSelection.getSelectedFieldNames().length > 0; + enablefromStep(SOSUBFORM_PAGE, enabled); + setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, enabled); + if (enabled) + { + if (curFormConfiguration.hasSubForm()) + { + enabled = toggleSubFormSteps(); + } + else + { + setStepEnabled(SOSUBFORMFIELDS_PAGE, false); + setStepEnabled(SOFIELDLINKER_PAGE, false); + } + } + setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, enabled); + } + } +} diff --git a/wizards/com/sun/star/wizards/form/MANIFEST.MF b/wizards/com/sun/star/wizards/form/MANIFEST.MF new file mode 100644 index 0000000000..af4c0a07d5 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/MANIFEST.MF @@ -0,0 +1,2 @@ +RegistrationClassName: com.sun.star.wizards.form.CallFormWizard +UNO-Type-Path: diff --git a/wizards/com/sun/star/wizards/form/StyleApplier.java b/wizards/com/sun/star/wizards/form/StyleApplier.java new file mode 100644 index 0000000000..f780273a97 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/StyleApplier.java @@ -0,0 +1,444 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Configuration; +import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.NoValidPathException; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.document.Control; +import com.sun.star.wizards.document.DatabaseControl; +import com.sun.star.wizards.document.GridControl; +import com.sun.star.wizards.document.TimeStampControl; +import com.sun.star.wizards.text.TextStyleHandler; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.WizardDialog; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; + +public class StyleApplier +{ + + private final XPropertySet xPageStylePropertySet; + private final XMultiServiceFactory xMSF; + private final XRadioButton optNoBorder; + private final XRadioButton opt3DLook; + private final XListBox lstStyles; + private final FormDocument curFormDocument; + private short iOldLayoutPos; + private String[] StyleNames; + private String[] FileNames; + private static final int SOBACKGROUNDCOLOR = 0; + private static final int SODBTEXTCOLOR = 1; + private static final int SOLABELTEXTCOLOR = 2; + private static final int SOBORDERCOLOR = 5; + private Short IBorderValue = Short.valueOf((short) 1); + + public StyleApplier(WizardDialog CurUnoDialog, FormDocument _curFormDocument) + { + this.curFormDocument = _curFormDocument; + xMSF = curFormDocument.xMSF; + + TextStyleHandler oTextStyleHandler = new TextStyleHandler(curFormDocument.xTextDocument); + xPageStylePropertySet = oTextStyleHandler.getStyleByName("PageStyles", "Standard"); + short curtabindex = (short) (FormWizard.SOSTYLE_PAGE * 100); + Integer IStyleStep = Integer.valueOf(FormWizard.SOSTYLE_PAGE); + String sPageStyles = CurUnoDialog.m_oResource.getResText("RID_FORM_86"); + String sNoBorder = CurUnoDialog.m_oResource.getResText("RID_FORM_29"); + String s3DLook = CurUnoDialog.m_oResource.getResText("RID_FORM_30"); + String sFlat = CurUnoDialog.m_oResource.getResText("RID_FORM_31"); + String sFieldBorder = CurUnoDialog.m_oResource.getResText("RID_FORM_28"); + setStyles(); + short[] SelLayoutPos; + SelLayoutPos = new short[] + { + 0 + }; + + CurUnoDialog.insertLabel("lblStyles", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], sPageStyles, 92, 25, IStyleStep, Short.valueOf(curtabindex++), 90 + }); + + lstStyles = CurUnoDialog.insertListBox("lstStyles", null, new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + changeLayout(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.SELECTED_ITEMS, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 143, "HID:WIZARDS_HID_DLGFORM_LSTSTYLES", 92, 35, SelLayoutPos, IStyleStep, this.StyleNames, Short.valueOf(curtabindex++), 90 + }); + + optNoBorder = CurUnoDialog.insertRadioButton("otpNoBorder", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + changeBorderLayouts(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Tag", PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMDNOBORDER", sNoBorder, 196, 39, IStyleStep, Short.valueOf(curtabindex++), "0", 93 + }); + + opt3DLook = CurUnoDialog.insertRadioButton("otp3DLook", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + changeBorderLayouts(); + } + }, + new String[] + { + 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, "Tag", PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMD3DBORDER", s3DLook, 196, 53, Short.valueOf((short) 1), IStyleStep, Short.valueOf(curtabindex++), "1", 93 + }); + + CurUnoDialog.insertRadioButton("otpFlat", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + changeBorderLayouts(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Tag", PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMDSIMPLEBORDER", sFlat, 196, 67, IStyleStep, Short.valueOf(curtabindex++), "2", 93 + }); + + CurUnoDialog.insertFixedLine("lnFieldBorder", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], sFieldBorder, 192, 25, IStyleStep, Short.valueOf(curtabindex++), 98 + }); + } + + private void setStyles() + { + try + { + Object oRootNode = Configuration.getConfigurationRoot(xMSF, "org.openoffice.Office.FormWizard/FormWizard/Styles", false); + XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, oRootNode); + String[] StyleNodeNames = xNameAccess.getElementNames(); + StyleNames = new String[StyleNodeNames.length]; + FileNames = new String[StyleNodeNames.length]; + for (int i = 0; i < StyleNodeNames.length; i++) + { + Object oStyleNode = xNameAccess.getByName(StyleNodeNames[i]); + StyleNames[i] = (String) Helper.getUnoPropertyValue(oStyleNode, PropertyNames.PROPERTY_NAME); + FileNames[i] = (String) Helper.getUnoPropertyValue(oStyleNode, "CssHref"); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private short getStyleIndex() + { + try + { + short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(lstStyles), PropertyNames.SELECTED_ITEMS)); + if (SelFields != null) + { + return SelFields[0]; + } + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + } + return (short) -1; + } + + public void applyStyle(boolean _bapplyalways) + { + short iStyle = getStyleIndex(); + if ((iStyle != iOldLayoutPos) || _bapplyalways) + { + if (iStyle > -1) + { + iOldLayoutPos = iStyle; + String sFileName = FileNames[iStyle]; + int[] iStyles = getStyleColors(sFileName); + applyDBControlProperties(iStyles); + } + } + } + + private void changeLayout() + { + short iPos = lstStyles.getSelectedItemPos(); + if (iPos != iOldLayoutPos) + { + iOldLayoutPos = iPos; + String sFileName = FileNames[iPos]; + int[] iStyles = getStyleColors(sFileName); + applyDBControlProperties(iStyles); + } + curFormDocument.unlockallControllers(); + } + + public Short getBorderType() + { + return IBorderValue; + } + + private void changeBorderLayouts() + { + try + { + curFormDocument.xTextDocument.lockControllers(); + + if (optNoBorder.getState()) + { + IBorderValue = Short.valueOf((short) 0); + } + else if (opt3DLook.getState()) + { + IBorderValue = Short.valueOf((short) 1); + } + else + { + IBorderValue = Short.valueOf((short) 2); + } + for (int m = 0; m < curFormDocument.oControlForms.size(); m++) + { + FormDocument.ControlForm curControlForm = curFormDocument.oControlForms.get(m); + if (curControlForm.getArrangemode() == FormWizard.AS_GRID) + { + GridControl oGridControl = curControlForm.getGridControl(); + oGridControl.xPropertySet.setPropertyValue(PropertyNames.PROPERTY_BORDER, IBorderValue); + } + else + { + DatabaseControl[] DBControls = curControlForm.getDatabaseControls(); + for (int n = 0; n < DBControls.length; n++) + { + if (DBControls[n].xServiceInfo.supportsService("com.sun.star.drawing.ShapeCollection")) + { + TimeStampControl oTimeStampControl = (TimeStampControl) DBControls[n]; + for (int i = 0; i < 2; i++) + { + XPropertySet xPropertySet = oTimeStampControl.getControlofGroupShapeByIndex(i); + if (xPropertySet == null) { + continue; + } + if (xPropertySet.getPropertySetInfo().hasPropertyByName(PropertyNames.PROPERTY_BORDER)) + { + xPropertySet.setPropertyValue(PropertyNames.PROPERTY_BORDER, IBorderValue); + } + } + } + else + { + if (DBControls[n].xPropertySet.getPropertySetInfo().hasPropertyByName(PropertyNames.PROPERTY_BORDER)) + { + DBControls[n].xPropertySet.setPropertyValue(PropertyNames.PROPERTY_BORDER, IBorderValue); + } + } + } + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + curFormDocument.unlockallControllers(); + } + + + + private int getStyleColor(String[] _sDataList, String _sHeader, String _sPropertyDescription) + { + int index = JavaTools.FieldInList(_sDataList, _sHeader); + if (index > -1) + { + String sPropName = PropertyNames.EMPTY_STRING; + while (((sPropName.indexOf('}') < 0) && (index < _sDataList.length - 1))) + { + String scurline = _sDataList[index++]; + if ((scurline.indexOf(_sPropertyDescription)) > 0) + { + if (scurline.indexOf(':') > 0) + { + String[] sPropList = JavaTools.ArrayoutofString(scurline, ":"); + String sPropValue = sPropList[1]; + sPropValue = sPropValue.trim(); + if (sPropValue.indexOf('#') > -1) + { + sPropValue = JavaTools.replaceSubString(sPropValue, PropertyNames.EMPTY_STRING, PropertyNames.SEMI_COLON); + sPropValue = JavaTools.replaceSubString(sPropValue, PropertyNames.EMPTY_STRING, PropertyNames.SPACE); + return Integer.decode(sPropValue).intValue(); + } + } + } + } + } + return -1; + } + + private String getStylePath() + { + String StylesPath = ""; + try + { + StylesPath = FileAccess.getOfficePath(xMSF, "Config", "", ""); + StylesPath = FileAccess.combinePaths(xMSF, StylesPath, "/wizard/form/styles"); + } + catch (NoValidPathException e) + { + } + return StylesPath; + } + + private int[] getStyleColors(String _filename) + { + String sFilePath = getStylePath() + "/" + _filename; + int[] oStylePropList = new int[6]; + String[] sData = FileAccess.getDataFromTextFile(xMSF, sFilePath); + if (sData != null) { + oStylePropList[SOBACKGROUNDCOLOR] = getStyleColor(sData, ".toctitle {", "background-color:"); + oStylePropList[SODBTEXTCOLOR] = getStyleColor(sData, ".doctitle {", "color:"); + oStylePropList[SOLABELTEXTCOLOR] = getStyleColor(sData, ".toctitle {", "color:"); + oStylePropList[SOBORDERCOLOR] = getStyleColor(sData, ".tcolor {", "border-color:"); + } + return oStylePropList; + } + + private void setDBControlColors(XPropertySet xPropertySet, int[] _iStyleColors) + { + try + { + if (xPropertySet.getPropertySetInfo().hasPropertyByName("TextColor")) + { + if (_iStyleColors[SODBTEXTCOLOR] > -1) + { + xPropertySet.setPropertyValue("TextColor", Integer.decode("#00000")); + } + } + if (xPropertySet.getPropertySetInfo().hasPropertyByName("BackgroundColor")) + { + xPropertySet.setPropertyValue("BackgroundColor", Integer.decode("#DDDDDD")); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private void applyDBControlProperties(int[] _iStyleColors) + { + try + { + for (int m = 0; m < curFormDocument.oControlForms.size(); m++) + { + FormDocument.ControlForm curControlForm = curFormDocument.oControlForms.get(m); + if (curControlForm.getArrangemode() == FormWizard.AS_GRID) + { + if (_iStyleColors[SOLABELTEXTCOLOR] > -1) + { + curControlForm.oGridControl.xPropertySet.setPropertyValue("TextColor", Integer.valueOf(_iStyleColors[SODBTEXTCOLOR])); + } + curControlForm.oGridControl.xPropertySet.setPropertyValue("BackgroundColor", Integer.decode("#DDDDDD")); + } + else + { + DatabaseControl[] DBControls = curControlForm.getDatabaseControls(); + for (int n = 0; n < DBControls.length; n++) + { + if (_iStyleColors[SODBTEXTCOLOR] > -1) + { + DatabaseControl aDBControl = DBControls[n]; + if (aDBControl != null) + { + if (aDBControl.xServiceInfo.supportsService("com.sun.star.drawing.ShapeCollection")) + { + TimeStampControl oTimeStampControl = (TimeStampControl) aDBControl; + for (int i = 0; i < 2; i++) + { + XPropertySet xPropertySet = oTimeStampControl.getControlofGroupShapeByIndex(i); + if (xPropertySet == null) { + continue; + } + setDBControlColors(xPropertySet, _iStyleColors); + } + } + else + { + setDBControlColors(aDBControl.xPropertySet, _iStyleColors); + } + } + } + } + Control[] LabelControls = curControlForm.getLabelControls(); + for (int n = 0; n < LabelControls.length; n++) + { + if (_iStyleColors[SOLABELTEXTCOLOR] > -1) + { + LabelControls[n].xPropertySet.setPropertyValue("TextColor", Integer.valueOf(_iStyleColors[SOLABELTEXTCOLOR])); + } + } + } + } + xPageStylePropertySet.setPropertyValue("BackColor", Integer.valueOf(_iStyleColors[SOBACKGROUNDCOLOR])); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } +} diff --git a/wizards/com/sun/star/wizards/form/UIControlArranger.java b/wizards/com/sun/star/wizards/form/UIControlArranger.java new file mode 100644 index 0000000000..8f92e8ce66 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/UIControlArranger.java @@ -0,0 +1,295 @@ +/* + * 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 . + */ +package com.sun.star.wizards.form; + +import java.util.Map; +import java.util.HashMap; + +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XItemListener; +import com.sun.star.awt.XRadioButton; +import com.sun.star.lang.EventObject; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.IRenderer; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.document.Control; +import com.sun.star.wizards.ui.ButtonList; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; + +import javax.swing.DefaultListModel; +import javax.swing.ListModel; + +public class UIControlArranger +{ + + private final FormWizard CurUnoDialog; + private final FormDocument curFormDocument; + private short curtabindex; + private final XRadioButton optAlignLeft; + private final XRadioButton optAlignRight; + private final XControl flnLabelPlacement; + private final Map<String,String> helpTexts = new HashMap<String,String>(4); + private final ArrangeButtonList[] m_aArrangeList = new ArrangeButtonList[2]; + private final Integer IControlStep; + private static final int SOBASEIMAGEYPOSITION = 66; + private static final int SOIMAGELISTHEIGHT = 60; + private static final String ARRANGELISTSIDE = "private:graphicrepository/wizards/res/formarrangelistside_42.png"; + private static final String ARRANGELISTTOP = "private:graphicrepository/wizards/res/formarrangelisttop_42.png"; + private static final String ARRANGETABLE = "private:graphicrepository/wizards/res/formarrangetable_42.png"; + private static final String ARRANGEFREE = "private:graphicrepository/wizards/res/formarrangefree_42.png"; + + public UIControlArranger(FormWizard _CurUnoDialog, FormDocument _curFormDocument) + { + this.CurUnoDialog = _CurUnoDialog; + this.curFormDocument = _curFormDocument; + curtabindex = (short) (FormWizard.SOCONTROL_PAGE * 100); + IControlStep = Integer.valueOf(FormWizard.SOCONTROL_PAGE); + String sLabelPlacment = CurUnoDialog.m_oResource.getResText("RID_FORM_32"); + String sAlignLeft = CurUnoDialog.m_oResource.getResText("RID_FORM_33"); + String sAlignRight = CurUnoDialog.m_oResource.getResText("RID_FORM_34"); + + // Label "Label Placement" ----------------- + flnLabelPlacement = CurUnoDialog.insertFixedLine("lnLabelPlacement", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], sLabelPlacment, 97, 25, IControlStep, Short.valueOf(curtabindex++), 207 + }); + // Radio Button "Align Left" + optAlignLeft = CurUnoDialog.insertRadioButton("optAlignLeft", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + alignLabelControls(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMDALIGNLEFT", sAlignLeft, 107, 38, Short.valueOf((short) 1), IControlStep, Short.valueOf(curtabindex++), 171 + }); + // Radio Button "Align Right" + optAlignRight = CurUnoDialog.insertRadioButton("optAlignRight", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + alignLabelControls(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMDALIGNRIGHT", sAlignRight, Boolean.TRUE, 107, 50, IControlStep, Short.valueOf(curtabindex++), 171 + }); + + + DefaultListModel<String> imageModel = new DefaultListModel<String>(); + imageModel.addElement(ARRANGELISTSIDE); + imageModel.addElement(ARRANGELISTTOP); + imageModel.addElement(ARRANGETABLE); + imageModel.addElement(ARRANGEFREE); + + // "Columnar - Labels Left" + helpTexts.put(ARRANGELISTSIDE, CurUnoDialog.m_oResource.getResText("RID_FORM_36")); + + // "Columnar - Labels of Top" + helpTexts.put(ARRANGELISTTOP, CurUnoDialog.m_oResource.getResText("RID_FORM_37")); + + // "As Data Sheet" + helpTexts.put(ARRANGETABLE, CurUnoDialog.m_oResource.getResText("RID_FORM_40")); + + // "In Blocks - Labels Above" + helpTexts.put(ARRANGEFREE, CurUnoDialog.m_oResource.getResText("RID_FORM_39")); + + String sMainArrangementHeader = CurUnoDialog.m_oResource.getResText("RID_FORM_41"); // "Arrangement of the main form" + m_aArrangeList[0] = new ArrangeButtonList(0, imageModel, sMainArrangementHeader); + + String sSubArrangementHeader = CurUnoDialog.m_oResource.getResText("RID_FORM_42"); // "Arrangement of the sub form" + m_aArrangeList[1] = new ArrangeButtonList(1, imageModel, sSubArrangementHeader); + enableAlignControlGroup(false); + } + + public int getSelectedArrangement(int _formindex) + { + return m_aArrangeList[_formindex].m_aButtonList.getSelected() + 1; + } + + private class LayoutRenderer implements IRenderer + { + public String render(Object listItem) + { + if (listItem == null) + { + return PropertyNames.EMPTY_STRING; + } + return (String) helpTexts.get(listItem); + + } + } + + public void enableSubFormImageList(boolean _bdoEnable) + { + m_aArrangeList[1].m_aButtonList.setenabled(_bdoEnable); + CurUnoDialog.setControlProperty("lnLabelPlacment_2", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bdoEnable)); + } + + public short getAlignValue() + { + return optAlignLeft.getState() ? (short)0 : (short)2; + } + + private void alignLabelControls() + { + try + { + short iAlignValue = getAlignValue(); + for (int m = 0; m < curFormDocument.oControlForms.size(); m++) + { + FormDocument.ControlForm curControlForm = curFormDocument.oControlForms.get(m); + if (curControlForm.getArrangemode() == FormWizard.COLUMNAR_LEFT) + { + Control[] LabelControls = curControlForm.getLabelControls(); + if (LabelControls == null) { + continue; + } + for (int n = 0; n < LabelControls.length; n++) + { + LabelControls[n].xPropertySet.setPropertyValue(PropertyNames.PROPERTY_ALIGN, Short.valueOf(iAlignValue)); + } + } + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private void enableAlignControlGroup(boolean _bEnableAlignControlGroup) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(flnLabelPlacement), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bEnableAlignControlGroup)); + Helper.setUnoPropertyValue(UnoDialog.getModel(optAlignLeft), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bEnableAlignControlGroup)); + Helper.setUnoPropertyValue(UnoDialog.getModel(optAlignRight), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bEnableAlignControlGroup)); + } + + private class ArrangeButtonList implements XItemListener + { + + private final int formindex; + private final ButtonList m_aButtonList; + + public ArrangeButtonList(int _formindex, ListModel model, String _sArrangementHeader) + { + formindex = _formindex; + Integer YPos = Integer.valueOf(SOBASEIMAGEYPOSITION + _formindex * SOIMAGELISTHEIGHT); + // Label ArrangementHeader ---------------------- + CurUnoDialog.insertFixedLine("lnLabelPlacment_" + (_formindex + 1), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], + _sArrangementHeader, + 97, + YPos, + IControlStep, + Short.valueOf(curtabindex++), + 207 + }); + + int nypos = SOBASEIMAGEYPOSITION + 12 - 5 + _formindex * SOIMAGELISTHEIGHT; + m_aButtonList = new ButtonList(); + m_aButtonList.setPos(new Size(107, nypos)); + m_aButtonList.setButtonSize(new Size(26 + 6, 26 + 5)); + m_aButtonList.setCols(4); + m_aButtonList.setRows(1); + m_aButtonList.setName( "ButtonList_" + formindex ); + m_aButtonList.setStep(Short.valueOf((short) FormWizard.SOCONTROL_PAGE)); + m_aButtonList.setShowButtons(false); // shows a button line at ''wrong'' position like |<| 1..4/4 |>| + m_aButtonList.setRenderer(new LayoutRenderer()); + m_aButtonList.setGap(new Size(3, 3)); +// m_aButtonList.scaleImages = Boolean.FALSE; + m_aButtonList.tabIndex = curtabindex++; + m_aButtonList.helpURL = 34453 + (formindex * 4); + + m_aButtonList.setListModel(model); + m_aButtonList.create(CurUnoDialog); + m_aButtonList.setSelected(FormWizard.AS_GRID - 1); + m_aButtonList.addItemListener(this); + } + + public void itemStateChanged(ItemEvent arg0) + { + try + { + if (m_aArrangeList[formindex].m_aButtonList.isenabled()) + { + boolean bEnableAlignControlGroup; + if (curFormDocument.oControlForms.size() == 2) + { + final int nSelected0 = (m_aArrangeList[0].m_aButtonList.getSelected() + 1); + final int nSelected1 = (m_aArrangeList[1].m_aButtonList.getSelected() + 1); + + bEnableAlignControlGroup = ((nSelected0 == FormWizard.COLUMNAR_LEFT) || + (nSelected1 == FormWizard.COLUMNAR_LEFT)); + } + else + { + final int nSelected0 = (m_aArrangeList[0].m_aButtonList.getSelected() + 1); + bEnableAlignControlGroup = (nSelected0 == FormWizard.COLUMNAR_LEFT); + } + enableAlignControlGroup(bEnableAlignControlGroup); + final Short nBorderType = CurUnoDialog.getBorderType(); + final int nSelected = m_aButtonList.getSelected() + 1; + curFormDocument.oControlForms.get(formindex).initialize(nSelected, nBorderType); + } + } + catch (RuntimeException e) + { + e.printStackTrace(); + } + } + + /* (non-Javadoc) + * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject) + */ + public void disposing(EventObject arg0) + { + // TODO Auto-generated method stub + } + } +} diff --git a/wizards/com/sun/star/wizards/form/form.component b/wizards/com/sun/star/wizards/form/form.component new file mode 100644 index 0000000000..27ea341a94 --- /dev/null +++ b/wizards/com/sun/star/wizards/form/form.component @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . + --> + +<component loader="com.sun.star.loader.Java2" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation + name="com.sun.star.wizards.form.CallFormWizard$FormWizardImplementation"> + <service name="com.sun.star.wizards.form.CallFormWizard"/> + </implementation> +</component> diff --git a/wizards/com/sun/star/wizards/letter/CGLetter.py b/wizards/com/sun/star/wizards/letter/CGLetter.py new file mode 100644 index 0000000000..cf9bd76fe0 --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/CGLetter.py @@ -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() diff --git a/wizards/com/sun/star/wizards/letter/CGLetterWizard.py b/wizards/com/sun/star/wizards/letter/CGLetterWizard.py new file mode 100644 index 0000000000..eb1051c446 --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/CGLetterWizard.py @@ -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() diff --git a/wizards/com/sun/star/wizards/letter/CGPaperElementLocation.py b/wizards/com/sun/star/wizards/letter/CGPaperElementLocation.py new file mode 100644 index 0000000000..c57dde9099 --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/CGPaperElementLocation.py @@ -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() diff --git a/wizards/com/sun/star/wizards/letter/CallWizard.py b/wizards/com/sun/star/wizards/letter/CallWizard.py new file mode 100644 index 0000000000..fc12e1b5e5 --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/CallWizard.py @@ -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: diff --git a/wizards/com/sun/star/wizards/letter/LetterDocument.py b/wizards/com/sun/star/wizards/letter/LetterDocument.py new file mode 100644 index 0000000000..5860f28041 --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/LetterDocument.py @@ -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() diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialog.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialog.py new file mode 100644 index 0000000000..0208de833f --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialog.py @@ -0,0 +1,1122 @@ +# +# 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 .LetterWizardDialogConst import LetterWizardDialogConst, HIDMAIN, HID +from .LetterWizardDialogResources import LetterWizardDialogResources +from ..common.HelpIds import HelpIds +from ..ui.WizardDialog import WizardDialog, uno, UIConsts, PropertyNames + +from com.sun.star.awt.FontUnderline import SINGLE + +class LetterWizardDialog(WizardDialog): + + def __init__(self, xmsf): + super(LetterWizardDialog, self).__init__(xmsf, HIDMAIN ) + + #Load Resources + self.resources = LetterWizardDialogResources() + + #set dialog properties... + self.setDialogProperties(True, 210, True, 104, 52, 1, 1, + self.resources.resLetterWizardDialog_title, 350) + + self.fontDescriptor5 = \ + uno.createUnoStruct('com.sun.star.awt.FontDescriptor') + self.fontDescriptor6 = \ + uno.createUnoStruct('com.sun.star.awt.FontDescriptor') + self.fontDescriptor5.Weight = 100 + self.fontDescriptor6.Weight = 150 + + def buildStep1(self): + self.optBusinessLetter = self.insertRadioButton( + "optBusinessLetter", + LetterWizardDialogConst.OPTBUSINESSLETTER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 1), + self.resources.resoptBusinessLetter_value, + "optBusinessLetter", 97, 28, 1, 1, 184), self) + self.optPrivOfficialLetter = self.insertRadioButton( + "optPrivOfficialLetter", + LetterWizardDialogConst.OPTPRIVOFFICIALLETTER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 2), + self.resources.resoptPrivOfficialLetter_value, + "optPrivOfficialLetter", 97, 74, 1, 2, 184), self) + self.optPrivateLetter = self.insertRadioButton( + "optPrivateLetter", + LetterWizardDialogConst.OPTPRIVATELETTER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 3), + self.resources.resoptPrivateLetter_value, + "optPrivateLetter", 97, 106, 1, 3, 184), self) + self.lstBusinessStyle = self.insertListBox( + "lstBusinessStyle", + LetterWizardDialogConst.LSTBUSINESSSTYLE_ACTION_PERFORMED, + LetterWizardDialogConst.LSTBUSINESSSTYLE_ITEM_CHANGED, + ("Dropdown", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (True, 12, HelpIds.getHelpIdString(HID + 4), + "lstBusinessStyle", + 180, 40, 1, 4, 74), self) + self.chkBusinessPaper = self.insertCheckBox( + "chkBusinessPaper", + LetterWizardDialogConst.CHKBUSINESSPAPER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 5), + self.resources.reschkBusinessPaper_value, + "chkBusinessPaper", 110, 56, 0, 1, 5, 168), self) + self.lstPrivOfficialStyle = self.insertListBox( + "lstPrivOfficialStyle", + LetterWizardDialogConst.LSTPRIVOFFICIALSTYLE_ACTION_PERFORMED, + LetterWizardDialogConst.LSTPRIVOFFICIALSTYLE_ITEM_CHANGED, + ("Dropdown", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (True, 12, HelpIds.getHelpIdString(HID + 6), + "lstPrivOfficialStyle", 180, 86, 1, 6, 74), self) + self.lstPrivateStyle = self.insertListBox( + "lstPrivateStyle", + LetterWizardDialogConst.LSTPRIVATESTYLE_ACTION_PERFORMED, + LetterWizardDialogConst.LSTPRIVATESTYLE_ITEM_CHANGED, + ("Dropdown", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (True, 12, HelpIds.getHelpIdString(HID + 7), + "lstPrivateStyle", 180, 118, 1, 7, 74), self) + self.insertLabel("lblBusinessStyle", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblBusinessStyle_value, + "lblBusinessStyle", 110, 42, 1, 48, 60)) + self.insertLabel("lblPrivOfficialStyle", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblPrivOfficialStyle_value, + "lblPrivOfficialStyle", 110, 88, 1, 49, 60)) + self.insertLabel("lblTitle1", + ("FontDescriptor", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (self.fontDescriptor6, 16, + self.resources.reslblTitle1_value, True, + "lblTitle1", 91, 8, 1, 55, 212)) + self.insertLabel("lblPrivateStyle", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblPrivateStyle_value, + "lblPrivateStyle", 110, 120, 1, 74, 60)) + self.insertLabel("lblIntroduction", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (39, self.resources.reslblIntroduction_value, + True, + "lblIntroduction", 104, 145, 1, 80, 199)) + self.ImageControl3 = self.insertInfoImage(92, 145, 1) + + def buildStep2(self): + self.chkPaperCompanyLogo = self.insertCheckBox( + "chkPaperCompanyLogo", + LetterWizardDialogConst.CHKPAPERCOMPANYLOGO_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 8), + self.resources.reschkPaperCompanyLogo_value, + "chkPaperCompanyLogo", 97, 28, 0, 2, 8, 68), self) + self.numLogoHeight = self.insertNumericField( + "numLogoHeight", + LetterWizardDialogConst.NUMLOGOHEIGHT_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + "StrictFormat", + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 9), + "numLogoHeight", 138, 40, True, 2, True, 9, 3, 50), self) + self.numLogoX = self.insertNumericField( + "numLogoX", + LetterWizardDialogConst.NUMLOGOX_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 10), + "numLogoX", 286, 40, True, 2, 10, 0, 50), self) + self.numLogoWidth = self.insertNumericField( + "numLogoWidth", + LetterWizardDialogConst.NUMLOGOWIDTH_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 11), + "numLogoWidth", 138, 56, True, 2, 11, 3.8, 50), self) + self.numLogoY = self.insertNumericField( + "numLogoY", + LetterWizardDialogConst.NUMLOGOY_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 12), + "numLogoY", 286, 56, True, 2, 12, -3.4, 50), self) + self.chkPaperCompanyAddress = self.insertCheckBox( + "chkPaperCompanyAddress", + LetterWizardDialogConst.CHKPAPERCOMPANYADDRESS_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 13), + self.resources.reschkPaperCompanyAddress_value, + "chkPaperCompanyAddress", 98, 84, 0, 2, 13, 68), self) + self.numAddressHeight = self.insertNumericField( + "numAddressHeight", + LetterWizardDialogConst.NUMADDRESSHEIGHT_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + "StrictFormat", + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 14), + "numAddressHeight", 138, 96, True, 2, True, 14, 3, 50), self) + self.numAddressX = self.insertNumericField( + "numAddressX", + LetterWizardDialogConst.NUMADDRESSX_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 15), + "numAddressX", 286, 96, True, 2, 15, 3.8, 50), self) + self.numAddressWidth = self.insertNumericField( + "numAddressWidth", + LetterWizardDialogConst.NUMADDRESSWIDTH_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 16), + "numAddressWidth", 138, 112, True, 2, 16, 13.8, 50), self) + self.numAddressY = self.insertNumericField( + "numAddressY", + LetterWizardDialogConst.NUMADDRESSY_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 17), + "numAddressY", 286, 112, True, 2, 17, -3.4, 50), self) + self.chkCompanyReceiver = self.insertCheckBox( + "chkCompanyReceiver", + LetterWizardDialogConst.CHKCOMPANYRECEIVER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 18), + self.resources.reschkCompanyReceiver_value, + "chkCompanyReceiver", 103, 131, 0, 2, 18, 185), self) + self.chkPaperFooter = self.insertCheckBox( + "chkPaperFooter", + LetterWizardDialogConst.CHKPAPERFOOTER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 19), + self.resources.reschkPaperFooter_value, + "chkPaperFooter", 97, 158, 0, 2, 19, 68), self) + self.numFooterHeight = self.insertNumericField( + "numFooterHeight", + LetterWizardDialogConst.NUMFOOTERHEIGHT_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "Spin", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Value", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 20), + "numFooterHeight", 236, 156, True, 2, 20, 5, 50), self) + self.insertLabel("lblLogoHeight", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblLogoHeight_value, + "lblLogoHeight", 103, 42, 2, 68, 32)) + self.insertLabel("lblLogoWidth", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblLogoWidth_value, + "lblLogoWidth", 103, 58, 2, 69, 32)) + self.insertFixedLine( + "FixedLine5", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (2, + "FixedLine5", 90, 78, 2, 70, 255)) + self.insertFixedLine( + "FixedLine6", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (2, + "FixedLine6", 90, 150, 2, 71, 255)) + self.insertLabel("lblFooterHeight", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblFooterHeight_value, + "lblFooterHeight", 200, 158, 2, 72, 32)) + self.insertLabel("lblLogoX", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblLogoX_value, + "lblLogoX", 190, 42, 2, 84, 94)) + self.insertLabel("lblLogoY", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblLogoY_value, + "lblLogoY", 190, 58, 2, 85, 94)) + self.insertLabel("lblAddressHeight", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblAddressHeight_value, + "lblAddressHeight", 103, 98, 2, 86, 32)) + self.insertLabel("lblAddressWidth", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblAddressWidth_value, + "lblAddressWidth", 103, 114, 2, 87, 32)) + self.insertLabel("lblAddressX", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblAddressX_value, + "lblAddressX", 190, 98, 2, 88, 94)) + self.insertLabel("lblAddressY", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblAddressY_value, + "lblAddressY", 190, 114, 2, 89, 94)) + self.insertLabel("lblTitle2", + ("FontDescriptor", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (self.fontDescriptor6, 16, + self.resources.reslblTitle2_value, True, + "lblTitle2", 91, 8, 2, 91, 212)) + + def buildStep3(self): + self.chkUseLogo = self.insertCheckBox( + "chkUseLogo", + LetterWizardDialogConst.CHKUSELOGO_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 22), + self.resources.reschkUseLogo_value, + "chkUseLogo", 97, 34, 0, 3, 22, 212), self) + self.chkUseAddressReceiver = self.insertCheckBox( + "chkUseAddressReceiver", + LetterWizardDialogConst.CHKUSEADDRESSRECEIVER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 23), + self.resources.reschkUseAddressReceiver_value, + "chkUseAddressReceiver", 97, 49, 0, 3, 23, 212), self) + self.chkUseSigns = self.insertCheckBox( + "chkUseSigns", + LetterWizardDialogConst.CHKUSESIGNS_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 24), + self.resources.reschkUseSigns_value, + "chkUseSigns", 97, 62, 0, 3, 24, 212), self) + self.chkUseSubject = self.insertCheckBox( + "chkUseSubject", + LetterWizardDialogConst.CHKUSESUBJECT_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 25), + self.resources.reschkUseSubject_value, + "chkUseSubject", 97, 78, 0, 3, 25, 212), self) + self.chkUseSalutation = self.insertCheckBox( + "chkUseSalutation", + LetterWizardDialogConst.CHKUSESALUTATION_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 26), + self.resources.reschkUseSalutation_value, + "chkUseSalutation", 97, 93, 0, 3, 26, 66), self) + self.lstSalutation = self.insertComboBox( + "lstSalutation", + LetterWizardDialogConst.LSTSALUTATION_ACTION_PERFORMED, + LetterWizardDialogConst.LSTSALUTATION_ITEM_CHANGED, + LetterWizardDialogConst.LSTSALUTATION_TEXT_CHANGED, + ("Dropdown", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (True, 12, HelpIds.getHelpIdString(HID + 27), + "lstSalutation", 210, 90, 3, 27, 74), self) + self.chkUseBendMarks = self.insertCheckBox( + "chkUseBendMarks", + LetterWizardDialogConst.CHKUSEBENDMARKS_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 28), + self.resources.reschkUseBendMarks_value, + "chkUseBendMarks", 97, 107, 0, 3, 28, 212), self) + self.chkUseGreeting = self.insertCheckBox( + "chkUseGreeting", + LetterWizardDialogConst.CHKUSEGREETING_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 29), + self.resources.reschkUseGreeting_value, + "chkUseGreeting", 97, 122, 0, 3, 29, 66), self) + self.lstGreeting = self.insertComboBox( + "lstGreeting", + LetterWizardDialogConst.LSTGREETING_ACTION_PERFORMED, + LetterWizardDialogConst.LSTGREETING_ITEM_CHANGED, + LetterWizardDialogConst.LSTGREETING_TEXT_CHANGED, + ("Dropdown", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (True, 12, HelpIds.getHelpIdString(HID + 30), + "lstGreeting", 210, 121, 3, 30, 74), self) + self.chkUseFooter = self.insertCheckBox( + "chkUseFooter", + LetterWizardDialogConst.CHKUSEFOOTER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 31), + self.resources.reschkUseFooter_value, + "chkUseFooter", 97, 138, 0, 3, 31, 212), self) + self.insertLabel("lblTitle3", + ( + "FontDescriptor", PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (self.fontDescriptor6, 16, + self.resources.reslblTitle3_value, True, + "lblTitle3", 91, 8, 3, 90, 212)) + + def buildStep4(self): + self.optSenderPlaceholder = self.insertRadioButton( + "optSenderPlaceholder", + LetterWizardDialogConst.OPTSENDERPLACEHOLDER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 32), + self.resources.resoptSenderPlaceholder_value, + "optSenderPlaceholder", 104, 42, 4, 32, 149), self) + self.optSenderDefine = self.insertRadioButton( + "optSenderDefine", + LetterWizardDialogConst.OPTSENDERDEFINE_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 33), + self.resources.resoptSenderDefine_value, + "optSenderDefine", 104, 54, 4, 33, 149), self) + self.txtSenderName = self.insertTextField( + "txtSenderName", + LetterWizardDialogConst.TXTSENDERNAME_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 34), + "txtSenderName", 182, 67, 4, 34, 119), self) + self.txtSenderStreet = self.insertTextField( + "txtSenderStreet", + LetterWizardDialogConst.TXTSENDERSTREET_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 35), + "txtSenderStreet", 182, 81, 4, 35, 119), self) + self.txtSenderPostCode = self.insertTextField( + "txtSenderPostCode", + LetterWizardDialogConst.TXTSENDERPOSTCODE_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 36), + "txtSenderPostCode", 182, 95, 4, 36, 25), self) + self.txtSenderState = self.insertTextField( + "txtSenderState", + LetterWizardDialogConst.TXTSENDERSTATE_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 37), + "txtSenderState", 211, 95, 4, 37, 21), self) + self.txtSenderCity = self.insertTextField( + "txtSenderCity", + LetterWizardDialogConst.TXTSENDERCITY_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 38), + "txtSenderCity", 236, 95, 4, 38, 65), self) + self.optReceiverPlaceholder = self.insertRadioButton( + "optReceiverPlaceholder", + LetterWizardDialogConst.OPTRECEIVERPLACEHOLDER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 39), + self.resources.resoptReceiverPlaceholder_value, + "optReceiverPlaceholder", 104, 145, 4, 39, 200), self) + self.optReceiverDatabase = self.insertRadioButton( + "optReceiverDatabase", + LetterWizardDialogConst.OPTRECEIVERDATABASE_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 40), + self.resources.resoptReceiverDatabase_value, + "optReceiverDatabase", 104, 157, 4, 40, 200), self) + self.insertLabel("lblSenderAddress", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblSenderAddress_value, + "lblSenderAddress", 97, 28, 4, 64, 136)) + self.insertFixedLine("FixedLine2", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (5, + "FixedLine2", 90, 126, 4, 75, 212)) + self.insertLabel("lblReceiverAddress", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblReceiverAddress_value, + "lblReceiverAddress", 97, 134, 4, 76, 136)) + self.insertLabel("lblSenderName", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblSenderName_value, + "lblSenderName", 113, 69, 4, 77, 68)) + self.insertLabel("lblSenderStreet", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblSenderStreet_value, + "lblSenderStreet", 113, 82, 4, 78, 68)) + self.insertLabel("lblPostCodeCity", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblPostCodeCity_value, + "lblPostCodeCity", 113, 97, 4, 79, 68)) + self.insertLabel("lblTitle4", + ("FontDescriptor", PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (self.fontDescriptor6, 16, + self.resources.reslblTitle4_value, True, + "lblTitle4", 91, 8, 4, 92, 212)) + + def buildStep5(self): + self.txtFooter = self.insertTextField( + "txtFooter", + LetterWizardDialogConst.TXTFOOTER_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (47, HelpIds.getHelpIdString(HID + 41), True, + "txtFooter", 97, 40, 5, 41, 203), self) + self.chkFooterNextPages = self.insertCheckBox( + "chkFooterNextPages", + LetterWizardDialogConst.CHKFOOTERNEXTPAGES_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 42), + self.resources.reschkFooterNextPages_value, + "chkFooterNextPages", 97, 92, 0, 5, 42, 202), self) + self.chkFooterPageNumbers = self.insertCheckBox( + "chkFooterPageNumbers", + LetterWizardDialogConst.CHKFOOTERPAGENUMBERS_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STATE, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 43), + self.resources.reschkFooterPageNumbers_value, + "chkFooterPageNumbers", 97, 106, 0, 5, 43, 201), self) + self.insertLabel("lblFooter", + ("FontDescriptor", PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (self.fontDescriptor5, 8, self.resources.reslblFooter_value, + "lblFooter", 97, 28, 5, 52, 116)) + self.insertLabel("lblTitle5", + ("FontDescriptor", PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (self.fontDescriptor6, 16, + self.resources.reslblTitle5_value, True, + "lblTitle5", 91, 8, 5, 93, 212)) + + def buildStep6(self): + self.txtTemplateName = self.insertTextField( + "txtTemplateName", + LetterWizardDialogConst.TXTTEMPLATENAME_TEXT_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Text", + PropertyNames.PROPERTY_WIDTH), + (12, HelpIds.getHelpIdString(HID + 44), + "txtTemplateName", 202, 56, 6, 44, + self.resources.restxtTemplateName_value, 100), self) + self.optCreateLetter = self.insertRadioButton( + "optCreateLetter", + LetterWizardDialogConst.OPTCREATELETTER_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 45), + self.resources.resoptCreateLetter_value, + "optCreateLetter", 104, 111, 6, 50, 198), self) + self.optMakeChanges = self.insertRadioButton( + "optMakeChanges", + LetterWizardDialogConst.OPTMAKECHANGES_ITEM_CHANGED, + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, HelpIds.getHelpIdString(HID + 46), + self.resources.resoptMakeChanges_value, + "optMakeChanges", 104, 123, 6, 51, 198), self) + self.insertLabel("lblFinalExplanation1", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (26, self.resources.reslblFinalExplanation1_value, True, + "lblFinalExplanation1", 97, 28, 6, 52, 205)) + self.insertLabel("lblProceed", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblProceed_value, + "lblProceed", 97, 100, 6, 53, 204)) + self.insertLabel("lblFinalExplanation2", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (33, self.resources.reslblFinalExplanation2_value, True, + "lblFinalExplanation2", 104, 145, 6, 54, 199)) + self.insertImage( + "ImageControl2", + ("Border", PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_IMAGEURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + "ScaleImage", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (0, 10, + UIConsts.INFOIMAGEURL, + "ImageControl2", 92, 145, False, 6, 66, 10)) + self.insertLabel("lblTemplateName", + (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (8, self.resources.reslblTemplateName_value, + "lblTemplateName", 97, 58, 6, 82, 101)) + self.insertLabel("lblTitle6", + ("FontDescriptor", PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_MULTILINE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (self.fontDescriptor6, 16, + self.resources.reslblTitle6_value, True, + "lblTitle6", 91, 8, 6, 94, 212)) diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogConst.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialogConst.py new file mode 100644 index 0000000000..8517b700eb --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogConst.py @@ -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 diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py new file mode 100644 index 0000000000..66c0e33457 --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py @@ -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 diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.py new file mode 100644 index 0000000000..3a7802f2ba --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.py @@ -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) diff --git a/wizards/com/sun/star/wizards/letter/__init__.py b/wizards/com/sun/star/wizards/letter/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/__init__.py diff --git a/wizards/com/sun/star/wizards/letter/letter.component b/wizards/com/sun/star/wizards/letter/letter.component new file mode 100644 index 0000000000..f7496d8297 --- /dev/null +++ b/wizards/com/sun/star/wizards/letter/letter.component @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . + --> +<component loader="com.sun.star.loader.Python" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.wizards.letter.CallWizard"> + <service name="com.sun.star.task.Job"/> + </implementation> +</component> diff --git a/wizards/com/sun/star/wizards/query/CallQueryWizard.java b/wizards/com/sun/star/wizards/query/CallQueryWizard.java new file mode 100644 index 0000000000..6f92ea445e --- /dev/null +++ b/wizards/com/sun/star/wizards/query/CallQueryWizard.java @@ -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 . + */ +package com.sun.star.wizards.query; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Type; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; + +/** This class capsulates the class, that implements the minimal component, a + * factory for creating the service (<CODE>__getServiceFactory</CODE>). + */ +public class CallQueryWizard +{ + + /** Gives a factory for creating the service. + * This method is called by the <code>JavaLoader</code> + * <p> + * @return Returns a <code>XSingleServiceFactory</code> for creating the component. + * @see com.sun.star.comp.loader.JavaLoader + * @param stringImplementationName The implementation name of the component. + * @param xMSF The service manager, who gives access to every known service. + * @param xregistrykey Makes structural information (except regarding tree structures) of a single + * registry key accessible. + */ + public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(String stringImplementationName, com.sun.star.lang.XMultiServiceFactory xMSF, com.sun.star.registry.XRegistryKey xregistrykey) + { + com.sun.star.lang.XSingleServiceFactory xsingleservicefactory = null; + if (stringImplementationName.equals(QueryWizardImplementation.class.getName())) + { + xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(QueryWizardImplementation.class, QueryWizardImplementation.__serviceName, xMSF, xregistrykey); + } + return xsingleservicefactory; + } + + /** This class implements the component. At least the interfaces XServiceInfo, + * XTypeProvider, and XInitialization should be provided by the service. + */ + public static class QueryWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.task.XJobExecutor + { + private PropertyValue[] m_wizardContext; + // the next two fields are accessed by reflection, do not delete! + public String Command; + public final Integer CommandType = com.sun.star.sdb.CommandType.QUERY; + + /** The constructor of the inner class has a XMultiServiceFactory parameter. + * @param i_serviceFactory A special service factory could be introduced while initializing. + */ + public QueryWizardImplementation( XMultiServiceFactory i_serviceFactory ) + { + super(); + m_serviceFactory = i_serviceFactory; + registerProperty( PropertyNames.COMMAND, (short)( PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID ) ); + registerProperty( PropertyNames.COMMAND_TYPE, PropertyAttribute.READONLY ); + } + + public void trigger(String sEvent) + { + try + { + if (sEvent.equals(PropertyNames.START)) + { + QueryWizard CurQueryWizard = new QueryWizard( m_serviceFactory, m_wizardContext ); + CurQueryWizard.start(); + } + } + catch (Exception exception) + { + System.err.println(exception); + } + System.gc(); + } + /** The service name, that must be used to get an instance of this service. + */ + private static final String __serviceName = "com.sun.star.wizards.query.CallQueryWizard"; + /** The service manager, that gives access to all registered services. + */ + private final com.sun.star.lang.XMultiServiceFactory m_serviceFactory; + + /** This method is a member of the interface for initializing an object + * directly after its creation. + * @param object This array of arbitrary objects will be passed to the + * component after its creation. + * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be + * passed to the caller. + */ + public void initialize(Object[] object) throws com.sun.star.uno.Exception + { + m_wizardContext = Properties.convertToPropertyValueArray(object); + } + + /** This method returns an array of all supported service names. + * @return Array of supported service names. + */ + public java.lang.String[] getSupportedServiceNames() + { + String[] stringSupportedServiceNames = new String[] { __serviceName }; + + return stringSupportedServiceNames; + } + + /** This method returns true, if the given service will be + * supported by the component. + * @param stringService Service name. + * @return True, if the given service name will be supported. + */ + public boolean supportsService(String stringService) + { + boolean booleanSupportsService = false; + + if (stringService.equals(__serviceName)) + { + booleanSupportsService = true; + } + return booleanSupportsService; + } + + @Override + public byte[] getImplementationId() + { + return new byte[0]; + } + + /** Return the class name of the component. + * @return Class name of the component. + */ + public java.lang.String getImplementationName() + { + return QueryWizardImplementation.class.getName(); + } + + /** Provides a sequence of all types (usually interface types) + * provided by the object. + * @return Sequence of all types (usually interface types) provided by the + * service. + */ + @Override + public Type[] getTypes() + { + Type[] typeReturn = + { + }; + + try + { + typeReturn = new Type[] + { + new Type(com.sun.star.task.XJobExecutor.class), new Type(com.sun.star.lang.XTypeProvider.class), new Type(com.sun.star.lang.XServiceInfo.class), new Type(com.sun.star.lang.XInitialization.class) + }; + } + catch (Exception exception) + { + System.err.println(exception); + } + + return typeReturn; + } + } +} diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java new file mode 100644 index 0000000000..6a556beffe --- /dev/null +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -0,0 +1,197 @@ +/* + * 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 . + */ +package com.sun.star.wizards.query; + +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.XRadioButton; +import com.sun.star.awt.XTextComponent; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdbc.SQLException; +import com.sun.star.uno.AnyConverter; +import com.sun.star.wizards.common.HelpIds; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; + +import java.util.logging.Level; +import java.util.logging.Logger; + +public class Finalizer +{ + private final QueryWizard m_queryWizard; + private final String resQuery; + private final XTextComponent m_aTxtTitle; + private final XRadioButton xRadioDisplayQuery; + private final QuerySummary CurDBMetaData; + + public Finalizer( QueryWizard i_queryWizard, QuerySummary _CurDBMetaData ) + { + short curtabindex = (short) (100 * QueryWizard.SOSUMMARY_PAGE); + String reslblQueryTitle; + String resoptDisplayQuery; + String resoptModifyQuery; + String resflnSummary; + String reslblHowGoOn; + this.m_queryWizard = i_queryWizard; + this.CurDBMetaData = _CurDBMetaData; + reslblQueryTitle = m_queryWizard.m_oResource.getResText("RID_QUERY_5"); + resoptDisplayQuery = m_queryWizard.m_oResource.getResText("RID_QUERY_6"); + resoptModifyQuery = m_queryWizard.m_oResource.getResText("RID_QUERY_7"); + resflnSummary = m_queryWizard.m_oResource.getResText("RID_QUERY_87"); + reslblHowGoOn = m_queryWizard.m_oResource.getResText("RID_QUERY_8"); + resQuery = m_queryWizard.m_oResource.getResText("RID_QUERY_1"); + int curHelpIndex = 40955; + + m_queryWizard.insertLabel("lblQueryTitle", new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, reslblQueryTitle, 95, 27, Integer.valueOf(QueryWizard.SOSUMMARY_PAGE), Short.valueOf(curtabindex++), 52 + }); + m_aTxtTitle = m_queryWizard.insertTextField("txtQueryTitle", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent event) { + changeTitle(); + } + }, new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 12, HelpIds.getHelpIdString(curHelpIndex++), 95, 37, Integer.valueOf(QueryWizard.SOSUMMARY_PAGE), Short.valueOf(curtabindex++), 90 + }); + m_queryWizard.insertLabel("lblHowGoOn", new String[] + { + 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 + }, + new Object[] + { + 16, reslblHowGoOn, Boolean.TRUE, 192, 27, Integer.valueOf(QueryWizard.SOSUMMARY_PAGE), Short.valueOf(curtabindex++), 112 + }); + this.xRadioDisplayQuery = m_queryWizard.insertRadioButton("optDisplayQuery", + new String[] + { + 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 + }, + new Object[] + { + 9, HelpIds.getHelpIdString(curHelpIndex++), resoptDisplayQuery, 192, 46, Short.valueOf((short) 1), Integer.valueOf(QueryWizard.SOSUMMARY_PAGE), Short.valueOf(curtabindex++), 118 + }); + + m_queryWizard.insertRadioButton("optModifyQuery", + new String[] + { + 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 + }, + new Object[] + { + 10, HelpIds.getHelpIdString(curHelpIndex++), resoptModifyQuery, 192, 56, Integer.valueOf(QueryWizard.SOSUMMARY_PAGE), Short.valueOf(curtabindex++), 118 + }); + m_queryWizard.insertFixedLine("flnSummary", new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, resflnSummary, 95, 68, 8, Short.valueOf(curtabindex++), 209 + }); + m_queryWizard.insertTextField("txtSummary", 0, null, new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.READ_ONLY, PropertyNames.PROPERTY_STEP, "VScroll", PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 96, HelpIds.getHelpIdString(curHelpIndex++), Boolean.TRUE, 95, 80, Boolean.TRUE, 8, Boolean.TRUE, 209 + }); + } + + private void changeTitle() + { + final String TitleName = m_aTxtTitle.getText(); + m_queryWizard.enableFinishButton( TitleName.length() > 0 ); + } + + /* TODO: The title textbox always has to be updated when + a new Table has been selected if it is clear that the user has not made any input meanwhile + */ + protected String initialize() + { + try + { + String sCurQueryName = AnyConverter.toString(Helper.getUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text")); + if (sCurQueryName != null && sCurQueryName.equals(PropertyNames.EMPTY_STRING)) + { + String[] sCommandNames = CurDBMetaData.getIncludedCommandNames(); + sCurQueryName = resQuery + "_" + sCommandNames[0]; + sCurQueryName = CurDBMetaData.suggestName( CommandType.QUERY, sCurQueryName ); + Helper.setUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text", sCurQueryName); + } + CurDBMetaData.setSummaryString(); + m_queryWizard.setControlProperty("txtSummary", "Text", CurDBMetaData.getSummaryString()); + return sCurQueryName; + } + catch (IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + return PropertyNames.EMPTY_STRING; + } + catch (SQLException exception) + { + exception.printStackTrace(System.err); + return PropertyNames.EMPTY_STRING; + } + + } + + private String getTitle() + { + return (String) Helper.getUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text"); + } + + public String finish() + { + String queryName = getTitle(); + if ( CurDBMetaData.getSQLQueryComposer().setQueryCommand( m_queryWizard.xWindow, true, true ) + && CurDBMetaData.createQuery( CurDBMetaData.getSQLQueryComposer(), queryName ) + ) + return queryName; + + return PropertyNames.EMPTY_STRING; + } + + public final boolean displayQueryDesign() + { + try + { + final short state = AnyConverter.toShort( Helper.getUnoPropertyValue( UnoDialog.getModel( xRadioDisplayQuery ), PropertyNames.PROPERTY_STATE ) ); + final boolean viewMode = state == (short)1; + return !viewMode; + } + catch ( IllegalArgumentException ex ) + { + Logger.getLogger( Finalizer.class.getName() ).log( Level.SEVERE, null, ex ); + } + return false; + } +} diff --git a/wizards/com/sun/star/wizards/query/MANIFEST.MF b/wizards/com/sun/star/wizards/query/MANIFEST.MF new file mode 100644 index 0000000000..abb009f220 --- /dev/null +++ b/wizards/com/sun/star/wizards/query/MANIFEST.MF @@ -0,0 +1,2 @@ +RegistrationClassName: com.sun.star.wizards.query.CallQueryWizard +UNO-Type-Path: diff --git a/wizards/com/sun/star/wizards/query/QuerySummary.java b/wizards/com/sun/star/wizards/query/QuerySummary.java new file mode 100644 index 0000000000..443c964535 --- /dev/null +++ b/wizards/com/sun/star/wizards/query/QuerySummary.java @@ -0,0 +1,223 @@ +/* + * 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 . + */ +package com.sun.star.wizards.query; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.db.FieldColumn; +import com.sun.star.wizards.db.QueryMetaData; +import com.sun.star.wizards.ui.FilterComponent; + +public class QuerySummary extends QueryMetaData +{ + + private String sSummary; + private Resource oResource; + private final String sSeparator; + private final String sReturnChar; + private final String sAnd; + private final String sOr; + + public QuerySummary(XMultiServiceFactory _xMSF, Resource _oResource) + { + super(_xMSF); + this.oResource = _oResource; + sAnd = oResource.getResText("RID_QUERY_38"); + sOr = oResource.getResText("RID_QUERY_39"); + sSeparator = oResource.getResText("RID_QUERY_91"); + sReturnChar = String.valueOf((char) 13) + String.valueOf((char) 13); + } + + public void setSummaryString() + { + try + { + String sFieldNamesFraction = PropertyNames.EMPTY_STRING; + String sSortingFraction = PropertyNames.EMPTY_STRING; + String sFilterFraction = PropertyNames.EMPTY_STRING; + String sAggregateFraction = PropertyNames.EMPTY_STRING; + String sGroupByFraction = PropertyNames.EMPTY_STRING; + String sHavingFraction = PropertyNames.EMPTY_STRING; + sFieldNamesFraction = combineFieldNameFraction() + sReturnChar; + sSortingFraction = combinePartString("RID_QUERY_51", getSortFieldNames(), "RID_QUERY_52", "RID_QUERY_93", new String[] + { + "<FIELDNAME>", "<SORTMODE>" + }) + sReturnChar; + sFilterFraction = combineFilterNameFraction(this.getFilterConditions(), "RID_QUERY_53", "RID_QUERY_54") + sReturnChar; + if (xDBMetaData.supportsGroupBy()) + { + sGroupByFraction = combinePartString("RID_QUERY_57", GroupFieldNames, "RID_QUERY_58") + sReturnChar; + sHavingFraction = combineFilterNameFraction(getGroupByFilterConditions(), "RID_QUERY_59", "RID_QUERY_60"); + } + // TODO: remove the last return from the string + sSummary = sFieldNamesFraction + sSortingFraction + sFilterFraction + sAggregateFraction + sGroupByFraction + sHavingFraction; + sSummary = JavaTools.replaceSubString(sSummary, PropertyNames.EMPTY_STRING, "~"); + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public String getSummaryString() + { + return sSummary; + } + + private String combineFilterNameFraction(PropertyValue[][] _filterconditions, String _InitResID, String _AlternativeResID) + { + if (_filterconditions != null && _filterconditions.length > 0) + { + String sconditions = PropertyNames.EMPTY_STRING; + String sStart = oResource.getResText(_InitResID); + String BaseString = oResource.getResText("RID_QUERY_96"); + if (_filterconditions.length == 1) + { + PropertyValue[] curfilterconditions = _filterconditions[0]; + for (int i = 0; i < curfilterconditions.length; i++) + { + sconditions += FilterComponent.getDisplayCondition(BaseString, _filterconditions[0][i], this); + sconditions = appendClauseSeparator(sconditions, PropertyNames.SPACE + sAnd + PropertyNames.SPACE, i, curfilterconditions.length); + } + } + else + { + + for (int i = 0; i < _filterconditions.length; i++) + { + sconditions += FilterComponent.getDisplayCondition(BaseString, _filterconditions[i][0], this); + sconditions = appendClauseSeparator(sconditions, PropertyNames.SPACE + sOr + PropertyNames.SPACE, i, _filterconditions.length); + } + } + return sStart + sconditions; + } + return oResource.getResText(_AlternativeResID); + } + + private String combineFieldNameFraction() + { + String CurString = PropertyNames.EMPTY_STRING; + String sReturn = oResource.getResText("RID_QUERY_50"); + String BaseString = oResource.getResText("RID_QUERY_92"); + for (int i = 0; i < FieldColumns.length; i++) + { + CurString = BaseString; + FieldColumn CurDBFieldColumn = super.getFieldColumnByDisplayName(FieldColumns[i].getDisplayFieldName()); + int iAggregate = getAggregateIndex(FieldColumns[i].getFieldName()); + if (iAggregate > -1) + { + String sAggregateDisplay = AggregateFieldNames[iAggregate][1] + "(" + AggregateFieldNames[iAggregate][0] + ")"; + CurString = JavaTools.replaceSubString(CurString, sAggregateDisplay, "<FIELDNAME>"); + } + else + { + CurString = JavaTools.replaceSubString(CurString, CurDBFieldColumn.getDisplayFieldName(), "<FIELDNAME>"); + } + sReturn += JavaTools.replaceSubString(CurString, CurDBFieldColumn.getFieldTitle(), "<FIELDTITLE>"); + sReturn = appendClauseSeparator(sReturn, sSeparator, i, FieldColumns.length); + } + return sReturn; + } + + private String appendClauseSeparator(String _basestring, String _suffix, int _i, int _fieldcount) + { + if (_i < _fieldcount - 1) + { + _basestring += _suffix; + } + return _basestring; + } + // TODO: How can you merge the following two methods to a single one in a smarter way?? + + private String combinePartString(String _InitResID, String[] _FieldNames, String _AlternativeResID) + { + if (_FieldNames != null && _FieldNames.length > 0) + { + return ArrayFieldsToString(_InitResID, _FieldNames); + } + return oResource.getResText(_AlternativeResID); + } + + private String ArrayFieldsToString(String _InitResID, String[] _FieldNames) + { + StringBuilder sReturn = new StringBuilder(oResource.getResText(_InitResID)); + int FieldCount = _FieldNames.length; + for (int i = 0; i < FieldCount; i++) + { + sReturn.append(this.getFieldColumnByDisplayName(_FieldNames[i]).getFieldTitle()); + if (i < FieldCount - 1) + { + sReturn.append(sSeparator); + } + } + return sReturn.toString(); + } + + private String combinePartString(String _InitResID, String[][] _FieldNames, String _AlternativeResID, String _BaseStringID, String[] _ReplaceTags) + { + if (_FieldNames != null && _FieldNames.length > 0) + { + return ArrayFieldsToString(_InitResID, _FieldNames, _BaseStringID, _ReplaceTags); + } + return oResource.getResText(_AlternativeResID); + } + + private String ArrayFieldsToString(String _InitResID, String[][] _FieldNames, String _BaseStringID, String[] _ReplaceTags) + { + String CurString = PropertyNames.EMPTY_STRING; + StringBuilder sReturn = new StringBuilder(oResource.getResText(_InitResID)); + int FieldCount = _FieldNames.length; + if (FieldCount > 0) + { + int DimCount = _FieldNames[0].length; + String BaseString = oResource.getResText(_BaseStringID); + for (int i = 0; i < FieldCount; i++) + { + for (int a = 0; a < DimCount; a++) + { + if (a == 0) + { + int iAggregate = getAggregateIndex(this.getFieldColumnByDisplayName(_FieldNames[i][a]).getDisplayFieldName()); + if (iAggregate > -1) + { + String sAggregateDisplay = AggregateFieldNames[iAggregate][1] + "(" + AggregateFieldNames[iAggregate][0] + ")"; + CurString = JavaTools.replaceSubString(BaseString, sAggregateDisplay, _ReplaceTags[a]); + } + else + { + CurString = JavaTools.replaceSubString(BaseString, this.getFieldColumnByDisplayName(_FieldNames[i][a]).getFieldTitle(), _ReplaceTags[a]); + } + } + else + { + CurString = JavaTools.replaceSubString(CurString, _FieldNames[i][a], _ReplaceTags[a]); + } + } + sReturn.append(CurString); + if (i < FieldCount - 1) + { + sReturn.append(sSeparator); + } + } + } + return sReturn.toString(); + } +} diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java new file mode 100644 index 0000000000..8f460e55ef --- /dev/null +++ b/wizards/com/sun/star/wizards/query/QueryWizard.java @@ -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 . + */ +package com.sun.star.wizards.query; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.PropertyValue; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdbc.SQLException; +import com.sun.star.uno.AnyConverter; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.db.DatabaseObjectWizard; +import com.sun.star.wizards.db.QueryMetaData; +import com.sun.star.wizards.ui.AggregateComponent; +import com.sun.star.wizards.ui.CommandFieldSelection; +import com.sun.star.wizards.ui.FieldSelection; +import com.sun.star.wizards.ui.FilterComponent; +import com.sun.star.wizards.ui.SortingComponent; +import com.sun.star.wizards.ui.TitlesComponent; + +public class QueryWizard extends DatabaseObjectWizard +{ + + private static final int SOFIELDSELECTION_PAGE = 1; + private static final int SOSORTING_PAGE = 2; + private static final int SOFILTER_PAGE = 3; + private static final int SOAGGREGATE_PAGE = 4; + private static final int SOGROUPSELECTION_PAGE = 5; + private static final int SOGROUPFILTER_PAGE = 6; + private static final int SOTITLES_PAGE = 7; + protected static final int SOSUMMARY_PAGE = 8; + private CommandFieldSelection m_DBCommandFieldSelectio; + private SortingComponent m_sortingComponent; + private FieldSelection m_groupFieldSelection; + private TitlesComponent m_titlesComponent; + private FilterComponent m_filterComponent; + private FilterComponent m_groupFilterComponent; + private AggregateComponent m_aggregateComponent; + private Finalizer m_finalizer; + private QuerySummary m_DBMetaData; + private String reslblFieldHeader; + private String reslblAliasHeader; + private String reslblFields; + private String reslblSelFields; + private String reslblTables; + private String reslblGroupBy; + private String resmsgNonNumericAsGroupBy; + private String m_createdQuery; + + public QueryWizard(XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext) + { + super(xMSF, 40970, i_wizardContext); + addResourceHandler(); + m_DBMetaData = new QuerySummary(xMSF, m_oResource); + } + + public static void main(String i_args[]) + { + executeWizardFromCommandLine( i_args, new WizardFromCommandLineStarter() { + public void start(XMultiServiceFactory factory, PropertyValue[] curproperties) { + QueryWizard wizard = new QueryWizard(factory, curproperties); + wizard.start(); + } + }); + } + + public String start() + { + try + { + if (m_DBMetaData.getConnection(m_wizardContext)) + { + reslblFields = m_oResource.getResText("RID_QUERY_4"); + reslblFieldHeader = m_oResource.getResText("RID_QUERY_19"); //Fieldnames in AliasComponent + reslblAliasHeader = m_oResource.getResText("RID_QUERY_20"); //Fieldtitles header in AliasComponent + reslblSelFields = m_oResource.getResText("RID_QUERY_50"); + reslblTables = m_oResource.getResText("RID_QUERY_3"); + reslblGroupBy = m_oResource.getResText("RID_QUERY_18"); + String resQueryWizard = m_oResource.getResText("RID_QUERY_2"); + resmsgNonNumericAsGroupBy = m_oResource.getResText("RID_QUERY_88"); + Helper.setUnoPropertyValues(xDialogModel, new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_MOVEABLE, PropertyNames.PROPERTY_NAME, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_TITLE, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 210, Boolean.TRUE, "DialogQuery", 102, 41, 1, Short.valueOf((short) 0), resQueryWizard, 310 + }); + drawNaviBar(); + setRightPaneHeaders(m_oResource, "RID_QUERY_", 70, 8); + this.setMaxStep(8); + buildSteps(); + this.m_DBCommandFieldSelectio.preselectCommand(m_wizardContext, false); + + XWindowPeer windowPeer = UnoRuntime.queryInterface(XWindowPeer.class, m_frame.getContainerWindow()); + createWindowPeer(windowPeer); + m_DBMetaData.setWindowPeer(this.xControl.getPeer()); + insertQueryRelatedSteps(); + executeDialog(m_frame.getContainerWindow().getPosSize()); + } + } + catch (java.lang.Exception jexception) + { + jexception.printStackTrace(System.err); + } + m_groupFilterComponent = null; + m_titlesComponent = null; + m_aggregateComponent = null; + m_DBCommandFieldSelectio = null; + xWindowPeer = null; + m_finalizer = null; + m_DBMetaData.finish(); + m_DBMetaData = null; + System.gc(); + + return m_createdQuery; + } + + private void enableRoadmapItems(boolean _bEnabled) + { + try + { + Object oRoadmapItem; + int CurStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP)); + boolean bEnabled = false; + int CurItemID; + for (int i = 0; i < getRMItemCount(); i++) + { + oRoadmapItem = this.xIndexContRoadmap.getByIndex(i); + CurItemID = AnyConverter.toInt(Helper.getUnoPropertyValue(oRoadmapItem, "ID")); + switch (CurItemID) + { + case SOAGGREGATE_PAGE: + if (_bEnabled) + { + bEnabled = ((m_DBMetaData.hasNumericalFields()) && (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar())); + } + break; + case SOGROUPSELECTION_PAGE: + bEnabled = m_DBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY; + break; + case SOGROUPFILTER_PAGE: + bEnabled = false; + if (_bEnabled) + { + bEnabled = (m_DBMetaData.GroupByFilterConditions.length > 0); + } + + break; + default: + if (CurItemID > CurStep) + { + bEnabled = _bEnabled; + } + else + { + bEnabled = true; + } + break; + } + super.setStepEnabled(CurItemID, bEnabled); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void insertQueryRelatedSteps() + { + try + { + setRMItemLabels(m_oResource); + addRoadmap(); + int i = 0; + i = insertRoadmapItem(0, true, SOFIELDSELECTION_PAGE - 1, SOFIELDSELECTION_PAGE); + i = insertRoadmapItem(i, false, SOSORTING_PAGE - 1, SOSORTING_PAGE); // Orderby is always supported + i = insertRoadmapItem(i, false, SOFILTER_PAGE - 1, SOFILTER_PAGE); + if (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar()) + { + i = insertRoadmapItem(i, m_DBMetaData.hasNumericalFields(), SOAGGREGATE_PAGE - 1, SOAGGREGATE_PAGE); + } + if (m_DBMetaData.xDBMetaData.supportsGroupBy()) + { + i = insertRoadmapItem(i, false, SOGROUPSELECTION_PAGE - 1, SOGROUPSELECTION_PAGE); + i = insertRoadmapItem(i, false, SOGROUPFILTER_PAGE - 1, SOGROUPFILTER_PAGE); + } + i = insertRoadmapItem(i, false, SOTITLES_PAGE - 1, SOTITLES_PAGE); + i = insertRoadmapItem(i, false, SOSUMMARY_PAGE - 1, SOSUMMARY_PAGE); + setRoadmapInteractive(true); + setRoadmapComplete(true); + setCurrentRoadmapItemID((short) 1); + } + catch (com.sun.star.uno.Exception exception) + { + Resource.showCommonResourceError(xMSF); + } + } + + private void buildSteps() + { + try + { + m_DBCommandFieldSelectio = new CommandFieldSelection( + this, m_DBMetaData, 120, reslblFields, reslblSelFields, reslblTables, + m_DBMetaData.supportsQueriesInFrom(), 40850); + m_DBCommandFieldSelectio.setAppendMode(true); + m_DBCommandFieldSelectio.addFieldSelectionListener(new FieldSelectionListener()); + m_sortingComponent = new SortingComponent(this, SOSORTING_PAGE, 95, 27, 210, 40865); + m_filterComponent = new FilterComponent(this, SOFILTER_PAGE, 97, 27, 3, m_DBMetaData, 40878); + m_filterComponent.addNumberFormats(); + + if (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar()) + { + m_aggregateComponent = new AggregateComponent(this, m_DBMetaData, SOAGGREGATE_PAGE, 97, 69, 209, 5, 40895); + } + if (m_DBMetaData.xDBMetaData.supportsGroupBy()) + { + m_groupFieldSelection = new FieldSelection(this, SOGROUPSELECTION_PAGE, 95, 27, 210, 150, reslblFields, this.reslblGroupBy, 40915, false); + m_groupFieldSelection.addFieldSelectionListener(new FieldSelectionListener()); + m_groupFilterComponent = new FilterComponent(this, SOGROUPFILTER_PAGE, 97, 27, 3, m_DBMetaData, 40923); + } + m_titlesComponent = new TitlesComponent(this, SOTITLES_PAGE, 97, 37, 207, 7, reslblFieldHeader, reslblAliasHeader, 40940); + m_finalizer = new Finalizer(this, m_DBMetaData); + enableNavigationButtons(false, false, false); + } + catch (com.sun.star.uno.Exception exception) + { + Resource.showCommonResourceError(xMSF); + } + } + + @Override + public boolean finishWizard() + { + int ncurStep = getCurrentStep(); + if ((ncurStep == SOSUMMARY_PAGE) + || (switchToStep(ncurStep, SOSUMMARY_PAGE))) + { + m_createdQuery = m_finalizer.finish(); + if (m_createdQuery.length() > 0) + { + loadSubComponent(CommandType.QUERY, m_createdQuery, m_finalizer.displayQueryDesign()); + xDialog.endExecute(); + return true; + } + } + return false; + } + + @Override + protected void enterStep(int nOldStep, int nNewStep) + { + try + { + if (nOldStep <= SOGROUPSELECTION_PAGE && nNewStep > SOGROUPSELECTION_PAGE) + { + if (m_DBMetaData.xDBMetaData.supportsGroupBy()) + { + m_DBMetaData.setGroupFieldNames(m_groupFieldSelection.getSelectedFieldNames()); + m_DBMetaData.GroupFieldNames = JavaTools.removeOutdatedFields(m_DBMetaData.GroupFieldNames, m_DBMetaData.NonAggregateFieldNames); + m_DBMetaData.GroupByFilterConditions = JavaTools.removeOutdatedFields(m_DBMetaData.GroupByFilterConditions, m_DBMetaData.GroupFieldNames); + } + } + switch (nNewStep) + { + case SOFIELDSELECTION_PAGE: + break; + case SOSORTING_PAGE: + m_sortingComponent.initialize(m_DBMetaData.getDisplayFieldNames(), m_DBMetaData.getSortFieldNames()); + break; + case SOFILTER_PAGE: + m_filterComponent.initialize(m_DBMetaData.getFilterConditions(), m_DBMetaData.getDisplayFieldNames()); + break; + case SOAGGREGATE_PAGE: + m_aggregateComponent.initialize(); + break; + case SOGROUPSELECTION_PAGE: + break; + case SOGROUPFILTER_PAGE: + m_groupFilterComponent.initialize(m_DBMetaData.GroupByFilterConditions, m_DBMetaData.getGroupFieldNames()); + break; + case SOTITLES_PAGE: + m_titlesComponent.initialize(m_DBMetaData.getDisplayFieldNames(), m_DBMetaData.FieldTitleSet); + break; + case SOSUMMARY_PAGE: + m_finalizer.initialize(); + break; + default: + break; + } + } + catch (SQLException e) + { + e.printStackTrace(System.err); + } + } + + @Override + protected void leaveStep(int nOldStep, int nNewStep) + { + switch (nOldStep) + { + case SOFIELDSELECTION_PAGE: + m_DBMetaData.reorderFieldColumns(m_DBCommandFieldSelectio.getSelectedFieldNames()); + m_DBMetaData.initializeFieldTitleSet(); + m_DBMetaData.setNumericFields(); + searchForOutdatedFields(); + break; + case SOSORTING_PAGE: + m_DBMetaData.setSortFieldNames(m_sortingComponent.getSortFieldNames()); + break; + case SOFILTER_PAGE: + m_DBMetaData.setFilterConditions(m_filterComponent.getFilterConditions()); + break; + case SOAGGREGATE_PAGE: + m_DBMetaData.AggregateFieldNames = m_aggregateComponent.getAggregateFieldNames(); + break; + case SOGROUPSELECTION_PAGE: + break; + case SOGROUPFILTER_PAGE: + m_DBMetaData.setGroupByFilterConditions(this.m_groupFilterComponent.getFilterConditions()); + break; + case SOTITLES_PAGE: + m_DBMetaData.setFieldTitles(m_titlesComponent.getFieldTitles()); + break; + case SOSUMMARY_PAGE: + break; + default: + break; + } + if (nOldStep < SOGROUPSELECTION_PAGE && nNewStep >= SOGROUPSELECTION_PAGE) + { + try + { + if (m_DBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY) + { + if (m_DBMetaData.xDBMetaData.supportsGroupBy()) + { + m_DBMetaData.setNonAggregateFieldNames(); + m_groupFieldSelection.initialize(m_DBMetaData.getUniqueAggregateFieldNames(), false, m_DBMetaData.xDBMetaData.getMaxColumnsInGroupBy()); + m_groupFieldSelection.initializeSelectedFields(m_DBMetaData.NonAggregateFieldNames); + m_groupFieldSelection.setMultipleMode(false); + setStepEnabled(SOGROUPFILTER_PAGE, m_aggregateComponent.isGroupingpossible() && m_DBMetaData.NonAggregateFieldNames.length > 0); + } + } + } + catch (SQLException e) + { + e.printStackTrace( System.err ); + } + } + } + + private void searchForOutdatedFields() + { + String[] sFieldNames = m_DBMetaData.getFieldNames(); + String[][] sRemovedFields = JavaTools.removeOutdatedFields(m_DBMetaData.getSortFieldNames(), sFieldNames); + m_DBMetaData.setSortFieldNames(sRemovedFields); + m_DBMetaData.setFilterConditions(JavaTools.removeOutdatedFields(m_DBMetaData.getFilterConditions(), sFieldNames)); + m_DBMetaData.AggregateFieldNames = JavaTools.removeOutdatedFields(m_DBMetaData.AggregateFieldNames, sFieldNames); + } + + private void enableWizardSteps(String[] NewItems) + { + boolean bEnabled = NewItems.length > 0; + setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, bEnabled); + setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, bEnabled); + enableRoadmapItems(bEnabled); // Note: Performance wise this could be improved + } + + private class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener + { + + private int ID; + + public void setID(String sIncSuffix) + { + ID = 1; + if (sIncSuffix != null) + { + if ((!sIncSuffix.equals(PropertyNames.EMPTY_STRING)) && (!sIncSuffix.equals("_"))) + { + String sID = JavaTools.ArrayoutofString(sIncSuffix, "_")[1]; + ID = Integer.parseInt(sID); + } + } + } + + public void shiftFromLeftToRight(String[] SelItems, String[] NewItems) + { + if (ID == 1) + { + m_DBMetaData.addSeveralFieldColumns(SelItems, m_DBCommandFieldSelectio.getSelectedCommandName()); + enableWizardSteps(NewItems); + m_DBCommandFieldSelectio.changeSelectedFieldNames(m_DBMetaData.getDisplayFieldNames()); + m_DBCommandFieldSelectio.toggleCommandListBox(NewItems); + } + else + { + boolean bEnabled = (m_groupFieldSelection.getSelectedFieldNames().length > 0); + Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPFILTER_PAGE), PropertyNames.PROPERTY_ENABLED, bEnabled); + } + } + + public void shiftFromRightToLeft(String[] SelItems, String[] NewItems) + { + // TODO When the ListFieldbox is refilled only fields of the current Command may be merged into the Listbox + if (ID == 1) + { + enableWizardSteps(NewItems); + String[] sSelfieldNames = m_DBMetaData.getFieldNames(SelItems, m_DBCommandFieldSelectio.getSelectedCommandName()); + m_DBCommandFieldSelectio.addItemsToFieldsListbox(sSelfieldNames); + m_DBMetaData.removeSeveralFieldColumnsByDisplayFieldName(SelItems); + m_DBCommandFieldSelectio.toggleCommandListBox(NewItems); + + } + else + { + boolean bEnabled = (m_groupFieldSelection.getSelectedFieldNames().length > 0); + String CurDisplayFieldName = SelItems[0]; + if (JavaTools.FieldInList(m_DBMetaData.NonAggregateFieldNames, CurDisplayFieldName) > -1) + { + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, resmsgNonNumericAsGroupBy); + m_groupFieldSelection.xSelectedFieldsListBox.addItems(SelItems, m_groupFieldSelection.xSelectedFieldsListBox.getItemCount()); + String FieldList[] = m_groupFieldSelection.xFieldsListBox.getItems(); + int index = JavaTools.FieldInList(FieldList, CurDisplayFieldName); + if (index > -1) + { + m_groupFieldSelection.xFieldsListBox.removeItems((short) index, (short) 1); + } + } + else + { + Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPFILTER_PAGE), PropertyNames.PROPERTY_ENABLED, bEnabled); + } + } + } + + public void moveItemDown(String item) + { + } + + public void moveItemUp(String item) + { + } + } +} diff --git a/wizards/com/sun/star/wizards/query/query.component b/wizards/com/sun/star/wizards/query/query.component new file mode 100644 index 0000000000..c349617d83 --- /dev/null +++ b/wizards/com/sun/star/wizards/query/query.component @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . + --> + +<component loader="com.sun.star.loader.Java2" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name= + "com.sun.star.wizards.query.CallQueryWizard$QueryWizardImplementation"> + <service name="com.sun.star.wizards.query.CallQueryWizard"/> + </implementation> +</component> diff --git a/wizards/com/sun/star/wizards/report/CallReportWizard.java b/wizards/com/sun/star/wizards/report/CallReportWizard.java new file mode 100644 index 0000000000..08ca4bf89f --- /dev/null +++ b/wizards/com/sun/star/wizards/report/CallReportWizard.java @@ -0,0 +1,205 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.Type; +import com.sun.star.text.XTextDocument; +import com.sun.star.wizards.common.Properties; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.wizards.common.NamedValueCollection; +import com.sun.star.wizards.common.PropertyNames; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** This class capsulates the class, that implements the minimal component, a + * factory for creating the service (<CODE>__getServiceFactory</CODE>). + */ +public class CallReportWizard +{ + + private static boolean bWizardstartedalready; + + /** Gives a factory for creating the service. + * This method is called by the <code>JavaLoader</code> + * <p> + * @return Returns a <code>XSingleServiceFactory</code> for creating the component. + * @see com.sun.star.comp.loader.JavaLoader + * @param stringImplementationName The implementation name of the component. + * @param xMSF The service manager, who gives access to every known service. + * @param xregistrykey Makes structural information (except regarding treestructures) of a single + * registry key accessible. + */ + public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(String stringImplementationName, com.sun.star.lang.XMultiServiceFactory xMSF, com.sun.star.registry.XRegistryKey xregistrykey) + { + com.sun.star.lang.XSingleServiceFactory xsingleservicefactory = null; + if (stringImplementationName.equals( + ReportWizardImplementation.class.getName())) + { + xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory( + ReportWizardImplementation.class, + ReportWizardImplementation.__serviceName, + xMSF, + xregistrykey); + } + return xsingleservicefactory; + } + + /** This class implements the component. At least the interfaces XServiceInfo, + * XTypeProvider, and XInitialization should be provided by the service. + */ + public static class ReportWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.task.XJobExecutor + { + + private PropertyValue[] m_wizardContext; + + /** The constructor of the inner class has a XMultiServiceFactory parameter. + * @param xmultiservicefactoryInitialization A special service factory + * could be introduced while initializing. + */ + public ReportWizardImplementation(com.sun.star.lang.XMultiServiceFactory xmultiservicefactoryInitialization) + { + super(); + xmultiservicefactory = xmultiservicefactoryInitialization; + } + + public void trigger(String sEvent) + { + try + { + if (sEvent.equals(PropertyNames.START)) + { + if (!bWizardstartedalready) + { + ReportWizard CurReportWizard = new ReportWizard( xmultiservicefactory, m_wizardContext ); + CurReportWizard.startReportWizard(); + } + bWizardstartedalready = false; + } + else if (sEvent.equals("fill")) + { + Dataimport CurDataimport = new Dataimport(xmultiservicefactory); + if (m_wizardContext != null) + { + NamedValueCollection context = new NamedValueCollection( m_wizardContext ); + XTextDocument textDocument = context.queryOrDefault( "TextDocument", null, XTextDocument.class ); + XDatabaseDocumentUI documentUI = context.queryOrDefault( "DocumentUI", null, XDatabaseDocumentUI.class ); + if ( textDocument != null ) + { + CurDataimport.createReport(xmultiservicefactory, documentUI, textDocument, m_wizardContext); + } + } + } + } + catch (Exception e) + { + Logger.getLogger(CallReportWizard.class.getName()).log(Level.SEVERE, null, e); + } + System.gc(); + } + /** The service name, that must be used to get an instance of this service. + */ + private static final String __serviceName = "com.sun.star.wizards.report.CallReportWizard"; + /** The service manager, that gives access to all registered services. + */ + private final com.sun.star.lang.XMultiServiceFactory xmultiservicefactory; + + /** This method is a member of the interface for initializing an object + * directly after its creation. + * @param object This array of arbitrary objects will be passed to the + * component after its creation. + * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be + * passed to the caller. + */ + public void initialize(Object[] object) throws com.sun.star.uno.Exception + { + this.m_wizardContext = Properties.convertToPropertyValueArray(object); + + } + + /** This method returns an array of all supported service names. + * @return Array of supported service names. + */ + public java.lang.String[] getSupportedServiceNames() + { + String[] stringSupportedServiceNames = new String[] { __serviceName }; + + return stringSupportedServiceNames; + } + + /** This method returns true, if the given service will be + * supported by the component. + * @param stringService Service name. + * @return True, if the given service name will be supported. + */ + public boolean supportsService(String stringService) + { + boolean booleanSupportsService = false; + + if (stringService.equals(__serviceName)) + { + booleanSupportsService = true; + } + return booleanSupportsService; + } + + @Override + public byte[] getImplementationId() + { + return new byte[0]; + } + + /** Return the class name of the component. + * @return Class name of the component. + */ + public java.lang.String getImplementationName() + { + return ReportWizardImplementation.class.getName(); + } + + /** Provides a sequence of all types (usually interface types) + * provided by the object. + * @return Sequence of all types (usually interface types) provided by the + * service. + */ + @Override + public Type[] getTypes() + { + Type[] typeReturn = + { + }; + + try + { + typeReturn = new Type[] + { + new Type(com.sun.star.task.XJobExecutor.class), + new Type(com.sun.star.lang.XTypeProvider.class), + new Type(com.sun.star.lang.XServiceInfo.class), + new Type(com.sun.star.lang.XInitialization.class) + }; + } + catch (Exception e) + { + Logger.getLogger(CallReportWizard.class.getName()).log(Level.SEVERE, null, e); + } + + return typeReturn; + } + } +} diff --git a/wizards/com/sun/star/wizards/report/DBColumn.java b/wizards/com/sun/star/wizards/report/DBColumn.java new file mode 100644 index 0000000000..22fe7e657e --- /dev/null +++ b/wizards/com/sun/star/wizards/report/DBColumn.java @@ -0,0 +1,445 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.beans.PropertyState; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertyState; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.style.ParagraphAdjust; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +import com.sun.star.table.XTableColumns; +import com.sun.star.table.XTableRows; +import com.sun.star.text.XDependentTextField; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.db.*; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.text.TextDocument; +import com.sun.star.wizards.text.TextTableHandler; +import com.sun.star.wizards.text.TextFieldHandler; + +public class DBColumn +{ + + private XCell xValCell; + private XTextRange xValTextCell; + private XTextCursor xValCellCursor; + public XCell xNameCell; + private XTextRange xNameTextCell; + private boolean bAlignLeft; + private String CharFontName; + private PropertyState PropertyState; + public int ValColumn = 1; + private int ValRow = 0; + public FieldColumn CurDBField; + private XTextTable xTextTable; + private XTableColumns xTableColumns; + private XCellRange xCellRange; + public XNamed xTableName; + private boolean bIsGroupColumn; + private RecordParser CurDBMetaData; + private RecordTable CurRecordTable; + private TextTableHandler oTextTableHandler; + + public DBColumn(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i, boolean _bforce) + { + initializeRecordTableMembers(_CurRecordTable, _oTextTableHandler, _CurDBMetaData, i, _bforce); + } + + public DBColumn(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i) + { + initializeRecordTableMembers(_CurRecordTable, _oTextTableHandler, _CurDBMetaData, i, false); + } + + private void initializeRecordTableMembers(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i, boolean _bForce) + { + this.oTextTableHandler = _oTextTableHandler; + this.CurDBMetaData = _CurDBMetaData; + this.CurRecordTable = _CurRecordTable; + bIsGroupColumn = false; + if (CurDBMetaData.RecordFieldColumns != null) + { + CurDBField = CurDBMetaData.getFieldColumnByFieldName(CurDBMetaData.RecordFieldColumns[i].getFieldName()); + } + else + { + CurDBField = CurDBMetaData.getFieldColumnByFieldName(CurDBMetaData.getRecordFieldName(i)); + } + if (_bForce) + { + assignCells(i, true); + } + else + { + for (int n = 0; n < CurRecordTable.xTableColumns.getCount(); n++) + { + assignCells(n, false); + } + } + } + + private boolean assignCells(int _nColumn, boolean _bforce) + { + try + { + XCell xCell = CurRecordTable.xCellRange.getCellByPosition(_nColumn, 0); + XTextRange xTextCell = UnoRuntime.queryInterface(XTextRange.class, xCell); + String CompString = "Column"; + XTextCursor xLocCellCursor = TextDocument.createTextCursor(xCell); + if (isNameCell(xLocCellCursor, CurDBField.getFieldName(), CompString) || (_bforce)) + { + xNameCell = xCell; + xNameTextCell = xTextCell; + xValCell = CurRecordTable.xCellRange.getCellByPosition(_nColumn, 1); + xValTextCell = UnoRuntime.queryInterface(XTextRange.class, xValCell); + xValCellCursor = TextDocument.createTextCursor(xValCell); + ValColumn = _nColumn; + return true; + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return false; + } + + public DBColumn(TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, String _FieldName, String TableName, DBColumn OldDBColumn) { + this.oTextTableHandler = _oTextTableHandler; + this.CurDBMetaData = _CurDBMetaData; + CurDBField = CurDBMetaData.getFieldColumnByDisplayName(_FieldName); + bIsGroupColumn = true; + getTableColumns(TableName); + xNameCell = OldDBColumn.xNameCell; + xNameTextCell = OldDBColumn.xNameTextCell; + xValCell = OldDBColumn.xValCell; + xValTextCell = OldDBColumn.xValTextCell; + xValCellCursor = TextDocument.createTextCursor(xValCell); + ValColumn = OldDBColumn.ValColumn; + ValRow = OldDBColumn.ValRow; + initializeNumberFormat(); + } + + public DBColumn(TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, String _FieldName, String TableName) throws Exception + { + this.oTextTableHandler = _oTextTableHandler; + this.CurDBMetaData = _CurDBMetaData; + CurDBField = CurDBMetaData.getFieldColumnByFieldName(_FieldName); + bIsGroupColumn = true; + XTextRange xTextCell; + XCell xCell; + getTableColumns(TableName); + + if (xTextTable == null) + return; + + XTableRows xRows = xTextTable.getRows(); + + for (int n = 0; n < xTableColumns.getCount(); n++) + { + for (int m = 0; m < xRows.getCount(); m++) + { + xCell = xCellRange.getCellByPosition(n, m); + xTextCell = UnoRuntime.queryInterface(XTextRange.class, xCell); + String CompString = TableName.substring(4); + XTextCursor xLocCellCursor = TextDocument.createTextCursor(xCell); + if (isNameCell(xLocCellCursor, CurDBField.getFieldName(), CompString)) + { + xNameCell = xCell; + xNameTextCell = xTextCell; + } + else + { //In Grouping Sections only two cells are allowed ' if (CellString.equals(CurFieldString)){ + xValCell = xCell; + xValTextCell = xTextCell; + xValCellCursor = xLocCellCursor; + ValColumn = n; + ValRow = m; + checkforLeftAlignment(); + } + } + } + } + + private void getTableColumns(String TableName) + { + try + { + XNameAccess xAllTextTables = oTextTableHandler.xTextTablesSupplier.getTextTables(); + if (xAllTextTables.hasByName(TableName)) + { + Object oTextTable = xAllTextTables.getByName(TableName); + xCellRange = UnoRuntime.queryInterface(XCellRange.class, oTextTable); + xTextTable = UnoRuntime.queryInterface(XTextTable.class, oTextTable); + xTableName = UnoRuntime.queryInterface(XNamed.class, oTextTable); + xTableColumns = xTextTable.getColumns(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void initializeNumberFormat() + { + if (CurDBField.isBoolean()) + { + NumberFormatter oNumberFormatter = oTextTableHandler.getNumberFormatter(); + int iLogicalFormatKey = oNumberFormatter.setBooleanReportDisplayNumberFormat(); + oNumberFormatter.setNumberFormat(xValCell, iLogicalFormatKey, oNumberFormatter); + } + else + { + oTextTableHandler.getNumberFormatter().setNumberFormat(xValCell, CurDBField.getDBFormatKey(), CurDBMetaData.getNumberFormatter()); + } + setCellFont(); + } + + public void insertColumnData(TextFieldHandler oTextFieldHandler, boolean _bIsLandscape) + { + insertUserFieldToTableCell(oTextFieldHandler); + replaceValueCellofTable(_bIsLandscape); + } + + private void insertUserFieldToTableCell(TextFieldHandler oTextFieldHandler) + { + XTextCursor xTextCursor = TextDocument.createTextCursor(xNameCell); + xTextCursor.gotoStart(false); + xTextCursor.gotoEnd(true); + xTextCursor.setString(PropertyNames.EMPTY_STRING); + oTextFieldHandler.insertUserField(xTextCursor, CurDBField.getFieldName(), CurDBField.getFieldTitle()); + } + + + + public void formatValueCell() + { + initializeNumberFormat(); + if (checkforLeftAlignment()) + { + bAlignLeft = true; + } + } + + private boolean checkforLeftAlignment() + { + bAlignLeft = ((CurDBField.isNumberFormat()) && (ValColumn == xTableColumns.getCount() - 1)); + return bAlignLeft; + } + + public void modifyCellContent(XCellRange xCellRange, Object CurGroupValue) + { + try + { + xValCell = xCellRange.getCellByPosition(ValColumn, ValRow); + xValTextCell = UnoRuntime.queryInterface(XTextRange.class, xValCell); + modifyCellContent(CurGroupValue); + if (bAlignLeft) + { + xValCellCursor = TextDocument.createTextCursor(xValCell); + Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", Integer.valueOf(com.sun.star.style.ParagraphAdjust.LEFT_value)); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void modifyCellContent(Object CurGroupValue) + { + double dblValue = 0; + try + { + if (xValCell != null) + { + if (AnyConverter.isString(CurGroupValue)) + { + String sValue = AnyConverter.toString(CurGroupValue); + xValTextCell.setString(sValue); + } + else + { + if (AnyConverter.isBoolean(CurGroupValue)) + { + dblValue = AnyConverter.toInt(CurGroupValue); + } + if (AnyConverter.isByte(CurGroupValue)) + { + dblValue = AnyConverter.toByte(CurGroupValue); + } + else if (AnyConverter.isDouble(CurGroupValue)) + { + dblValue = AnyConverter.toDouble(CurGroupValue); + } + else if (AnyConverter.isFloat(CurGroupValue)) + { + dblValue = AnyConverter.toFloat(CurGroupValue); + } + else if (AnyConverter.isInt(CurGroupValue)) + { + dblValue = AnyConverter.toInt(CurGroupValue); + } + else if (AnyConverter.isLong(CurGroupValue)) + { + dblValue = AnyConverter.toLong(CurGroupValue); + } + else if (AnyConverter.isShort(CurGroupValue)) + { + dblValue = AnyConverter.toShort(CurGroupValue); + } + xValCell.setValue(dblValue); + } + } + } + catch (IllegalArgumentException exception) + { + System.err.println(exception); + } + } + // If the parameter CurGroupValue is null the placeholders are inserted + private void replaceValueCellofTable(boolean _bIsLandscape) + { + try + { + Object CurGroupValue; + if (!bIsGroupColumn && !CurDBField.isNumberFormat()) + { + CurGroupValue = BlindtextCreator.adjustBlindTextlength(CurDBField.getFieldTitle(), CurDBField.getFieldWidth(), _bIsLandscape, bIsGroupColumn, CurDBMetaData.getRecordFieldNames()); + } + else + { + CurGroupValue = CurDBField.getDefaultValue(); + } + modifyCellContent(CurGroupValue); + if (bAlignLeft) + { + Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", Integer.valueOf(ParagraphAdjust.LEFT_value)); + } + + int nFieldType = CurDBField.getFieldType(); + if ((nFieldType == com.sun.star.sdbc.DataType.BIT) || + (nFieldType == com.sun.star.sdbc.DataType.BOOLEAN)) + { + CharFontName = "StarSymbol"; + Helper.setUnoPropertyValue(xValCellCursor, "CharFontName", CharFontName); + if (!bIsGroupColumn) + { + Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", Integer.valueOf(ParagraphAdjust.CENTER_value)); + } + } + else + { + if (PropertyState == com.sun.star.beans.PropertyState.DEFAULT_VALUE) + { + XPropertyState xPropState = UnoRuntime.queryInterface(XPropertyState.class, xValCellCursor); + xPropState.setPropertyToDefault("CharFontName"); + } + else + { + if (PropertyState == com.sun.star.beans.PropertyState.DIRECT_VALUE) + { + Helper.setUnoPropertyValue(xValCellCursor, "CharFontName", CharFontName); + } + } + } + } + catch (com.sun.star.beans.UnknownPropertyException exception) + { + exception.printStackTrace(System.err); + } + } + + public void setCellFont() + { + try + { + XPropertyState xPropertyState; + int nFieldType = CurDBField.getFieldType(); + if ((nFieldType == com.sun.star.sdbc.DataType.BIT) || + (nFieldType == com.sun.star.sdbc.DataType.BOOLEAN)) + { + CharFontName = "StarSymbol"; + PropertyState = com.sun.star.beans.PropertyState.DIRECT_VALUE; + xValCellCursor.gotoStart(false); + xValCellCursor.gotoEnd(true); + Helper.setUnoPropertyValue(xValCellCursor, "CharFontName", CharFontName); + } + else + { + xPropertyState = UnoRuntime.queryInterface(XPropertyState.class, xValCellCursor); + PropertyState = xPropertyState.getPropertyState("CharFontName"); + CharFontName = AnyConverter.toString(Helper.getUnoPropertyValue(xValCellCursor, "CharFontName")); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private boolean isNameCell(XTextCursor xCellCursor, String CurFieldName, String CompString) + { + try + { + xCellCursor.gotoStart(false); + XTextRange xTextRange = xCellCursor.getEnd(); + Object oTextField = Helper.getUnoPropertyValue(xTextRange, "TextField"); + if (AnyConverter.isVoid(oTextField)) + { + return false; + } + else + { + XDependentTextField xDependent = UnoRuntime.queryInterface(XDependentTextField.class, oTextField); + XPropertySet xMaster = xDependent.getTextFieldMaster(); + String UserFieldName = (String) xMaster.getPropertyValue(PropertyNames.PROPERTY_NAME); + boolean bIsNameCell = false; + if ((UserFieldName.startsWith(CompString)) || (UserFieldName.equals(CurFieldName))) + { + bIsNameCell = true; + } + else + { + // stupid hack, 'Title' is not a real good Table-Cell-Name + // take a look at xmloff/source/text/txtvfldi.txt, there exists 2 '_renamed_' strings + String sLocalCurFieldName = CurFieldName + "_renamed_"; + if (UserFieldName.startsWith(sLocalCurFieldName)) + { + bIsNameCell = true; + } + } + return bIsNameCell; + } + } + // Todo: Insert a resource; Exception should be thrown to the calling routine + catch (Exception exception) + { + exception.printStackTrace(System.err); + return true; //most probably this is really the Namecell!!!! + } + } +} diff --git a/wizards/com/sun/star/wizards/report/Dataimport.java b/wizards/com/sun/star/wizards/report/Dataimport.java new file mode 100644 index 0000000000..8e9d3e321c --- /dev/null +++ b/wizards/com/sun/star/wizards/report/Dataimport.java @@ -0,0 +1,169 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.text.XTextDocument; +import com.sun.star.wizards.ui.*; +import com.sun.star.wizards.common.*; +import com.sun.star.uno.Exception; + +import java.util.logging.Level; +import java.util.logging.Logger; + +public class Dataimport extends UnoDialog2 implements com.sun.star.awt.XActionListener +{ + + // ReportTextDocument CurReportDocument; + IReportDocument CurReportDocument; + + private String sProgressDBConnection; + private String sProgressDataImport; + private String sProgressTitle; + private String sStop; + + public Dataimport(XMultiServiceFactory _xMSF) + { + super(_xMSF); + super.addResourceHandler(); + sProgressDBConnection = m_oResource.getResText("RID_DB_COMMON_34"); + sProgressDataImport = m_oResource.getResText("RID_REPORT_67"); + sProgressTitle = m_oResource.getResText("RID_REPORT_62"); + m_oResource.getResText("RID_REPORT_63"); + sStop = m_oResource.getResText("RID_DB_COMMON_21"); + + } + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + + public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) + { + // bStopProcess = true; + CurReportDocument.StopProcess(); + } + + private void showProgressDisplay(boolean bgetConnection) + { + try + { + Helper.setUnoPropertyValues(xDialogModel, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TITLE, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 84, 0, sProgressTitle, 180 + }); + com.sun.star.awt.FontDescriptor oFontDesc = new com.sun.star.awt.FontDescriptor(); + oFontDesc.Weight = com.sun.star.awt.FontWeight.BOLD; + if (bgetConnection) + { + insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblProgressDBConnection", + new String[] + { + PropertyNames.FONT_DESCRIPTOR, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + oFontDesc, 10, sProgressDBConnection, 6, 6, 0, 150 + }); + + insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblProgressDataImport", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, sProgressDataImport, 6, 24, 0, 120 + }); + } + else + { + insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblProgressDataImport", + new String[] + { + PropertyNames.FONT_DESCRIPTOR, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + oFontDesc, 10, sProgressDataImport, 6, 24, 0, 120 + }); + } + insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblCurProgress", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, PropertyNames.EMPTY_STRING, 12, 42, 0, 120 + }); + + insertButton("cmdCancel", 10000, this, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH, PropertyNames.PROPERTY_LABEL + }, + new Object[] + { + 14, HelpIds.getHelpIdString(34321), 74, 58, 0, Short.valueOf((short) 1), 40, sStop + }); + createWindowPeer(CurReportDocument.getWizardParent()); + calculateDialogPosition(CurReportDocument.getFrame().getComponentWindow().getPosSize()); + xWindow.setVisible(true); + super.xReschedule.reschedule(); + } + catch (Exception e) + { + Logger.getLogger(Dataimport.class.getName()).log(Level.SEVERE, null, e); + // return; + } + catch (java.lang.Exception e) + { + Logger.getLogger(Dataimport.class.getName()).log(Level.SEVERE, null, e); + // return; + } + } + + private void importReportData(final XMultiServiceFactory _xMSF, PropertyValue[] _properties) + { + if (CurReportDocument.reconnectToDatabase(_xMSF, _properties)) + { + // The following calls to remove the Sections must occur after the connection to the database + modifyFontWeight("lblProgressDBConnection", com.sun.star.awt.FontWeight.NORMAL); + modifyFontWeight("lblProgressDataImport", com.sun.star.awt.FontWeight.BOLD); + CurReportDocument.insertDatabaseDatatoReportDocument(_xMSF); + } + xComponent.dispose(); + CurReportDocument.getRecordParser().dispose(); + } + + public void createReport( XMultiServiceFactory xMSF, XDatabaseDocumentUI i_documentUI, XTextDocument _textDocument, + PropertyValue[] properties) + { + CurReportDocument = ReportTextImplementation.create( xMSF, i_documentUI, _textDocument, m_oResource ); + showProgressDisplay(true); + importReportData(xMSF, properties); + } +} diff --git a/wizards/com/sun/star/wizards/report/GroupFieldHandler.java b/wizards/com/sun/star/wizards/report/GroupFieldHandler.java new file mode 100644 index 0000000000..26543bb462 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/GroupFieldHandler.java @@ -0,0 +1,185 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import java.util.ArrayList; + +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.CommandMetaData; +import com.sun.star.wizards.db.QueryMetaData; +import com.sun.star.wizards.ui.FieldSelection; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.WizardDialog; + +public class GroupFieldHandler extends FieldSelection +{ + + private IReportDocument CurReportDocument; + private final ArrayList<String> GroupFieldVector = new ArrayList<String>(); + private QueryMetaData CurDBMetaData; + private static final short MAXSELFIELDS = 4; + + public GroupFieldHandler(IReportDocument _CurReportDocument, WizardDialog _CurUnoDialog) + { + super(_CurUnoDialog, ReportWizard.SOGROUPPAGE, 95, 27, 210, 127, + _CurUnoDialog.m_oResource.getResText("RID_REPORT_19"), + _CurUnoDialog.m_oResource.getResText("RID_REPORT_50"), 34340, false); + + try + { + this.CurReportDocument = _CurReportDocument; + this.CurDBMetaData = CurReportDocument.getRecordParser(); + CurUnoDialog.setControlProperty("lstFields_2", "MultiSelection", Boolean.FALSE); + CurUnoDialog.setControlProperty("lstSelFields_2", "MultiSelection", Boolean.FALSE); + addFieldSelectionListener(new FieldSelectionListener()); + String sNote = ReportWizard.getBlindTextNote(_CurReportDocument, _CurUnoDialog.m_oResource); + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblBlindTextNote_1", + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.FALSE, 18, sNote, Boolean.TRUE, 95, 158, Integer.valueOf(ReportWizard.SOGROUPPAGE), 209 + }); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private boolean isGroupField(String _FieldName) + { + return (JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, _FieldName) != -1); + } + + public void initialize() + { + try + { + ArrayList<String> NormalFieldsVector = new ArrayList<String>(); + ArrayList<String> SelFieldsVector = new ArrayList<String>(); + String[] sFieldNames = CurDBMetaData.getFieldNames(); + for (int i = 0; i < sFieldNames.length; i++) + { + String sfieldtitle = sFieldNames[i]; // CurDBMetaData.getFieldTitle(sFieldNames[i]); + if (isGroupField(sFieldNames[i])) + { + SelFieldsVector.add(sfieldtitle); + } + else + { + NormalFieldsVector.add(sfieldtitle); + } + } + String[] SelFields = new String[SelFieldsVector.size()]; + SelFieldsVector.toArray(SelFields); + String[] NormalFields = new String[NormalFieldsVector.size()]; + NormalFieldsVector.toArray(NormalFields); + super.initialize(NormalFields, SelFields, true); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void removeGroupFieldNames() + { + emptyFieldsListBoxes(); + GroupFieldVector.clear(); + CurUnoDialog.setControlProperty("lblBlindTextNote_1", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + } + + public void getGroupFieldNames(CommandMetaData CurDBMetaData) + { + String[] GroupFieldNames = new String[GroupFieldVector.size()]; + GroupFieldVector.toArray(GroupFieldNames); + CurDBMetaData.GroupFieldNames = GroupFieldNames; + } + // @Override + @Override + protected void toggleListboxButtons(short iFieldsSelIndex, short iSelFieldsSelIndex) + { + super.toggleListboxButtons(iFieldsSelIndex, iSelFieldsSelIndex); + int iSelCount = xSelectedFieldsListBox.getItemCount(); + if (iSelCount >= MAXSELFIELDS) + { + CurUnoDialog.setControlProperty("cmdMoveSelected" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + } + } + + @Override + public void selectFields(boolean bMoveAll) + { + int iSelCount = xSelectedFieldsListBox.getItemCount(); + if (iSelCount < MAXSELFIELDS) + { + super.selectFields(bMoveAll); + } + + } + + /* protected */ private class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener + { + + public void moveItemDown(String Selitem) + { + CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); + } + + public void moveItemUp(String item) + { + CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); + } + + public void shiftFromLeftToRight(String[] Selitems, String[] Newitems) + { + String CurGroupTitle = Selitems[0]; + int iSelCount = xSelectedFieldsListBox.getItemCount(); + String[] CurGroupNames = xFieldsListBox.getItems(); + CurReportDocument.liveupdate_addGroupNametoDocument(CurGroupNames, CurGroupTitle, GroupFieldVector, CurReportDocument.getReportPath(), iSelCount); + CurUnoDialog.setControlProperty("lblBlindTextNote_1", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + if (iSelCount >= MAXSELFIELDS) + { + toggleMoveButtons(false, false); + } + } + + public void shiftFromRightToLeft(String[] OldSelitems, String[] Newitems) + { + int iSelPos = OldSelitems.length; + if (iSelPos > 0) + { + String OldGroupTitle = OldSelitems[0]; + String[] NewSelList = xSelectedFieldsListBox.getItems(); + CurReportDocument.liveupdate_removeGroupName(NewSelList, OldGroupTitle, GroupFieldVector); + String[] NewSelGroupNames = xSelectedFieldsListBox.getItems(); + CurUnoDialog.setControlProperty("lblBlindTextNote_1", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(NewSelGroupNames.length == 0)); + + // CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); + } + } + + public void setID(String sIncSuffix) + { + } + } +} diff --git a/wizards/com/sun/star/wizards/report/IReportBuilderLayouter.java b/wizards/com/sun/star/wizards/report/IReportBuilderLayouter.java new file mode 100644 index 0000000000..ad7993df0d --- /dev/null +++ b/wizards/com/sun/star/wizards/report/IReportBuilderLayouter.java @@ -0,0 +1,106 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +/** + * This Interface separate the ReportBuilderImplementation from the layout. + * Only these less methods are allowed to access from the ReportBuilderImplementation. + */ +public interface IReportBuilderLayouter +{ + + /** + * Get the internal name of the current layout. + * This name identifies the layout in the internal access list. + * @return the internal layout name. + */ + String getName(); + + /** + * Get the localized name of the layout, which is shown in the layout page of the report wizard. + * This name comes out of the resource and will be translate in different languages. + * @return localized name of the layout. + */ + String getLocalizedName(); + + /** + * For Landscape give nOrientation == com.sun.star.wizards.report.ReportLayouter.SOOPTLANDSCAPE + * All other numbers are interpreted as portrait format. + */ + void setPageOrientation(int nOrientation); + + /** + * dispose the layouter + */ + void dispose(); + + /** + * Set the table name of the report + * This is the name to the database table. + * @param _nType something of com.sun.star.sdb.CommandType + */ + void setTableName(int _nType, String TableName); + + /** + * Insert the field names, these are the field names out of a given datebase table + */ + void insertFieldNames(final String[] FieldNames); + + /** + * Insert the field type (Varchar, int, ...) as internal an int representation. + */ + void insertFieldTypes(int[] FieldTypes); + + /** + * Insert the field width in count of chars as given in the database. + */ + void insertFieldWidths(int[] FieldWidths); + + /** + * Insert the titles of the field names. This names are free formed + */ + void insertFieldTitles(String[] _aFieldTitles); + + /** + * Insert the names of the groups, the group names are names out of the field names. + * + * If a group name is given here, it will not shown in the fields/titles, but must be in the field string list. + */ + void insertGroupNames(String[] _aGroupFieldNames); + + /** + * Insert the names of the groups which should be used as sorting, the group names are names out of the field names. + * + * If a group name is given here, it will not shown in the fields/titles, but must be in the field string list. + */ + void insertSortingNames(String[][] _aSortFieldNames); + + /** + * This method redraws the whole layout with all its content + */ + void layout(); + + /** + * Initialize the current Layouter with data's out of another Layouter. + * + * This Method copies the internal fields, groups and titles + */ + void initializeData(IReportBuilderLayouter aOtherLayouter); + + void loadAndSetBackgroundTemplate(String LayoutTemplatePath); +} diff --git a/wizards/com/sun/star/wizards/report/IReportDefinitionReadAccess.java b/wizards/com/sun/star/wizards/report/IReportDefinitionReadAccess.java new file mode 100644 index 0000000000..3cdabfc236 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/IReportDefinitionReadAccess.java @@ -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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.report.XReportDefinition; + +/** + * This interface contains only one function to give access to the ReportDefinition. + * The ReportDefinition will be initialized very late, late after the ReportLayouters. + * So we need this interface for the late access. + */ +public interface IReportDefinitionReadAccess +{ + + /** + * Gives access to a ReportDefinition, if initialized. + * @return a ReportDefinition or null. + */ + XReportDefinition getReportDefinition(); /* should throw NullPointerException but does not. */ + + + /** + * This ServiceFactory is the 'global' Service Factory, which knows all and everything in the program. + * @return the global service factory of the program + */ + XMultiServiceFactory getGlobalMSF(); + + /** + * Returns the file path to the default report definition, we need this name for early initialisation + */ + String getDefaultHeaderLayout(); +} diff --git a/wizards/com/sun/star/wizards/report/IReportDocument.java b/wizards/com/sun/star/wizards/report/IReportDocument.java new file mode 100644 index 0000000000..ec04d67807 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/IReportDocument.java @@ -0,0 +1,219 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.wizards.common.Resource; +import java.util.ArrayList; + +/** + * New Interface which gives us the possibility to switch on the fly between the old + * Wizard and the new Report Builder Wizard, which use the same UI. + */ +public interface IReportDocument +{ + + // initialisation + + void initialize( + final XDatabaseDocumentUI i_documentUI, + final Resource i_resource + ); + + + // Access Helper + + /** + * Gives access to the DB Values + */ + com.sun.star.wizards.db.RecordParser getRecordParser(); + + /** + * Give access to the parent document + * It is a document in the old Wizard + * It is a Report Builder in the new Wizard + */ + com.sun.star.awt.XWindowPeer getWizardParent(); + + /** + * + * @return the Frame of the document Window or Report Builder Window + */ + com.sun.star.frame.XFrame getFrame(); + + XComponent getComponent(); + + + // First step: After entering the table name, select fields + + /** + * Is called after first step, set Tablename and the fields, which should occur in the Report. + */ + void initializeFieldColumns(final int _aType, final String TableName, final String[] FieldNames); + + /** + * Empties the report document + */ + void clearDocument(); + + /** + * Empties the report document, if we called back, don't remove Grouping/Sorting + */ + void removeTextTableAndTextSection(); + + + // Second step: Label field titles + + /** + * Set new names for the titles + */ + void setFieldTitles(final String[] sFieldTitles); + + /** + * Change the name of the 'title' of one field. + * It is possible to give all element names new names which are used as + * element title of a given element name. + * This is only used as a preview + */ + void liveupdate_changeUserFieldContent(final String FieldName, final String TitleName); + + // Third step: Grouping + + /* Grouping Page */ + // Document should not hold the grouping information! + /** + * Called by press ('greater than') add a group to the group list + */ + boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, ArrayList<String> GroupFieldVector, ArrayList<String> ReportPath, int iSelCount); + + void refreshGroupFields(String[] _sNewNames); + /** + * Called by press ('less than') Removes an already set Groupname out of the list + */ + void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, java.util.ArrayList<String> GroupFieldVector); + + /** + * set the list how to group + */ + void setGrouping(String[] aGroupList); + + // Fourth step: Sorting + + /** + * Set the list how to sort + */ + void setSorting(String[][] aSort); + + // Fivth step: Templates / Layout + + /* Template Page */ + void setPageOrientation(int nOrientation) throws com.sun.star.lang.IllegalArgumentException; + + int getDefaultPageOrientation(); + + ArrayList<String> getReportPath(); + + String getLayoutPath(); + + String getContentPath(); + + /** + * Called if a new Layout is selected + */ + void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/); + + /** + * Called if a new Template is selected + */ + void liveupdate_changeContentTemplate(String ContentTemplatePath); + + void layout_selectFirstPage(); + + void layout_setupRecordSection(String TemplateName); + + // finishing + + // preview (update titlenames) + // addTextListener + /** + * Set the Title into the document from the 'Create Report Page' + * BUG: The Title is empty after create Report. + */ + void liveupdate_updateReportTitle(String _sTitleName); + + /** + * Store the document by the given name + */ + void store(String Name, int OpenMode) throws com.sun.star.uno.Exception; + + /** + * The current report is added to the DB View under the given name + * + * TODO: add Name to this functionality + */ + void addReportToDBView(); + + void importReportData(ReportWizard aWizard); + + /** + * Create the final Report document + */ + void createAndOpenReportDocument( + final String Name, + final boolean _bAsTemplate, + final boolean _bOpenInDesign + ); + + void dispose(); + + // Garbage dump + + /* DataImport */ + // ??? + // ??? + boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] Properties); + // ??? + void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF); + // ??? + /** + * set an internal variable to stop a maybe longer DB access. + */ + void StopProcess(); // cancel + + /** + * Returns a string list of layouts. + */ + String[][] getDataLayout(); + + /** + * Returns a string list of header layouts + */ + String[][] getHeaderLayout(); + + void setCommandType(int CommandType); + + void setCommand(String Command); + + /** + * check internal invariants + */ + void checkInvariants() throws java.lang.Exception; +} diff --git a/wizards/com/sun/star/wizards/report/MANIFEST.MF b/wizards/com/sun/star/wizards/report/MANIFEST.MF new file mode 100644 index 0000000000..1a4f8da6e3 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/MANIFEST.MF @@ -0,0 +1,2 @@ +RegistrationClassName: com.sun.star.wizards.report.CallReportWizard +UNO-Type-Path: diff --git a/wizards/com/sun/star/wizards/report/RecordTable.java b/wizards/com/sun/star/wizards/report/RecordTable.java new file mode 100644 index 0000000000..50e605dbc5 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/RecordTable.java @@ -0,0 +1,85 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCellRange; +import com.sun.star.table.XTableColumns; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.text.TextTableHandler; +import com.sun.star.wizards.text.ViewHandler; + +public class RecordTable +{ + + XNamed xTableName; + XCellRange xCellRange; + public XTextTable xTextTable; + private TextTableHandler oTextTableHandler; + XTableColumns xTableColumns; + + public RecordTable(TextTableHandler _oTextTableHandler) + { + try + { + this.oTextTableHandler = _oTextTableHandler; + XNameAccess xAllTextTables = oTextTableHandler.xTextTablesSupplier.getTextTables(); + if ((xAllTextTables.hasByName(ReportTextDocument.TBLRECORDSECTION)) || (xAllTextTables.hasByName(ReportTextDocument.COPYOFTBLRECORDSECTION))) + { + Object oTable; + if (xAllTextTables.hasByName(ReportTextDocument.COPYOFTBLRECORDSECTION)) + { + oTable = xAllTextTables.getByName(ReportTextDocument.COPYOFTBLRECORDSECTION); + } + else + { + oTable = xAllTextTables.getByName(ReportTextDocument.TBLRECORDSECTION); + } + xTextTable = UnoRuntime.queryInterface(XTextTable.class, oTable); + xTableName = UnoRuntime.queryInterface(XNamed.class, xTextTable); + } + else + { + XIndexAccess xTableIndex = UnoRuntime.queryInterface(XIndexAccess.class, xAllTextTables); + int n = xTableIndex.getCount() - 1; + Object x = xTableIndex.getByIndex(n); + xTextTable = UnoRuntime.queryInterface(XTextTable.class, x); + xTableName = UnoRuntime.queryInterface(XNamed.class, xTextTable); + xTableName.setName(ReportTextDocument.TBLRECORDSECTION); + } + xTextTable.getRows(); + xTableColumns = xTextTable.getColumns(); + xCellRange = UnoRuntime.queryInterface(XCellRange.class, xTextTable); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void adjustOptimalTableWidths(XMultiServiceFactory _xMSF, ViewHandler oViewHandler) + { // setTableColumnSeparators(){ + oTextTableHandler.adjustOptimalTableWidths(_xMSF, xTextTable); + oViewHandler.collapseViewCursorToStart(); + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportFinalizer.java b/wizards/com/sun/star/wizards/report/ReportFinalizer.java new file mode 100644 index 0000000000..048c2d3e92 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportFinalizer.java @@ -0,0 +1,259 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XTextComponent; +import com.sun.star.uno.Exception; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.RecordParser; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.WizardDialog; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; + +public class ReportFinalizer +{ + + private WizardDialog CurUnoDialog; + private XTextComponent xTitleTextBox; + private String StoreName; + private String OldDefaultName; + private IReportDocument CurReportDocument; + public static final int SOCREATEDOCUMENT = 1; + public static final int SOCREATETEMPLATE = 2; + public static final int SOUSETEMPLATE = 3; + public ReportFinalizer(IReportDocument _CurReportDocument, WizardDialog _CurUnoDialog) + { + this.CurUnoDialog = _CurUnoDialog; + this.CurReportDocument = _CurReportDocument; + short curtabindex = (short) (ReportWizard.SOSTOREPAGE * 100); + + String sSaveAsTemplate = CurUnoDialog.m_oResource.getResText("RID_REPORT_40"); + String sUseTemplate = CurUnoDialog.m_oResource.getResText("RID_REPORT_41"); + String sEditTemplate = CurUnoDialog.m_oResource.getResText("RID_REPORT_42"); + String sSaveAsDocument = CurUnoDialog.m_oResource.getResText("RID_REPORT_43"); + String sReportTitle = CurUnoDialog.m_oResource.getResText("RID_REPORT_33"); + String slblHowProceed = CurUnoDialog.m_oResource.getResText("RID_REPORT_78"); + String slblChooseReportKind = CurUnoDialog.m_oResource.getResText("RID_REPORT_79"); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblTitle", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, sReportTitle, 95, 27, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 68 + }); + + xTitleTextBox = CurUnoDialog.insertTextField("txtTitle", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent arg0) { + changeReportTitle(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 12, "HID:WIZARDS_HID_DLGREPORT_4_TITLE", 95, 37, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 209 + }); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblChooseReportKind", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblChooseReportKind, 95, 57, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 209 + }); + + CurUnoDialog.insertRadioButton("optCreateDocument", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubTemplateControls(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_5_OPTSTATDOCUMENT", sSaveAsDocument, 95, 69, Short.valueOf((short) 0), Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 138 + }); + + CurUnoDialog.insertRadioButton("optCreateReportTemplate", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubTemplateControls(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + 8, "HID:WIZARDS_HID_DLGREPORT_5_OPTDYNTEMPLATE", sSaveAsTemplate, 95, 81, Short.valueOf((short) 1), Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 209 + }); + + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblHowProceed", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblHowProceed, 105, 93, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 209 + }); + + + CurUnoDialog.insertRadioButton("optEditTemplate", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubTemplateControls(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_5_OPTEDITTEMPLATE", sEditTemplate, 111, 105, 6, Short.valueOf(curtabindex++), 138 + }); + + CurUnoDialog.insertRadioButton("optUseTemplate", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubTemplateControls(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_5_OPTUSETEMPLATE", sUseTemplate, 111, 115, Short.valueOf((short) 1), Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 138 + }); + } + + + /** + * This function is called if one of the radio buttons is pressed + */ + private void toggleSubTemplateControls() + { + // String sStorePath = PropertyNames.EMPTY_STRING; + Short iState = (Short) CurUnoDialog.getControlProperty("optCreateReportTemplate", PropertyNames.PROPERTY_STATE); + boolean bDoTemplateEnable = iState.shortValue() == 1; + CurUnoDialog.setControlProperty("optEditTemplate", PropertyNames.PROPERTY_ENABLED, bDoTemplateEnable); + CurUnoDialog.setControlProperty("optUseTemplate", PropertyNames.PROPERTY_ENABLED, bDoTemplateEnable); + CurUnoDialog.setControlProperty("lblHowProceed", PropertyNames.PROPERTY_ENABLED, bDoTemplateEnable); + + String sTitle = xTitleTextBox.getText(); + boolean bDoEnable = sTitle.equals(PropertyNames.EMPTY_STRING); + CurUnoDialog.enableFinishButton(!bDoEnable); + } + public void initialize(RecordParser _CurDBMetaData) + { + String FirstCommandName = _CurDBMetaData.getIncludedCommandNames()[0]; + String DefaultName = Desktop.getUniqueName(_CurDBMetaData.getReportDocuments(), FirstCommandName); + if (!DefaultName.equals(OldDefaultName)) + { + OldDefaultName = DefaultName; + } + xTitleTextBox.setText(DefaultName); + } + + public String getStoreName() + { + if (CurUnoDialog != null) + { + String LocStoreName = xTitleTextBox.getText(); + if (!LocStoreName.equals(PropertyNames.EMPTY_STRING)) + { + StoreName = LocStoreName; + } + } + return StoreName; + } + + private void changeReportTitle() + { + final String TitleName = xTitleTextBox.getText(); + CurReportDocument.liveupdate_updateReportTitle(TitleName); + CurUnoDialog.enableFinishButton(!PropertyNames.EMPTY_STRING.equals(TitleName)); + } + + public int getReportOpenMode() + { + int ReportMode = SOCREATEDOCUMENT; + boolean bcreateTemplate = ((Short) CurUnoDialog.getControlProperty("optCreateReportTemplate", PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + if (bcreateTemplate) + { + ReportMode = SOCREATETEMPLATE; + } + boolean buseTemplate = ((Short) CurUnoDialog.getControlProperty("optUseTemplate", PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + if (buseTemplate) + { + ReportMode = SOUSETEMPLATE; + } + boolean buseDocument = ((Short) CurUnoDialog.getControlProperty("optCreateDocument", PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + if (buseDocument) + { + ReportMode = SOCREATEDOCUMENT; + } + return ReportMode; + } + + public boolean finish() + { + StoreName = getStoreName(); + if (!CurReportDocument.getRecordParser().getReportDocuments().hasByHierarchicalName(StoreName)) + { + try + { + CurReportDocument.store(StoreName, getReportOpenMode()); + ReportWizard.bCloseDocument = false; + return true; + } + catch(Exception e) + { + CurUnoDialog.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK,e.getLocalizedMessage() ); + CurUnoDialog.enableFinishButton(false); + return false; + } + } + String sMsgReportDocumentNameDuplicate = CurUnoDialog.m_oResource.getResText("RID_REPORT_76"); + String sShowMsgReportNameisDuplicate = JavaTools.replaceSubString(sMsgReportDocumentNameDuplicate, StoreName, "%REPORTNAME"); + /* int iMsg = */ CurUnoDialog.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sShowMsgReportNameisDuplicate); + CurUnoDialog.enableFinishButton(false); + return false; + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportImplementationHelper.java b/wizards/com/sun/star/wizards/report/ReportImplementationHelper.java new file mode 100644 index 0000000000..54b0bac368 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportImplementationHelper.java @@ -0,0 +1,49 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.wizards.db.RecordParser; + +public class ReportImplementationHelper +{ + + private RecordParser m_aCurDBMetaData; + private final XMultiServiceFactory m_xMSF; + protected int m_nDefaultPageOrientation; + + public ReportImplementationHelper(XMultiServiceFactory _aMSF, int _nOrientation) + { + m_xMSF = _aMSF; + m_nDefaultPageOrientation = _nOrientation; + } + + public RecordParser getRecordParser() + { + if (m_aCurDBMetaData == null) + { + m_aCurDBMetaData = new RecordParser(getMSF()); + } + return m_aCurDBMetaData; + } + + public XMultiServiceFactory getMSF() + { + return m_xMSF; + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportLayouter.java b/wizards/com/sun/star/wizards/report/ReportLayouter.java new file mode 100644 index 0000000000..f6397ce92c --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportLayouter.java @@ -0,0 +1,425 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.awt.XListBox; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.ui.*; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XSearchable; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.container.XIndexAccess; +import com.sun.star.text.*; +import com.sun.star.wizards.common.TextElement; +import com.sun.star.wizards.common.PlaceholderTextElement; + +import java.util.List; +import java.util.ArrayList; + +public class ReportLayouter +{ + + private UnoDialog CurUnoDialog; + private static final int SOCONTENTLST = 29; + final public static int SOOPTLANDSCAPE = 30; + final public static int SOOPTPORTRAIT = 31; + private static final int SOLAYOUTLST = 32; + private XListBox xContentListBox; + private XListBox xLayoutListBox; + private int iOldContentPos; + private int iOldLayoutPos; + private IReportDocument CurReportDocument; + private String[][] LayoutFiles; + private String[][] ContentFiles; + private Object aOrientationImage; + private final XMultiServiceFactory m_xMSF; + private XTextRange trTitleconst, trAuthorconst, trDateconst, trPageconst; + private TextElement teTitleconst, teAuthorconst, teDateconst, tePageconst; + private List<XTextRange> constRangeList = new ArrayList<XTextRange>(); + private final boolean isBuilderInstalled; + + public ReportLayouter(XMultiServiceFactory _xMSF, IReportDocument _CurReportDocument, UnoDialog _CurUnoDialog, boolean _isBuilderInstalled) + { + m_xMSF = _xMSF; + isBuilderInstalled = _isBuilderInstalled; + try + { + short curtabindex = (short) (100 * ReportWizard.SOTEMPLATEPAGE); + this.CurUnoDialog = _CurUnoDialog; + this.CurReportDocument = _CurReportDocument; + //TODO the constructor for the OfficePathRetriever is redundant and should be instantiated elsewhere + String slblDataStructure = CurUnoDialog.m_oResource.getResText("RID_REPORT_15"); + String slblPageLayout = CurUnoDialog.m_oResource.getResText("RID_REPORT_16"); + + String sOrientationHeader = CurUnoDialog.m_oResource.getResText("RID_REPORT_22"); + String sOrientVertical = CurUnoDialog.m_oResource.getResText("RID_REPORT_23"); + String sOrientHorizontal = CurUnoDialog.m_oResource.getResText("RID_REPORT_24"); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblContent", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblDataStructure, 95, 27, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 99 + }); + + short iSelPos = 0; + ContentFiles = CurReportDocument.getDataLayout(); + iSelPos = (short) JavaTools.FieldInList(ContentFiles[1], CurReportDocument.getContentPath()); + if (iSelPos < 0) + { + iSelPos = 0; + } + iOldContentPos = iSelPos; + xContentListBox = CurUnoDialog.insertListBox("lstContent", SOCONTENTLST, new ActionListenerImpl(), new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.SELECTED_ITEMS, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 108, "HID:WIZARDS_HID_DLGREPORT_4_DATALAYOUT", 95, 37, new short[] + { + iSelPos + }, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), ContentFiles[0], Short.valueOf(curtabindex++), 99 + }); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblLayout", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblPageLayout, 205, 27, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 99 + }); + + short iSelLayoutPos = 0; + LayoutFiles = CurReportDocument.getHeaderLayout(); + iSelLayoutPos = (short) JavaTools.FieldInList(LayoutFiles[1], CurReportDocument.getLayoutPath()); + if (iSelLayoutPos < 0) + { + iSelLayoutPos = (short) JavaTools.FieldInList(LayoutFiles[0], CurReportDocument.getLayoutPath()); + if (iSelLayoutPos < 0) + { + iSelLayoutPos = 0; + } + } + xLayoutListBox = CurUnoDialog.insertListBox("lstLayout", SOLAYOUTLST, new ActionListenerImpl(), new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.SELECTED_ITEMS, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 108, "HID:WIZARDS_HID_DLGREPORT_4_PAGELAYOUT", 205, 37, new short[] + { + iSelLayoutPos + }, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), LayoutFiles[0], Short.valueOf(curtabindex++), 99 + }); + iOldLayoutPos = iSelPos; + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblOrientation", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, sOrientationHeader, 95, 148, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 74 + }); + + short m_nLandscapeState = CurReportDocument.getDefaultPageOrientation() == SOOPTLANDSCAPE ? (short) 1 : 0; + CurUnoDialog.insertRadioButton("optLandscape", SOOPTLANDSCAPE, new ItemListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_4_LANDSCAPE", sOrientHorizontal, 101, 158, Short.valueOf(m_nLandscapeState), Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 60 + }); + + short m_nPortraitState = CurReportDocument.getDefaultPageOrientation() == SOOPTPORTRAIT ? (short) 1 : (short) 0; + CurUnoDialog.insertRadioButton("optPortrait", SOOPTPORTRAIT, new ItemListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_4_PORTRAIT", sOrientVertical, 101, 171, Short.valueOf(m_nPortraitState), Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 60 + }); + + aOrientationImage = CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlImageControlModel", "imgOrientation", + new String[] + { + PropertyNames.PROPERTY_BORDER, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, "ScaleImage", PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Short.valueOf("0"), 23, 164, 158, Boolean.FALSE, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), 30 + }); + + String sNote = ReportWizard.getBlindTextNote(CurReportDocument, CurUnoDialog.m_oResource); + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblBlindTextNote_2", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 34, sNote, Boolean.TRUE, 205, 148, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), 99 + }); + if (m_nLandscapeState == 1) + { + CurUnoDialog.getPeerConfiguration().setImageUrl(aOrientationImage, "private:graphicrepository/wizards/res/landscape_32.png"); + } + else + { + CurUnoDialog.getPeerConfiguration().setImageUrl(aOrientationImage, "private:graphicrepository/wizards/res/portrait_32.png"); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void initialize(String _defaultTemplatePath) + { + CurReportDocument.layout_setupRecordSection(_defaultTemplatePath); + if (CurUnoDialog.getControlProperty("txtTitle", "Text").equals(PropertyNames.EMPTY_STRING)) + { + String[] sCommandNames = CurReportDocument.getRecordParser().getIncludedCommandNames(); + CurUnoDialog.setControlProperty("txtTitle", "Text", sCommandNames[0]); + } + CurReportDocument.layout_selectFirstPage(); + CurUnoDialog.setFocus("lblContent"); + } + + class ItemListenerImpl implements com.sun.star.awt.XItemListener + { + + public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) + { + try + { + int iPos; + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + // LLA: should we lock controllers here? + // CurReportDocument.getDoc().xTextDocument.lockControllers(); + int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); + switch (iKey) + { + case SOCONTENTLST: + iPos = xContentListBox.getSelectedItemPos(); + if (iPos != iOldContentPos) + { + iOldContentPos = iPos; + CurReportDocument.liveupdate_changeContentTemplate(ContentFiles[1][iPos]); + if(!isBuilderInstalled) + { + clearConstants(); + drawConstants(); + } + } + break; + + case SOLAYOUTLST: + iPos = xLayoutListBox.getSelectedItemPos(); + if (iPos != iOldLayoutPos) + { + iOldLayoutPos = iPos; + CurReportDocument.liveupdate_changeLayoutTemplate(LayoutFiles[1][iPos]/*, Desktop.getBitmapPath(m_xMSF)*/); + if(!isBuilderInstalled) + { + clearConstants(); + drawConstants(); + } + } + break; + + case SOOPTLANDSCAPE: + // CurReportDocument.getDoc().changePageOrientation(true); + try + { + CurReportDocument.setPageOrientation(SOOPTLANDSCAPE); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + } + Helper.setUnoPropertyValue(aOrientationImage, PropertyNames.PROPERTY_IMAGEURL, "private:graphicrepository/wizards/res/landscape_32.png"); + + break; + + case SOOPTPORTRAIT: + // CurReportDocument.getDoc().changePageOrientation( false); + try + { + CurReportDocument.setPageOrientation(SOOPTPORTRAIT); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + } + + CurUnoDialog.setControlProperty("imgOrientation", PropertyNames.PROPERTY_IMAGEURL, Desktop.getBitmapPath(m_xMSF) + "/portrait.gif"); + Helper.setUnoPropertyValue(aOrientationImage, PropertyNames.PROPERTY_IMAGEURL, "private:graphicrepository/wizards/res/portrait_32.png"); + break; + + default: + break; + } + } + catch (RuntimeException e) + { + e.printStackTrace(); + } + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + } + + public void disposing(EventObject eventObject) + { + } + } + + class ActionListenerImpl implements com.sun.star.awt.XActionListener + { + + public void disposing(EventObject eventObject) + { + } + + public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) + { + try + { + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + boolean blandscape = (((Short) CurUnoDialog.getControlProperty("optLandscape", PropertyNames.PROPERTY_STATE)).shortValue() == 1); + CurReportDocument.setPageOrientation((blandscape) ? SOOPTLANDSCAPE : SOOPTPORTRAIT); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + } + } + + public void drawConstants() + { + constRangeList = searchFillInItems(1); + + XTextRange item = null; + + for (int i = 0; i < constRangeList.size(); i++) + { + item = constRangeList.get(i); + String text = item.getString().trim().toLowerCase(); + if (text.equals("#titleconst#")) + { + teTitleconst = new PlaceholderTextElement(item, CurUnoDialog.m_oResource.getResText("RID_REPORT_86"), PropertyNames.EMPTY_STRING, m_xMSF); + trTitleconst = item; + constRangeList.remove(i--); + writeTitle(teTitleconst, trTitleconst, CurUnoDialog.m_oResource.getResText("RID_REPORT_86")); + } + else if (text.equals("#authorconst#")) + { + teAuthorconst = new PlaceholderTextElement(item, CurUnoDialog.m_oResource.getResText("RID_REPORT_87"), PropertyNames.EMPTY_STRING, m_xMSF); + trAuthorconst = item; + constRangeList.remove(i--); + writeTitle(teAuthorconst, trAuthorconst, CurUnoDialog.m_oResource.getResText("RID_REPORT_87")); + } + else if (text.equals("#dateconst#")) + { + teDateconst = new PlaceholderTextElement(item, CurUnoDialog.m_oResource.getResText("RID_REPORT_88"), PropertyNames.EMPTY_STRING, m_xMSF); + trDateconst = item; + constRangeList.remove(i--); + writeTitle(teDateconst, trDateconst, CurUnoDialog.m_oResource.getResText("RID_REPORT_88")); + } + else if (text.equals("#pageconst#")) + { + tePageconst = new PlaceholderTextElement(item, CurUnoDialog.m_oResource.getResText("RID_REPORT_93"), PropertyNames.EMPTY_STRING, m_xMSF); + trPageconst = item; + constRangeList.remove(i--); + writeTitle(tePageconst, trPageconst, CurUnoDialog.m_oResource.getResText("RID_REPORT_93")); + } + } + } + + private void clearConstants() + { + constRangeList.clear(); + trTitleconst = null; + teTitleconst = null; + trAuthorconst = null; + teAuthorconst = null; + trDateconst = null; + teDateconst = null; + trPageconst = null; + tePageconst = null; + } + + private void writeTitle(TextElement te, XTextRange tr, String text) + { + te.setText(text == null ? PropertyNames.EMPTY_STRING : text); + te.write(tr); + } + + private List<XTextRange> searchFillInItems(int type) + { + try + { + XSearchable xSearchable = UnoRuntime.queryInterface(XSearchable.class, CurReportDocument.getComponent()); + XSearchDescriptor sd = xSearchable.createSearchDescriptor(); + + if(type == 0) + { + sd.setSearchString("<[^>]+>"); + } + else if(type == 1) + { + sd.setSearchString("#[^#]+#"); + } + sd.setPropertyValue("SearchRegularExpression", Boolean.TRUE); + sd.setPropertyValue("SearchWords", Boolean.TRUE); + + XIndexAccess ia = xSearchable.findAll(sd); + List<XTextRange> l = new ArrayList<XTextRange>(ia.getCount()); + for (int i = 0; i < ia.getCount(); i++) + { + try + { + l.add(UnoRuntime.queryInterface(XTextRange.class, ia.getByIndex(i))); + } + catch (Exception ex) + { + System.err.println("Nonfatal Error in finding fillins."); + } + } + return l; + } + catch (Exception ex) + { + throw new IllegalArgumentException("Fatal Error: Loading template failed: searching fillins failed", ex); + } + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportTextDocument.java b/wizards/com/sun/star/wizards/report/ReportTextDocument.java new file mode 100644 index 0000000000..1c109c0b1f --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportTextDocument.java @@ -0,0 +1,668 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.text.XRelativeTextContentRemove; +import com.sun.star.text.XTextContent; +import java.util.ArrayList; +import java.util.Comparator; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.db.*; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.ui.*; +import com.sun.star.sdb.CommandType; +import com.sun.star.text.XTextDocument; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.text.TextTableHandler; +import com.sun.star.wizards.text.TextSectionHandler; +import com.sun.star.wizards.text.TextStyleHandler; +import com.sun.star.wizards.text.TextFieldHandler; +import com.sun.star.wizards.text.ViewHandler; +import com.sun.star.wizards.document.FormHandler; +import java.util.logging.Level; +import java.util.logging.Logger; + +class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implements Comparator<FieldColumn> +{ + + private static final String ISLANDSCAPE = "IsLandscape"; + private static final String ISVISIBLE = "IsVisible"; + private static final String QUERYNAME = "QueryName"; + private static final String SIZE = "Size"; + private Object ReportPageStyle; + private Object FirstPageStyle; + public ArrayList<DBColumn> DBColumnsVector; + private RecordTable CurRecordTable; + private String sMsgCommonReportError; + private String ContentTemplatePath; + private boolean bIsCurLandscape; + public TextTableHandler oTextTableHandler; + public TextSectionHandler oTextSectionHandler; + public FormHandler oFormHandler; + private TextStyleHandler oTextStyleHandler; + public TextFieldHandler oTextFieldHandler; + public ViewHandler oViewHandler; + public static final String TBLRECORDSECTION = "Tbl_RecordSection"; + public static final String TBLGROUPSECTION = "Tbl_GroupField"; + public static final String RECORDSECTION = "RecordSection"; + public static final String GROUPSECTION = "GroupField"; + public static final String COPYOFTBLRECORDSECTION = "CopyOf" + TBLRECORDSECTION; + public static final String COPYOFTBLGROUPSECTION = "CopyOf" + TBLGROUPSECTION; + public static final String COPYOFRECORDSECTION = "CopyOf" + RECORDSECTION; + public static final String COPYOFGROUPSECTION = "CopyOf" + GROUPSECTION; + private RecordParser CurDBMetaData; + + /** Creates new ReportDocument */ + public ReportTextDocument(XMultiServiceFactory xMSF, XTextDocument _textDocument, Resource oResource, RecordParser _aRP) + { + super(xMSF, _textDocument, false); + lateInit(oResource, _aRP); + } + + public ReportTextDocument(XMultiServiceFactory xMSF, String _sPreviewURL, Resource oResource, RecordParser _aRP) + { + super(xMSF, _sPreviewURL, true, null); + lateInit(oResource, _aRP); + } + + private void lateInit(Resource oResource, RecordParser _aRecordParser) + { + oTextTableHandler = new TextTableHandler(xTextDocument); + oTextSectionHandler = new TextSectionHandler(xMSFDoc, xTextDocument); + oFormHandler = new FormHandler(xMSFDoc, xTextDocument); + oTextStyleHandler = new TextStyleHandler(xTextDocument); + oViewHandler = new ViewHandler(xTextDocument); + oTextFieldHandler = new TextFieldHandler(xMSFDoc, xTextDocument); + DBColumnsVector = new java.util.ArrayList<DBColumn>(); + NumberFormatter oNumberFormatter = oTextTableHandler.getNumberFormatter(); + CurDBMetaData = _aRecordParser; + long lDateCorrection = oNumberFormatter.getNullDateCorrection(); + oNumberFormatter.setBooleanReportDisplayNumberFormat(); + oNumberFormatter.setNullDateCorrection(lDateCorrection); + sMsgCommonReportError = oResource.getResText("RID_REPORT_72"); + sMsgCommonReportError = JavaTools.replaceSubString(sMsgCommonReportError, String.valueOf((char) 13), "<BR>"); + bIsCurLandscape = true; + getReportPageStyles(); + } + + public void swapContentTemplate(String ContentTemplatePath) + { + this.ContentTemplatePath = ContentTemplatePath; + loadSectionsfromTemplate(ContentTemplatePath); + oTextStyleHandler.loadStyleTemplates(ContentTemplatePath, "LoadTextStyles"); + if (CurRecordTable != null) + { + CurRecordTable.adjustOptimalTableWidths(xMSF, oViewHandler); + } + oViewHandler.selectFirstPage(oTextTableHandler); + } + + public void swapLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/) + { + try + { + boolean bOldIsCurLandscape = AnyConverter.toBoolean(Helper.getUnoPropertyValue(ReportPageStyle, ISLANDSCAPE)); + oTextStyleHandler.loadStyleTemplates(LayoutTemplatePath, "LoadPageStyles"); + changePageOrientation(bOldIsCurLandscape); + oViewHandler.selectFirstPage(oTextTableHandler); + } + catch (IllegalArgumentException e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + } + } + + public void createReportForm(String SOREPORTFORMNAME) + { + com.sun.star.container.XNameContainer xNamedForm = oFormHandler.insertFormbyName(SOREPORTFORMNAME); + XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, xNamedForm); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND_TYPE, Integer.toString(CurDBMetaData.getCommandType())); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, CurDBMetaData.getCommandName()); + if (CurDBMetaData.getCommandType() == CommandType.QUERY) + { + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND, ""); + //DBMetaData.CommandObject oCommand = CurDBMetaData.getQueryByName(CurDBMetaData.getCommandName()); + //oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, COMMAND, CurDBMetaData.Command); + } + else + { + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND, CurDBMetaData.Command); + } + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "GroupFieldNames", JavaTools.ArraytoString(CurDBMetaData.GroupFieldNames)); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "FieldNames", JavaTools.ArraytoString(CurDBMetaData.getFieldNames())); + String[][] sortFieldNames = CurDBMetaData.getSortFieldNames(); + if (sortFieldNames != null && sortFieldNames.length > 0) + { + final String space = ","; + final String colon = ";"; + StringBuilder orderBy = new StringBuilder(); + for (String[] sortPair : sortFieldNames) + { + orderBy.append(sortPair[0]).append(space).append(sortPair[1]).append(colon); + } + if (orderBy.length() != 0) + { + orderBy.delete(orderBy.lastIndexOf(colon), orderBy.length()); + } + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Sorting", orderBy.toString()); + } + else + { + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Sorting", ""); + } + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "RecordFieldNames", JavaTools.ArraytoString(CurDBMetaData.getRecordFieldNames())); + } + + private void getReportPageStyles() + { + try + { + Object oPageStyleFamily = oTextStyleHandler.xStyleFamiliesSupplier.getStyleFamilies().getByName("PageStyles"); + ReportPageStyle = Helper.getUnoObjectbyName(oPageStyleFamily, "Standard"); + FirstPageStyle = Helper.getUnoObjectbyName(oPageStyleFamily, "First Page"); + } + catch (Exception e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + } + } + + public void changePageOrientation(boolean bNewLandscape) + { + try + { + com.sun.star.awt.Size oNewSize; + getReportPageStyles(); + com.sun.star.awt.Size oLocSize = (com.sun.star.awt.Size) Helper.getUnoStructValue(ReportPageStyle, SIZE); + bIsCurLandscape = AnyConverter.toBoolean(Helper.getUnoPropertyValue(ReportPageStyle, ISLANDSCAPE)); + if (bIsCurLandscape != bNewLandscape) + { + oNewSize = new com.sun.star.awt.Size(oLocSize.Height, oLocSize.Width); + Helper.setUnoPropertyValue(ReportPageStyle, ISLANDSCAPE, bNewLandscape); + Helper.setUnoPropertyValue(ReportPageStyle, SIZE, oNewSize); + Helper.setUnoPropertyValue(FirstPageStyle, ISLANDSCAPE, bNewLandscape); + Helper.setUnoPropertyValue(FirstPageStyle, SIZE, oNewSize); + AnyConverter.toInt(Helper.getUnoPropertyValue(ReportPageStyle, "LeftMargin")); + AnyConverter.toInt(Helper.getUnoPropertyValue(ReportPageStyle, "RightMargin")); + if (CurRecordTable != null) + { + CurRecordTable.adjustOptimalTableWidths(xMSF, oViewHandler); + } + } + } + catch (IllegalArgumentException e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + } + } + + private boolean loadSectionsfromTemplate(String sTemplateUrl) + { + try + { + int i; + DBColumn CurDBColumn; + int GroupCount = CurDBMetaData.GroupFieldNames.length; + CurRecordTable = null; + for (i = 0; i < GroupCount; i++) + { + String SectionName = GROUPSECTION + Integer.toString(i + 1); + oTextTableHandler.renameTextTable("Tbl_" + SectionName, "MyTextTable"); + oTextSectionHandler.linkSectiontoTemplate(sTemplateUrl, SectionName); + oTextTableHandler.renameTextTable("MyTextTable", "Tbl_" + SectionName); + } + if (oTextSectionHandler.xTextSectionsSupplier.getTextSections().getElementNames().length > CurDBMetaData.GroupFieldNames.length) + { + oTextSectionHandler.linkSectiontoTemplate(sTemplateUrl, RECORDSECTION); + CurRecordTable = new RecordTable(oTextTableHandler); + insertColumnstoRecordTable(); + } + for (i = 0; i < GroupCount; i++) + { + CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, CurDBMetaData.GroupFieldNames[i], TBLGROUPSECTION + (i + 1)); + CurDBColumn.formatValueCell(); + DBColumnsVector.set(i, CurDBColumn); + replaceFieldValueInGroupTable(CurDBColumn, i); + } + return true; + } + catch (Exception e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + return false; + } + } + + public void setupRecordSection(String TemplateName) + { + this.ContentTemplatePath = TemplateName; + if (CurDBMetaData.getRecordFieldNames().length > 0) + { + boolean bAddParagraph = true; + if (CurDBMetaData.GroupFieldNames != null) + { + bAddParagraph = (CurDBMetaData.GroupFieldNames.length == 0); + } + oTextSectionHandler.insertTextSection(RECORDSECTION, TemplateName, bAddParagraph); + CurRecordTable = new RecordTable(oTextTableHandler); + insertColumnstoRecordTable(); + if (CurRecordTable != null) + { + CurRecordTable.adjustOptimalTableWidths(xMSF, oViewHandler); + } + } + else + { + CurRecordTable = null; + } + } + + public void refreshGroupFields(String[] _sNewNames) + { + int nSize = DBColumnsVector.size(); + for (int i = 0; i < nSize; i++) + { + DBColumn CurDBColumn = DBColumnsVector.get(i); + String sFieldName = CurDBColumn.CurDBField.getFieldName(); + if (!sFieldName.equals(_sNewNames[i])) + { + CurDBColumn.CurDBField = CurDBMetaData.getFieldColumnByDisplayName(_sNewNames[i]); + CurDBColumn.insertColumnData(oTextFieldHandler, bIsCurLandscape); + } + } + } + + private void updateTextSections(String[] SelGroupNames) + { + String TableName; + DBColumn OldDBColumn; + DBColumn CurDBColumn; + // XNameAccess xTableNames = oTextTableHandler.xTextTablesSupplier.getTextTables(); + int GroupFieldCount = SelGroupNames.length; + for (int i = 0; i < GroupFieldCount; i++) + { + TableName = TBLGROUPSECTION + Integer.toString(i + 1); + OldDBColumn = DBColumnsVector.get(i); + CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, SelGroupNames[i], TableName, OldDBColumn); + CurDBColumn.formatValueCell(); + DBColumnsVector.set(i, CurDBColumn); + CurDBColumn.insertColumnData(oTextFieldHandler, this.bIsCurLandscape); + } + } + + private void replaceFieldValueInGroupTable(DBColumn CurDBColumn, int TableIndex) + { + String TableName = TBLGROUPSECTION + (TableIndex + 1); + // Note: for some reason the table might lose its name and has to be renamed therefore + String OldTableName = CurDBColumn.xTableName.getName(); + if (OldTableName.compareTo(TableName) != 0) + { + CurDBColumn.xTableName.setName(TableName); + } + CurDBColumn.insertColumnData(oTextFieldHandler, this.bIsCurLandscape); + CurDBColumn.setCellFont(); + } + + private void insertColumnstoRecordTable() + { + int GroupCount = CurDBMetaData.GroupFieldNames.length; + DBColumn CurDBColumn; + // Note for some reason the table might lose its name and has to be renamed therefore + String OldTableName = CurRecordTable.xTableName.getName(); + if (OldTableName.compareTo(TBLRECORDSECTION) != 0) + { + CurRecordTable = new RecordTable(oTextTableHandler); + } + com.sun.star.table.XTableColumns xColumns = CurRecordTable.xTextTable.getColumns(); + int ColCount = xColumns.getCount(); + int RecordCount = CurDBMetaData.getRecordFieldNames().length; + if (ColCount > RecordCount) + { + int RemoveCount = ColCount - RecordCount; + xColumns.removeByIndex(0, RemoveCount); + } + else if (ColCount < RecordCount) + { + int AddCount = RecordCount - ColCount; + CurRecordTable.xTextTable.getColumns().insertByIndex(ColCount, AddCount); + } + for (int i = 0; i < RecordCount; i++) + { + CurDBColumn = new DBColumn(CurRecordTable, oTextTableHandler, CurDBMetaData, i, true); + CurDBColumn.initializeNumberFormat(); + CurDBColumn.insertColumnData(oTextFieldHandler, this.bIsCurLandscape); + if (DBColumnsVector.size() <= (i + GroupCount)) + { + DBColumnsVector.add(CurDBColumn); + } + else + { + DBColumnsVector.set(i + GroupCount, CurDBColumn); + } + } + } + + public boolean addGroupNametoDocument(String CurGroupTitle, ArrayList<String> GroupFieldVector, ArrayList<String> ReportPath, int iSelCount) + { + DBColumn CurDBColumn = null; + int GroupCount = GroupFieldVector.size(); + if (GroupCount < 4) + { + removeGroupNamesofRecordTable(iSelCount); + FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByTitle(CurGroupTitle); + GroupFieldVector.add(CurFieldColumn.getFieldName()); + GroupCount += 1; + try + { + String sPath = FileAccess.getPathFromList(xMSF, ReportPath, "cnt-default.ott"); + oTextSectionHandler.insertTextSection(GROUPSECTION + GroupCount, sPath, GroupCount == 1); + CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, CurFieldColumn.getFieldName(), TBLGROUPSECTION + (GroupCount)); + CurDBColumn.formatValueCell(); + DBColumnsVector.add(CurDBColumn); + replaceFieldValueInGroupTable(CurDBColumn, GroupCount - 1); + } + catch (Exception exception) + { + showCommonReportErrorBox(exception); + } + + } + + return (CurDBColumn != null); + } + + public void removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, java.util.ArrayList<String> GroupFieldVector) + { + removeGroupNamesofRecordTable(NewSelGroupNames.length + 1); + FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByTitle(CurGroupTitle); + GroupFieldVector.remove(CurFieldColumn.getFieldName()); + oTextSectionHandler.removeLastTextSection(); + oTextTableHandler.removeLastTextTable(); + // if the previously selected item is somewhere in the middle of the listbox (and not at the end) the + // Textsections have to be updated + if (JavaTools.FieldInList(NewSelGroupNames, CurGroupTitle) == -1) + { + updateTextSections(NewSelGroupNames); + } + int iSelItemCount = NewSelGroupNames.length; + DBColumnsVector.remove(iSelItemCount); + } + + private void removeGroupNamesofRecordTable(int GroupFieldCount) + { + int CurFieldCount = DBColumnsVector.size(); + if (CurFieldCount > GroupFieldCount) + { + for (int i = CurFieldCount - 1; i >= GroupFieldCount; i--) + { + DBColumnsVector.remove(i); + } + } + } + + private void showCommonReportErrorBox(Exception exception) + { + String SystemContentPath = JavaTools.convertfromURLNotation(ContentTemplatePath); + String sMsgCurCommonReportError = JavaTools.replaceSubString(sMsgCommonReportError, SystemContentPath, "%PATH"); + CurDBMetaData.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgCurCommonReportError); + exception.printStackTrace(System.err); + } + + public void getallDBColumns() + { + try + { + DBColumn CurDBColumn; + for (int i = 0; i < CurDBMetaData.FieldColumns.length; i++) + { + if (i < CurDBMetaData.GroupFieldNames.length) + { + CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, CurDBMetaData.GroupFieldNames[i], COPYOFTBLGROUPSECTION + (i + 1)); + } + else + { + if (CurRecordTable == null) + { + CurRecordTable = new RecordTable(oTextTableHandler); + } + CurDBColumn = new DBColumn(CurRecordTable, oTextTableHandler, CurDBMetaData, i - CurDBMetaData.GroupFieldNames.length); + } + if (CurDBColumn.xNameCell != null) + { + DBColumnsVector.add(CurDBColumn); + } + else + { + String DelFieldName; + if (i < CurDBMetaData.GroupFieldNames.length) + { + DelFieldName = CurDBMetaData.GroupFieldNames[i]; + CurDBMetaData.GroupFieldNames = JavaTools.removefromList(CurDBMetaData.GroupFieldNames, new String[] + { + DelFieldName + }); + CurDBMetaData.GroupFieldColumns = removeFieldColumnByFieldName(DelFieldName, CurDBMetaData.GroupFieldColumns); + } + else + { + DelFieldName = CurDBMetaData.getRecordFieldName(i - CurDBMetaData.GroupFieldNames.length); + String[] aNewList = JavaTools.removefromList(CurDBMetaData.getRecordFieldNames(), new String[] + { + DelFieldName + }); + CurDBMetaData.setRecordFieldNames(aNewList); + CurDBMetaData.RecordFieldColumns = removeFieldColumnByFieldName(DelFieldName, CurDBMetaData.RecordFieldColumns); + CurDBMetaData.FieldColumns = removeFieldColumnByFieldName(DelFieldName, CurDBMetaData.FieldColumns); + + } + i--; + } + } + java.util.Arrays.sort(CurDBMetaData.RecordFieldColumns, this); + } + catch (Exception exception) + { + showCommonReportErrorBox(exception); + } + } + + public int compare(FieldColumn oFieldColumn1, FieldColumn oFieldColumn2) + { + DBColumn oDBColumn1 = getDBColumnByName(oFieldColumn1.getFieldName()); + DBColumn oDBColumn2 = getDBColumnByName(oFieldColumn2.getFieldName()); + if (oDBColumn1.ValColumn < oDBColumn2.ValColumn) + { + return -1; + } + else if (oDBColumn1.ValColumn == oDBColumn2.ValColumn) + { + return 0; + } + else + { + return 1; + } + } + + private DBColumn getDBColumnByName(String _FieldName) + { + for (int i = 0; i < DBColumnsVector.size(); i++) + { + DBColumn oDBColumn = DBColumnsVector.get(i); + if (oDBColumn.CurDBField.getFieldName().equals(_FieldName)) + { + return oDBColumn; + } + } + throw new IllegalArgumentException("Searching for column " + _FieldName + " failed"); + } + + private static FieldColumn[] removeFieldColumnByFieldName(String _FieldName, FieldColumn[] _FieldColumns) + { + try + { + ArrayList<FieldColumn> aFieldColumns = new ArrayList<FieldColumn>(); + for (int i = 0; i < _FieldColumns.length; i++) + { + FieldColumn CurFieldColumn = _FieldColumns[i]; + if (!CurFieldColumn.getFieldName().equals(_FieldName)) + { + aFieldColumns.add(CurFieldColumn); + } + } + FieldColumn[] aRetList = new FieldColumn[aFieldColumns.size()]; + aFieldColumns.toArray(aRetList); + return aRetList; + } + catch (RuntimeException e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + return null; + } + } + + public void removeAllVisibleTextSections() + { + int GroupCount = CurDBMetaData.GroupFieldNames.length; + String[] sInvisibleSectionNames = new String[GroupCount + 1]; + sInvisibleSectionNames[0] = RECORDSECTION; + for (int i = 1; i <= GroupCount; i++) + { + sInvisibleSectionNames[i] = GROUPSECTION + i; + } + XNameAccess xNameAccessTextSections = UnoRuntime.queryInterface(XNameAccess.class, oTextSectionHandler.xTextSectionsSupplier.getTextSections()); + String[] sSectionNames = xNameAccessTextSections.getElementNames(); + for (int i = 0; i < sSectionNames.length; i++) + { + String sSectionName = sSectionNames[i]; + if (JavaTools.FieldInList(sInvisibleSectionNames, sSectionName) < 0) + { + oTextSectionHandler.removeTextSectionbyName(sSectionName); + } + } + } + + private String[] getLayoutTextTableNames() + { + int GroupCount = CurDBMetaData.GroupFieldNames.length; + String[] sLayoutTableNames = new String[GroupCount + 1]; + for (int i = 0; i < GroupCount; i++) + { + sLayoutTableNames[i] = TBLGROUPSECTION + (i + 1); + } + sLayoutTableNames[GroupCount] = TBLRECORDSECTION; + return sLayoutTableNames; + } + + public void removeNonLayoutTextTables() + { + String[] sLayoutTableNames = getLayoutTextTableNames(); + XNameAccess xNameAccessTextTables = UnoRuntime.queryInterface(XNameAccess.class, oTextTableHandler.xTextTablesSupplier.getTextTables()); + String[] sTableNames = xNameAccessTextTables.getElementNames(); + for (int i = 0; i < sTableNames.length; i++) + { + String sTableName = sTableNames[i]; + if (JavaTools.FieldInList(sLayoutTableNames, sTableName) < 0) + { + oTextTableHandler.removeTextTablebyName(sTableName); + } + } + } + + public void removeLayoutTextTables() + { + String[] sLayoutTableNames = getLayoutTextTableNames(); + XNameAccess xNameAccessTextTables = UnoRuntime.queryInterface(XNameAccess.class, oTextTableHandler.xTextTablesSupplier.getTextTables()); + XRelativeTextContentRemove xRelativeTextContentRemove = UnoRuntime.queryInterface(XRelativeTextContentRemove.class, xText); + String[] sTableNames = xNameAccessTextTables.getElementNames(); + for (int i = 0; i < sTableNames.length; i++) + { + String sTableName = sTableNames[i]; + if (JavaTools.FieldInList(sLayoutTableNames, sTableName) > -1) + { + if (!sTableName.equals(sLayoutTableNames[0])) + { + XTextContent xTextContent = UnoRuntime.queryInterface(XTextContent.class, oTextTableHandler.getByName(sTableName)); + boolean bleaveloop = false; + while (!bleaveloop) + { + try + { + xRelativeTextContentRemove.removeTextContentAfter(xTextContent); + // IllegalArgumentException may be thrown when no paragraphbreak is there + } + catch (IllegalArgumentException iexception) + { + bleaveloop = true; + } + } + } + oTextTableHandler.removeTextTablebyName(sTableName); + } + } + } + + public void setLayoutSectionsVisible(boolean _IsVisible) + { + try + { + XNameAccess xTextSections = oTextSectionHandler.xTextSectionsSupplier.getTextSections(); + Object oTextSection; + int GroupFieldCount = CurDBMetaData.GroupFieldNames.length; + for (int i = 0; i < GroupFieldCount; i++) + { + oTextSection = xTextSections.getByName(GROUPSECTION + String.valueOf(i + 1)); + Helper.setUnoPropertyValue(oTextSection, ISVISIBLE, _IsVisible); + } + if (xTextSections.hasByName(RECORDSECTION)) + { + oTextSection = xTextSections.getByName(RECORDSECTION); + Helper.setUnoPropertyValue(oTextSection, ISVISIBLE, _IsVisible); + } + } + catch (Exception e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + } + } + + public void removeCopiedTextSections() + { + int GroupCount = CurDBMetaData.GroupFieldNames.length; + String[] sCopyTextSections = new String[GroupCount + 1]; + String[] sCopyTextTables = new String[GroupCount + 1]; + sCopyTextSections[0] = COPYOFRECORDSECTION; + sCopyTextTables[0] = COPYOFTBLRECORDSECTION; + for (int i = 1; i <= GroupCount; i++) + { + sCopyTextSections[i] = COPYOFGROUPSECTION + (i); + sCopyTextTables[i] = COPYOFTBLGROUPSECTION + (i); + } + for (int i = 0; i <= GroupCount; i++) + { + oTextTableHandler.removeTextTablebyName(sCopyTextTables[i]); + oTextSectionHandler.removeTextSectionbyName(sCopyTextSections[i]); + } + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java new file mode 100644 index 0000000000..590d544738 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java @@ -0,0 +1,831 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNamed; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.XComponent; +import com.sun.star.sdb.CommandType; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.Any; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.InvalidQueryException; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.Resource; +import com.sun.star.lang.XMultiServiceFactory; + +import com.sun.star.sdb.application.DatabaseObject; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.SystemDialog; +import com.sun.star.wizards.db.DBMetaData; +import com.sun.star.wizards.document.OfficeDocument; +import com.sun.star.wizards.ui.UIConsts; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class ReportTextImplementation extends ReportImplementationHelper implements IReportDocument +{ + + private ReportTextDocument m_aDoc; + private Object m_aInitialDoc; + private Resource m_resource; + private XDatabaseDocumentUI m_documentUI; + + private void setInitialDocument(Object _aDoc) + { + m_aInitialDoc = _aDoc; + } + + /** + * This is a TEMPORARY function to give direct access to the old text document. + * We have to remove this!!! + * @return + */ + private ReportTextDocument getDoc() + { + if (m_aDoc == null) + { + if (m_aInitialDoc instanceof XTextDocument) + { + m_aDoc = new ReportTextDocument(getMSF(), (XTextDocument) m_aInitialDoc, m_resource, getRecordParser()); + } + else if (m_aInitialDoc instanceof String) + { + m_aDoc = new ReportTextDocument(getMSF(), (String) m_aInitialDoc, m_resource, getRecordParser()); + } + else + { + throw new RuntimeException("Unknown type for setInitialDocument() given."); + } + } + return m_aDoc; + } + + public void clearDocument() + { + getDoc().oTextSectionHandler.removeAllTextSections(); + getDoc().oTextTableHandler.removeAllTextTables(); + getDoc().DBColumnsVector = new ArrayList<DBColumn>(); + } + + protected ReportTextImplementation( XMultiServiceFactory i_serviceFactory ) + { + super( i_serviceFactory, ReportLayouter.SOOPTLANDSCAPE ); + } + + public void initialize( final XDatabaseDocumentUI i_documentUI, final Resource i_resource ) + { + m_documentUI = i_documentUI; + m_resource = i_resource; + + if ( m_aInitialDoc == null ) + setInitialDocument( getLayoutPath() ); + + initialResources(); + } + + static IReportDocument create( XMultiServiceFactory i_serviceFactory, XDatabaseDocumentUI i_documentUI, XTextDocument i_initialDocument, Resource i_resources ) + { + ReportTextImplementation a = new ReportTextImplementation( i_serviceFactory ); + a.setInitialDocument(i_initialDocument); + a.initialize( i_documentUI, i_resources ); + return a; + } + + public XWindowPeer getWizardParent() + { + return getDoc().xWindowPeer; + } + private static String sMsgQueryCreationImpossible; + private static String sReportFormNotExisting; + private static String sMsgEndAutopilot; + + private void initialResources() + { + sReportFormNotExisting = m_resource.getResText("RID_REPORT_64"); + sMsgQueryCreationImpossible = m_resource.getResText("RID_REPORT_65"); + m_resource.getResText("RID_REPORT_66"); + sMsgEndAutopilot = m_resource.getResText("RID_DB_COMMON_33"); + m_resource.getResText("RID_DB_COMMON_14"); + } + + private void addTextSectionCopies() + { + m_aDoc.setLayoutSectionsVisible(false); + XTextCursor xTextCursor = ReportTextDocument.createTextCursor(m_aDoc.xTextDocument.getText()); + xTextCursor.gotoStart(false); + for (int i = 0; i < getRecordParser().GroupFieldNames.length; i++) + { + XNamed xNamedTextSection = addLinkedTextSection(xTextCursor, ReportTextDocument.GROUPSECTION + Integer.toString(i + 1), null, null); + xNamedTextSection.setName(ReportTextDocument.COPYOFGROUPSECTION + (i + 1)); + renameTableofLastSection(ReportTextDocument.COPYOFTBLGROUPSECTION + (i + 1)); + } + if (getRecordParser().getRecordFieldNames().length > 0) + { + XNamed xNamedTextSection = addLinkedTextSection(xTextCursor, ReportTextDocument.RECORDSECTION, null, null); + xNamedTextSection.setName(ReportTextDocument.COPYOFRECORDSECTION); + renameTableofLastSection(ReportTextDocument.COPYOFTBLRECORDSECTION); + } + } + + private XNamed addLinkedTextSection(XTextCursor xTextCursor, String sLinkRegion, DBColumn CurDBColumn, Object CurGroupValue) + { + XNamed xNamedTextSection = null; + try + { + XInterface xTextSection = (XInterface) getDocumentServiceFactory().createInstance("com.sun.star.text.TextSection"); + XTextContent xTextSectionContent = UnoRuntime.queryInterface( XTextContent.class, xTextSection ); + xNamedTextSection = UnoRuntime.queryInterface( XNamed.class, xTextSection ); + xTextCursor.gotoEnd(false); + xTextCursor.getText().insertTextContent(xTextCursor, xTextSectionContent, true); + Helper.setUnoPropertyValue(xTextSection, "LinkRegion", sLinkRegion); + if (CurDBColumn != null) + { + boolean bIsGroupTable = (!sLinkRegion.equals(ReportTextDocument.RECORDSECTION)); + if (bIsGroupTable) + { + XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); + XCellRange xCellRange = UnoRuntime.queryInterface( XCellRange.class, xTextTable ); + CurDBColumn.modifyCellContent(xCellRange, CurGroupValue); + } + } + } + catch (Exception ex) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); + } + return xNamedTextSection; + } + + private void renameTableofLastSection(String _snewname) + { + XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); + XNamed xNamedTable = UnoRuntime.queryInterface( XNamed.class, xTextTable ); + xNamedTable.setName(_snewname); + } + + private int showMessageBox(String windowServiceName, int windowAttribute, String MessageText) + { + return SystemDialog.showMessageBox(getMSF(), getWizardParent(), windowServiceName, windowAttribute, MessageText); + } + + public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] _properties) + { + try + { + XNameContainer xNamedForms = getDoc().oFormHandler.getDocumentForms(); + Object oDBForm = Helper.getUnoObjectbyName(xNamedForms, ReportWizard.SOREPORTFORMNAME); + boolean bgetConnection; + if (oDBForm != null) + { + XNameAccess xNamedForm = UnoRuntime.queryInterface( XNameAccess.class, oDBForm ); + getRecordParser().Command = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, PropertyNames.COMMAND); + String sCommandType = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, PropertyNames.COMMAND_TYPE); + String sGroupFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "GroupFieldNames"); + String sFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "FieldNames"); + String sRecordFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "RecordFieldNames"); + + String sorting = PropertyNames.EMPTY_STRING; + if ( xNamedForm.hasByName( "Sorting" ) ) + sorting = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "Sorting"); + + String sQueryName = PropertyNames.EMPTY_STRING; + if ( xNamedForm.hasByName( "QueryName" ) ) + sQueryName = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "QueryName"); + + String[] sFieldNameList = JavaTools.ArrayoutofString(sFieldNames, PropertyNames.SEMI_COLON); + String[] sNewList = JavaTools.ArrayoutofString(sRecordFieldNames, PropertyNames.SEMI_COLON); + if ( sorting.length() > 0) + { + String[] sortList = JavaTools.ArrayoutofString(sorting, PropertyNames.SEMI_COLON); + ArrayList<String[]> aSortFields = new ArrayList<String[]>(); + for (String sortEntry : sortList) + { + aSortFields.add(JavaTools.ArrayoutofString(sortEntry, ",")); + } + String[][] sortFieldNames = new String[aSortFields.size()][2]; + aSortFields.toArray(sortFieldNames); + getRecordParser().setSortFieldNames(sortFieldNames); + } + getRecordParser().setRecordFieldNames(sNewList); + getRecordParser().GroupFieldNames = JavaTools.ArrayoutofString(sGroupFieldNames, PropertyNames.SEMI_COLON); + int nOrigCommandType = Integer.parseInt(sCommandType); + getRecordParser().setCommandType(nOrigCommandType); + + sMsgQueryCreationImpossible = JavaTools.replaceSubString(sMsgQueryCreationImpossible, getRecordParser().Command, "<STATEMENT>"); + bgetConnection = getRecordParser().getConnection(_properties); + int nCommandType = com.sun.star.sdb.CommandType.COMMAND; + boolean bexecute = false; + if (bgetConnection) + { + if ((getRecordParser().getCommandType() == CommandType.QUERY) && (getRecordParser().Command.equals(PropertyNames.EMPTY_STRING))) + { + DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); + if (getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) + { + getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND); + } + else + { + nCommandType = com.sun.star.sdb.CommandType.QUERY; + getRecordParser().Command = sQueryName; + } + } + + bexecute = getRecordParser().executeCommand(nCommandType); //sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot, sFieldNameList, true); + if (bexecute) + { + bexecute = getRecordParser().getFields(sFieldNameList, true); + + boolean addSort = true; + if ( (nOrigCommandType == CommandType.QUERY) && !sQueryName.equals(PropertyNames.EMPTY_STRING) ) + { + DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); + if (!getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) + addSort = false; + } + if ( !(addSort && bexecute) ) + { + return bexecute; + } + getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command); + getRecordParser().getSQLQueryComposer().prependSortingCriteria(); + getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery(); + + bexecute = getRecordParser().executeCommand(nCommandType); + } + return bexecute; + } + else + { + return false; + } + } + else + { + sReportFormNotExisting = JavaTools.replaceSubString(sReportFormNotExisting, ReportWizard.SOREPORTFORMNAME, "<REPORTFORM>"); + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sReportFormNotExisting + (char) 13 + sMsgEndAutopilot); + return false; + } + } + catch (InvalidQueryException queryexception) + { + return false; + } + catch (java.lang.Exception ex) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); + return false; + } + } + private boolean m_bStopProcess; + + public void StopProcess() + { + m_bStopProcess = true; + } + + public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF) + { + try + { + int ColIndex; + boolean breset; + Object oTable; + ArrayList<Object[]> DataVector = new ArrayList<Object[]>(); + DBColumn CurDBColumn; + Object CurGroupValue; + String CurGroupTableName; + getDoc().oTextFieldHandler.fixDateFields(true); + getDoc().removeAllVisibleTextSections(); + getDoc().removeNonLayoutTextTables(); + addTextSectionCopies(); + getDoc().getallDBColumns(); + int GroupFieldCount = getRecordParser().GroupFieldNames.length; + int FieldCount = getRecordParser().FieldColumns.length; + Object[] OldGroupFieldValues = new Object[GroupFieldCount]; + int RecordFieldCount = FieldCount - GroupFieldCount; + XTextDocument xTextDocument = getDoc().xTextDocument; + XTextCursor xTextCursor = ReportTextDocument.createTextCursor(getDoc().xTextDocument.getText()); + xTextDocument.lockControllers(); + + if (getRecordParser().ResultSet.next()) + { + replaceUserFields(); + Helper.setUnoPropertyValue(xTextCursor, "PageDescName", "First Page"); + for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++) + { + CurGroupTableName = ReportTextDocument.TBLGROUPSECTION + Integer.toString(ColIndex + 1); + oTable = getDoc().oTextTableHandler.xTextTablesSupplier.getTextTables().getByName(CurGroupTableName); + CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex); + OldGroupFieldValues[ColIndex] = CurGroupValue; + CurDBColumn = getDoc().DBColumnsVector.get(ColIndex); + addLinkedTextSection(xTextCursor, ReportTextDocument.GROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue); //COPYOF!!!! + } + if (getRecordParser().getcurrentRecordData(DataVector)) + { + m_bStopProcess = false; + while ((getRecordParser().ResultSet.next()) && (!m_bStopProcess)) + { + breset = false; + for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++) + { + CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex); + if ((!CurGroupValue.equals(OldGroupFieldValues[ColIndex])) || (breset)) + { + breset = true; + insertDataToRecordTable(xTextCursor, DataVector, RecordFieldCount); + CurDBColumn = getDoc().DBColumnsVector.get(ColIndex); + addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue); + OldGroupFieldValues[ColIndex] = CurGroupValue; + breset = ColIndex != GroupFieldCount - 1; + } + } + getRecordParser().getcurrentRecordData(DataVector); + } + insertDataToRecordTable(xTextCursor, DataVector, RecordFieldCount); + } + else + { + getDoc().unlockallControllers(); + return; + } + } + else + { + for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++) + { + CurDBColumn = getDoc().DBColumnsVector.get(ColIndex); + Object oValue = PropertyNames.EMPTY_STRING; + addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, oValue); + } + addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFRECORDSECTION, null, null); + Object[][] RecordArray = new Object[1][RecordFieldCount]; + for (int i = 0; i < RecordArray[0].length; i++) + { + RecordArray[0][i] = Any.VOID; + } + XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); + OfficeDocument.ArraytoCellRange(RecordArray, xTextTable, 0, 1); + } + getDoc().oTextSectionHandler.breakLinkofTextSections(); + } + catch (Exception ex) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); + } + getDoc().unlockallControllers(); + getDoc().setLayoutSectionsVisible(false); + getDoc().removeCopiedTextSections(); + getDoc().oTextSectionHandler.removeInvisibleTextSections(); + getDoc().removeLayoutTextTables(); + } + + private void insertDataToRecordTable(XTextCursor xTextCursor, ArrayList<Object[]> DataVector, int FieldCount) + { + int DataLength = DataVector.size(); + if ((FieldCount > 0) && (DataLength > 0)) + { + addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFRECORDSECTION, null, null); + Object[][] RecordArray = new Object[DataLength][FieldCount]; + DataVector.toArray(RecordArray); + XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); + if (DataLength > 1) + { + xTextTable.getRows().insertByIndex(xTextTable.getRows().getCount(), DataLength - 1); + } + OfficeDocument.ArraytoCellRange(RecordArray, xTextTable, 0, 1); + } + DataVector.clear(); + } + private void replaceUserFields() + { + DBColumn CurDBColumn; + XTextCursor xNameCellCursor; + String FieldContent; + int iCount = getDoc().DBColumnsVector.size(); + for (int i = 0; i < iCount; i++) + { + CurDBColumn = getDoc().DBColumnsVector.get(i); + xNameCellCursor = ReportTextDocument.createTextCursor(CurDBColumn.xNameCell); + xNameCellCursor.gotoStart(false); + FieldContent = getDoc().oTextFieldHandler.getUserFieldContent(xNameCellCursor); + if (!FieldContent.equals(PropertyNames.EMPTY_STRING)) + { + xNameCellCursor.goRight((short) 1, true); + xNameCellCursor.setString(FieldContent); + } + } + } + + public XFrame getFrame() + { + return m_aDoc.xFrame; + } + + private XMultiServiceFactory getDocumentServiceFactory() + { + return m_aDoc.xMSFDoc; + } + + public void store(String _sName, int _nOpenMode) throws com.sun.star.uno.Exception + { + getDoc().createReportForm(ReportWizard.SOREPORTFORMNAME); + getDoc().oTextFieldHandler.updateDateFields(); + getDoc().oTextFieldHandler.fixDateFields(false); + if ((_nOpenMode == ReportFinalizer.SOCREATETEMPLATE || _nOpenMode == ReportFinalizer.SOUSETEMPLATE)) + { + getDoc().oTextSectionHandler.breakLinkofTextSections(); + getRecordParser().storeDatabaseDocumentToTempPath(getComponent(), _sName); + } + } + + public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, ArrayList<String> GroupFieldVector, ArrayList<String> ReportPath, int iSelCount) + { + return getDoc().addGroupNametoDocument(CurGroupTitle, GroupFieldVector, ReportPath, iSelCount); + } + + public void refreshGroupFields(String[] _sNewNames) + { + getDoc().refreshGroupFields(_sNewNames); + } + + public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, ArrayList<String> GroupFieldVector) + { + getDoc().removeGroupName(NewSelGroupNames, CurGroupTitle, GroupFieldVector); + } + + public void setPageOrientation(int nOrientation) throws com.sun.star.lang.IllegalArgumentException + { + // LLA: should we lock controllers here? + // CurReportDocument.getDoc().xTextDocument.lockControllers(); + if (nOrientation == ReportLayouter.SOOPTLANDSCAPE) + { + getDoc().changePageOrientation(true); + } + else if (nOrientation == ReportLayouter.SOOPTPORTRAIT) + { + getDoc().changePageOrientation(false); + } + else + { + throw new com.sun.star.lang.IllegalArgumentException("Unknown Orientation."); + } + } + + public void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/) + { + getDoc().swapLayoutTemplate(LayoutTemplatePath/*, BitmapPath*/); + } + + public void liveupdate_changeContentTemplate(String ContentTemplatePath) + { + getDoc().swapContentTemplate(ContentTemplatePath); + } + + public void layout_setupRecordSection(String TemplateName) + { + getDoc().setupRecordSection(TemplateName); + } + + public void removeTextTableAndTextSection() + { + getDoc().oTextSectionHandler.removeTextSectionbyName("RecordSection"); + getDoc().oTextTableHandler.removeTextTablebyName("Tbl_RecordSection"); + } + + public void layout_selectFirstPage() + { + getDoc().oViewHandler.selectFirstPage(getDoc().oTextTableHandler); + } + + public void dispose() + { + OfficeDocument.dispose(getMSF(), getComponent()); + } + + public XComponent getComponent() + { + return getDoc().xComponent; + } + + public void liveupdate_changeUserFieldContent(String fieldname, String sfieldtitle) + { + getDoc().oTextFieldHandler.changeUserFieldContent(fieldname, sfieldtitle); + } + + public void liveupdate_updateReportTitle(String _sTitleName) + { + } + + public void addReportToDBView() + { + getRecordParser().addReportDocument(getComponent(), true); + } + + public void createAndOpenReportDocument( String sReportName, boolean _bAsTemplate, boolean _bOpenInDesign ) + { + try + { + m_documentUI.loadComponent( DatabaseObject.REPORT, sReportName, _bOpenInDesign ); + } + catch ( Exception ex ) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); + } + } + + public void initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames) + { + getRecordParser().initializeFieldColumns(FieldNames, TableName); + } + + public void setFieldTitles(String[] sFieldTitles) + { + getRecordParser().setFieldTitles(sFieldTitles); + } + + public void setSorting(String[][] aSortFieldNames) + { + getRecordParser().setSortFieldNames(aSortFieldNames); + } + + public void setGrouping(String[] aGroupFieldNames) + { + getRecordParser().prependSortFieldNames(aGroupFieldNames); + } + +// TODO: we have to change to String List!!!! + private ArrayList<String> m_aReportPath = null; + + public ArrayList<String> getReportPath() + { + if (m_aReportPath == null) + { + // Check general availability of office paths + try + { + m_aReportPath = FileAccess.getOfficePaths(getMSF(), "Template"); + FileAccess.combinePaths(getMSF(), m_aReportPath, "/wizard/report"); + } + catch (Exception e) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, e ); + } + } + return m_aReportPath; + } + + public String getContentPath() + { + ArrayList<String> aReportPath = getReportPath(); + for (int i = 0; i < aReportPath.size(); i++) + { + String sPath = aReportPath.get(i); + sPath += "/cnt-default.ott"; + if (FileAccess.isPathValid(getMSF(), sPath)) + { + return sPath; + } + } + return PropertyNames.EMPTY_STRING; + } + + public String getLayoutPath() + { + ArrayList<String> aReportPath = getReportPath(); + for (int i = 0; i < aReportPath.size(); i++) + { + String sPath = aReportPath.get(i); + sPath += "/stl-default.ott"; + if (FileAccess.isPathValid(getMSF(), sPath)) + { + return sPath; + } + } + return PropertyNames.EMPTY_STRING; + } + + public int getDefaultPageOrientation() + { + return m_nDefaultPageOrientation; + } + + public String[][] getDataLayout() + { + String[][] ContentFiles; + try + { + ContentFiles = FileAccess.getFolderTitles(getMSF(), "cnt", getReportPath()); + exchangeContentTitlesWithLocalisedOnes(ContentFiles); + } + catch (com.sun.star.wizards.common.NoValidPathException e) + { + ContentFiles = new String[2][]; + String[] a = new String[] { "DefaultLayoutOfData" }; + String[] b = new String[] { "default" }; + ContentFiles[1] = a; + ContentFiles[0] = b; + } + return ContentFiles; + } + + public String[][] getHeaderLayout() + { + String[][] LayoutFiles; + try + { + LayoutFiles = FileAccess.getFolderTitles(getMSF(), "stl", getReportPath()); + exchangeLayoutTitlesWithLocalisedOnes(LayoutFiles); + } + catch (com.sun.star.wizards.common.NoValidPathException e) + { + LayoutFiles = new String[2][]; + String[] a = new String[] { "DefaultLayoutOfHeaders" }; + String[] b = new String[] { "default" }; + LayoutFiles[1] = a; + LayoutFiles[0] = b; + } + return LayoutFiles; + } + + public void importReportData(ReportWizard _aWizard) + { + Dataimport CurDataimport = new Dataimport(_aWizard.xMSF); + CurDataimport.CurReportDocument = this; + _aWizard.importReportData(_aWizard.xMSF, CurDataimport); + } + + public void setCommandType(int _nCommand) + { + // already set somewhere else + } + + public void setCommand(String _sCommand) + { + getRecordParser().Command = _sCommand; + } + + public void checkInvariants() throws java.lang.Exception + { + } + + private void exchangeContentTitlesWithLocalisedOnes(String[][] ContentFiles) + { + for(int i = 0; i < ContentFiles[0].length; ++i) + { + if( ContentFiles[0][i].equals("Align Left - Border") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_94"); + } + else if( ContentFiles[0][i].equals("Align Left - Compact") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_95"); + } + else if( ContentFiles[0][i].equals("Align Left - Elegant") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_96"); + } + else if( ContentFiles[0][i].equals("Align Left - Highlighted") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_97"); + } + else if( ContentFiles[0][i].equals("Align Left - Modern") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_98"); + } + else if( ContentFiles[0][i].equals("Align Left - Red & Blue") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_99"); + } + else if( ContentFiles[0][i].equals("Default") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_100"); + } + else if( ContentFiles[0][i].equals("Outline - Borders") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_101"); + } + else if( ContentFiles[0][i].equals("Outline - Compact") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_102"); + } + else if( ContentFiles[0][i].equals("Outline - Elegant") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_103"); + } + else if( ContentFiles[0][i].equals("Outline - Highlighted") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_104"); + } + else if( ContentFiles[0][i].equals("Outline - Modern") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_105"); + } + else if( ContentFiles[0][i].equals("Outline - Red & Blue") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_106"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Borders") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_107"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Compact") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_108"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Elegant") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_109"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Highlighted") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_110"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Modern") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_111"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Red & Blue") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_112"); + } + } + } + + private void exchangeLayoutTitlesWithLocalisedOnes(String[][] LayoutFiles) + { + for(int i = 0; i < LayoutFiles[0].length; ++i) + { + if( LayoutFiles[0][i].equals("Bubbles") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_113"); + } + else if( LayoutFiles[0][i].equals("Cinema") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_114"); + } + else if( LayoutFiles[0][i].equals("Controlling") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_115"); + } + else if( LayoutFiles[0][i].equals("Default") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_116"); + } + else if( LayoutFiles[0][i].equals("Drafting") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_117"); + } + else if( LayoutFiles[0][i].equals("Finances") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_118"); + } + else if( LayoutFiles[0][i].equals("Flipchart") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_119"); + } + else if( LayoutFiles[0][i].equals("Formal with Company Logo") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_120"); + } + else if( LayoutFiles[0][i].equals("Generic") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_121"); + } + else if( LayoutFiles[0][i].equals("Worldmap") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_122"); + } + } + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java new file mode 100644 index 0000000000..1b3eff175d --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -0,0 +1,676 @@ +/* + * 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 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XTextListener; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XContentEnumerationAccess; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.logging.XLogger; +import com.sun.star.logging.XLoggerPool; +import com.sun.star.sdb.CommandType; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.logging.LogLevel; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.common.SystemDialog; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.DBMetaData; +import com.sun.star.wizards.db.DatabaseObjectWizard; +import com.sun.star.wizards.db.RecordParser; +import com.sun.star.wizards.db.SQLQueryComposer; +import com.sun.star.wizards.ui.CommandFieldSelection; +import com.sun.star.wizards.ui.SortingComponent; +import com.sun.star.wizards.ui.TitlesComponent; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; + +import java.lang.reflect.Method; +import java.util.Map; + +public class ReportWizard extends DatabaseObjectWizard implements XTextListener +{ + private SortingComponent CurSortingComponent; + private TitlesComponent CurTitlesComponent; + private CommandFieldSelection CurDBCommandFieldSelection; + private GroupFieldHandler CurGroupFieldHandler; + private ReportLayouter CurReportLayouter; + private ReportFinalizer CurReportFinalizer; + private int nReportMode = ReportFinalizer.SOCREATEDOCUMENT; + private String m_sReportName = PropertyNames.EMPTY_STRING; + protected static final String SOREPORTFORMNAME = "ReportSource"; + private static final int SOMAINPAGE = 1; + private static final int SOTITLEPAGE = 2; + protected static final int SOGROUPPAGE = 3; + private static final int SOSORTPAGE = 4; + protected static final int SOTEMPLATEPAGE = 5; + protected static final int SOSTOREPAGE = 6; + private IReportDocument m_reportDocument; + private static String sMsgWizardName; + private static String slblFields; + private static String slblSelFields; + private static String sShowBinaryFields; + private String[] WizardHeaderText = new String[6]; + private static String slblColumnTitles; + private static String slblColumnNames; + private static String slblTables; + protected static boolean bCloseDocument; + private boolean bHasEscapeProcessing = true; + + public ReportWizard(XMultiServiceFactory i_serviceFactory, final PropertyValue[] i_wizardContext) + { + super(i_serviceFactory, 34320, i_wizardContext); + super.addResourceHandler(); + if (getReportResources(false)) + { + Helper.setUnoPropertyValues(xDialogModel, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_MOVEABLE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_TITLE, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Integer.valueOf(210), + Boolean.TRUE, + "DialogReport", + 102, + 41, + 1, + Short.valueOf((short) 0), + sMsgWizardName, + 310 + }); + drawNaviBar(); + setRightPaneHeaders(this.WizardHeaderText); + } + } + + @Override + protected void enterStep(int nOldStep, int nNewStep) + { + if ((nOldStep >= SOTEMPLATEPAGE) && (nNewStep < SOTEMPLATEPAGE)) + { + m_reportDocument.removeTextTableAndTextSection(); + } + switch (nNewStep) + { + case SOMAINPAGE: + CurDBCommandFieldSelection.setModified(false); + break; + + case SOTITLEPAGE: + String[] aFieldNames = m_reportDocument.getRecordParser().getFieldNames(); + Map<String, String> aFieldTitleSet = m_reportDocument.getRecordParser().getFieldTitleSet(); + CurTitlesComponent.initialize(aFieldNames, aFieldTitleSet); + break; + + case SOGROUPPAGE: + CurGroupFieldHandler.initialize(); + break; + + case SOSORTPAGE: + String[] aFieldNames2 = m_reportDocument.getRecordParser().getFieldNames(); + String[][] aSortFieldNames = m_reportDocument.getRecordParser().getSortFieldNames(); + CurSortingComponent.initialize(aFieldNames2, aSortFieldNames); + int nLength = m_reportDocument.getRecordParser().GroupFieldNames.length; + CurSortingComponent.setReadOnlyUntil(nLength); + break; + + case SOTEMPLATEPAGE: + break; + + case SOSTOREPAGE: + //TODO initialize with suitable PathName + CurReportFinalizer.initialize(m_reportDocument.getRecordParser()); + break; + + default: + break; + } + } + + @Override + protected void leaveStep(int nOldStep, int nNewStep) + { + + switch (nOldStep) + { + case SOMAINPAGE: + String[] aSelectedFieldNames = CurDBCommandFieldSelection.getSelectedFieldNames(); + String aTableName = CurDBCommandFieldSelection.getSelectedCommandName(); + int nType = CurDBCommandFieldSelection.getSelectedCommandType(); + m_reportDocument.initializeFieldColumns(nType, aTableName, aSelectedFieldNames); + if (CurDBCommandFieldSelection.isModified()) + { + // cleanup document + m_reportDocument.clearDocument(); + m_reportDocument.getRecordParser().setGroupFieldNames(new String[] + { + }); + CurGroupFieldHandler.removeGroupFieldNames(); + } + break; + + case SOTITLEPAGE: + String[] sFieldTitles = CurTitlesComponent.getFieldTitles(); + // set new field name titles + // CurReportDocument.getRecordParser().setFieldTitles(sFieldTitles); + m_reportDocument.setFieldTitles(sFieldTitles); + break; + + case SOGROUPPAGE: + // TODO: DESIGN!!! a getter should return a value!!! + CurGroupFieldHandler.getGroupFieldNames(m_reportDocument.getRecordParser()); + String[] aGroupFieldNames = m_reportDocument.getRecordParser().GroupFieldNames; + // CurReportDocument.getRecordParser().prependSortFieldNames(aGroupFieldNames); + m_reportDocument.setGrouping(aGroupFieldNames); + break; + + case SOSORTPAGE: + String[][] aSortFieldNames = CurSortingComponent.getSortFieldNames(); + // CurReportDocument.getRecordParser().SortFieldNames = aSortFieldNames; + m_reportDocument.setSorting(aSortFieldNames); + // TODO: why do we make a switch here + super.enablefromStep(SOTEMPLATEPAGE, true); + break; + + case SOTEMPLATEPAGE: + break; + + case SOSTOREPAGE: + break; + + default: + break; + } + + if ((nOldStep < SOTEMPLATEPAGE) && (super.getNewStep() >= SOTEMPLATEPAGE)) + { +// this is called before SOTEMPLATEPAGE, after SOGROUPPAGE + m_reportDocument.getRecordParser().createRecordFieldNames(); + CurReportLayouter.initialize(m_reportDocument.getContentPath()); + } + } + + private void dialogFinish() + { + this.xComponent.dispose(); + if (bCloseDocument) + { + m_reportDocument.dispose(); + return; + } + + if ((nReportMode == ReportFinalizer.SOCREATETEMPLATE) + || (nReportMode == ReportFinalizer.SOUSETEMPLATE)) + { + m_reportDocument.addReportToDBView(); + boolean bOpenInDesign = (nReportMode == ReportFinalizer.SOCREATETEMPLATE); + m_reportDocument.createAndOpenReportDocument(m_sReportName, true, bOpenInDesign); + } + else + { + m_reportDocument.importReportData(this); + m_reportDocument.createAndOpenReportDocument(m_sReportName, false, false); + } + } + + private boolean executeQuery() + { + boolean bQueryCreated = false; + final RecordParser recordParser = m_reportDocument.getRecordParser(); + final SQLQueryComposer sqlQueryComposer = recordParser.getSQLQueryComposer(); + if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE) + { + if (m_reportDocument instanceof ReportTextImplementation) + { + bQueryCreated = sqlQueryComposer.setQueryCommand(this.xWindow, false, false); + m_reportDocument.setCommandType(CommandType.COMMAND); + String sQuery = sqlQueryComposer.getQuery(); + m_reportDocument.setCommand(sQuery); + } + else + { + bQueryCreated = true; + } + } + else + { + try + { + String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName(); + DBMetaData.CommandObject oCommand = recordParser.getQueryByName(sQueryName); + bHasEscapeProcessing = recordParser.hasEscapeProcessing(oCommand.getPropertySet()); + String sCommand = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND); + if (bHasEscapeProcessing) + { + if (m_reportDocument instanceof ReportTextImplementation) + { + sqlQueryComposer.m_xQueryAnalyzer.setQuery(sCommand); + sqlQueryComposer.prependSortingCriteria(); + m_reportDocument.setCommandType(CommandType.COMMAND); + m_reportDocument.setCommand(sqlQueryComposer.getQuery()); + } + } + else + { + m_reportDocument.setCommandType(CommandType.COMMAND); + m_reportDocument.setCommand(sCommand); + } + bQueryCreated = true; + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + if (!bQueryCreated) + { + super.vetoableChange(null); + } + return bQueryCreated; + } + + private void buildSteps() + { + // CurReportDocument.getDoc().xProgressBar.setValue(30); + CurDBCommandFieldSelection = new CommandFieldSelection(this, m_reportDocument.getRecordParser(), 100, slblFields, slblSelFields, slblTables, true, 34330); + CurDBCommandFieldSelection.addFieldSelectionListener(new FieldSelectionListener()); + if (!isReportBuilderInstalled()) + { + insertLabel("lblBinaryFields", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 16, sShowBinaryFields, 95, 162, 1, 210 + }); + } + CurTitlesComponent = new TitlesComponent(this, SOTITLEPAGE, 97, 37, 210, 7, slblColumnNames, slblColumnTitles, 34381); + CurTitlesComponent.addTextListener(this); + CurGroupFieldHandler = new GroupFieldHandler(m_reportDocument, this); + CurSortingComponent = new SortingComponent(this, SOSORTPAGE, 95, 30, 210, 34348); + CurReportLayouter = new ReportLayouter(xMSF, m_reportDocument, this, isReportBuilderInstalled()); + CurReportFinalizer = new ReportFinalizer(m_reportDocument, this); + bCloseDocument = true; + enableNavigationButtons(false, false, false); + } + + @Override + public boolean finishWizard() + { + final int ncurStep = getCurrentStep(); + if ((switchToStep(ncurStep, SOSTOREPAGE)) || (ncurStep == SOSTOREPAGE)) + { + if (this.executeQuery()) + { + if (CurReportFinalizer.finish()) + { + nReportMode = CurReportFinalizer.getReportOpenMode(); + m_sReportName = CurReportFinalizer.getStoreName(); + xDialog.endExecute(); + return true; + } + } + } + return false; + } + + @Override + public void cancelWizard() + { + xDialog.endExecute(); + } + + private void insertQueryRelatedSteps() + { + setRMItemLabels(m_oResource); + addRoadmap(); + int i = 0; + i = insertRoadmapItem(0, true, m_oResource.getResText("RID_QUERY_80"), SOMAINPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_68"), SOTITLEPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_11"), SOGROUPPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_12"), SOSORTPAGE); // Orderby is always supported + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_13"), SOTEMPLATEPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_14"), SOSTOREPAGE); + setRoadmapInteractive(true); + setRoadmapComplete(true); + setCurrentRoadmapItemID((short) 1); + } + + private boolean isReportBuilderInstalled() + { + //! Check if the new Report Builder Extension is available + XContentEnumerationAccess a = com.sun.star.uno.UnoRuntime.queryInterface(XContentEnumerationAccess.class, xMSF); + com.sun.star.container.XEnumeration e = a.createContentEnumeration("org.libreoffice.report.pentaho.SOReportJobFactory"); + if (e == null) + { + return false; + } + return e.hasMoreElements(); + } + + private static XLogger m_xLogger; + + private static void initializeLogger(XMultiServiceFactory _xMSF) + { + XComponentContext xContext = Helper.getComponentContext(_xMSF); + + final Object aLoggerPool = xContext.getValueByName("/singletons/com.sun.star.logging.LoggerPool"); + if (aLoggerPool == null) + { + System.out.println("Can't get singleton from logging"); + } + final XLoggerPool xLoggerPool = UnoRuntime.queryInterface(XLoggerPool.class, aLoggerPool); + m_xLogger = xLoggerPool.getNamedLogger("com.sun.star.wizards.ReportBuilder"); + } + + public static XLogger getLogger() + { + return m_xLogger; + } + + public void startReportWizard() + { + initializeLogger(xMSF); + getLogger().log(LogLevel.SEVERE, "Start Report Wizard"); + + if (isReportBuilderInstalled()) + { + Class<?> a = null; + try + { + a = Class.forName("com.sun.star.wizards.reportbuilder.ReportBuilderImplementation"); + } + catch (ClassNotFoundException e) + { + System.err.println("ReportBuilderImplementation is unavailable"); + } + if (a != null) + { + try + { + Method aMethod = a.getMethod("create", new Class[] + { + XMultiServiceFactory.class + }); + m_reportDocument = (IReportDocument) aMethod.invoke(a, xMSF + ); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + + try + { + if (m_reportDocument == null) + { + // Fallback, if there is no reportbuilder wizard implementation, we use the old wizard + m_reportDocument = new ReportTextImplementation(xMSF); + } + + m_reportDocument.initialize(m_docUI, m_oResource); + + if (m_reportDocument.getRecordParser().getConnection(m_wizardContext)) + { + buildSteps(); + + if(!isReportBuilderInstalled()) CurReportLayouter.drawConstants(); + + m_reportDocument.checkInvariants(); + + this.CurDBCommandFieldSelection.preselectCommand(m_wizardContext, false); + + createWindowPeer(m_reportDocument.getWizardParent()); + + m_reportDocument.getRecordParser().setWindowPeer(this.xControl.getPeer()); + insertQueryRelatedSteps(); + short RetValue = executeDialog(m_reportDocument.getFrame().getComponentWindow().getPosSize()); + if (RetValue == 0) + { + dialogFinish(); + } + } + m_reportDocument.getRecordParser().dispose(); + } + catch (java.io.IOException e) + { + String sMessage = e.getMessage(); + if (sMessage.equals("default.otr")) + { + sMessage = m_oResource.getResText("RID_REPORT_92"); + } + // show a dialog with the error message + SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMessage); + } + catch (java.lang.Exception jexception) + { + jexception.printStackTrace(System.err); + } + } + + public void importReportData(final XMultiServiceFactory xMSF, final Dataimport CurDataimport) + { + boolean bDocisStored = false; + try + { + boolean bexecute = false; + if (!bHasEscapeProcessing) + { + bexecute = m_reportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.QUERY); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) + } + else + { + bexecute = m_reportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.COMMAND); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) + } + if (bexecute) + { + bexecute = m_reportDocument.getRecordParser().getFields(m_reportDocument.getRecordParser().getFieldNames(), false); + } + if (bexecute) + { + // CurDataimport.insertDatabaseDatatoReportDocument(xMSF); + m_reportDocument.insertDatabaseDatatoReportDocument(xMSF); + } + + if (CurReportFinalizer.getReportOpenMode() == ReportFinalizer.SOCREATEDOCUMENT) + { + bDocisStored = m_reportDocument.getRecordParser().storeDatabaseDocumentToTempPath(m_reportDocument.getComponent(), CurReportFinalizer.getStoreName()); + } + } + catch (com.sun.star.wizards.common.InvalidQueryException queryexception) + { + } + CurDataimport.xComponent.dispose(); + if (bDocisStored) + { + m_reportDocument.getRecordParser().addReportDocument(m_reportDocument.getComponent(), false); + } + m_reportDocument.getRecordParser().dispose(); + } + + private boolean getReportResources(boolean bgetProgressResourcesOnly) + { + sMsgWizardName = super.m_oResource.getResText("RID_REPORT_0"); + if (!bgetProgressResourcesOnly) + { + sShowBinaryFields = m_oResource.getResText("RID_REPORT_60"); + slblTables = m_oResource.getResText("RID_FORM_6"); + slblFields = m_oResource.getResText("RID_FORM_12"); + slblSelFields = m_oResource.getResText("RID_REPORT_9"); + WizardHeaderText[0] = m_oResource.getResText("RID_REPORT_28"); + WizardHeaderText[1] = m_oResource.getResText("RID_REPORT_69"); + WizardHeaderText[2] = m_oResource.getResText("RID_REPORT_29"); + WizardHeaderText[3] = m_oResource.getResText("RID_REPORT_30"); + WizardHeaderText[4] = m_oResource.getResText("RID_REPORT_31"); + WizardHeaderText[5] = m_oResource.getResText("RID_REPORT_32"); + } + slblColumnTitles = m_oResource.getResText("RID_REPORT_70"); + slblColumnNames = m_oResource.getResText("RID_REPORT_71"); + return true; + } + + public static String getBlindTextNote(Object _aDocument, Resource _oResource) + { + String sBlindTextNote = PropertyNames.EMPTY_STRING; + if (_aDocument instanceof ReportTextImplementation) + { + sBlindTextNote = _oResource.getResText("RID_REPORT_75"); + sBlindTextNote = JavaTools.replaceSubString(sBlindTextNote, String.valueOf((char) 13), "<BR>"); + } + return sBlindTextNote; + } + + private void enableRoadmapItems(boolean _bEnabled) + { + try + { + Object oRoadmapItem = null; + int CurStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP)); + boolean bEnabled = false; + int CurItemID; + for (int i = 0; i < getRMItemCount(); i++) + { + oRoadmapItem = this.xIndexContRoadmap.getByIndex(i); + CurItemID = AnyConverter.toInt(Helper.getUnoPropertyValue(oRoadmapItem, "ID")); + if (CurItemID > CurStep) + { + bEnabled = _bEnabled; + } + else + { + bEnabled = true; + } + + Helper.setUnoPropertyValue(oRoadmapItem, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void enableWizardSteps(String[] NewItems) + { + boolean bEnabled = NewItems.length > 0; + setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); + setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); + enableRoadmapItems(bEnabled); // Note: Performance wise this could be improved + } + + public void textChanged(TextEvent xTextEvent) + { + try + { + Object oModel = UnoDialog.getModel(xTextEvent.Source); + String sContent = (String) Helper.getUnoPropertyValue(oModel, "Text"); + String fieldname = this.CurTitlesComponent.getFieldNameByTitleControl(oModel); + // CurReportDocument.getDoc().oTextFieldHandler.changeUserFieldContent(fieldname, sfieldtitle); + m_reportDocument.liveupdate_changeUserFieldContent(fieldname, sContent); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + @Override + public void disposing(EventObject EventObject) + { + } + + private void toggleSortingPage() + { + int nlCommandType = this.CurDBCommandFieldSelection.getSelectedCommandType(); + boolean bdoenable = (nlCommandType == CommandType.TABLE); + if (!bdoenable) + { + String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName(); + DBMetaData.CommandObject oCommand = m_reportDocument.getRecordParser().getQueryByName(sQueryName); + bdoenable = m_reportDocument.getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()); + } + super.setStepEnabled(SOSORTPAGE, bdoenable); + } + + private class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener + { + + private int m_nID; + + public void setID(String sIncSuffix) + { + m_nID = 1; + if (sIncSuffix != null) + { + if ((!sIncSuffix.equals(PropertyNames.EMPTY_STRING)) && (!sIncSuffix.equals("_"))) + { + String sID = JavaTools.ArrayoutofString(sIncSuffix, "_")[1]; + m_nID = Integer.parseInt(sID); + } + } + } + + public void shiftFromLeftToRight(String[] SelItems, String[] NewItems) + { + if (m_nID == 1) + { + CurDBCommandFieldSelection.setModified(true); + enableWizardSteps(NewItems); + toggleSortingPage(); + } + } + + public void shiftFromRightToLeft(String[] SelItems, String[] NewItems) + { + // TODO When the ListFieldbox is refilled only fields of the current Command may be merged into the Listbox + if (m_nID == 1) + { + enableWizardSteps(NewItems); + CurDBCommandFieldSelection.setModified(true); + } + } + + public void moveItemDown(String item) + { + } + + public void moveItemUp(String item) + { + } + } +} diff --git a/wizards/com/sun/star/wizards/report/report.component b/wizards/com/sun/star/wizards/report/report.component new file mode 100644 index 0000000000..68c8ce9402 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/report.component @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . + --> + +<component loader="com.sun.star.loader.Java2" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name= + "com.sun.star.wizards.report.CallReportWizard$ReportWizardImplementation"> + <service name="com.sun.star.wizards.report.CallReportWizard"/> + </implementation> +</component> diff --git a/wizards/com/sun/star/wizards/reportbuilder/MANIFEST.MF b/wizards/com/sun/star/wizards/reportbuilder/MANIFEST.MF new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/MANIFEST.MF @@ -0,0 +1 @@ + diff --git a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java new file mode 100644 index 0000000000..1c7a90ba32 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java @@ -0,0 +1,692 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XHierarchicalNameContainer; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.report.XReportDefinition; +import com.sun.star.sdb.XSubDocument; +import com.sun.star.sdb.application.DatabaseObject; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XModeSelector; +import com.sun.star.util.XModifiable; +import com.sun.star.util.XURLTransformer; +import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.NamedValueCollection; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.db.FieldColumn; +import com.sun.star.wizards.report.IReportBuilderLayouter; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.report.IReportDocument; +import com.sun.star.wizards.report.ReportImplementationHelper; +import com.sun.star.wizards.report.ReportLayouter; +import com.sun.star.wizards.report.ReportWizard; +import com.sun.star.wizards.ui.UIConsts; + +/** + * This class use the IReportDocument Interface to communicate between the UI + * and the ReportBuilderLayouter which communicates to the new Report Builder. + */ +@SuppressWarnings("ucd") +public class ReportBuilderImplementation extends ReportImplementationHelper + implements IReportDocument, IReportDefinitionReadAccess +{ + + private Resource m_resource; + private XDatabaseDocumentUI m_documentUI; + private static final int MAXIMUM_GROUPCOUNT = 4; + private String[] groupNames = null; + + private ReportBuilderImplementation(XMultiServiceFactory _serviceFactory) + { + // creates an access to the ReportBuilder Extension + super(_serviceFactory, ReportLayouter.SOOPTLANDSCAPE); + } + + public static IReportDocument create(XMultiServiceFactory i_serviceFactory) + { + return new ReportBuilderImplementation(i_serviceFactory); + } + + public void initialize(final XDatabaseDocumentUI i_documentUI, final Resource i_resource) + { + m_documentUI = i_documentUI; + m_resource = i_resource; + } + + public void clearDocument() + { + } + + public XWindowPeer getWizardParent() + { + return UnoRuntime.queryInterface(XWindowPeer.class, getFrame().getComponentWindow()); + } + private XFrame m_xFrame = null; + private String m_sReportBuilderLayoutName = PropertyNames.EMPTY_STRING; + + /** + * Get access to the current ReportLayouter, which depends on the name. + * To change the ReportBuilderLayouter use <code>setReportBuilderLayouterName(String Name)</code>. + * @return + */ + private IReportBuilderLayouter getReportBuilderLayouter() + { + return getLayoutMap().get(m_sReportBuilderLayoutName); + } + private Object m_aReportDocument; + private XPropertySet m_documentDefinition; + private XReportDefinition m_reportDocument; + + /** + * initialize the Report Builder and open it representation + * @param _aDoc + */ + private void initialize(Object _aDoc) + { + m_aReportDocument = _aDoc; + + try + { + NamedValueCollection creationArgs = new NamedValueCollection(); + creationArgs.put("DocumentServiceName", "com.sun.star.report.ReportDefinition"); + creationArgs.put("Mode", "remote"); + + XComponent[] docDefinition = new XComponent[] + { + null + }; + XComponent reportDefinitionComp = m_documentUI.createComponentWithArguments( + DatabaseObject.REPORT, creationArgs.getPropertyValues(), docDefinition); + + m_documentDefinition = UnoRuntime.queryInterface(XPropertySet.class, docDefinition[0]); + m_reportDocument = UnoRuntime.queryInterface(XReportDefinition.class, reportDefinitionComp); + } + catch (com.sun.star.uno.Exception e) + { + ReportWizard.getLogger().log(com.sun.star.logging.LogLevel.SEVERE, "Problems with initialize the ReportDefinition" + e.getMessage()); + + } + + switchOffPropertyBrowser(); + switchOffAddFieldWindow(); + + setPageOrientation(m_nDefaultPageOrientation, false /* NO_LAYOUT*/); + } + + private XModeSelector getModeSelector() + { + final XController xController = getReportDefinition().getCurrentController(); + return UnoRuntime.queryInterface(XModeSelector.class, xController); + } + + private void switchOffAddFieldWindow() + { + try + { + getModeSelector().setMode("remote"); + } + catch (com.sun.star.uno.Exception e) + { + } + } + + private void switchOnAddFieldWindow() + { + try + { + getModeSelector().setMode("normal"); + } + catch (com.sun.star.uno.Exception e) + { + } + } + + private void switchOffPropertyBrowser() + { + try + { + final XController xController = getReportDefinition().getCurrentController(); + final XDispatchProvider xDP = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + + // Create special service for parsing of given URL. + final Object aURLTransformer = getMSF().createInstance("com.sun.star.util.URLTransformer"); + final XURLTransformer xURLTransformer = UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class, aURLTransformer); + + com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1]; + aURL[0] = new com.sun.star.util.URL(); + aURL[0].Complete = ".uno:ControlProperties"; + xURLTransformer.parseStrict(aURL); + + final XDispatch xDispatch = xDP.queryDispatch(aURL[0], "_self", 0); + PropertyValue[] xEmpty = new PropertyValue[0]; + xDispatch.dispatch(aURL[0], xEmpty); + } + catch (com.sun.star.uno.Exception e) + { + } + } + + private void switchOnPropertyBrowser() + { + // This is implemented with a toggle algorithm. + switchOffPropertyBrowser(); + } + + /** + * Returns the Frame of the underlying Document + * @return Returns the Frame of the parent (underlying) Document + */ + public XFrame getFrame() + { + if (m_xFrame == null) + { + initialize(getRecordParser().getReportDocuments()); + m_xFrame = getReportDefinition().getCurrentController().getFrame(); + setPageOrientation(m_nDefaultPageOrientation, true /* NO_LAYOUT*/); + } + return m_xFrame; + } + + public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] Properties) + { + return false; + } + + public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF) + { + } + + public void StopProcess() + { + } + + public void store(String Name, int OpenMode) throws com.sun.star.uno.Exception + { + // store into the ZIP Storage + if (OpenMode == 1 /* static Report */) + { + // we will store later + return; + } + + final XCommandProcessor xProcessor = UnoRuntime.queryInterface(XCommandProcessor.class, m_documentDefinition); + final com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command(); + aCommand.Name = "store"; + + xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null); + + final XHierarchicalNameContainer aNameContainer = UnoRuntime.queryInterface(XHierarchicalNameContainer.class, m_aReportDocument); + aNameContainer.insertByHierarchicalName(Name, m_documentDefinition); + } + + public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, ArrayList<String> GroupFieldVector, ArrayList<String> ReportPath, int iSelCount) + { + final int GroupCount = GroupFieldVector.size(); + if (GroupCount < MAXIMUM_GROUPCOUNT) + { + final FieldColumn CurFieldColumn = getRecordParser().getFieldColumnByTitle(CurGroupTitle); + GroupFieldVector.add(CurFieldColumn.getFieldName()); + } + return true; + } + + public void refreshGroupFields(String[] _sNewNames) + { + } + + public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, ArrayList<String> GroupFieldVector) + { + final FieldColumn CurFieldColumn = getRecordParser().getFieldColumnByTitle(CurGroupTitle); + GroupFieldVector.remove(CurFieldColumn.getFieldName()); + } + + private void setPageOrientation(int nOrientation, boolean bDoLayout) + { + getReportBuilderLayouter().setPageOrientation(nOrientation); + if (bDoLayout) + { + getReportBuilderLayouter().layout(); + } + } + + public void setPageOrientation(int nOrientation) + { + setPageOrientation(nOrientation, true); + } + + public void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/) + { + /* Right Listbox */ + final IReportBuilderLayouter aLayouter = getReportBuilderLayouter(); + aLayouter.loadAndSetBackgroundTemplate(LayoutTemplatePath); + aLayouter.layout(); + } + + /** + * Change the current Layouter by a new one with the given Name _sName. + * If there exist no other layouter with the given name, nothing happens, the layouter will not change to + * an illegal one. + * @param _sName Name of the other layouter. + */ + public void setReportBuilderLayouterName(String _sName) + { + final IReportBuilderLayouter aCurrentLayouter = getReportBuilderLayouter(); + final IReportBuilderLayouter aNewLayouter = m_aLayoutMap.get(_sName); + if (aNewLayouter != null) + { + m_sReportBuilderLayoutName = _sName; + aNewLayouter.initializeData(aCurrentLayouter); + aNewLayouter.layout(); + } + } + + public void liveupdate_changeContentTemplate(String ContentTemplatePath) + { + /* Left Listbox */ + setReportBuilderLayouterName(ContentTemplatePath); + } + + public void layout_setupRecordSection(String TemplateName) + { + } + + public void removeTextTableAndTextSection() + { + } + + public void layout_selectFirstPage() + { + } + + private void closeReportDefinition() + { + try + { + if (m_documentDefinition != null) + { + // set the document to "not modified", to ensure that it won't ask the user before closing + XModifiable documentModify = UnoRuntime.queryInterface(XModifiable.class, m_reportDocument); + documentModify.setModified(false); + // actually close + XSubDocument subComponent = UnoRuntime.queryInterface(XSubDocument.class, m_documentDefinition); + subComponent.close(); + } + } + catch (Exception ex) + { + Logger.getLogger(ReportBuilderImplementation.class.getName()).log(Level.SEVERE, null, ex); + } + m_documentDefinition = null; + m_reportDocument = null; + } + + public void dispose() + { + getReportBuilderLayouter().dispose(); + closeReportDefinition(); + } + + public XComponent getComponent() + { + return null; + } + + public void liveupdate_changeUserFieldContent(String fieldName, String titlename) + { + } + + public void liveupdate_updateReportTitle(String _sTitleName) + { + } + + public void addReportToDBView() + { + } + + private XComponent loadReport(final String i_reportName) + { + try + { + return m_documentUI.loadComponent(DatabaseObject.REPORT, i_reportName, false); + } + catch (Exception ex) + { + Logger.getLogger(ReportBuilderImplementation.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + + private XComponent loadReportFromDocumentDefinition() + { + final XCommandProcessor commandProcessor = UnoRuntime.queryInterface(XCommandProcessor.class, m_documentDefinition); + + com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command(); + aCommand.Name = "open"; + try + { + final Object result = commandProcessor.execute(aCommand, commandProcessor.createCommandIdentifier(), null); + return UnoRuntime.queryInterface(XComponent.class, result); + } + catch (Exception ex) + { + Logger.getLogger(ReportBuilderImplementation.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + + public void createAndOpenReportDocument(String i_name, boolean i_asTemplate, boolean i_openForEditing) + { + if (i_openForEditing) + { + // we won't destroy the report builder window, also don't create a document + // Do we need to reopen the report builder with the known name? + switchOnAddFieldWindow(); + switchOnPropertyBrowser(); + return; + } + + if (i_asTemplate) + { + // don't need the report definition anymore - the document it represents has already been stored + closeReportDefinition(); + + // open the report, again, this time not in design, but containing data + loadReport(i_name); + } + else + { + // execute the report from the (yet unsaved) report definition + XComponent document = loadReportFromDocumentDefinition(); + + // don't need the report definition anymore + closeReportDefinition(); + + // store the generated report + if (getRecordParser().storeDatabaseDocumentToTempPath(document, i_name)) + { + getRecordParser().addReportDocument(document, false); + } + } + + dispose(); + } + + public void initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames) + { + getRecordParser().initializeFieldColumns(FieldNames, TableName); + + final com.sun.star.wizards.db.RecordParser a = getRecordParser(); + int[] FieldTypes = new int[FieldNames.length]; + int[] FieldWidths = new int[FieldNames.length]; + for (int i = 0; i < FieldNames.length; i++) + { + FieldTypes[i] = a.FieldColumns[i].getFieldType(); + FieldWidths[i] = a.FieldColumns[i].getFieldWidth(); + } + getReportBuilderLayouter().setTableName(_nType, TableName); + getReportBuilderLayouter().insertFieldNames(FieldNames); + getReportBuilderLayouter().insertFieldTypes(FieldTypes); + getReportBuilderLayouter().insertFieldWidths(FieldWidths); + + getReportBuilderLayouter().layout(); + } + + public void setFieldTitles(String[] _aFieldTitles) + { + getRecordParser().setFieldTitles(_aFieldTitles); + + getReportBuilderLayouter().insertFieldTitles(_aFieldTitles); + getReportBuilderLayouter().layout(); + } + + public void setSorting(String[][] _aSortFieldNames) + { + getRecordParser().setSortFieldNames(_aSortFieldNames); + if (groupNames != null) + { + getRecordParser().prependSortFieldNames(groupNames); + } + getReportBuilderLayouter().insertSortingNames(_aSortFieldNames); + getReportBuilderLayouter().layout(); + } + + public void setGrouping(String[] _aGroupFieldNames) + { + groupNames = _aGroupFieldNames; + getRecordParser().prependSortFieldNames(_aGroupFieldNames); + + getReportBuilderLayouter().insertGroupNames(_aGroupFieldNames); + getReportBuilderLayouter().layout(); + } + + public String getLayoutPath() + { + return "default"; + } + private ArrayList<String> m_aReportPath; + + public ArrayList<String> getReportPath() + { + if (m_aReportPath == null) + { + // Check general availability of office paths + m_aReportPath = FileAccess.getOfficePaths(getMSF(), "Template"); + FileAccess.combinePaths(getMSF(), m_aReportPath, "/wizard/report"); + } + return m_aReportPath; + } + + public String getContentPath() + { + return PropertyNames.EMPTY_STRING; + } + + public int getDefaultPageOrientation() + { + return m_nDefaultPageOrientation; + } + + private LinkedHashMap<String, IReportBuilderLayouter> m_aLayoutMap = null; + + private void insertIntoLayoutMap(IReportBuilderLayouter _aLayout) + { + insertIntoLayoutMap(_aLayout, false); + } + + private void insertIntoLayoutMap(IReportBuilderLayouter _aLayout, boolean _bDefault) + { + if (_aLayout != null) + { + final String sName = _aLayout.getName(); + if (_bDefault) + { + m_sReportBuilderLayoutName = sName; // here we set the default layout name! + } + m_aLayoutMap.put(sName, _aLayout); + } + } + + /** + * Initialize all well known com.sun.star.wizards.report.layout.ReportBuilderLayouter Objects and create exact one instance. + */ + private LinkedHashMap<String, IReportBuilderLayouter> getLayoutMap() + { + if (m_aLayoutMap == null) + { + // The LayoutMap is empty, so we create a new LinkedHashMap + m_aLayoutMap = new LinkedHashMap<String, IReportBuilderLayouter>(); + + // TODO: We must know the name of a layouts, There should be a way to say where to find, not the names. + IReportBuilderLayouter aLayout = new com.sun.star.wizards.reportbuilder.layout.Tabular(this, m_resource); + insertIntoLayoutMap(aLayout, true); + aLayout = new com.sun.star.wizards.reportbuilder.layout.ColumnarSingleColumn(this, m_resource); + insertIntoLayoutMap(aLayout); + aLayout = new com.sun.star.wizards.reportbuilder.layout.ColumnarTwoColumns(this, m_resource); + insertIntoLayoutMap(aLayout); + aLayout = new com.sun.star.wizards.reportbuilder.layout.ColumnarThreeColumns(this, m_resource); + insertIntoLayoutMap(aLayout); + aLayout = new com.sun.star.wizards.reportbuilder.layout.InBlocksLabelsAbove(this, m_resource); + insertIntoLayoutMap(aLayout); + aLayout = new com.sun.star.wizards.reportbuilder.layout.InBlocksLabelsLeft(this, m_resource); + insertIntoLayoutMap(aLayout); + + } + return m_aLayoutMap; + } + + /** + * Return a string array array with all found layouts + * At the moment these layout are hard coded + */ + public String[][] getDataLayout() + { + String[][] ContentFiles; + ContentFiles = new String[2][]; + String[] a = new String[getLayoutMap().size()]; + String[] b = new String[getLayoutMap().size()]; + + // run through the whole layoutmap and + final Set<String> aKeys = getLayoutMap().keySet(); + final Iterator<String> aKeyIterator = aKeys.iterator(); + int i = 0; + while (aKeyIterator.hasNext()) + { + final String sKey = aKeyIterator.next(); + a[i] = sKey; + final IReportBuilderLayouter aLayouter = m_aLayoutMap.get(sKey); + b[i++] = aLayouter.getLocalizedName(); + } + + ContentFiles[1] = a; + ContentFiles[0] = b; + return ContentFiles; + } + private String m_sDefaultHeaderLayoutPath; + + public String[][] getHeaderLayout() + { + String[][] LayoutFiles; + try + { + // TODO: check different languages in header layouts + ArrayList<String> aReportPath = FileAccess.getOfficePaths(getMSF(), "Template"); + FileAccess.combinePaths(getMSF(), aReportPath, "/wizard/report"); + + LayoutFiles = FileAccess.getFolderTitles(getMSF(), null, aReportPath, ".otr"); + } + catch (com.sun.star.wizards.common.NoValidPathException e) + { + // if there are problems, don't show anything is a little bit hard. + LayoutFiles = new String[2][]; + String[] a = new String[] { "DefaultLayoutOfHeaders" }; + String[] b = new String[] { "default" }; + LayoutFiles[1] = a; + LayoutFiles[0] = b; + } + for (int i = 0; i < LayoutFiles[0].length; i++) + { + if (LayoutFiles[0][i].equals("default")) + { + m_sDefaultHeaderLayoutPath = LayoutFiles[1][i]; + break; + } + } + exchangeLayoutTitlesWithLocalisedOnes(LayoutFiles); + return LayoutFiles; + } + + private void exchangeLayoutTitlesWithLocalisedOnes(String[][] LayoutFiles) + { + for(int i = 0; i < LayoutFiles[0].length; ++i) + { + if( LayoutFiles[0][i] == null) { break;} + if( LayoutFiles[0][i].equals("default") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_100"); + } + } + } + + public XReportDefinition getReportDefinition() + { + if (m_reportDocument == null) + { + throw new NullPointerException("Report Definition is not already initialized, check if you too early access the report definition."); + } + return m_reportDocument; + } + + public XMultiServiceFactory getGlobalMSF() + { + return getMSF(); + } + + public void importReportData(ReportWizard aWizard) + { + } + + public String getDefaultHeaderLayout() + { + return m_sDefaultHeaderLayoutPath; + } + + public void setCommand(String _sCommand) + { + getRecordParser().Command = _sCommand; + getReportDefinition().setCommand(_sCommand); + } + + public void setCommandType(int _nCommand) + { + getReportDefinition().setCommandType(_nCommand); + } + + public void checkInvariants() throws java.lang.Exception + { + final String sDefaultHeaderLayoutPath = getDefaultHeaderLayout(); + if (sDefaultHeaderLayoutPath == null) + { + throw new java.io.IOException("default.otr"); + } + + FileAccess aAccess = new FileAccess(getGlobalMSF()); + if (!aAccess.exists(sDefaultHeaderLayoutPath, true)) + { + throw new java.io.IOException("default.otr"); + } + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java new file mode 100644 index 0000000000..e31e6cc961 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java @@ -0,0 +1,91 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.Rectangle; +import com.sun.star.report.XSection; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.ui.UIConsts; + +public class ColumnarSingleColumn extends ReportBuilderLayouter +{ + + public ColumnarSingleColumn(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource) + { + super(_xDefinitionAccess, _aResource); + } + + public String getName() + { + return "ColumnarSingleColumnLayoutOfData"; + } + + public String getLocalizedName() + { + return getResource().getResText("RID_REPORT_81"); + } + + @Override + protected void insertDetailFields() + { + copyDetailProperties(); + + final String[] aFieldTitleNames = getFieldTitleNames(); + if (aFieldTitleNames == null) + { + return; + } + final String[] aFieldNames = getFieldNames(); + if (aFieldNames == null) + { + return; + } + + final XSection xSection = getReportDefinition().getDetail(); + + Rectangle aRect = new Rectangle(); + + final int nLabelWidth = getMaxLabelWidth(); + final SectionObject aSOLabel = getDesignTemplate().getDetailLabel(); + aSOLabel.setFontToBold(); + final SectionObject aSOTextField = getDesignTemplate().getDetailTextField(); + + final int nWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups()) - nLabelWidth; + + for (int i = 0; i < aFieldNames.length; i++) + { + aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + final String sLabel = aFieldTitleNames[i]; + aRect = insertLabel(xSection, sLabel, aRect, nLabelWidth, aSOLabel); + final String sFieldName = convertToFieldName(aFieldNames[i]); + aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSOTextField); + int nHeight = aRect.Height; + aRect.Y += Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight), nHeight); + } + aRect.Y += aSOLabel.getHeight(LayoutConstants.EmptyLineHeight); // one empty line + xSection.setHeight(aRect.Y); + doNotBreakInTable(xSection); + } + + @Override + protected void insertDetailFieldTitles(int lastGroupPosition) + { + // we won't extra field titles + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarThreeColumns.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarThreeColumns.java new file mode 100644 index 0000000000..81d4ad50ac --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarThreeColumns.java @@ -0,0 +1,49 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.ui.*; + +public class ColumnarThreeColumns extends ColumnarTwoColumns +{ + + public ColumnarThreeColumns(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource) + { + super(_xDefinitionAccess, _aResource); + } + + @Override + public String getName() + { + return "ColumnarThreeColumnsLayoutOfData"; + } + + @Override + public String getLocalizedName() + { + return getResource().getResText("RID_REPORT_83"); + } + + @Override + protected void insertDetailFields() + { + insertDetailFields(3); + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java new file mode 100644 index 0000000000..6d21dce05e --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java @@ -0,0 +1,123 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.Rectangle; +import com.sun.star.report.XSection; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.ui.UIConsts; + +public class ColumnarTwoColumns extends ReportBuilderLayouter +{ + + public ColumnarTwoColumns(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource) + { + super(_xDefinitionAccess, _aResource); + } + + public String getName() + { + return "ColumnarTwoColumnsLayoutOfData"; + } + + public String getLocalizedName() + { + return getResource().getResText("RID_REPORT_82"); + } + + @Override + protected void insertDetailFields() + { + insertDetailFields(2); + } + + protected void insertDetailFields(int _nColumns) + { + copyDetailProperties(); + + if (_nColumns < 1) + { + return; + } + final String[] aFieldTitleNames = getFieldTitleNames(); + if (aFieldTitleNames == null) + { + return; + } + final String[] aFieldNames = getFieldNames(); + if (aFieldNames == null) + { + return; + } + + final XSection xSection = getReportDefinition().getDetail(); + + Rectangle aRect = new Rectangle(); + + final int nLabelWidth = getMaxLabelWidth(); // 3000; + + final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups()); + int i = 0; + int nRows = aFieldNames.length / _nColumns; + if ((aFieldNames.length % _nColumns) != 0) + { + ++nRows; + } + final int nWidth = (nUsablePageWidth - nLabelWidth * _nColumns) / _nColumns; + if (nWidth < 0) + { + // TODO: error message in logging + return; + } + + final SectionObject aSOLabel = getDesignTemplate().getDetailLabel(); + aSOLabel.setFontToBold(); + final SectionObject aSOTextField = getDesignTemplate().getDetailTextField(); + int nMaxHeight = 0; + for (int x = 0; x < _nColumns; x++) + { + aRect.Y = 0; + for (int y = 0; y < nRows; y++) + { + aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()) + x * (nWidth + nLabelWidth); + if (i < aFieldNames.length) + { + final String sLabel = aFieldTitleNames[i]; + aRect = insertLabel(xSection, sLabel, aRect, nLabelWidth, aSOLabel); + final String sFieldName = convertToFieldName(aFieldNames[i]); + aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSOTextField); + + aRect.Y += Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight), aRect.Height); + ++i; + } + } + nMaxHeight = Math.max(aRect.Y, nMaxHeight); + } + aRect.Y = Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight) * nRows, nMaxHeight); + aRect.Y += aSOLabel.getHeight(LayoutConstants.EmptyLineHeight); // one empty line + xSection.setHeight(aRect.Y); + doNotBreakInTable(xSection); + } + + @Override + protected void insertDetailFieldTitles(int lastGroupPosition) + { + // we won't extra field titles + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/DesignTemplate.java b/wizards/com/sun/star/wizards/reportbuilder/layout/DesignTemplate.java new file mode 100644 index 0000000000..54f0c492b0 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/DesignTemplate.java @@ -0,0 +1,302 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.report.XFixedText; +import com.sun.star.report.XFormattedField; +import com.sun.star.report.XGroup; +import com.sun.star.report.XGroups; +import com.sun.star.report.XReportDefinition; +import com.sun.star.report.XSection; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; + +public class DesignTemplate +{ + + private XReportDefinition m_xReportDefinition; + + private DesignTemplate() + { + } + + // All functions from XReportDefinition, we use + + XGroups getGroups() + { + return m_xReportDefinition.getGroups(); + } + + XSection getDetail() + { + return m_xReportDefinition.getDetail(); + } + + boolean getReportHeaderOn() + { + return m_xReportDefinition.getReportHeaderOn(); + } + + XSection getReportHeader() throws com.sun.star.container.NoSuchElementException + { + return m_xReportDefinition.getReportHeader(); + } + + boolean getReportFooterOn() + { + return m_xReportDefinition.getReportFooterOn(); + } + + XSection getReportFooter() throws com.sun.star.container.NoSuchElementException + { + return m_xReportDefinition.getReportFooter(); + } + + boolean getPageHeaderOn() + { + return m_xReportDefinition.getPageHeaderOn(); + } + + XSection getPageHeader() throws com.sun.star.container.NoSuchElementException + { + return m_xReportDefinition.getPageHeader(); + } + + boolean getPageFooterOn() + { + return m_xReportDefinition.getPageFooterOn(); + } + + XSection getPageFooter() throws com.sun.star.container.NoSuchElementException + { + return m_xReportDefinition.getPageFooter(); + } + private SectionObject m_aDetailLabel; + private SectionObject m_aDetailTextField; + private SectionObject[] m_aGroupLabel; + private SectionObject[] m_aGroupTextField; + + SectionObject getDetailLabel() + { + if (m_aDetailLabel == null) + { + return SectionEmptyObject.create(); + } + return m_aDetailLabel; + } + + SectionObject getDetailTextField() + { + if (m_aDetailTextField == null) + { + return SectionEmptyObject.create(); + } + return m_aDetailTextField; + } + + SectionObject getGroupTextField(int _nGroup) + { + return getGroupSectionObject(m_aGroupTextField, _nGroup); + } + + SectionObject getGroupLabel(int _nGroup) + { + return getGroupSectionObject(m_aGroupLabel, _nGroup); + } + + private SectionObject getGroupSectionObject(SectionObject _aGroupList[], int _nGroup) + { + SectionObject a = null; + if (_nGroup < _aGroupList.length) + { + a = _aGroupList[_nGroup]; + } + else + { + // if there are not enough groups, the last one will win + if (_aGroupList.length > 0) + { + a = _aGroupList[_aGroupList.length - 1]; + } + } + // we show if the group is null + if (a == null) + { + a = SectionEmptyObject.create(); + // an empty group has to use bold font + a.setPropertyValue("CharWeight", Float.valueOf(com.sun.star.awt.FontWeight.BOLD)); + } + return a; + } + + // we analyse the loaded ReportDefinition, we want to know the FontDescriptor of all XSections + private void analyseReportDefinition() + { + final XSection xDetailSection = m_xReportDefinition.getDetail(); + final int nDetailCount = xDetailSection.getCount(); + for (int i = 0; i < nDetailCount; i++) + { + try + { + Object aObj = xDetailSection.getByIndex(i); + // is aObj a label + // is aObj a textfield + // m_aDetailLabel_FD + // m_aDetailTextField_FD + XFixedText aFixedText = UnoRuntime.queryInterface(XFixedText.class, aObj); + if (aFixedText != null && + m_aDetailLabel == null) + { + m_aDetailLabel = SectionLabel.create(aFixedText); + } + else + { + XFormattedField aFormattedField = UnoRuntime.queryInterface(XFormattedField.class, aObj); + if (aFormattedField != null && + m_aDetailTextField == null) + { + m_aDetailTextField = SectionTextField.create(aFormattedField); + } + } + } + catch (com.sun.star.lang.IndexOutOfBoundsException ex) + { + } + catch (com.sun.star.lang.WrappedTargetException ex) + { + } + } + + final XGroups xGroups = m_xReportDefinition.getGroups(); + final int nGroupCount = xGroups.getCount(); + // create a m_aGroupLabel_FD[] + // create a m_aGroupTextField_FD[] + m_aGroupLabel = new SectionObject[nGroupCount]; + m_aGroupTextField = new SectionObject[nGroupCount]; + + for (int nGroup = 0; nGroup < nGroupCount; nGroup++) + { + try + { + Object aGroup = xGroups.getByIndex(nGroup); + XGroup xGroup = UnoRuntime.queryInterface(XGroup.class, aGroup); + XSection xGroupSection = xGroup.getHeader(); + + final int nCount = xGroupSection.getCount(); + for (int i = 0; i < nCount; i++) + { + try + { + Object aObj = xGroupSection.getByIndex(i); + XFixedText aFixedText = UnoRuntime.queryInterface(XFixedText.class, aObj); + // is aObj a label + // is aObj a textfield + if (aFixedText != null && + m_aGroupLabel[nGroup] == null) + { + m_aGroupLabel[nGroup] = SectionLabel.create(aFixedText); + } + else + { + XFormattedField aFormattedField = UnoRuntime.queryInterface(XFormattedField.class, aObj); + if (aFormattedField != null && + m_aGroupTextField[nGroup] == null) + { + m_aGroupTextField[nGroup] = SectionTextField.create(aFormattedField); + } + } + } + catch (com.sun.star.lang.IndexOutOfBoundsException ex) + { + } + catch (com.sun.star.lang.WrappedTargetException ex) + { + } + } + } + catch (com.sun.star.container.NoSuchElementException ex) + { + } + catch (com.sun.star.lang.IndexOutOfBoundsException ex) + { + } + catch (com.sun.star.lang.WrappedTargetException ex) + { + } + } + } + + /** + * close our current ReportDefinition + */ + void close() + { + try + { + m_xReportDefinition.close(true); + } + catch (com.sun.star.util.CloseVetoException e) + { + } + } + + /** + * create a new DesignTemplate by try to load an otr file from the given path. + * Internally we store the loaded ReportDefinition. + */ + public static DesignTemplate create(XMultiServiceFactory _xMSF, String _sPath) + { + DesignTemplate a = new DesignTemplate(); + try + { + a.load(_xMSF, _sPath); + } + catch (com.sun.star.lang.WrappedTargetRuntimeException e) + { + // this should not happen + a = null; + throw new java.lang.RuntimeException(e); + } + catch (com.sun.star.uno.Exception e) + { + a = null; + } + catch (Exception e) + { + a = null; + } + return a; + } + + private void load(XMultiServiceFactory _xMSF, String _sPath) throws com.sun.star.uno.Exception + { + final Object aObj = _xMSF.createInstance("com.sun.star.report.ReportDefinition"); + m_xReportDefinition = UnoRuntime.queryInterface(XReportDefinition.class, aObj); + + PropertyValue[] aLoadProps = new PropertyValue[2]; + aLoadProps[0] = Properties.createProperty(PropertyNames.URL, _sPath); + aLoadProps[1] = Properties.createProperty(PropertyNames.READ_ONLY, Boolean.TRUE); + + m_xReportDefinition.load(aLoadProps); + analyseReportDefinition(); + } + +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java new file mode 100644 index 0000000000..08dbc2db52 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java @@ -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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.Rectangle; +import com.sun.star.report.XSection; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.ui.*; + +public class InBlocksLabelsAbove extends ColumnarTwoColumns +{ + + public InBlocksLabelsAbove(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource) + { + super(_xDefinitionAccess, _aResource); + } + + @Override + public String getName() + { + return "InBlocksLabelsAboveLayoutOfData"; + } + + @Override + public String getLocalizedName() + { + return getResource().getResText("RID_REPORT_85"); + } + + @Override + protected void insertDetailFields() + { + copyDetailProperties(); + + final String[] aFieldTitleNames = getFieldTitleNames(); + if (aFieldTitleNames == null) + { + return; + } + final String[] aFieldNames = getFieldNames(); + if (aFieldNames == null) + { + return; + } + + final XSection xSection = getReportDefinition().getDetail(); + + Rectangle aRectLabels = new Rectangle(); + Rectangle aRectFields = new Rectangle(); + + + final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups()); + + int i = 0; + int nCount = aFieldTitleNames.length; + aRectLabels.Y = 0; + aRectLabels.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + + aRectFields.Y = LayoutConstants.LabelHeight; + aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + + // first run only calculates the width. + int nDelta = 0; + int nFieldWidth = 3000; + while (nCount > 0) + { + aRectFields.X += nFieldWidth; + + final int nNextX = aRectFields.X + nFieldWidth; + if (nNextX > (getPageWidth() - getRightPageIndent())) + { + // all other values are not from interest. + break; + } + + ++i; + --nCount; + } + final int nDeltaTotal = nUsablePageWidth - i * nFieldWidth; + nDelta = nDeltaTotal; + if (i > 0) + { + nDelta = nDeltaTotal / i; + } + + aRectLabels.Y = 0; + aRectLabels.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + + final SectionObject aSOLabel = getDesignTemplate().getDetailLabel(); + aSOLabel.setFontToBold(); + final SectionObject aSOTextField = getDesignTemplate().getDetailTextField(); + + aRectFields.Y = aSOLabel.getHeight(LayoutConstants.LabelHeight); + aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + i = 0; + nCount = aFieldTitleNames.length; + int nLastHeight = 0; + while (nCount > 0) + { + final String sLabel = aFieldTitleNames[i]; + final int nLabelWidth = 3000 + nDelta; + aRectLabels = insertLabel(xSection, sLabel, aRectLabels, nLabelWidth, aSOLabel); + final String sFieldName = convertToFieldName(aFieldNames[i]); + nFieldWidth = 3000 + nDelta; + aRectFields = insertFormattedField(xSection, sFieldName, aRectFields, nFieldWidth, aSOTextField); + nLastHeight = Math.max(nLastHeight, aRectFields.Height); + int nNextX = aRectFields.X + nFieldWidth; + if ((nNextX > (getPageWidth() - getRightPageIndent())) && nCount > 1) + { + int nHeight = (aSOLabel.getHeight(LayoutConstants.LabelHeight) + Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight)); + nLastHeight = 0; + aRectLabels.Y += nHeight; // 2 * label height + aRectLabels.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + + aRectFields.Y += nHeight; + aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + } + ++i; + --nCount; + } + aRectFields.Y += Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight); + aRectFields.Y += aSOTextField.getHeight(LayoutConstants.EmptyLineHeight); // one empty line + xSection.setHeight(aRectFields.Y); + doNotBreakInTable(xSection); + } + + @Override + protected void insertDetailFieldTitles(int lastGroupPosition) + { + // we won't extra field titles + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java new file mode 100644 index 0000000000..cf88cb29ac --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java @@ -0,0 +1,119 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.Rectangle; +import com.sun.star.report.XSection; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.ui.*; + +public class InBlocksLabelsLeft extends ColumnarTwoColumns +{ + + public InBlocksLabelsLeft(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource) + { + super(_xDefinitionAccess, _aResource); + } + + @Override + public String getName() + { + return "InBlocksLabelsLeftLayoutOfData"; + } + + @Override + public String getLocalizedName() + { + return getResource().getResText("RID_REPORT_84"); + } + + @Override + protected void insertDetailFields() + { + copyDetailProperties(); + + final String[] aFieldTitleNames = getFieldTitleNames(); + if (aFieldTitleNames == null) + { + return; + } + final String[] aFieldNames = getFieldNames(); + if (aFieldNames == null) + { + return; + } + + final XSection xSection = getReportDefinition().getDetail(); + + Rectangle aRectLabelFields = new Rectangle(); + + final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups()); + + final int nLabelWidth = getMaxLabelWidth(); // 3000; + int nFieldWidth = 3000; + + final int nFactor = nUsablePageWidth / (nLabelWidth + nFieldWidth); + int nDeltaTotal = 0; + int nDelta = 0; + if (nFactor > 0) + { + nDeltaTotal = nUsablePageWidth - (nFactor * (nLabelWidth + nFieldWidth)); + nDelta = nDeltaTotal / nFactor; + } + + int i = 0; + int nCount = aFieldTitleNames.length; + aRectLabelFields.Y = 0; + aRectLabelFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + + SectionObject aSOLabel = getDesignTemplate().getDetailLabel(); + aSOLabel.setFontToBold(); + SectionObject aSOTextField = getDesignTemplate().getDetailTextField(); + int nLastHeight = 0; + while (nCount > 0) + { + final String sLabel = aFieldTitleNames[i]; + aRectLabelFields = insertLabel(xSection, sLabel, aRectLabelFields, nLabelWidth, aSOLabel); + final String sFieldName = convertToFieldName(aFieldNames[i]); + nFieldWidth = 3000 + nDelta; + aRectLabelFields = insertFormattedField(xSection, sFieldName, aRectLabelFields, nFieldWidth, aSOTextField); + nLastHeight = Math.max(aRectLabelFields.Height, nLastHeight); + final int nNextX = aRectLabelFields.X + nLabelWidth + nFieldWidth; + if (nNextX > (getPageWidth() - getRightPageIndent())) + { + // TODO: label height is fix + aRectLabelFields.Y += Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight); + nLastHeight = 0; + aRectLabelFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + } + ++i; + --nCount; + } + aRectLabelFields.Y += Math.max(aSOLabel.getHeight(LayoutConstants.EmptyLineHeight), nLastHeight); // one empty line + xSection.setHeight(aRectLabelFields.Y); + doNotBreakInTable(xSection); + } + + @Override + protected void insertDetailFieldTitles(int lastGroupPosition) + { + // we won't extra field titles + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java b/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java new file mode 100644 index 0000000000..9b294a12da --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java @@ -0,0 +1,37 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.reportbuilder.layout; + +public class LayoutConstants +{ + public static final int LabelHeight = 500; + public static final int FormattedFieldHeight = 500; + public static final int EmptyLineHeight = 500; + + public static final int BinaryHeight = 4000; + public static final int MemoFieldHeight = 4000; + + public static final int LineHeight = 250; + + /** + * Groups will indent + * This is the factor (5mm) which will multiply with the current indent + */ + public static final int IndentFactorWidth = 500; +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java new file mode 100644 index 0000000000..cfa2071a3c --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java @@ -0,0 +1,1582 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.FontDescriptor; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XLayoutConstrains; +import com.sun.star.awt.XUnitConversion; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.report.XFixedLine; +import com.sun.star.report.XFixedText; +import com.sun.star.report.XFormattedField; +import com.sun.star.report.XGroup; +import com.sun.star.report.XGroups; +import com.sun.star.report.XImageControl; +import com.sun.star.report.XReportComponent; +import com.sun.star.report.XReportControlModel; +import com.sun.star.report.XReportDefinition; +import com.sun.star.report.XSection; +import com.sun.star.drawing.XShape; +import com.sun.star.sdbc.DataType; +import com.sun.star.style.XStyle; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XNumberFormatTypes; +import com.sun.star.util.XNumberFormats; +import com.sun.star.util.XNumberFormatsSupplier; +import com.sun.star.wizards.common.Configuration; +import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.PropertySetHelper; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.report.IReportBuilderLayouter; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.ui.UIConsts; + +import java.util.HashMap; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * This class is abstract and more like a helper for create different layouts for Report Builder Wizard. + */// TODO: let a little bit place between 2 formatted fields +// TODO: move all sectionobjects which have a connect to the right max page width to left if there is a orientation change. +abstract public class ReportBuilderLayouter implements IReportBuilderLayouter +{ + + private IReportDefinitionReadAccess m_xReportDefinitionReadAccess; + private final Resource m_aResource; + private String[][] m_aSortNames; + + /** + * dispose the ReportBuilderLayouter + */ + public void dispose() + { + closeDesignTemplate(); + m_xReportDefinitionReadAccess = null; + } + + /** + * The Constructor is protected, this is an abstract class, use Tabular or other to create an instance. + * @param _xDefinitionAccess + * @param _aResource + */ + protected ReportBuilderLayouter(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource) + { + m_xReportDefinitionReadAccess = _xDefinitionAccess; + m_aResource = _aResource; + } + + /** + * Access to the current ReportDefinition + * @return the ReportDefinition + */ + public XReportDefinition getReportDefinition() + { + // we have to ask our parent for this value + return m_xReportDefinitionReadAccess.getReportDefinition(); + } + + /** + * Access to the global MultiServiceFactory + * @return the global Service Factory + */ + private XMultiServiceFactory getGlobalMSF() + { + return m_xReportDefinitionReadAccess.getGlobalMSF(); + } + + /** + * Layout the complete report new, by all information we know until this time. + * + * If there are some information less, it is no problem for this function, they will be leaved out. + * It is possible to call this function after every change, but be careful, could take a little bit longer. + */ + public synchronized void layout() + { + try + { + // we bring the clear and insert methods together, this should be a little bit smoother + clearReportHeader(); + insertReportHeader(); + + clearReportFooter(); + insertReportFooter(); + + clearPageHeader(); + insertPageHeader(); + + clearPageFooter(); + insertPageFooter(); + + clearGroups(); + int lastGroupPosition = insertGroups(); + + clearDetails(); + insertDetailFieldTitles(lastGroupPosition); + insertDetailFields(); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) + { + // could happen, if you change the count of values + } + catch (java.lang.RuntimeException e) + { + throw e; + } + catch (Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + + + /** + * Remove all Groups + */ + private void clearGroups() + { + final XGroups xGroups = getReportDefinition().getGroups(); + while (xGroups.hasElements()) + { + try + { + xGroups.removeByIndex(0); + } + catch (com.sun.star.uno.Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + + /** + * Remove all fields + * @param _xSectionToClear + */ + private void emptySection(XSection _xSectionToClear) + { + if (_xSectionToClear == null) + { + return; + } + while (_xSectionToClear.hasElements()) + { + try + { + final Object aObj = _xSectionToClear.getByIndex(0); + final XShape aShape = UnoRuntime.queryInterface(XShape.class, aObj); + _xSectionToClear.remove(aShape); + } + catch (com.sun.star.uno.Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + + } + } + + private void clearDetails() + { + final XSection xSection = getReportDefinition().getDetail(); + emptySection(xSection); + } + + /** + * @param _nGroupCount + * @return the left indent in 1/100mm + */ + protected int getLeftGroupIndent(int _nGroupCount) + { +// TODO: Fix values for group indent (1/2cm) only the first 2 groups + int nIndent = 0; + final int MAX_INDENT = 2; + if (_nGroupCount <= MAX_INDENT) + { + nIndent = _nGroupCount * LayoutConstants.IndentFactorWidth; + } + else + { + nIndent = MAX_INDENT * LayoutConstants.IndentFactorWidth; + } + return nIndent; + } + + private int m_nLeftIndent = -1; + + /** + * Get left page indent. + * The left indent is the area on the left side which will no be printed. + * The default is 2000 1/100mm what is 2cm of DIN A4. + * @return the left indent in 1/100mm + */ + protected int getLeftPageIndent() + { + if (m_nLeftIndent < 0) + { + m_nLeftIndent = getFromPageStyles("LeftMargin", 2000); + } + return m_nLeftIndent; + } + + private int m_nRightIndent = -1; + + /** + * Get right page indent. + * The right indent is the area on the right side which will no be printed. + * The default is 2000 1/100mm what is 2cm of DIN A4. + * @return the right indent in 1/100mm + */ + protected int getRightPageIndent() + { + if (m_nRightIndent < 0) + { + m_nRightIndent = getFromPageStyles("RightMargin", 2000); + } + return m_nRightIndent; + } + + private XStyle getUsedStyle(String _sStyleName) + { + XStyle aUsedStyle = null; + final XNameAccess xNameAccess = getReportDefinition().getStyleFamilies(); + try + { + // get all Page Styles + final Object aPageStylesObj = xNameAccess.getByName(_sStyleName); + final XNameAccess xContainer = UnoRuntime.queryInterface(XNameAccess.class, aPageStylesObj); + + // step over all Page Styles, search the one which is in use + final String[] aElementNames = xContainer.getElementNames(); + for (int i = 0; i < aElementNames.length; i++) + { + final String sName = aElementNames[i]; + final Object aObj = xContainer.getByName(sName); + final XStyle xStyle = UnoRuntime.queryInterface(XStyle.class, aObj); + if (xStyle.isInUse()) + { + aUsedStyle = xStyle; + break; + } + } + } + catch (com.sun.star.uno.Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + return aUsedStyle; + } + + private int getFromPageStyles(String _sStyleName, int _nDefault) + { + int nValue = _nDefault; + final XStyle xStyle = getUsedStyle("PageStyles"); + if (xStyle != null) + { + // we found the page style which is in use + final PropertySetHelper aHelper = new PropertySetHelper(xStyle); + nValue = aHelper.getPropertyValueAsInteger(_sStyleName, nValue); + } + return nValue; + } + + private void setToPageStyles(String _sStyleName, Object _aObj) + { + final XStyle xStyle = getUsedStyle("PageStyles"); + if (xStyle != null) + { + final PropertySetHelper aHelper = new PropertySetHelper(xStyle); + aHelper.setPropertyValueDontThrow(_sStyleName, _aObj); + } + } + + private int m_nPageWidth = -1; + + /** + * Get page width. The default is 21000 1/100mm what is 21cm of DIN A4. + * @return the Width of the page in 1/100mm + */ + protected int getPageWidth() + { + if (m_nPageWidth < 0) + { + m_nPageWidth = getFromPageStyles(PropertyNames.PROPERTY_WIDTH, 21000); + } + return m_nPageWidth; + } + + + /** + * Stores the Group names. To insert/create a report with such group names, call layout() + */ + public void insertGroupNames(String[] _aGroupNames) + { + m_aGroupNames = _aGroupNames; + } + + public void insertSortingNames(String[][] _aSortFieldNames) + { + m_aSortNames = _aSortFieldNames; + } + + protected void copyGroupProperties(int _nGroup) + { + if (getDesignTemplate() != null) + { + try + { + final XGroups xForeignGroups = getDesignTemplate().getGroups(); + if (_nGroup < xForeignGroups.getCount()) + { + XGroup xForeignGroup = UnoRuntime.queryInterface(XGroup.class, xForeignGroups.getByIndex(_nGroup)); + XSection xForeignGroupSection = xForeignGroup.getHeader(); + + if (xForeignGroupSection != null) + { + final XGroups xGroups = getReportDefinition().getGroups(); + Object aGroup = xGroups.getByIndex(_nGroup); + XGroup xGroup = UnoRuntime.queryInterface(XGroup.class, aGroup); + XSection xGroupSection = xGroup.getHeader(); + + // copy Properties + copyProperties(xForeignGroupSection, xGroupSection); + } + } + } + catch (Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + + private int insertGroups() + { + final XGroups xGroups = getReportDefinition().getGroups(); + int lastGroupPosition = -1; + + if (m_aGroupNames != null) + { + final int nLeftPageIndent = getLeftPageIndent(); + final int nLabelWidth = getMaxLabelWidth(); // 3000; + final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups()); + final int nFieldWidth = nUsablePageWidth - nLabelWidth; + + XGroup aLastGroup = null; + // after done with all groups, we need access to the last group, for set property 'KeepTogether' so we remember it. + + for (int i = 0; i < m_aGroupNames.length; i++) + { + lastGroupPosition = i; + final XGroup xGroup = xGroups.createGroup(); + aLastGroup = xGroup; + + xGroup.setExpression(m_aGroupNames[i]); + xGroup.setHeaderOn(true); + + try + { + int nCount = xGroups.getCount(); + xGroups.insertByIndex(nCount, xGroup); + final XSection xGroupSection = xGroup.getHeader(); + copyGroupProperties(nCount); + + Rectangle aRect = new Rectangle(); + aRect.X = nLeftPageIndent + getLeftGroupIndent(i); + SectionObject aSO = getDesignTemplate().getGroupLabel(i); + aRect = insertLabel(xGroupSection, getTitleFromFieldName(m_aGroupNames[i]), aRect, nLabelWidth, aSO); + final String sGroupName = convertToFieldName(m_aGroupNames[i]); + aSO = getDesignTemplate().getGroupTextField(i); + aRect = insertFormattedField(xGroupSection, sGroupName, aRect, nFieldWidth, aSO); + int height = aRect.Height; + + // draw a line under the label/formattedfield + aRect.X = nLeftPageIndent + getLeftGroupIndent(i); + aRect.Y = aRect.Height; + final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X; + final int nLineHeight = LayoutConstants.LineHeight; + insertHorizontalLine(xGroupSection, aRect, nLineWidth, nLineHeight); + xGroupSection.setHeight(height + nLineHeight); + } + catch (com.sun.star.uno.Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + + // hold the inner group together + if (aLastGroup != null) + { + doNotBreakInTable(aLastGroup); + } + } + if (m_aSortNames != null) + { + for (String[] sortFieldName : m_aSortNames) + { + try + { + final XGroup xGroup = xGroups.createGroup(); + xGroup.setExpression(sortFieldName[0]); + xGroup.setSortAscending(PropertyNames.ASC.equals(sortFieldName[1])); + xGroup.setHeaderOn(false); + int nCount = xGroups.getCount(); + xGroups.insertByIndex(nCount, xGroup); + } + catch (java.lang.Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + return lastGroupPosition; + } + + + /** + * Give a list off all field title names to insert the field title names, call layout() + */ + public void insertFieldTitles(String[] _aFieldTitleNames) + { + m_aFieldTitleNames = _aFieldTitleNames; + } + + + private String getTitleFromFieldName(String _sField) + { + for (int i = 0; i < m_aFieldNames.length; i++) + { + if (m_aFieldNames[i].equals(_sField)) + { + return m_aFieldTitleNames[i]; + } + } + return PropertyNames.EMPTY_STRING; + } + + private int getTypeFromFieldName(String _sField) + { + for (int i = 0; i < m_aFieldNames.length; i++) + { + if (m_aFieldNames[i].equals(_sField)) + { + return m_aFieldTypes[i]; + } + } + return 0; + } + + private boolean listContains(String[] _aList, String _aValue) + { + for (int i = 0; i < _aList.length; i++) + { + if (_aList[i].equals(_aValue)) + { + return true; + } + } + return false; + } + + + /** + * Helper to get all field names without the names which are already in the group names + * @param _aList + * @param _aGetResultFrom + * @return + */ + private String[] getNamesWithoutGroupNames(String[] _aList, String[] _aGetResultFrom) + { + if (_aList == null) + { + return new String[] + { + }; /* empty list */ + } + if (getCountOfGroups() == 0) + { + if (_aGetResultFrom != null) + { + return _aGetResultFrom; + } + return _aList; + } + final int nNewLength = _aList.length - getCountOfGroups(); + String[] aNewList = new String[nNewLength]; + int j = 0; + for (int i = 0; i < _aList.length; i++) + { + final String sField = _aList[i]; + if (listContains(m_aGroupNames, sField)) + { + continue; + } + if (_aGetResultFrom != null) + { + aNewList[j++] = _aGetResultFrom[i]; + } + else + { + aNewList[j++] = sField; + } + if (j == nNewLength) + { + break; // Emergency break, we leave the result list. + } + } + return aNewList; + } + + + protected int calculateFieldWidth(int _nLeftIndent, int _nFieldCount) + { + int nWidth = 3000; + if (_nFieldCount > 0) + { + nWidth = (getPageWidth() - getLeftPageIndent() - getRightPageIndent() - _nLeftIndent) / _nFieldCount; + } + return nWidth; + } + + protected String[] getFieldTitleNames() + { + return getNamesWithoutGroupNames(m_aFieldNames, m_aFieldTitleNames); + } + + + abstract protected void insertDetailFieldTitles(int lastGroupPosition); + + + /** + * Give a list off all field names to insert the field names, call layout() + */ + public void insertFieldNames(String[] _aFieldNames) + { + m_aFieldNames = _aFieldNames; + } + + public void insertFieldTypes(int[] _aFieldTypes) + { + m_aFieldTypes = _aFieldTypes; + } + + public void insertFieldWidths(int[] _aFieldWidths) + { + m_aFieldWidths = _aFieldWidths; + } + + protected int getCountOfGroups() + { + return ((m_aGroupNames == null) ? 0 : m_aGroupNames.length); + } + + + protected String[] getFieldNames() + { + return getNamesWithoutGroupNames(m_aFieldNames, null); + } + + abstract protected void insertDetailFields(); + + protected void copyDetailProperties() + { + if (getDesignTemplate() != null) + { + try + { + XSection xForeignSection = getDesignTemplate().getDetail(); + if (xForeignSection != null) + { + XSection xSection = getReportDefinition().getDetail(); + + // copy Properties + copyProperties(xForeignSection, xSection); + } + } + catch (Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + + protected Rectangle insertLabel(XSection _xSection, String _sLabel, Rectangle _aRect, int _nWidth, SectionObject _aSO) + { + if (_xSection != null) + { + try + { + final Object aFixedText = getMSFofReportDefinition().createInstance("com.sun.star.report.FixedText"); + final XFixedText xFixedText = UnoRuntime.queryInterface(XFixedText.class, aFixedText); + + + int nHeight = LayoutConstants.LabelHeight; // default height of label is fixed. + if (_aSO != null) + { + if (_aSO instanceof SectionEmptyObject) + { + float fCharWeight = _aSO.getCharWeight(com.sun.star.awt.FontWeight.NORMAL); + if (fCharWeight > 0.1f) + { + xFixedText.setCharWeight(fCharWeight); + } + } + else + { +// TODO: there seems to be some problems with copy all properties from the design template to the current design + final FontDescriptor aFD = _aSO.getFontDescriptor(); + if (aFD != null) + { + xFixedText.setFontDescriptor(aFD); + copyProperties(_aSO.getParent(), xFixedText); + } + nHeight = _aSO.getHeight(LayoutConstants.LabelHeight); + } + } + xFixedText.setLabel(_sLabel); + + xFixedText.setPositionX(_aRect.X); + xFixedText.setPositionY(_aRect.Y); + + // Width will calculate from outside. + // We have to set, because there exist no right default (0) + xFixedText.setWidth(_nWidth); + _aRect.X += _nWidth; + xFixedText.setHeight(nHeight); + _xSection.add(xFixedText); + } + catch (com.sun.star.uno.Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + return _aRect; + } + + + protected String convertToFieldName(String _sElementName) + { + final StringBuffer aDataField = new StringBuffer(32); + aDataField.append("field:[").append(_sElementName).append(']'); + return aDataField.toString(); + + } + + private String convertFromFieldName(String _sName) + { + if (_sName.startsWith("field:[")) + { + int nCloseBrace = _sName.lastIndexOf(']'); + return _sName.substring(7, nCloseBrace).trim(); + } + return _sName; + } + + + /** + * Insert an already formatted field name into a given section + * + * Use 'convertToFieldName(dbfield)' to convert a dbfield name in the right. + * + * @param _xSection in which section the formatted field will store + * @param _sFormattedfield as String a dbfield or another function + * @param _aRect .X, .Y are the absolute position (1/100mm) where the formatted field will set + * @param _nWidth the width of the field in 1/100mm + * @param _aSO + * @return a new Rectangle with the new Rect.X position, Rect.Y will not change. + */ + protected Rectangle insertFormattedField(XSection _xSection, String _sFormattedfield, Rectangle _aRect, int _nWidth, SectionObject _aSO) + { + return insertFormattedField(_xSection, _sFormattedfield, _aRect, _nWidth, _aSO, (short) com.sun.star.awt.TextAlign.LEFT); + } + + private Rectangle insertFormattedField(XSection _xSection, String _sFormattedfield, Rectangle _aRect, int _nWidth, SectionObject _aSO, short _nAlignment) + { + if (_xSection != null) + { + try + { + Object aField; + int nHeight = LayoutConstants.FormattedFieldHeight; + + int nType = getTypeFromFieldName(convertFromFieldName(_sFormattedfield)); + if (nType == DataType.BINARY + || nType == DataType.VARBINARY + || nType == DataType.LONGVARBINARY) + { + aField = getMSFofReportDefinition().createInstance("com.sun.star.report.ImageControl"); + nHeight = LayoutConstants.BinaryHeight; + } + else + { + aField = getMSFofReportDefinition().createInstance("com.sun.star.report.FormattedField"); + nHeight = LayoutConstants.FormattedFieldHeight; + if (nType == DataType.LONGVARCHAR) /* memo */ + + { + nHeight = LayoutConstants.MemoFieldHeight; // special case for memo + } + } + _aRect.Height = nHeight; + + final XReportControlModel xReportControlModel = UnoRuntime.queryInterface(XReportControlModel.class, aField); + if (xReportControlModel != null) + { + // #i86907# not documented right in idl description. + xReportControlModel.setDataField(_sFormattedfield); + if (_aSO != null) + { + // TODO: there seems to be some problems with copy all properties from the design template to the current design + final FontDescriptor aFD = _aSO.getFontDescriptor(); + if (aFD != null) + { + xReportControlModel.setFontDescriptor(aFD); + copyProperties(_aSO.getParent(), xReportControlModel); + } + nHeight = _aSO.getHeight(nHeight); + } + xReportControlModel.setPositionX(_aRect.X); + xReportControlModel.setPositionY(_aRect.Y); + xReportControlModel.setWidth(_nWidth); + _aRect.X += _nWidth; + xReportControlModel.setHeight(nHeight); + + if (nType == DataType.BINARY + || nType == DataType.VARBINARY + || nType == DataType.LONGVARBINARY) + { + final XImageControl xImageControl = UnoRuntime.queryInterface(XImageControl.class, xReportControlModel); + if (xImageControl != null) + { + xImageControl.setScaleMode(com.sun.star.awt.ImageScaleMode.ISOTROPIC); + } + } + else + { + try + { + xReportControlModel.setParaAdjust(_nAlignment); + } + catch (com.sun.star.beans.UnknownPropertyException ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + // spezial case rpt:now() (default date format) + if (_sFormattedfield.equals("rpt:now()")) + { + final XFormattedField xFormattedField = UnoRuntime.queryInterface(XFormattedField.class, xReportControlModel); + + XNumberFormatsSupplier x = xFormattedField.getFormatsSupplier(); + XNumberFormats xFormats = x.getNumberFormats(); + XNumberFormatTypes x3 = UnoRuntime.queryInterface(XNumberFormatTypes.class, xFormats); + com.sun.star.lang.Locale aLocale = new com.sun.star.lang.Locale(); + aLocale.Country = Locale.getDefault().getCountry(); + aLocale.Language = Locale.getDefault().getLanguage(); + + int nFormat = x3.getStandardFormat(com.sun.star.util.NumberFormat.DATE, aLocale); + xFormattedField.setFormatKey(nFormat); + } + _xSection.add(xReportControlModel); + } + } + catch (com.sun.star.uno.Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + return _aRect; + } + + +// TODO: check with Query, this code will not work with Queries + public void setTableName(int _aType, String _sTableName) + { + m_aCommandType = _aType; + m_sTableName = _sTableName; + + getReportDefinition().setCommandType(_aType); + getReportDefinition().setCommand(_sTableName); + } + private XMultiServiceFactory m_xMSF; + + private XMultiServiceFactory getMSFofReportDefinition() + { + if (m_xMSF == null) + { + m_xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, getReportDefinition()); + } + return m_xMSF; + } + + + + + private Rectangle insertHorizontalLine(XSection _xSection, Rectangle _aRect, int _nWidth, int _nHeight) + { + return insertLine(_xSection, _aRect, _nWidth, _nHeight, 0); + } + + private Rectangle insertLine(XSection _xSection, Rectangle _aRect, int _nWidth, int _nHeight, int _nOrientation) + { + if (_xSection != null) + { + try + { + final Object aFixedLine = getMSFofReportDefinition().createInstance("com.sun.star.report.FixedLine"); + final XFixedLine xFixedLine = UnoRuntime.queryInterface(XFixedLine.class, aFixedLine); + + xFixedLine.setOrientation(_nOrientation); + // TODO: line width is fixed + xFixedLine.setLineWidth(8); + + xFixedLine.setPositionX(_aRect.X); + xFixedLine.setPositionY(_aRect.Y); + + xFixedLine.setWidth(_nWidth); + _aRect.X += _nWidth; + xFixedLine.setHeight(_nHeight); + _xSection.add(xFixedLine); + } + catch (com.sun.star.uno.Exception ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + return _aRect; + } + + + private void clearReportHeader() + { + XSection xSection; + try + { + if (getReportDefinition().getReportHeaderOn()) + { + xSection = getReportDefinition().getReportHeader(); + emptySection(xSection); + } + } + catch (com.sun.star.container.NoSuchElementException ex) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, ex); + } + } + + private void insertReportHeader() + { + if (getDesignTemplate() != null) + { + if (getDesignTemplate().getReportHeaderOn()) + { + // copy all Section information from Page Header to our Header + try + { + XSection xForeignSection = getDesignTemplate().getReportHeader(); + + if (xForeignSection != null) + { + getReportDefinition().setReportHeaderOn(true); + XSection xSection = getReportDefinition().getReportHeader(); + + // copy Sections + copySection(xForeignSection, xSection); + } + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + else + { + // we won't a page header + getReportDefinition().setReportHeaderOn(false); + } + } + } + + private void clearReportFooter() + { + XSection xSection; + try + { + if (getReportDefinition().getReportFooterOn()) + { + xSection = getReportDefinition().getReportFooter(); + emptySection(xSection); + } + } + catch (com.sun.star.container.NoSuchElementException e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + + private void insertReportFooter() + { + if (getDesignTemplate() != null) + { + if (getDesignTemplate().getReportFooterOn()) + { + // copy all Section information from Page Header to our Header + try + { + XSection xForeignSection = getDesignTemplate().getReportFooter(); + + if (xForeignSection != null) + { + getReportDefinition().setReportFooterOn(true); + XSection xSection = getReportDefinition().getReportFooter(); + + // copy Sections + copySection(xForeignSection, xSection); + } + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + else + { + // we won't a page header + getReportDefinition().setReportFooterOn(false); + } + } + } + + + private void clearPageHeader() + { + XSection xSection; + try + { + if (getReportDefinition().getPageHeaderOn()) + { + xSection = getReportDefinition().getPageHeader(); + emptySection(xSection); + } + } + catch (com.sun.star.container.NoSuchElementException e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + + private void clearPageFooter() + { + XSection xSection; + try + { + if (getReportDefinition().getPageFooterOn()) + { + xSection = getReportDefinition().getPageFooter(); + emptySection(xSection); + } + } + catch (com.sun.star.container.NoSuchElementException e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + + public void setPageOrientation(int _nOrientation) + { + final int nWidth = getFromPageStyles(PropertyNames.PROPERTY_WIDTH, 0); + final int nHeight = getFromPageStyles(PropertyNames.PROPERTY_HEIGHT, 0); + + if (com.sun.star.wizards.report.ReportLayouter.SOOPTLANDSCAPE == _nOrientation) + { + setToPageStyles("IsLandscape", Boolean.TRUE); + if (nWidth < nHeight) + { + setToPageStyles(PropertyNames.PROPERTY_WIDTH, Integer.valueOf(nHeight)); + setToPageStyles(PropertyNames.PROPERTY_HEIGHT, Integer.valueOf(nWidth)); + } + } + else + { + setToPageStyles("IsLandscape", Boolean.FALSE); + if (nHeight < nWidth) + { + setToPageStyles(PropertyNames.PROPERTY_WIDTH, Integer.valueOf(nHeight)); + setToPageStyles(PropertyNames.PROPERTY_HEIGHT, Integer.valueOf(nWidth)); + } + } + // dirty the PageWidth + m_nPageWidth = -1; + } + + /** + * Returns the width and height of a given string (_sText) in 1/100mm drawn in the given font descriptor. + * TODO: This function is a performance leak, we could store already calculated values in a map, to build a cache. Access should be much faster then. + * + * @param _sText + * @param _aFont + * @return width of given text in 1/100mm + */ + private Size getPreferredSize(String _sText, FontDescriptor _aFont) + { + Size aSizeMM_100TH = new Size(0, 0); + try + { + + final Object aFixedTextModel = getGlobalMSF().createInstance("com.sun.star.awt.UnoControlFixedTextModel"); + final XControlModel xFixedTextModel = UnoRuntime.queryInterface(XControlModel.class, aFixedTextModel); + + final PropertySetHelper aPropertySetHelper = new PropertySetHelper(xFixedTextModel); + aPropertySetHelper.setPropertyValueDontThrow(PropertyNames.FONT_DESCRIPTOR, _aFont); + + final Object aUnoCtrlFixedText = getGlobalMSF().createInstance("com.sun.star.awt.UnoControlFixedText"); + + final XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, aUnoCtrlFixedText); + xWindow.setVisible(false); + + final XControl xControl = UnoRuntime.queryInterface(XControl.class, aUnoCtrlFixedText); + xControl.setModel(xFixedTextModel); + + final com.sun.star.awt.XFixedText xFixedText = UnoRuntime.queryInterface(com.sun.star.awt.XFixedText.class, aUnoCtrlFixedText); + xFixedText.setText(_sText); + + final XLayoutConstrains xLayoutConstraints = UnoRuntime.queryInterface(XLayoutConstrains.class, aUnoCtrlFixedText); + final Size aSizeInPixel = xLayoutConstraints.getPreferredSize(); + + final XWindowPeer xPeerOfReportDefinition = UnoRuntime.queryInterface(XWindowPeer.class, getReportDefinition().getCurrentController().getFrame().getComponentWindow()); + xControl.createPeer(null, xPeerOfReportDefinition); + + final XWindowPeer x = xControl.getPeer(); + + final XUnitConversion xConversion = UnoRuntime.queryInterface(XUnitConversion.class, x); + aSizeMM_100TH = xConversion.convertSizeToLogic(aSizeInPixel, com.sun.star.util.MeasureUnit.MM_100TH); + // we don't need the created objects any longer + final XComponent xFixedTextDeleter = UnoRuntime.queryInterface(XComponent.class, xFixedText); + xFixedTextDeleter.dispose(); + + final XComponent xFixedTextModelDeleter = UnoRuntime.queryInterface(XComponent.class, aFixedTextModel); + xFixedTextModelDeleter.dispose(); + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + return aSizeMM_100TH; + } + + private String getTableName() + { + if (m_sTableName != null) + { + return m_sTableName; + } + return PropertyNames.EMPTY_STRING; + } + + private String getUserNameFromConfiguration() + { + String sFirstName = PropertyNames.EMPTY_STRING; + String sLastName = PropertyNames.EMPTY_STRING; + try + { + Object oProdNameAccess = Configuration.getConfigurationRoot(getGlobalMSF(), "org.openoffice.UserProfile/Data", false); + sFirstName = (String) Helper.getUnoObjectbyName(oProdNameAccess, "givenname"); + sLastName = (String) Helper.getUnoObjectbyName(oProdNameAccess, "sn"); + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + return sFirstName + PropertyNames.SPACE + sLastName; + } + + /** + * Helper function, to copy all not read only properties of _xFromSection to _xToSection + * @param _aFrom + * @param _aTo + */ + private void copyProperties(Object _aFrom, Object _aTo) + { + XPropertySet xFrom = UnoRuntime.queryInterface(XPropertySet.class, _aFrom); + XPropertySet xTo = UnoRuntime.queryInterface(XPropertySet.class, _aTo); + + + XPropertySetInfo xForeignPropInfo = xFrom.getPropertySetInfo(); + XPropertySetInfo xSectionPropInfo = xTo.getPropertySetInfo(); + Property[] aAllProperties = xForeignPropInfo.getProperties(); + for (int i = 0; i < aAllProperties.length; i++) + { + String sPropertyName = aAllProperties[i].Name; + if (xSectionPropInfo.hasPropertyByName(sPropertyName)) + { + try + { + Property aDestProp = xForeignPropInfo.getPropertyByName(sPropertyName); + if ((aDestProp.Attributes & PropertyAttribute.READONLY) == 0) + { + xTo.setPropertyValue(sPropertyName, xFrom.getPropertyValue(sPropertyName)); + } + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + } + } + + /** + * Helper function to copy the whole content of _xFromSection to the _xToSection + * @param _xFromSection + * @param _xToSection + */ + private void copySection(XSection _xFromSection, XSection _xToSection) + { + copyProperties(_xFromSection, _xToSection); + + try + { + XEnumeration xEnum = _xFromSection.createEnumeration(); + while (xEnum.hasMoreElements()) + { + Object aEnumObj = xEnum.nextElement(); + XReportComponent aComponent = UnoRuntime.queryInterface(XReportComponent.class, aEnumObj); + + if (aComponent != null) + { + Object aClone = aComponent.createClone(); + if (aClone != null) + { + XShape aShape = UnoRuntime.queryInterface(XShape.class, aClone); + + // normally 'createClone' will create a real clone of the component, + // but there seems some problems, we have to control. + copyProperties(aComponent, aClone); + + // aShape.setPosition(aComponent.getPosition()); + // aShape.setSize(aComponent.getSize()); + _xToSection.add(aShape); + } + } + } + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + + private void insertPageHeader() + { + if (getDesignTemplate() != null) + { + if (getDesignTemplate().getPageHeaderOn()) + { + // copy all Section information from Page Header to our Header + try + { + XSection xForeignSection = getDesignTemplate().getPageHeader(); + + if (xForeignSection != null) + { + getReportDefinition().setPageHeaderOn(true); + XSection xSection = getReportDefinition().getPageHeader(); + + // copy Sections + copySection(xForeignSection, xSection); + } + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + else + { + // we won't a page header + // getReportDefinition().setPageHeaderOn(true); + getReportDefinition().setPageHeaderOn(false); + } + } + else + { + if (getReportDefinition() == null) + { + return; + } + // there is no foreign report definition + // TODO: #i86902# rpt:Title() out of the document + + // TODO: #i86902# rpt:Author() can't set with something like rpt:author() + // TODO: #i86902# more fieldnames need. + final String sTitleTitle = getResource().getResText("RID_REPORT_86"); // "Title:" + final String sTitle = getTableName(); // "Default title, this is a first draft report generated by the new report wizard."; + final String sAuthorTitle = getResource().getResText("RID_REPORT_87"); // "Author:" + final String sAuthor = getUserNameFromConfiguration(); // "You"; + final String sDateTitle = getResource().getResText("RID_REPORT_88"); // "Date:" + // TODO: #i86911# Date: we need to set the style of the date. + final String sDate = "rpt:now()"; + + try + { + getReportDefinition().setPageHeaderOn(true); + XSection xSection = null; + xSection = getReportDefinition().getPageHeader(); + + Rectangle aRect = new Rectangle(); + aRect.X = getLeftPageIndent(); + SectionObject aSOLabel = SectionEmptyObject.create(); + aSOLabel.setFontToBold(); + aRect.Y = aSOLabel.getHeight(LayoutConstants.LabelHeight); + + final int nWidth = 3000; + + aRect = insertLabel(xSection, sTitleTitle, aRect, nWidth, aSOLabel); + + final int nTitleWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - 3000; + aRect = insertLabel(xSection, sTitle, aRect, nTitleWidth, aSOLabel); + + aRect.Y += aSOLabel.getHeight(LayoutConstants.LabelHeight) + LayoutConstants.LineHeight; + + aRect.X = getLeftPageIndent(); + aRect = insertLabel(xSection, sAuthorTitle, aRect, nWidth, aSOLabel); + aRect = insertLabel(xSection, sAuthor, aRect, nTitleWidth, aSOLabel); + + aRect.Y += aSOLabel.getHeight(LayoutConstants.LabelHeight); + + aRect.X = getLeftPageIndent(); + aRect = insertLabel(xSection, sDateTitle, aRect, nWidth, aSOLabel); + aRect = insertFormattedField(xSection, sDate, aRect, nTitleWidth, aSOLabel); + + aRect.Y += aSOLabel.getHeight(LayoutConstants.FormattedFieldHeight) + LayoutConstants.LineHeight; + + // draw a line under the label/formattedfield + aRect.X = getLeftPageIndent(); + final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X; + final int nLineHeight = LayoutConstants.LineHeight; + insertHorizontalLine(xSection, aRect, nLineWidth, nLineHeight); + + aRect.Y += nLineHeight; + + xSection.setHeight(aRect.Y); + } + catch (com.sun.star.uno.Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + } + + private void insertPageFooter() + { + if (getDesignTemplate() != null) + { + if (getDesignTemplate().getPageFooterOn()) + { + try + { + XSection xForeignSection = getDesignTemplate().getPageFooter(); + + if (xForeignSection != null) + { + getReportDefinition().setPageFooterOn(true); + XSection xSection = getReportDefinition().getPageFooter(); + + // copy Sections + copySection(xForeignSection, xSection); + } + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + else + { + getReportDefinition().setPageFooterOn(false); + } + } + else + { + if (getReportDefinition() == null) + { + return; + } + + // TODO: how should we arrive this code (set page and pagecount in the middle of the page footer) + // If there exists a design template, don't use it. + + // we don't have a default report definition + final String sPageOf = getResource().getResText("RID_REPORT_89"); // 'Page #page# of #count#' + + // Convert + // 'Page #page# of #count#' + // to something like + // '\"Page \" & PageNumber() & \" of \" & PageCount()' + // due to the fact that it is not fixed, where #page# or #count# occurs, we make it + // a little bit trickier. + // we first surround the string with double quotes, + // second, replace the #...# + // last, we remove double 'double quotes'. + final String sSurroundDoubleQuotes = "\"" + sPageOf + "\""; + final String sPageNumber = sSurroundDoubleQuotes.replaceAll("#page#", "\" & PageNumber() & \""); + final String sPageCount = sPageNumber.replaceAll("#count#", "\" & PageCount() & \""); + final String sNoLastUnusedQuotes = sPageCount.replaceAll(" & \\\"\\\"", PropertyNames.EMPTY_STRING); + final String sNoFirstUnusedQuotes = sNoLastUnusedQuotes.replaceAll("\\\"\\\" & ", PropertyNames.EMPTY_STRING); + + final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent(); + + try + { + getReportDefinition().setPageFooterOn(true); + XSection xSection = null; + xSection = getReportDefinition().getPageFooter(); + + Rectangle aRect = new Rectangle(); + aRect.X = getLeftPageIndent(); + + // draw a line over the label/formattedfield + final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X; + final int nLineHeight = LayoutConstants.LineHeight; + insertHorizontalLine(xSection, aRect, nLineWidth, nLineHeight); + + aRect.Y += nLineHeight; + aRect.Y += LayoutConstants.LabelHeight; + + aRect.X = getLeftPageIndent(); + + aRect = insertFormattedField(xSection, "rpt:" + sNoFirstUnusedQuotes, aRect, nUsablePageWidth, null, (short) com.sun.star.awt.TextAlign.CENTER); + + aRect.Y += LayoutConstants.FormattedFieldHeight + LayoutConstants.LineHeight; + xSection.setHeight(aRect.Y); + } + catch (Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + } + + protected Resource getResource() + { + return m_aResource; + } + private int m_aCommandType; // Table or Query + private String m_sTableName; + private String[] m_aGroupNames; + private String[] m_aFieldNames; + private String[] m_aFieldTitleNames; + private int[] m_aFieldWidths; + private int[] m_aFieldTypes; + private DesignTemplate m_xDesignTemplate = null; + + public void initializeData(IReportBuilderLayouter _aOther) + { + if (_aOther instanceof ReportBuilderLayouter) + { + final ReportBuilderLayouter aOther = (ReportBuilderLayouter) _aOther; + m_aCommandType = aOther.m_aCommandType; + m_sTableName = aOther.m_sTableName; + m_aGroupNames = aOther.m_aGroupNames; + m_aFieldNames = aOther.m_aFieldNames; + m_aFieldTitleNames = aOther.m_aFieldTitleNames; + m_aFieldWidths = aOther.m_aFieldWidths; + m_aFieldTypes = aOther.m_aFieldTypes; + m_xDesignTemplate = aOther.m_xDesignTemplate; + + // dirty PageWidth + m_nPageWidth = -1; + } + } + + /** + * Get the maximal label width of all labels + * @return the width in 1/100mm + */ + protected int getMaxLabelWidth() + { + int nWidth = 0; + final String[] aFieldTitles = m_aFieldTitleNames; // we want all Field Titles here // getFieldTitleNames(); + for (int i = 0; i < aFieldTitles.length; i++) + { + final String sLabel = aFieldTitles[i]; + nWidth = Math.max(nWidth, getLabelWidth(sLabel)); + } + for (int i = 0; i < m_aGroupNames.length; i++) + { + final String sGroupName = m_aGroupNames[i]; + final SectionObject a = getDesignTemplate().getGroupLabel(i); + final FontDescriptor aFD = a.getFontDescriptor(); + nWidth = Math.max(nWidth, getLabelWidth(sGroupName, aFD)); + } + + if (nWidth == 0) + { + nWidth = 3000; + } + else + { + nWidth += 500; + } + return nWidth; + } + + /** + * Get width of a given string (Label) in 1/100mm + * @param _sLabel + * @return the width in 1/100mm + */ + private int getLabelWidth(String _sLabel) + { + return getLabelWidth(_sLabel, 0.0f, 0.0f); + } + private XFixedText m_aFixedTextHelper = null; + private HashMap<String, Integer> m_aLabelWidthMap; + + private int getLabelWidth(String _sLabel, FontDescriptor _aFD) + { + float fCharWeight = 0.0f; + float fCharHeight = 0.0f; + if (_aFD != null) + { + fCharWeight = _aFD.Weight; + fCharHeight = _aFD.Height; + } + return getLabelWidth(_sLabel, fCharWeight, fCharHeight); + } + + private int getLabelWidth(String _sLabel, float _nCharWeight, float _nCharHeight) + { + int nWidth = 0; + + if (m_aLabelWidthMap == null) + { + m_aLabelWidthMap = new HashMap<String, Integer>(); + } + // At first, try to get the Width out of a HashMap (Cache) + StringBuffer aKey = new StringBuffer(40); + final String sKey = aKey.append(_sLabel).append(_nCharWeight).append(_nCharHeight).toString(); + if (m_aLabelWidthMap.containsKey(sKey)) + { + final Object aWidth = m_aLabelWidthMap.get(sKey); + final Integer aIntegerWidth = (Integer) aWidth; + nWidth = aIntegerWidth.intValue(); + } + else + { + try + { + if (m_aFixedTextHelper == null) + { + final Object aFixedText = getMSFofReportDefinition().createInstance("com.sun.star.report.FixedText"); + m_aFixedTextHelper = UnoRuntime.queryInterface(XFixedText.class, aFixedText); + } + + m_aFixedTextHelper.setLabel(_sLabel); + if (_nCharWeight > 0.1f) + { + m_aFixedTextHelper.setCharWeight(_nCharWeight); + } + if (_nCharHeight > 0.1f) + { + m_aFixedTextHelper.setCharHeight(_nCharHeight); + } + + final FontDescriptor xFont = m_aFixedTextHelper.getFontDescriptor(); + final Size aSize = getPreferredSize(_sLabel, xFont); + nWidth = aSize.Width; + // cache the found width + m_aLabelWidthMap.put(sKey, Integer.valueOf(nWidth)); + } + catch (com.sun.star.uno.Exception e) + { + Logger.getLogger(ReportBuilderLayouter.class.getName()).log(Level.SEVERE, null, e); + } + } + return nWidth; + } + + protected void doNotBreakInTable(Object _xSectionOrGroup) + { + final PropertySetHelper aHelper = new PropertySetHelper(_xSectionOrGroup); + aHelper.setPropertyValueDontThrow("KeepTogether", Boolean.TRUE); + } + + protected DesignTemplate getDesignTemplate() + { + if (m_xDesignTemplate == null) + { + // initialise the report definition. + String sDefaultHeaderLayout = m_xReportDefinitionReadAccess.getDefaultHeaderLayout(); + loadAndSetBackgroundTemplate(sDefaultHeaderLayout); + } + return m_xDesignTemplate; + } + + /** + * If there already exists a foreign report definition, which we use to get the layout from + * close it. + * Veto is not allowed here. + */ + private void closeDesignTemplate() + { + if (m_xDesignTemplate != null) + { + m_xDesignTemplate.close(); + m_xDesignTemplate = null; + } + } + + /** + * load the given string as a template and use its content to paint the other + */ + public void loadAndSetBackgroundTemplate(String LayoutTemplatePath) + { + closeDesignTemplate(); + + String sName = FileAccess.getFilename(LayoutTemplatePath); + if (sName.equalsIgnoreCase("default.otr_") + || LayoutTemplatePath.equals("DefaultLayoutOfHeaders")) + { + // this is the default layout, we don't want to have a layout for this. + } + else + { + XMultiServiceFactory xMSF = getGlobalMSF(); + m_xDesignTemplate = DesignTemplate.create(xMSF, LayoutTemplatePath); + } + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionEmptyObject.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionEmptyObject.java new file mode 100644 index 0000000000..f8f03c4c04 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionEmptyObject.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.FontDescriptor; + +public class SectionEmptyObject extends SectionObject +{ + + protected SectionEmptyObject() + { + m_aParentObject = null; + } + + public static SectionObject create() + { + return new SectionEmptyObject(); + } + + @Override + public FontDescriptor getFontDescriptor() + { + return null; + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionLabel.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionLabel.java new file mode 100644 index 0000000000..8a40270336 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionLabel.java @@ -0,0 +1,55 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.FontDescriptor; +import com.sun.star.report.XFixedText; + +public class SectionLabel extends SectionObject +{ + + private SectionLabel(XFixedText _aFixedText) + { + m_aParentObject = _aFixedText; + } + + public static SectionObject create(XFixedText _aFixedText) + { + return new SectionLabel(_aFixedText); + } + + /** + * Return the current FontDescriptor + */ + @Override + public FontDescriptor getFontDescriptor() + { + FontDescriptor a = null; + try + { + final XFixedText aLabel = (XFixedText) getParent(); + a = aLabel.getFontDescriptor(); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + } + return a; + } +} + + diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java new file mode 100644 index 0000000000..f39cc47174 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java @@ -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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.FontDescriptor; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.PropertySetHelper; + +abstract public class SectionObject +{ + + Object m_aParentObject; // this could be FixedText or FormattedField or null + private PropertySetHelper m_aPropertySetHelper; + + public SectionObject() + { + m_aParentObject = null; + } + + protected Object getParent() + { + return m_aParentObject; + } + + abstract public FontDescriptor getFontDescriptor(); + + private PropertySetHelper getPropertySetHelper() + { + if (m_aPropertySetHelper == null) + { + m_aPropertySetHelper = new PropertySetHelper(getParent()); + } + return m_aPropertySetHelper; + } + + public int getHeight(int _nDefault) + { + return getPropertySetHelper().getPropertyValueAsInteger(PropertyNames.PROPERTY_HEIGHT, _nDefault); + } + + public float getCharWeight(float _nDefault) + { + return(float) getPropertySetHelper().getPropertyValueAsDouble("CharWeight", _nDefault); + } + + public void setFontToBold() + { + setPropertyValue("CharWeight", Float.valueOf(com.sun.star.awt.FontWeight.BOLD)); + } + + public void setPropertyValue(String _sKey, Object _nValue) + { + getPropertySetHelper().setPropertyValueDontThrow(_sKey, _nValue); + } +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionTextField.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionTextField.java new file mode 100644 index 0000000000..bc7be4e884 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionTextField.java @@ -0,0 +1,52 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.FontDescriptor; +import com.sun.star.report.XFormattedField; + +public class SectionTextField extends SectionObject +{ + + private SectionTextField(XFormattedField _aFormattedField) + { + m_aParentObject = _aFormattedField; + // We would like to know, what properties are in this object. + } + + public static SectionObject create(XFormattedField _aFormattedField) + { + return new SectionTextField(_aFormattedField); + } + + @Override + public FontDescriptor getFontDescriptor() + { + FontDescriptor a = null; + try + { + XFormattedField aField = (XFormattedField) getParent(); + a = aField.getFontDescriptor(); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + } + return a; + } +} + diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java b/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java new file mode 100644 index 0000000000..814de5a932 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java @@ -0,0 +1,139 @@ +/* + * 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 . + */ +package com.sun.star.wizards.reportbuilder.layout; + +import com.sun.star.awt.Rectangle; +import com.sun.star.report.XGroup; +import com.sun.star.report.XGroups; +import com.sun.star.report.XSection; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.ui.UIConsts; + +public class Tabular extends ReportBuilderLayouter +{ + + public Tabular(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource) + { + super(_xDefinitionAccess, _aResource); + } + + public String getName() + { + return "DefaultLayoutOfData"; + } + + public String getLocalizedName() + { + return getResource().getResText("RID_REPORT_80"); + } + + @Override + protected void insertDetailFields() + { + copyDetailProperties(); + + String[] aFieldNames = getFieldNames(); + if (aFieldNames == null) + { + return; + } + if (aFieldNames.length == 0) + { + return; + } + + final XSection xSection = getReportDefinition().getDetail(); + + Rectangle aRect = new Rectangle(); + aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + + final int nWidth = calculateFieldWidth(getLeftGroupIndent(getCountOfGroups()), aFieldNames.length); + final SectionObject aSO = getDesignTemplate().getDetailTextField(); + int nHeight = LayoutConstants.FormattedFieldHeight; + for (int i = 0; i < aFieldNames.length; i++) + { + final String sFieldName = convertToFieldName(aFieldNames[i]); + aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSO); + nHeight = Math.max(aRect.Height, nHeight); + } + nHeight = Math.max(aSO.getHeight(nHeight), nHeight); + xSection.setHeight(nHeight); + } + + @Override + protected void insertDetailFieldTitles(int lastGroupPosition) + { + final String[] aFieldTitleNames = getFieldTitleNames(); + if (aFieldTitleNames == null || aFieldTitleNames.length == 0) + { + return; + } + try + { + SectionObject aSO = null; + final XGroups xGroups = getReportDefinition().getGroups(); + final XGroup xGroup; + if (lastGroupPosition == -1) + { + // Spezial case, there is no Group. + xGroup = xGroups.createGroup(); + xGroup.setHeaderOn(true); + + xGroups.insertByIndex(xGroups.getCount(), xGroup); + copyGroupProperties(0); + aSO = getDesignTemplate().getDetailLabel(); + aSO.setFontToBold(); + } + else + { + // we insert the titles in the last group + xGroup = UnoRuntime.queryInterface(XGroup.class, xGroups.getByIndex(lastGroupPosition)); + + // We don't need to copy the GroupProperties, because this is done in the insertGroup() member function + // copyGroupProperties(0); + aSO = getDesignTemplate().getGroupLabel(lastGroupPosition); + } + + XSection xSection = xGroup.getHeader(); + Rectangle aRect = new Rectangle(); + aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); + if (lastGroupPosition == -1) + { + xSection.setHeight(0); // group height + a little empty line) + aRect.Y = 0; + } + else + { + aRect.Y = xSection.getHeight() + LayoutConstants.LineHeight; + } + + final int nWidth = calculateFieldWidth(getLeftGroupIndent(getCountOfGroups()), aFieldTitleNames.length); + + for (int i = 0; i < aFieldTitleNames.length; i++) + { + aRect = insertLabel(xSection, aFieldTitleNames[i], aRect, nWidth, aSO); + } + xSection.setHeight(xSection.getHeight() + aSO.getHeight(LayoutConstants.LabelHeight)); + } + catch (com.sun.star.uno.Exception e) + { + } + } +} diff --git a/wizards/com/sun/star/wizards/table/CGCategory.java b/wizards/com/sun/star/wizards/table/CGCategory.java new file mode 100644 index 0000000000..c0a1148f90 --- /dev/null +++ b/wizards/com/sun/star/wizards/table/CGCategory.java @@ -0,0 +1,71 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Configuration; + +/** + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class CGCategory +{ + + private static final String CGROOTPATH = "/org.openoffice.Office.TableWizard/TableWizard/"; + private XMultiServiceFactory xMSF; + XNameAccess xNameAccessTablesNode; + private XNameAccess xNameAccessCurBusinessNode; + + public CGCategory(XMultiServiceFactory _xMSF) + { + xMSF = _xMSF; + } + + public void initialize(String category) + { + try + { + Object oconfigView = Configuration.getConfigurationRoot(xMSF, CGROOTPATH, false); //business/Tables + xNameAccessCurBusinessNode = Configuration.getChildNodebyName( + UnoRuntime.queryInterface(XNameAccess.class, oconfigView), + category); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public String[] getTableNames() + { + try + { + xNameAccessTablesNode = UnoRuntime.queryInterface(XNameAccess.class, xNameAccessCurBusinessNode.getByName("Tables")); + return Configuration.getNodeDisplayNames(xNameAccessTablesNode); + } + catch (Exception e) + { + e.printStackTrace(System.err); + return null; + } + } +} diff --git a/wizards/com/sun/star/wizards/table/CGTable.java b/wizards/com/sun/star/wizards/table/CGTable.java new file mode 100644 index 0000000000..1b6313b4bb --- /dev/null +++ b/wizards/com/sun/star/wizards/table/CGTable.java @@ -0,0 +1,82 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.wizards.common.Configuration; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.PropertyNames; + +public class CGTable +{ + + private XMultiServiceFactory xMSF; + XNameAccess xNameAccessFieldsNode; + + public CGTable(XMultiServiceFactory _xMSF) + { + xMSF = _xMSF; + } + + public void initialize(XNameAccess _xNameAccessParentNode, int _index) + { + try + { + XNameAccess xNameAccessTableNode = Configuration.getChildNodebyIndex(_xNameAccessParentNode, _index); + xNameAccessFieldsNode = Configuration.getChildNodebyName(xNameAccessTableNode, "Fields"); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public String[] getFieldNames(boolean _bgetbyShortName, int _imaxcolumnchars) + { + try + { + String[] fieldnames = null; + if (_bgetbyShortName) + { + fieldnames = Configuration.getNodeChildNames(xNameAccessFieldsNode, "ShortName"); + for (int i = 0; i < fieldnames.length; i++) + { + if (fieldnames[i].length() > _imaxcolumnchars) + { + fieldnames[i] = fieldnames[i].substring(0, _imaxcolumnchars); + } + } + } + else + { + fieldnames = Configuration.getNodeChildNames(xNameAccessFieldsNode, PropertyNames.PROPERTY_NAME); + } + for (int i = 0; i < fieldnames.length; i++) + { + fieldnames[i] = Desktop.removeSpecialCharacters(xMSF, Configuration.getLocale(xMSF), fieldnames[i]); + } + return fieldnames; + } + catch (Exception e) + { + e.printStackTrace(System.err); + return null; + } + } +} diff --git a/wizards/com/sun/star/wizards/table/CallTableWizard.java b/wizards/com/sun/star/wizards/table/CallTableWizard.java new file mode 100644 index 0000000000..1a437b53ee --- /dev/null +++ b/wizards/com/sun/star/wizards/table/CallTableWizard.java @@ -0,0 +1,175 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.Type; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; + +/** This class capsulates the class, that implements the minimal component, a + * factory for creating the service (<CODE>__getServiceFactory</CODE>). + */ +public class CallTableWizard +{ + + /** Gives a factory for creating the service. + * This method is called by the <code>JavaLoader</code> + * <p> + * @return Returns a <code>XSingleServiceFactory</code> for creating the component. + * @see com.sun.star.comp.loader.JavaLoader + * @param stringImplementationName The implementation name of the component. + * @param xMSF The service manager, who gives access to every known service. + * @param xregistrykey Makes structural information (except regarding tree structures) of a single + * registry key accessible. + */ + public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(String stringImplementationName, com.sun.star.lang.XMultiServiceFactory xMSF, com.sun.star.registry.XRegistryKey xregistrykey) + { + com.sun.star.lang.XSingleServiceFactory xsingleservicefactory = null; + if (stringImplementationName.equals(TableWizardImplementation.class.getName())) + { + xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(TableWizardImplementation.class, TableWizardImplementation.__serviceName, xMSF, xregistrykey); + } + return xsingleservicefactory; + } + + /** This class implements the component. At least the interfaces XServiceInfo, + * XTypeProvider, and XInitialization should be provided by the service. + */ + public static class TableWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.task.XJobExecutor + { + + private PropertyValue[] m_wizardContext; + // the next two fields are accessed by reflection, do not delete! + public String Command; + public final Integer CommandType = com.sun.star.sdb.CommandType.TABLE; + + /** The constructor of the inner class has a XMultiServiceFactory parameter. + */ + public TableWizardImplementation(com.sun.star.lang.XMultiServiceFactory i_serviceFactory) + { + super(); + m_serviceFactory = i_serviceFactory; + registerProperty( PropertyNames.COMMAND, (short)( PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID ) ); + registerProperty( PropertyNames.COMMAND_TYPE, PropertyAttribute.READONLY ); + } + + public void trigger( String sEvent ) + { + try + { + if ( sEvent.equals(PropertyNames.START) ) + { + TableWizard CurTableWizard = new TableWizard( m_serviceFactory, m_wizardContext ); + CurTableWizard.startTableWizard(); + } + } + catch (Exception exception) + { + System.err.println(exception); + } + System.gc(); + } + /** The service name, that must be used to get an instance of this service. + */ + private static final String __serviceName = "com.sun.star.wizards.table.CallTableWizard"; + /** The service manager, that gives access to all registered services. + */ + private final com.sun.star.lang.XMultiServiceFactory m_serviceFactory; + + /** This method is a member of the interface for initializing an object + * directly after its creation. + * @param object This array of arbitrary objects will be passed to the + * component after its creation. + * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be + * passed to the caller. + */ + public void initialize(Object[] object) throws com.sun.star.uno.Exception + { + m_wizardContext = Properties.convertToPropertyValueArray(object); + } + + /** This method returns an array of all supported service names. + * @return Array of supported service names. + */ + public java.lang.String[] getSupportedServiceNames() + { + String[] stringSupportedServiceNames = new String[] { __serviceName }; + + return stringSupportedServiceNames; + } + + /** This method returns true, if the given service will be + * supported by the component. + * @param stringService Service name. + * @return True, if the given service name will be supported. + */ + public boolean supportsService(String stringService) + { + boolean booleanSupportsService = false; + + if (stringService.equals(__serviceName)) + { + booleanSupportsService = true; + } + return booleanSupportsService; + } + + @Override + public byte[] getImplementationId() + { + return new byte[0]; + } + + /** Return the class name of the component. + * @return Class name of the component. + */ + public java.lang.String getImplementationName() + { + return TableWizardImplementation.class.getName(); + } + + /** Provides a sequence of all types (usually interface types) + * provided by the object. + * @return Sequence of all types (usually interface types) provided by the + * service. + */ + @Override + public Type[] getTypes() + { + Type[] typeReturn = + { + }; + + try + { + typeReturn = new Type[] + { + new Type(com.sun.star.task.XJobExecutor.class), new Type(com.sun.star.lang.XTypeProvider.class), new Type(com.sun.star.lang.XServiceInfo.class), new Type(com.sun.star.lang.XInitialization.class) + }; + } + catch (Exception exception) + { + System.err.println(exception); + } + + return typeReturn; + } + } +} diff --git a/wizards/com/sun/star/wizards/table/FieldDescription.java b/wizards/com/sun/star/wizards/table/FieldDescription.java new file mode 100644 index 0000000000..95a8471363 --- /dev/null +++ b/wizards/com/sun/star/wizards/table/FieldDescription.java @@ -0,0 +1,152 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import java.util.ArrayList; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.Locale; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Configuration; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; + +public class FieldDescription +{ + private String tablename = PropertyNames.EMPTY_STRING; + private XPropertySet xPropertySet; + private final ArrayList<PropertyValue> aPropertyValues; + private String Name; + + public FieldDescription(XMultiServiceFactory _xMSF, Locale _aLocale, ScenarioSelector _curscenarioselector, String _fieldname, String keyname, int _nmaxcharCount) + { + tablename = _curscenarioselector.getTableName(); + Name = _fieldname; + aPropertyValues = new ArrayList<PropertyValue>(); + XNameAccess xNameAccessTableNode = _curscenarioselector.oCGTable.xNameAccessFieldsNode; + XNameAccess xNameAccessFieldNode; + if (_curscenarioselector.bcolumnnameislimited) + { + xNameAccessFieldNode = Configuration.getChildNodebyDisplayName(_xMSF, _aLocale, xNameAccessTableNode, keyname, "ShortName", _nmaxcharCount); + } + else + { + xNameAccessFieldNode = Configuration.getChildNodebyDisplayName(_xMSF, _aLocale, xNameAccessTableNode, keyname, PropertyNames.PROPERTY_NAME, _nmaxcharCount); + } + setFieldProperties(xNameAccessFieldNode); + } + + public FieldDescription(String _fieldname) + { + Name = _fieldname; + aPropertyValues = new ArrayList<PropertyValue>(); + Integer Type = Integer.valueOf(com.sun.star.sdbc.DataType.VARCHAR); + aPropertyValues.add(Properties.createProperty(PropertyNames.PROPERTY_NAME, _fieldname)); + aPropertyValues.add(Properties.createProperty("Type", Type)); + } + + public void setName(String _newfieldname) + { + for (int i = 0; i < aPropertyValues.size(); i++) + { + PropertyValue aPropertyValue = aPropertyValues.get(i); + if (aPropertyValue.Name.equals(PropertyNames.PROPERTY_NAME)) + { + aPropertyValue.Value = _newfieldname; + aPropertyValues.set(i, aPropertyValue); + Name = _newfieldname; + return; + } + } + } + + public String getName() + { + return Name; + } + + public String gettablename() + { + return tablename; + } + + private boolean propertyexists(String _propertyname) + { + boolean bexists = false; + try + { + if (xPropertySet.getPropertySetInfo().hasPropertyByName(_propertyname)) + { + Object oValue = xPropertySet.getPropertyValue(_propertyname); + bexists = (!com.sun.star.uno.AnyConverter.isVoid(oValue)); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return bexists; + } + + private void setFieldProperties(XNameAccess _xNameAccessFieldNode) + { + try + { + xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _xNameAccessFieldNode); + if (propertyexists(PropertyNames.PROPERTY_NAME)) + { + aPropertyValues.add(Properties.createProperty(PropertyNames.PROPERTY_NAME, Name)); + } + if (propertyexists("Type")) + { + aPropertyValues.add(Properties.createProperty("Type", xPropertySet.getPropertyValue("Type"))); + } + if (propertyexists("Scale")) + { + aPropertyValues.add(Properties.createProperty("Scale", xPropertySet.getPropertyValue("Scale"))); + } + if (propertyexists("Precision")) + { + aPropertyValues.add(Properties.createProperty("Precision", xPropertySet.getPropertyValue("Precision"))); + } + if (propertyexists("DefaultValue")) + { + aPropertyValues.add(Properties.createProperty("DefaultValue", xPropertySet.getPropertyValue("DefaultValue")));// DefaultValue = (Boolean) xPropertySet.getPropertyValue("DefaultValue"); + //Type = 4; // TODO where is the error?(Integer) xPropertySet.getPropertyValue("Type"); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public PropertyValue[] getPropertyValues() + { + if (aPropertyValues != null) + { + PropertyValue[] aProperties = new PropertyValue[aPropertyValues.size()]; + aPropertyValues.toArray(aProperties); + return aProperties; + } + return null; + } +} diff --git a/wizards/com/sun/star/wizards/table/FieldFormatter.java b/wizards/com/sun/star/wizards/table/FieldFormatter.java new file mode 100644 index 0000000000..75a1ade73a --- /dev/null +++ b/wizards/com/sun/star/wizards/table/FieldFormatter.java @@ -0,0 +1,444 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import com.sun.star.awt.ActionEvent; +import com.sun.star.awt.FontDescriptor; +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.XButton; +import com.sun.star.awt.XItemListener; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XTextComponent; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.EventObject; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.TableDescriptor; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.event.XActionListenerAdapter; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; + +public class FieldFormatter implements XItemListener +{ + + private TableWizard CurUnoDialog; + private TableDescriptor curTableDescriptor; + private Object oColumnDescriptorModel; + private XTextComponent txtfieldname; + private XListBox xlstFieldNames; + private XButton btnminus; + private XButton btnShiftUp; + private XButton btnShiftDown; + private short curtabindex; + private String suntitled; + private Integer IFieldFormatStep; + + public FieldFormatter(TableWizard _CurUnoDialog) + { + this.CurUnoDialog = _CurUnoDialog; + curtabindex = (short) (TableWizard.SOFIELDSFORMATPAGE * 100); + IFieldFormatStep = Integer.valueOf(TableWizard.SOFIELDSFORMATPAGE); + String sFieldName = CurUnoDialog.m_oResource.getResText("RID_TABLE_23"); + String sFieldNames = CurUnoDialog.m_oResource.getResText("RID_TABLE_25"); + String sfieldinfo = CurUnoDialog.m_oResource.getResText("RID_TABLE_20"); + String sbtnplushelptext = CurUnoDialog.m_oResource.getResText("RID_TABLE_45"); + String sbtnminushelptext = CurUnoDialog.m_oResource.getResText("RID_TABLE_46"); + + suntitled = CurUnoDialog.m_oResource.getResText("RID_TABLE_43"); + + CurUnoDialog.insertLabel("lblFieldNames", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], sFieldNames, 91, 27, IFieldFormatStep, Short.valueOf(curtabindex++), 67 + }); + + try + { + xlstFieldNames = CurUnoDialog.insertListBox("lstfieldnames", 3, null, this, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 133, "HID:WIZARDS_HID_DLGTABLE_LB_SELFIELDNAMES", 92, 37, IFieldFormatStep, Short.valueOf(curtabindex++), 62 + }); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + + FontDescriptor oFontDesc = new FontDescriptor(); + oFontDesc.Name = "StarSymbol"; + + btnShiftUp = CurUnoDialog.insertButton("btnShiftUp", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + shiftFieldNameUp(); + } + }, + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + Boolean.FALSE, oFontDesc, 14, "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDUP", String.valueOf((char) 8743), 158, 139, IFieldFormatStep, Short.valueOf(curtabindex++), 14 + }); + + btnShiftDown = CurUnoDialog.insertButton("btnShiftDown", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + shiftFieldNameDown(); + } + }, + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + Boolean.FALSE, oFontDesc, 14, "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDDOWN", String.valueOf((char) 8744), 158, 156, IFieldFormatStep, Short.valueOf(curtabindex++), 14 + }); + oFontDesc = new FontDescriptor(); + oFontDesc.Weight = com.sun.star.awt.FontWeight.BOLD; + oFontDesc.Height = (short) 13; + btnminus = CurUnoDialog.insertButton("btnminus", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + removeFieldName(); + } + }, + new String[] + { + PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + oFontDesc, 14, "HID:WIZARDS_HID_DLGTABLE_CMDMINUS", "-", 118, 175, IFieldFormatStep, Short.valueOf(curtabindex++), 14 + }); + + XButton btnplus = CurUnoDialog.insertButton("btnplus", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + addFieldName(); + } + }, + new String[] + { + PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + oFontDesc, 14, "HID:WIZARDS_HID_DLGTABLE_CMDPLUS", "+", 137, 175, IFieldFormatStep, Short.valueOf(curtabindex++), 14 + }); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "ColDescriptorHeader", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.ORIENTATION, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, sfieldinfo, 0, 158, 27, IFieldFormatStep, Short.valueOf(curtabindex++), 165 + }); + + + CurUnoDialog.insertLabel("lblFieldName", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], sFieldName, 158, 39, IFieldFormatStep, Short.valueOf(curtabindex++), 94 + }); + + txtfieldname = CurUnoDialog.insertTextField("txtfieldname", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent event) { + modifyFieldName(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGTABLE_COLNAME", 274, 37, IFieldFormatStep, Short.valueOf(curtabindex++), PropertyNames.EMPTY_STRING, 50 + }); + txtfieldname.addTextListener(CurUnoDialog); + CurUnoDialog.getPeerConfiguration().setAccessibleName(btnplus, sbtnplushelptext); + CurUnoDialog.getPeerConfiguration().setAccessibleName(btnminus, sbtnminushelptext); + } + + public void initialize(TableDescriptor _curTableDescriptor, String[] _fieldnames) + { + if (oColumnDescriptorModel == null) + { + oColumnDescriptorModel = CurUnoDialog.insertControlModel("com.sun.star.sdb.ColumnDescriptorControlModel", "oColumnDescriptor", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH, "EditWidth" + }, // PropertyNames.PROPERTY_HELPURL + new Object[] + { + 82, 158, 52, IFieldFormatStep, Short.valueOf(curtabindex++), 166, 50 + }); //, "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER" + curTableDescriptor = _curTableDescriptor; + Helper.setUnoPropertyValue(oColumnDescriptorModel, PropertyNames.ACTIVE_CONNECTION, _curTableDescriptor.DBConnection); + txtfieldname.setMaxTextLen((short) this.curTableDescriptor.getMaxColumnNameLength()); + } + else + { + int nStep = ((Integer) Helper.getUnoPropertyValue(oColumnDescriptorModel, PropertyNames.PROPERTY_STEP)).intValue(); + if (nStep > IFieldFormatStep.intValue()) + { + Helper.setUnoPropertyValue(oColumnDescriptorModel, PropertyNames.PROPERTY_STEP, IFieldFormatStep); + CurUnoDialog.repaintDialogStep(); + } + } + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST, _fieldnames); + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] + { + 0 + }); + updateColumnDescriptor(_fieldnames[0], curTableDescriptor.getByName(_fieldnames[0])); + toggleButtons(); + CurUnoDialog.setFocus("lstfieldnames"); + } + + private void toggleButtons() + { + boolean benableShiftUpButton = false; + boolean benableShiftDownButton = false; + boolean bfieldnameisselected = Helper.getUnoArrayPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS) != null; + int ilistcount = /* xlstFieldNames.getItemCount();*/ UnoDialog.getListBoxItemCount(xlstFieldNames); + boolean blistispopulated = (ilistcount > 0); + if (bfieldnameisselected) + { + int iselpos = xlstFieldNames.getSelectedItemPos(); + benableShiftUpButton = (iselpos != 0); + benableShiftDownButton = (iselpos != ilistcount - 1); + } + Helper.setUnoPropertyValue(UnoDialog.getModel(btnShiftUp), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benableShiftUpButton)); + Helper.setUnoPropertyValue(UnoDialog.getModel(btnShiftDown), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benableShiftDownButton)); + Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(blistispopulated)); + CurUnoDialog.setcompleted(TableWizard.SOFIELDSFORMATPAGE, blistispopulated); + } + + private void addFieldName() + { + String snewfieldname = Desktop.getUniqueName(xlstFieldNames.getItems(), suntitled, PropertyNames.EMPTY_STRING); + short icount = xlstFieldNames.getItemCount(); + if (CurUnoDialog.verifyfieldcount(icount)) + { + xlstFieldNames.addItem(snewfieldname, icount); + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] + { + icount + }); + toggleButtons(); + FieldDescription curfielddescription = new FieldDescription(snewfieldname); + CurUnoDialog.fielditems.put(snewfieldname, curfielddescription); + curTableDescriptor.addColumn(curfielddescription.getPropertyValues()); + updateColumnDescriptor(snewfieldname, curTableDescriptor.getByName(snewfieldname)); + CurUnoDialog.setControlVisible("oColumnDescriptor", true); + CurUnoDialog.repaintDialogStep(); + } + } + + private void removeFieldName() + { + String[] fieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST); + short ipos = UnoDialog.getSelectedItemPos(xlstFieldNames); + String fieldname = fieldnames[ipos]; + xlstFieldNames.removeItems(ipos, (short) 1); + CurUnoDialog.fielditems.remove(fieldname); + int ilistcount = /* xlstFieldNames.getItemCount();*/ UnoDialog.getListBoxItemCount(xlstFieldNames); + if ((ipos) < ilistcount) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] + { + ipos + }); + } + else + { + if (ilistcount > -1) + { + ipos = (short) ((short) ilistcount - (short) 1); + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] + { + ipos + }); + } + } + curTableDescriptor.dropColumnbyName(fieldname); + fieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST); + boolean benable = ((ipos > -1) && (ipos < fieldnames.length)); + if (benable) + { + String snewfieldname = fieldnames[ipos]; + updateColumnDescriptor(snewfieldname, curTableDescriptor.getByName(snewfieldname)); + toggleButtons(); + } + else + { + Helper.setUnoPropertyValue(UnoDialog.getModel(txtfieldname), "Text", PropertyNames.EMPTY_STRING); + Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benable)); + CurUnoDialog.setcompleted(TableWizard.SOFIELDSFORMATPAGE, benable); + } + Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benable)); + CurUnoDialog.setControlVisible("oColumnDescriptor", benable); + CurUnoDialog.repaintDialogStep(); + } + + private void modifyFieldName() + { + String newfieldname = txtfieldname.getText(); + String oldfieldname = xlstFieldNames.getSelectedItem(); + if (!newfieldname.equals(oldfieldname)) + { + if (curTableDescriptor.modifyColumnName(oldfieldname, newfieldname)) + { + Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, "Column"); + Helper.setUnoPropertyValue(oColumn, PropertyNames.PROPERTY_NAME, newfieldname); + FieldDescription curfielddescription = CurUnoDialog.fielditems.get(oldfieldname); + CurUnoDialog.fielditems.remove(oldfieldname); + curfielddescription.setName(newfieldname); + CurUnoDialog.fielditems.put(newfieldname, curfielddescription); + String[] fieldnames = xlstFieldNames.getItems(); + short ipos = xlstFieldNames.getSelectedItemPos(); + fieldnames[ipos] = newfieldname; + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST, fieldnames); + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] + { + ipos + }); + } + } + } + + private void shiftFieldNameUp() + { + short ipos = xlstFieldNames.getSelectedItemPos(); + String[] snewlist = shiftArrayItem(xlstFieldNames.getItems(), ipos, -1); + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST, snewlist); + if ((ipos - 1) > -1) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] + { + (short) (ipos - 1) + }); + curTableDescriptor.moveColumn(ipos, ipos - 1); + } + toggleButtons(); + } + + private void shiftFieldNameDown() + { + short ipos = xlstFieldNames.getSelectedItemPos(); + String[] snewlist = shiftArrayItem(xlstFieldNames.getItems(), ipos, 1); + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST, snewlist); + if ((ipos + 1) < xlstFieldNames.getItemCount()) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] + { + (short) (ipos + 1) + }); + curTableDescriptor.moveColumn(ipos, ipos + 1); + } + toggleButtons(); + } + + private String[] shiftArrayItem(String[] _slist, int _oldindex, int _shiftcount) + { + int newindex = _oldindex + _shiftcount; + if ((newindex >= 0) && (newindex < _slist.length)) + { + String buffer = _slist[newindex]; + _slist[newindex] = _slist[_oldindex]; + _slist[_oldindex] = buffer; + } + return _slist; + } + + public boolean updateColumnofColumnDescriptor() + { + Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, "Column"); + XPropertySet xColPropertySet = UnoRuntime.queryInterface(XPropertySet.class, oColumn); + if (xColPropertySet != null) + { + curTableDescriptor.modifyColumn(txtfieldname.getText(), xColPropertySet); + return true; + } + return false; + } + + private void updateColumnDescriptor(String _ColumnName, XPropertySet _xColumn) + { + updateColumnofColumnDescriptor(); + XPropertySet xNewPropertySet = curTableDescriptor.clonePropertySet(_ColumnName, _xColumn); + if (xNewPropertySet != null) + { + Helper.setUnoPropertyValue(oColumnDescriptorModel, "Column", xNewPropertySet); + } + txtfieldname.setText(_ColumnName); + } + + + + public void itemStateChanged(ItemEvent arg0) + { + String fieldname = xlstFieldNames.getSelectedItem(); + XPropertySet xColumn = curTableDescriptor.getByName(fieldname); + updateColumnDescriptor(fieldname, xColumn); + toggleButtons(); + } + + public boolean iscompleted() + { + String[] sfieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST); + return sfieldnames.length > 0; + } + + public String[] getFieldNames() + { + return (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST); + } + + /* (non-Javadoc) + * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject) + */ + public void disposing(EventObject arg0) + { + // TODO Auto-generated method stub + } +} diff --git a/wizards/com/sun/star/wizards/table/Finalizer.java b/wizards/com/sun/star/wizards/table/Finalizer.java new file mode 100644 index 0000000000..ce6c4bb315 --- /dev/null +++ b/wizards/com/sun/star/wizards/table/Finalizer.java @@ -0,0 +1,349 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.awt.XTextComponent; +import com.sun.star.sdbc.SQLException; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.TableDescriptor; +import com.sun.star.wizards.ui.*; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; + +public class Finalizer +{ + + private TableWizard CurUnoDialog; + private XRadioButton optModifyTable; + private XRadioButton optWorkWithTable; + private XTextComponent txtTableName; + private XListBox xCatalogListBox; + private XListBox xSchemaListBox; + private TableDescriptor curtabledescriptor; + private static int WORKWITHTABLEMODE = 0; + public static int MODIFYTABLEMODE = 1; + public static int STARTFORMWIZARDMODE = 2; + + public Finalizer(TableWizard _CurUnoDialog, TableDescriptor _curtabledescriptor) + { + try + { + this.CurUnoDialog = _CurUnoDialog; + this.curtabledescriptor = _curtabledescriptor; + short curtabindex = (short) (TableWizard.SOFINALPAGE * 100); + Integer IFINALSTEP = Integer.valueOf(TableWizard.SOFINALPAGE); + String slblTableName = CurUnoDialog.m_oResource.getResText("RID_TABLE_34"); + String slblProceed = CurUnoDialog.m_oResource.getResText("RID_TABLE_36"); + String sWorkWithTable = CurUnoDialog.m_oResource.getResText("RID_TABLE_38"); + String sStartFormWizard = CurUnoDialog.m_oResource.getResText("RID_TABLE_39"); + String sModifyTable = CurUnoDialog.m_oResource.getResText("RID_TABLE_37"); + String sCongratulations = CurUnoDialog.m_oResource.getResText("RID_TABLE_35"); + String slblCatalog = CurUnoDialog.m_oResource.getResText("RID_TABLE_49"); + String slblSchema = CurUnoDialog.m_oResource.getResText("RID_TABLE_50"); + String[] sCatalogNames = curtabledescriptor.getCatalogNames(); + String[] sSchemaNames = curtabledescriptor.getSchemaNames(); + int nListBoxPosX = 97; + int ndiffPosY = 0; + boolean bsupportsSchemata = false; + boolean bsupportsCatalogs = false; + + CurUnoDialog.insertLabel("lblTableName", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], slblTableName, 97, 25, IFINALSTEP, 220 + }); + txtTableName = CurUnoDialog.insertTextField("txtTableName", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent event) { + setCompletionFlag(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGTABLE_TXT_NAME", 97, 35, IFINALSTEP, Short.valueOf(curtabindex++), PropertyNames.EMPTY_STRING, 223 + }); + txtTableName.addTextListener(CurUnoDialog); + txtTableName.setMaxTextLen((short) this.curtabledescriptor.getMaxTableNameLength()); + if (this.curtabledescriptor.xDBMetaData.supportsCatalogsInTableDefinitions()) + { + if (sCatalogNames != null && sCatalogNames.length > 0) + { + bsupportsCatalogs = true; + String sCatalog = PropertyNames.EMPTY_STRING; + try + { + sCatalog = curtabledescriptor.DBConnection.getCatalog(); + } + catch (SQLException e1) + { + e1.printStackTrace(System.err); + } + CurUnoDialog.insertLabel("lblCatalog", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblCatalog, Integer.valueOf(nListBoxPosX), 52, IFINALSTEP, Short.valueOf(curtabindex++), 120 + }); + + try + { + xCatalogListBox = CurUnoDialog.insertListBox("lstCatalog", null, null, + new String[] + { + "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", Short.valueOf(UnoDialog.getListBoxLineCount()), Integer.valueOf(nListBoxPosX), 62, IFINALSTEP, sCatalogNames, Short.valueOf(curtabindex++), 80 + }); + int isel = JavaTools.FieldInList(sCatalogNames, sCatalog); + if (isel < 0) + { + isel = 0; + } + CurUnoDialog.setControlProperty("lstCatalog", PropertyNames.SELECTED_ITEMS, new short[] + { + (short) isel + }); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + nListBoxPosX = 200; + } + } + if (this.curtabledescriptor.xDBMetaData.supportsSchemasInTableDefinitions()) + { + if (sSchemaNames != null && sSchemaNames.length > 0) + { + bsupportsSchemata = true; + String sSchema = PropertyNames.EMPTY_STRING; + try + { + sSchema = (String) curtabledescriptor.getDataSourcePropertySet().getPropertyValue("User"); + } + catch (Exception e1) + { + e1.printStackTrace(System.err); + } + CurUnoDialog.insertLabel("lblSchema", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblSchema, Integer.valueOf(nListBoxPosX), 52, IFINALSTEP, Short.valueOf(curtabindex++), 80 + }); + + try + { + xSchemaListBox = CurUnoDialog.insertListBox("lstSchema", null, null, + new String[] + { + "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA", Short.valueOf(UnoDialog.getListBoxLineCount()), Integer.valueOf(nListBoxPosX), 62, IFINALSTEP, sSchemaNames, Short.valueOf(curtabindex++), 80 + }); + int isel = JavaTools.FieldInList(sSchemaNames, sSchema); + if (isel < 0) + { + isel = 0; + } + CurUnoDialog.setControlProperty("lstSchema", PropertyNames.SELECTED_ITEMS, new short[] + { + (short) isel + }); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + } + if ((!bsupportsCatalogs) && (!bsupportsSchemata)) + { + CurUnoDialog.insertLabel("lblcongratulations", + new String[] + { + 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 + }, + new Object[] + { + 16, sCongratulations, Boolean.TRUE, 97, 62, IFINALSTEP, Short.valueOf(curtabindex++), 226 + }); + } + else + { + ndiffPosY = 10; + } + CurUnoDialog.insertLabel("lblProceed", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], slblProceed, 97, Integer.valueOf(82 + ndiffPosY), IFINALSTEP, Short.valueOf(curtabindex++), 227 + }); + optWorkWithTable = CurUnoDialog.insertRadioButton("optWorkWithTable", null, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_WORKWITHTABLE", sWorkWithTable, 101, Integer.valueOf(97 + ndiffPosY), Short.valueOf((short) 1), IFINALSTEP, Short.valueOf(curtabindex++), 177 + }); + optModifyTable = CurUnoDialog.insertRadioButton("optModifyTable", null, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_MODIFYTABLE", sModifyTable, 101, Integer.valueOf(109 + ndiffPosY), IFINALSTEP, Short.valueOf(curtabindex++), 177 + }); + CurUnoDialog.insertRadioButton("optStartFormWizard", null, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_STARTFORMWIZARD", sStartFormWizard, 101, Integer.valueOf(121 + ndiffPosY), IFINALSTEP, Short.valueOf(curtabindex++), 177 + }); + } + catch (SQLException e) + { + e.printStackTrace(System.err); + } + } + + public void initialize(String _firsttablename) + { + setTableName(_firsttablename); + } + + public int finish() + { + if (optWorkWithTable.getState()) + { + return WORKWITHTABLEMODE; + } + else if (optModifyTable.getState()) + { + return MODIFYTABLEMODE; + } + else + { + return STARTFORMWIZARDMODE; + } + } + + public String getComposedTableName(String _stablename) + { + String scatalogname = null; + String sschemaname = null; + if (xCatalogListBox != null) + { + scatalogname = xCatalogListBox.getSelectedItem(); + } + if (xSchemaListBox != null) + { + sschemaname = xSchemaListBox.getSelectedItem(); + } + return curtabledescriptor.getComposedTableName(scatalogname, sschemaname, _stablename); + } + + private void setTableName(String _tablename) + { + if (txtTableName.getText().equals(PropertyNames.EMPTY_STRING)) + { + String ssuffix = Desktop.getIncrementSuffix(curtabledescriptor.getTableNamesAsNameAccess(), getComposedTableName(_tablename)); + txtTableName.setText(_tablename + ssuffix); + setCompletionFlag(); + } + } + + public String getTableName(String _firsttablename) + { + if (txtTableName.getText().equals(PropertyNames.EMPTY_STRING)) + { + setTableName(_firsttablename); + } + return txtTableName.getText(); + } + + public String getSchemaName() + { + if (xSchemaListBox != null) + { + return this.xSchemaListBox.getSelectedItem(); + } + else + { + return PropertyNames.EMPTY_STRING; + } + } + + public String getCatalogName() + { + if (xCatalogListBox != null) + { + return this.xCatalogListBox.getSelectedItem(); + } + else + { + return PropertyNames.EMPTY_STRING; + } + } + + public boolean iscompleted() + { + return (txtTableName.getText().length() > 0); + } + + private void setCompletionFlag() + { + CurUnoDialog.setcompleted(TableWizard.SOFINALPAGE, iscompleted()); + } + + public void setFocusToTableNameControl() + { + CurUnoDialog.setFocus("txtTableName"); + } +} diff --git a/wizards/com/sun/star/wizards/table/MANIFEST.MF b/wizards/com/sun/star/wizards/table/MANIFEST.MF new file mode 100644 index 0000000000..0fcfe1d3e8 --- /dev/null +++ b/wizards/com/sun/star/wizards/table/MANIFEST.MF @@ -0,0 +1,2 @@ +RegistrationClassName: com.sun.star.wizards.table.CallTableWizard +UNO-Type-Path: diff --git a/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java new file mode 100644 index 0000000000..289f76dd36 --- /dev/null +++ b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java @@ -0,0 +1,459 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import com.sun.star.awt.ActionEvent; +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.XCheckBox; +import com.sun.star.awt.XFixedText; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.uno.AnyConverter; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.TableDescriptor; +import com.sun.star.wizards.ui.FieldSelection; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.XFieldSelectionListener; +import com.sun.star.wizards.ui.event.XActionListenerAdapter; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; + +public class PrimaryKeyHandler implements XFieldSelectionListener +{ + + private final TableWizard CurUnoDialog; + private final XRadioButton optAddAutomatically; + private final XRadioButton optUseExisting; + private final XRadioButton optUseSeveral; + private final XCheckBox chkcreatePrimaryKey; + private final XCheckBox chkApplyAutoValueExisting; + private final XCheckBox chkApplyAutoValueAutomatic; + private final XListBox lstSinglePrimeKey; + private final XFixedText lblPrimeFieldName; + private final FieldSelection curPrimaryKeySelection; + private String[] fieldnames; + private final TableDescriptor curTableDescriptor; + private final boolean bAutoPrimaryKeysupportsAutoIncrementation; + private static final String SAUTOMATICKEYFIELDNAME = "ID"; + + public PrimaryKeyHandler(TableWizard _CurUnoDialog, TableDescriptor _curTableDescriptor) + { + this.CurUnoDialog = _CurUnoDialog; + curTableDescriptor = _curTableDescriptor; + bAutoPrimaryKeysupportsAutoIncrementation = curTableDescriptor.oTypeInspector.isAutoIncrementationSupported(); + short curtabindex = (short) ((TableWizard.SOPRIMARYKEYPAGE * 100) - 20); + Integer IPRIMEKEYSTEP = Integer.valueOf(TableWizard.SOPRIMARYKEYPAGE); + final String sExplanations = CurUnoDialog.m_oResource.getResText("RID_TABLE_26"); + final String screatePrimaryKey = CurUnoDialog.m_oResource.getResText("RID_TABLE_27"); + final String slblPrimeFieldName = CurUnoDialog.m_oResource.getResText("RID_TABLE_31"); + final String sApplyAutoValue = CurUnoDialog.m_oResource.getResText("RID_TABLE_33"); + final String sAddAutomatically = CurUnoDialog.m_oResource.getResText("RID_TABLE_28"); + final String sUseExisting = CurUnoDialog.m_oResource.getResText("RID_TABLE_29"); + final String sUseSeveral = CurUnoDialog.m_oResource.getResText("RID_TABLE_30"); + final String slblAvailableFields = CurUnoDialog.m_oResource.getResText("RID_QUERY_4"); + final String slblSelPrimaryFields = CurUnoDialog.m_oResource.getResText("RID_TABLE_32"); + CurUnoDialog.insertLabel("lblExplanation", + new String[] + { + 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 + }, + new Object[] + { + 40, sExplanations, Boolean.TRUE, 91, 27, IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 233 + }); + + chkcreatePrimaryKey = CurUnoDialog.insertCheckBox("chkcreatePrimaryKey", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CHK_USEPRIMEKEY", screatePrimaryKey, 97, 70, Short.valueOf((short) 1), IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 160 + }); + + optAddAutomatically = CurUnoDialog.insertRadioButton("optAddAutomatically", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_AUTOMATIC", sAddAutomatically, 106, 82, Short.valueOf((short) 1), IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 200 + }); + + optUseExisting = CurUnoDialog.insertRadioButton("optUseExisting", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, + new String[] + { + 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 + }, //94 + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SINGLE", sUseExisting, 106, 104, IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 200 + }); + + optUseSeveral = CurUnoDialog.insertRadioButton("optUseSeveral", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SEVERAL", sUseSeveral, 106, 132, IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 200 + }); + + chkApplyAutoValueAutomatic = CurUnoDialog.insertCheckBox("chkApplyAutoValueAutomatic", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, + new String[] + { + 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 + }, //107 + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE_AUTOMATIC", sApplyAutoValue, 116, 92, IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 68 + }); + + lblPrimeFieldName = CurUnoDialog.insertLabel("lblPrimeFieldName", + new String[] + { + 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 + }, + new Object[] + { + Boolean.FALSE, UIConsts.INTEGERS[8], slblPrimeFieldName, 116, 117, IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 46 + }); + + lstSinglePrimeKey = CurUnoDialog.insertListBox("lstSinglePrimeKey", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + onPrimeKeySelected(); + } + }, null, + new String[] + { + "Dropdown", + PropertyNames.PROPERTY_ENABLED, + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + "LineCount", + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, + Boolean.FALSE, + 12, + "HID:WIZARDS_HID_DLGTABLE_LB_PK_FIELDNAME", + Short.valueOf(UnoDialog.getListBoxLineCount()), + 162, + 115, + IPRIMEKEYSTEP, + Short.valueOf(curtabindex++), + 80 + }); + + chkApplyAutoValueExisting = CurUnoDialog.insertCheckBox("chkApplyAutoValueExisting", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, + new String[] + { + 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 + }, //107 + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE", sApplyAutoValue, 248, 117, IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 66 + }); + curPrimaryKeySelection = new FieldSelection(CurUnoDialog, IPRIMEKEYSTEP.intValue(), 116, 142, 208, 47, slblAvailableFields, slblSelPrimaryFields, 41234, false); + curPrimaryKeySelection.addFieldSelectionListener(this); + + } + + public void initialize() + { + // boolean breselect; + fieldnames = curTableDescriptor.getNonBinaryFieldNames(); + String[] skeyfieldnames = curPrimaryKeySelection.getSelectedFieldNames(); + curPrimaryKeySelection.initialize(fieldnames, false); + if (skeyfieldnames != null && skeyfieldnames.length > 0) + { + String[] snewkeyfieldnames = JavaTools.removeOutdatedFields(skeyfieldnames, fieldnames); + curPrimaryKeySelection.setSelectedFieldNames(snewkeyfieldnames); + } + String selfield = lstSinglePrimeKey.getSelectedItem(); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSinglePrimeKey), PropertyNames.STRING_ITEM_LIST, fieldnames); + if (selfield != null) + { + if (JavaTools.FieldInList(fieldnames, selfield) > -1) + { + lstSinglePrimeKey.selectItem(selfield, true); + } + } + togglePrimeKeyFields(); + } + + public boolean iscompleted() + { + if (chkcreatePrimaryKey.getState() == 0) + { + return true; + } + if (this.optAddAutomatically.getState()) + { + return true; + } + if (optUseExisting.getState()) + { + fieldnames = curTableDescriptor.getNonBinaryFieldNames(); + String selfield = lstSinglePrimeKey.getSelectedItem(); + if (selfield != null) + { + return (JavaTools.FieldInList(fieldnames, selfield) > -1); + } + } + if (optUseSeveral.getState()) + { + fieldnames = curTableDescriptor.getNonBinaryFieldNames(); + String[] skeyfieldnames = curPrimaryKeySelection.getSelectedFieldNames(); + String[] snewkeyfieldnames = JavaTools.removeOutdatedFields(skeyfieldnames, fieldnames); + return (snewkeyfieldnames.length > 0); + } + return false; + } + + private void togglePrimeKeyFields() + { + boolean bdoEnable = (this.chkcreatePrimaryKey.getState() == 1); + Helper.setUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoEnable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueAutomatic), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bAutoPrimaryKeysupportsAutoIncrementation && bdoEnable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(optUseExisting), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoEnable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(optUseSeveral), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoEnable)); + //toggle subcontrols of the radiobuttons... + toggleAutomaticAutoValueCheckBox(); + boolean benableSinglePrimekeyControls = bdoEnable && optUseExisting.getState(); + toggleSinglePrimeKeyFields(benableSinglePrimekeyControls); + boolean benableSeveralPrimekeyControls = bdoEnable && optUseSeveral.getState(); + curPrimaryKeySelection.toggleListboxControls(Boolean.valueOf(benableSeveralPrimekeyControls)); + // toggle the following steps of the dialog... + if (!bdoEnable) + { + CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, true); + } + else + { + if (benableSeveralPrimekeyControls) + { + CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0)); + } + else if (benableSinglePrimekeyControls) + { + CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, UnoDialog.isListBoxSelected(lstSinglePrimeKey)); //.getSelectedItemPos() != -1); + } + else if (optAddAutomatically.getState()) + { + CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, true); + } + } + } + + private boolean isAutoIncrementatable(String _fieldname) + { + try + { + XPropertySet xColPropertySet = curTableDescriptor.getByName(_fieldname); + if (xColPropertySet != null && curTableDescriptor.getDBDataTypeInspector() != null) + { + return curTableDescriptor.getDBDataTypeInspector().isAutoIncrementable(xColPropertySet); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return false; + } + + public boolean isAutomaticMode() + { + boolean bisAutomaticMode = false; + if (chkcreatePrimaryKey.getState() == 1) + { + bisAutomaticMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + } + return bisAutomaticMode; + } + + public String getAutomaticFieldName() + { + return SAUTOMATICKEYFIELDNAME; + } + + public boolean isAutoIncremented() + { + boolean bischecked = false; + if (chkcreatePrimaryKey.getState() == 1) + { + boolean bisAutomaticMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + boolean bisExistingMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optUseExisting), PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + if (bisAutomaticMode) + { + bischecked = chkApplyAutoValueAutomatic.getState() == (short) 1; + } + else if (bisExistingMode) + { + bischecked = chkApplyAutoValueExisting.getState() == (short) 1; + } + } + return bischecked; + } + + private void onPrimeKeySelected() + { + try + { + String selfieldname = lstSinglePrimeKey.getSelectedItem(); + boolean bdoenable = isAutoIncrementatable(selfieldname); + CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, lstSinglePrimeKey.getSelectedItemPos() != -1); + Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoenable)); + XPropertySet xColPropertySet = curTableDescriptor.getByName(selfieldname); + boolean bIsAutoIncremented = ((Boolean) xColPropertySet.getPropertyValue("IsAutoIncrement")).booleanValue(); + if (bIsAutoIncremented) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_STATE, Short.valueOf((short) 1)); + } + else + { + Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_STATE, Short.valueOf((short) 0)); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private void toggleAutomaticAutoValueCheckBox() + { + try + { + boolean bisAutomaticMode = AnyConverter.toBoolean(Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_ENABLED)); + boolean bdoenable = bAutoPrimaryKeysupportsAutoIncrementation && optAddAutomatically.getState() && bisAutomaticMode; + Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueAutomatic), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoenable)); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + } + } + + private void toggleSinglePrimeKeyFields(boolean _bdoenable) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(lblPrimeFieldName), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bdoenable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSinglePrimeKey), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bdoenable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bdoenable)); + boolean bdoenableAutoValueCheckBox = (isAutoIncrementatable(lstSinglePrimeKey.getSelectedItem()) && _bdoenable); + Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoenableAutoValueCheckBox)); + } + + public String[] getPrimaryKeyFields() + { + if (chkcreatePrimaryKey.getState() == 0) + { + return null; + } + if (fieldnames == null) + { + initialize(); + } + if (optUseSeveral.getState()) + { + return curPrimaryKeySelection.getSelectedFieldNames(); + } + else if (optUseExisting.getState()) + { + return new String[] + { + lstSinglePrimeKey.getSelectedItem() + }; + } + else if (optAddAutomatically.getState()) + { + return new String[] + { + SAUTOMATICKEYFIELDNAME + }; + } + return null; + } + + public void moveItemDown(String Selitem) + { + } + + public void moveItemUp(String Selitem) + { + } + + public void setID(String sIncSuffix) + { + } + + public void shiftFromLeftToRight(String[] SelItems, String[] NewItems) + { + CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0)); + } + + public void shiftFromRightToLeft(String[] OldSelItems, String[] NewItems) + { + CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0)); + } +} diff --git a/wizards/com/sun/star/wizards/table/ScenarioSelector.java b/wizards/com/sun/star/wizards/table/ScenarioSelector.java new file mode 100644 index 0000000000..7207005894 --- /dev/null +++ b/wizards/com/sun/star/wizards/table/ScenarioSelector.java @@ -0,0 +1,364 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import java.util.ArrayList; + +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.XItemListener; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.Locale; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.wizards.common.Configuration; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.TableDescriptor; +import com.sun.star.wizards.ui.FieldSelection; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.XFieldSelectionListener; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; + +/** + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class ScenarioSelector extends FieldSelection implements XItemListener, XFieldSelectionListener +{ + private static final int PRIVATE = 0; + private static final int BUSINESS = 1; + + private final XRadioButton optBusiness; + private XListBox xTableListBox; + private final TableWizard CurTableWizardUnoDialog; + private final TableDescriptor curtabledescriptor; + private final CGCategory oCGCategory; + protected CGTable oCGTable; + protected boolean bcolumnnameislimited; + private final int imaxcolumnchars; + private final String smytable; + private final Locale aLocale; + private final XMultiServiceFactory xMSF; + + public ScenarioSelector(TableWizard _CurUnoDialog, TableDescriptor _curtabledescriptor, String _reslblFields, String _reslblSelFields) + { + super(_CurUnoDialog, TableWizard.SOMAINPAGE, 91, 108, 230, 80, _reslblFields, _reslblSelFields, 41209, true); + CurTableWizardUnoDialog = _CurUnoDialog; + xMSF = CurUnoDialog.xMSF; + aLocale = Configuration.getLocale(xMSF); + curtabledescriptor = _curtabledescriptor; + imaxcolumnchars = this.curtabledescriptor.getMaxColumnNameLength(); + bcolumnnameislimited = (imaxcolumnchars > 0) && (imaxcolumnchars < 16); + addFieldSelectionListener(this); + short pretabindex = (short) (50); + String sExplanation = CurUnoDialog.m_oResource.getResText("RID_TABLE_14"); + String sCategories = CurUnoDialog.m_oResource.getResText("RID_TABLE_15"); + String sBusiness = CurUnoDialog.m_oResource.getResText("RID_TABLE_16"); + String sPrivate = CurUnoDialog.m_oResource.getResText("RID_TABLE_17"); + String sTableNames = CurUnoDialog.m_oResource.getResText("RID_TABLE_18"); + smytable = CurUnoDialog.m_oResource.getResText("RID_TABLE_44"); + Integer IMAINSTEP = Integer.valueOf(TableWizard.SOMAINPAGE); + oCGCategory = new CGCategory(CurUnoDialog.xMSF); + oCGTable = new CGTable(CurUnoDialog.xMSF); + CurUnoDialog.insertLabel("lblScenarioExplanation", + new String[] + { + 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 + }, + new Object[] + { + 32, sExplanation, Boolean.TRUE, 91, 27, IMAINSTEP, Short.valueOf(pretabindex++), 233 + }); + + CurUnoDialog.insertLabel("lblCategories", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, sCategories, 91, 60, IMAINSTEP, Short.valueOf(pretabindex++), 100 + }); + + optBusiness = CurTableWizardUnoDialog.insertRadioButton("optBusiness", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + selectCategory(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPTBUSINESS", sBusiness, 98, 70, Short.valueOf((short) 1), IMAINSTEP, Short.valueOf(pretabindex++), 78 + }); + + CurTableWizardUnoDialog.insertRadioButton("optPrivate", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + selectCategory(); + } + }, + new String[] + { + 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 + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPTPRIVATE", sPrivate, 182, 70, IMAINSTEP, Short.valueOf(pretabindex++), 90 + }); + + CurUnoDialog.insertLabel("lblTableNames", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, sTableNames, 91, 82, IMAINSTEP, Short.valueOf(pretabindex++), 80 + }); + + try + { + xTableListBox = CurUnoDialog.insertListBox("lstTableNames", 3, null, this, + new String[] + { + "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LBTABLES", Short.valueOf(UnoDialog.getListBoxLineCount()), 91, 92, IMAINSTEP, Short.valueOf(pretabindex++), getListboxWidth() + }); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + initializeCategory(BUSINESS); + } + + private void selectCategory() + { + if (optBusiness.getState()) + { + initializeCategory(BUSINESS); + } + else + { + initializeCategory(PRIVATE); + } + } + + private void initializeCategory(int _iCategory) + { + try + { + oCGCategory.initialize( + _iCategory == PRIVATE ? "private" : "business"); + xTableListBox.removeItems((short) 0, xTableListBox.getItemCount()); + xTableListBox.addItems(oCGCategory.getTableNames(), (short) _iCategory); + initializeTable(0); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private void initializeTable(int _iTable) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.SELECTED_ITEMS, new short[] + { + (short) _iTable + }); + oCGTable.initialize(oCGCategory.xNameAccessTablesNode, _iTable); + super.initialize(oCGTable.getFieldNames(bcolumnnameislimited, imaxcolumnchars), true); + } + + @Override + public String[] getSelectedFieldNames() + { + String[] displayfieldnames = super.getSelectedFieldNames(); + ArrayList<String> afieldnameVector = new ArrayList<String>(); + for (int i = 0; i < displayfieldnames.length; i++) + { + try + { + FieldDescription ofielddescription = CurTableWizardUnoDialog.fielditems.get(displayfieldnames[i]); + if (ofielddescription != null) + { + afieldnameVector.add(ofielddescription.getName()); + } + } + catch (RuntimeException e) + { + e.printStackTrace(System.err); + } + } + String[] fieldnames = new String[afieldnameVector.size()]; + return afieldnameVector.toArray(fieldnames); + } + + public boolean iscompleted() + { + return getSelectedFieldNames().length > 0; + } + + public void addColumnsToDescriptor() + { + String[] fieldnames = getSelectedFieldNames(); + for (int i = 0; i < fieldnames.length; i++) + { + try + { + FieldDescription curfielddescription = CurTableWizardUnoDialog.fielditems.get(fieldnames[i]); + PropertyValue[] aProperties = curfielddescription.getPropertyValues(); + if (aProperties != null) { + this.curtabledescriptor.addColumn(aProperties); + } + } + catch (RuntimeException e) + { + e.printStackTrace(System.err); + } + } + } + + public String getTableName() + { + return xTableListBox.getSelectedItem(); + } + + public String getFirstTableName() + { + String[] fieldnames = super.getSelectedFieldNames(); + if ((fieldnames.length) > 0) + { + for (int i = 0; i < CurTableWizardUnoDialog.fielditems.size(); i++) + { + String stablename = PropertyNames.EMPTY_STRING; + try + { + FieldDescription ofielddescription = CurTableWizardUnoDialog.fielditems.get(fieldnames[i]); + stablename = ofielddescription.gettablename(); + } + catch (RuntimeException e) + { + e.printStackTrace(System.err); + } + if (!stablename.equals(PropertyNames.EMPTY_STRING)) + { + return stablename; + } + } + } + return smytable; + } + + + + + + + /* (non-Javadoc) + * @see com.sun.star.awt.XItemListener#itemStateChanged(com.sun.star.awt.ItemEvent) + */ + public void itemStateChanged(ItemEvent arg0) + { + initializeTable(xTableListBox.getSelectedItemPos()); + } + + /* (non-Javadoc) + * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject) + */ + public void disposing(EventObject arg0) + { + } + + public void setID(String sIncSuffix) + { + } + + public void shiftFromLeftToRight(String[] SelItems, String[] NewItems) + { + if (!CurTableWizardUnoDialog.verifyfieldcount(NewItems.length)) + { + for (int i = 0; i < SelItems.length; i++) + { + int selindex = JavaTools.FieldInList(NewItems, SelItems[i]); + super.xSelectedFieldsListBox.removeItems((short) selindex, (short) 1); + /**TODO In this context the items should be better placed at their original position. + * but how is this position retrieved? + */ + super.xFieldsListBox.addItem(SelItems[i], xFieldsListBox.getItemCount()); + } + } + else + { + for (int i = 0; i < NewItems.length; i++) + { + int iduplicate; + if (CurTableWizardUnoDialog.fielditems.containsKey(NewItems[i])) + { + iduplicate = JavaTools.getDuplicateFieldIndex(NewItems, NewItems[i]); + if (iduplicate != -1) + { + String sdisplayname = Desktop.getUniqueName(NewItems, NewItems[iduplicate], PropertyNames.EMPTY_STRING); + FieldDescription curfielddescription = new FieldDescription(xMSF, aLocale, this, sdisplayname, NewItems[iduplicate], imaxcolumnchars); + CurTableWizardUnoDialog.fielditems.put(sdisplayname, curfielddescription); + NewItems[iduplicate] = sdisplayname; + setSelectedFieldNames(NewItems); + } + } + else + { + CurTableWizardUnoDialog.fielditems.put(NewItems[i], new FieldDescription(xMSF, aLocale, this, NewItems[i], NewItems[i], imaxcolumnchars)); + } + } + } + CurTableWizardUnoDialog.setcompleted(TableWizard.SOMAINPAGE, NewItems.length > 0); + } + + public void shiftFromRightToLeft(String[] SelItems, String[] NewItems) + { + for (int i = 0; i < SelItems.length; i++) + { + if (CurTableWizardUnoDialog.fielditems.containsKey(SelItems[i])) + { + CurTableWizardUnoDialog.fielditems.remove(SelItems[i]); + this.curtabledescriptor.dropColumnbyName(SelItems[i]); + } + } + CurTableWizardUnoDialog.setcompleted(TableWizard.SOMAINPAGE, NewItems.length > 0); + } + + public void moveItemDown(String item) + { + } + + public void moveItemUp(String item) + { + } +} diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java new file mode 100644 index 0000000000..67e0f537fe --- /dev/null +++ b/wizards/com/sun/star/wizards/table/TableWizard.java @@ -0,0 +1,412 @@ +/* + * 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 . + */ +package com.sun.star.wizards.table; + +import java.util.HashMap; + +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XTextListener; +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XInitialization; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.application.DatabaseObject; +import com.sun.star.sdbc.SQLException; +import com.sun.star.task.XJobExecutor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.db.DatabaseObjectWizard; +import com.sun.star.wizards.db.TableDescriptor; +import com.sun.star.wizards.ui.*; + +public class TableWizard extends DatabaseObjectWizard implements XTextListener +{ + + private static String slblFields; + private static String slblSelFields; + private Finalizer curFinalizer; + private ScenarioSelector curScenarioSelector; + private FieldFormatter curFieldFormatter; + private PrimaryKeyHandler curPrimaryKeyHandler; + HashMap<String, FieldDescription> fielditems; + private int wizardmode; + private String tablename; + private String serrToManyFields; + private String serrTableNameexists; + private String scomposedtablename; + private TableDescriptor curTableDescriptor; + public static final int SOMAINPAGE = 1; + public static final int SOFIELDSFORMATPAGE = 2; + public static final int SOPRIMARYKEYPAGE = 3; + public static final int SOFINALPAGE = 4; + private String sMsgColumnAlreadyExists = PropertyNames.EMPTY_STRING; + + private String m_tableName; + + public TableWizard( XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext ) + { + super( xMSF, 41200, i_wizardContext ); + super.addResourceHandler(); + String sTitle = m_oResource.getResText("RID_TABLE_1"); + Helper.setUnoPropertyValues(xDialogModel, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_MOVEABLE, PropertyNames.PROPERTY_NAME, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_TITLE, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 218, Boolean.TRUE, "DialogTable", 102, 41, 1, Short.valueOf((short) 0), sTitle, 330 + }); + drawNaviBar(); + fielditems = new HashMap<String, FieldDescription>(); + //TODO if reportResources cannot be gotten dispose officedocument + if (getTableResources()) + { + setRightPaneHeaders(m_oResource, "RID_TABLE_", 8, 4); + } + } + + @Override + protected void leaveStep(int nOldStep, int nNewStep) + { + switch (nOldStep) + { + case SOMAINPAGE: + curScenarioSelector.addColumnsToDescriptor(); + break; + case SOFIELDSFORMATPAGE: + curFieldFormatter.updateColumnofColumnDescriptor(); + String[] sfieldnames = curFieldFormatter.getFieldNames(); + super.setStepEnabled(SOFIELDSFORMATPAGE, sfieldnames.length > 0); + curScenarioSelector.setSelectedFieldNames(sfieldnames); + break; + case SOPRIMARYKEYPAGE: + break; + case SOFINALPAGE: + break; + default: + break; + } + } + + @Override + protected void enterStep(int nOldStep, int nNewStep) + { + switch (nNewStep) + { + case SOMAINPAGE: + break; + case SOFIELDSFORMATPAGE: + curFieldFormatter.initialize(curTableDescriptor, this.curScenarioSelector.getSelectedFieldNames()); + break; + case SOPRIMARYKEYPAGE: + curPrimaryKeyHandler.initialize(); + break; + case SOFINALPAGE: + curFinalizer.initialize(curScenarioSelector.getFirstTableName()); + break; + default: + break; + } + } + + + private boolean iscompleted(int _ndialogpage) + { + switch (_ndialogpage) + { + case SOMAINPAGE: + return curScenarioSelector.iscompleted(); + case SOFIELDSFORMATPAGE: + return this.curFieldFormatter.iscompleted(); + case SOPRIMARYKEYPAGE: + if (curPrimaryKeyHandler != null) + { + return this.curPrimaryKeyHandler.iscompleted(); + } + case SOFINALPAGE: + return this.curFinalizer.iscompleted(); + default: + return false; + } + } + + + public void setcompleted(int _ndialogpage, boolean _biscompleted) + { + boolean bScenarioiscompleted = _biscompleted; + boolean bPrimaryKeysiscompleted = _biscompleted; + boolean bFinalPageiscompleted = _biscompleted; + if (_ndialogpage == SOMAINPAGE) + { + curFinalizer.initialize(curScenarioSelector.getFirstTableName()); + } + else + { + bScenarioiscompleted = iscompleted(SOMAINPAGE); + } + if (_ndialogpage != TableWizard.SOPRIMARYKEYPAGE && (this.curPrimaryKeyHandler != null)) + { + bPrimaryKeysiscompleted = iscompleted(SOPRIMARYKEYPAGE); + } + if (_ndialogpage != TableWizard.SOFINALPAGE) + { + bFinalPageiscompleted = iscompleted(SOFINALPAGE); // Basically the finalpage is always enabled + } + if (bScenarioiscompleted) + { + super.setStepEnabled(SOFIELDSFORMATPAGE, true); + super.setStepEnabled(SOPRIMARYKEYPAGE, true); + if (bPrimaryKeysiscompleted) + { + super.enablefromStep(SOFINALPAGE, true); + super.enableFinishButton(bFinalPageiscompleted); + } + else + { + super.enablefromStep(SOFINALPAGE, false); + enableNextButton(false); + } + } + else if (_ndialogpage == SOFIELDSFORMATPAGE) + { + super.enablefromStep(super.getCurrentStep() + 1, iscompleted(SOFIELDSFORMATPAGE)); + } + else + { + super.enablefromStep(super.getCurrentStep() + 1, false); + } + } + +/* + public static void main(String args[]) + { + String ConnectStr = "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.NamingService"; + PropertyValue[] curproperties = null; + try + { + XMultiServiceFactory xLocMSF = com.sun.star.wizards.common.Desktop.connect(ConnectStr); + TableWizard CurTableWizard = new TableWizard(xLocMSF); + if (xLocMSF != null) + { + System.out.println("Connected to " + ConnectStr); + curproperties = new PropertyValue[1]; + curproperties[0] = Properties.createProperty("DataSourceName", "Bibliography"); + //curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///path/to/database.odb"); + CurTableWizard.startTableWizard(xLocMSF, curproperties); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } +*/ + private void buildSteps() + { + curScenarioSelector = new ScenarioSelector(this, this.curTableDescriptor, slblFields, slblSelFields); + curFieldFormatter = new FieldFormatter(this); + if ( this.curTableDescriptor.supportsPrimaryKeys() ) + { + curPrimaryKeyHandler = new PrimaryKeyHandler(this, curTableDescriptor); + } + curFinalizer = new Finalizer(this, curTableDescriptor); + enableNavigationButtons(false, false, false); + } + + private boolean createTable() + { + boolean bIsSuccessful = true; + boolean bTableCreated = false; + String schemaname = curFinalizer.getSchemaName(); + String catalogname = curFinalizer.getCatalogName(); + if (curTableDescriptor.supportsPrimaryKeys()) + { + String[] keyfieldnames = curPrimaryKeyHandler.getPrimaryKeyFields(); + if (keyfieldnames != null && keyfieldnames.length > 0) + { + boolean bIsAutoIncrement = curPrimaryKeyHandler.isAutoIncremented(); + bIsSuccessful = curTableDescriptor.createTable(catalogname, schemaname, tablename, keyfieldnames, bIsAutoIncrement); + bTableCreated = true; + } + } + if (!bTableCreated) + { + bIsSuccessful = curTableDescriptor.createTable(catalogname, schemaname, tablename); + } + if ((!bIsSuccessful) && (curPrimaryKeyHandler.isAutomaticMode())) + { + curTableDescriptor.dropColumnbyName(curPrimaryKeyHandler.getAutomaticFieldName()); + } + return bIsSuccessful; + } + + @Override + public boolean finishWizard() + { + super.switchToStep(super.getCurrentStep(), SOFINALPAGE); + tablename = curFinalizer.getTableName(curScenarioSelector.getFirstTableName()); + scomposedtablename = curFinalizer.getComposedTableName(tablename); + if (this.curTableDescriptor.isSQL92CheckEnabled()) + { + Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getLocale(this.curTableDescriptor.xMSF), tablename); + } + if ( tablename.length() > 0 ) + { + if (!curTableDescriptor.hasTableByName(scomposedtablename)) + { + wizardmode = curFinalizer.finish(); + if (createTable()) + { + final boolean editTableDesign = (wizardmode == Finalizer.MODIFYTABLEMODE ); + loadSubComponent( DatabaseObject.TABLE, curTableDescriptor.getComposedTableName(), editTableDesign ); + m_tableName = curTableDescriptor.getComposedTableName(); + super.xDialog.endExecute(); + return true; + } + } + else + { + String smessage = JavaTools.replaceSubString(serrTableNameexists, tablename, "%TABLENAME"); + super.showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage); + curFinalizer.setFocusToTableNameControl(); + } + } + return false; + } + + private void callFormWizard() + { + try + { + Object oFormWizard = this.xMSF.createInstance("com.sun.star.wizards.form.CallFormWizard"); + + NamedValueCollection wizardContext = new NamedValueCollection(); + wizardContext.put( PropertyNames.ACTIVE_CONNECTION, curTableDescriptor.DBConnection ); + wizardContext.put( "DataSource", curTableDescriptor.getDataSource() ); + wizardContext.put( PropertyNames.COMMAND_TYPE, CommandType.TABLE ); + wizardContext.put( PropertyNames.COMMAND, scomposedtablename ); + wizardContext.put( "DocumentUI", m_docUI ); + XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, oFormWizard ); + xInitialization.initialize( wizardContext.getPropertyValues() ); + XJobExecutor xJobExecutor = UnoRuntime.queryInterface( XJobExecutor.class, oFormWizard ); + xJobExecutor.trigger(PropertyNames.START); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + @Override + public void cancelWizard() + { + xDialog.endExecute(); + } + + private void insertFormRelatedSteps() + { + addRoadmap(); + int i = 0; + i = insertRoadmapItem(0, true, m_oResource.getResText("RID_TABLE_2"), SOMAINPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_TABLE_3"), SOFIELDSFORMATPAGE); + if (this.curTableDescriptor.supportsPrimaryKeys()) + { + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_TABLE_4"), SOPRIMARYKEYPAGE); + } + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_TABLE_5"), SOFINALPAGE); // Orderby is always supported + setRoadmapInteractive(true); + setRoadmapComplete(true); + setCurrentRoadmapItemID((short) 1); + } + + public String startTableWizard( ) + { + try + { + curTableDescriptor = new TableDescriptor(xMSF, super.xWindow, this.sMsgColumnAlreadyExists); + if ( curTableDescriptor.getConnection( m_wizardContext ) ) + { + buildSteps(); + createWindowPeer(); + curTableDescriptor.setWindowPeer(this.xControl.getPeer()); + insertFormRelatedSteps(); + short RetValue = executeDialog(); + xComponent.dispose(); + if ( RetValue == 0 ) + { + if ( wizardmode == Finalizer.STARTFORMWIZARDMODE ) + callFormWizard(); + return m_tableName; + } + } + } + catch (java.lang.Exception jexception) + { + jexception.printStackTrace(System.err); + } + return PropertyNames.EMPTY_STRING; + } + + private boolean getTableResources() + { + super.m_oResource.getResText("RID_TABLE_1"); + slblFields = m_oResource.getResText("RID_TABLE_19"); + slblSelFields = m_oResource.getResText("RID_TABLE_25"); + serrToManyFields = m_oResource.getResText("RID_TABLE_47"); + serrTableNameexists = m_oResource.getResText("RID_TABLE_48"); + sMsgColumnAlreadyExists = m_oResource.getResText("RID_TABLE_51"); + return true; + } + + public boolean verifyfieldcount(int _icount) + { + try + { + int maxfieldcount = curTableDescriptor.getMaxColumnsInTable(); + if (_icount >= (maxfieldcount - 1)) + { // keep one column as reserve for the automatically created key + String smessage = serrToManyFields; + smessage = JavaTools.replaceSubString(smessage, String.valueOf(maxfieldcount), "%COUNT"); + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, smessage); + return false; + } + } + catch (SQLException e) + { + e.printStackTrace(System.err); + } + return true; + } + + + /* (non-Javadoc) + * @see com.sun.star.awt.XTextListener#textChanged(com.sun.star.awt.TextEvent) + */ + public void textChanged(TextEvent aTextEvent) + { + if (this.curTableDescriptor.isSQL92CheckEnabled()) + { + Object otextcomponent = UnoDialog.getModel(aTextEvent.Source); + String sName = (String) Helper.getUnoPropertyValue(otextcomponent, "Text"); + sName = Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getLocale(curTableDescriptor.xMSF), sName); + Helper.setUnoPropertyValue(otextcomponent, "Text", sName); + } + } +} diff --git a/wizards/com/sun/star/wizards/table/table.component b/wizards/com/sun/star/wizards/table/table.component new file mode 100644 index 0000000000..a407c97232 --- /dev/null +++ b/wizards/com/sun/star/wizards/table/table.component @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . + --> + +<component loader="com.sun.star.loader.Java2" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name= + "com.sun.star.wizards.table.CallTableWizard$TableWizardImplementation"> + <service name="com.sun.star.wizards.table.CallTableWizard"/> + </implementation> +</component> diff --git a/wizards/com/sun/star/wizards/text/TextDocument.java b/wizards/com/sun/star/wizards/text/TextDocument.java new file mode 100644 index 0000000000..74a24eb7f3 --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextDocument.java @@ -0,0 +1,273 @@ +/* + * 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 . + */ +package com.sun.star.wizards.text; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XLoadable; +import com.sun.star.frame.XModule; +import com.sun.star.frame.XTerminateListener; +import com.sun.star.frame.XStorable; +import com.sun.star.awt.Size; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.task.XStatusIndicatorFactory; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XModifiable; +import com.sun.star.util.XNumberFormatsSupplier; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.document.OfficeDocument; + +public class TextDocument +{ + + public XComponent xComponent; + public com.sun.star.text.XTextDocument xTextDocument; + public com.sun.star.task.XStatusIndicator xProgressBar; + public com.sun.star.frame.XFrame xFrame; + public XText xText; + public XMultiServiceFactory xMSFDoc; + public XMultiServiceFactory xMSF; + public com.sun.star.awt.XWindowPeer xWindowPeer; + + // creates an instance of TextDocument by loading a given URL as preview + public TextDocument(XMultiServiceFactory xMSF, String _sPreviewURL, boolean bShowStatusIndicator, XTerminateListener listener) + { + this.xMSF = xMSF; + + xFrame = OfficeDocument.createNewFrame(xMSF, listener); + xTextDocument = loadAsPreview(_sPreviewURL, true); + xComponent = UnoRuntime.queryInterface(XComponent.class, xTextDocument); + + if (bShowStatusIndicator) + { + showStatusIndicator(); + } + init(); + } + + public static class ModuleIdentifier + { + + private final String m_identifier; + + private final String getIdentifier() + { + return m_identifier; + } + + public ModuleIdentifier(String _identifier) + { + m_identifier = _identifier; + } + } + + // creates an instance of TextDocument containing a blank text document + public TextDocument(XMultiServiceFactory xMSF, ModuleIdentifier _moduleIdentifier, boolean bShowStatusIndicator) + { + this.xMSF = xMSF; + + try + { + // create the empty document, and set its module identifier + xTextDocument = UnoRuntime.queryInterface(XTextDocument.class, + xMSF.createInstance("com.sun.star.text.TextDocument")); + + XLoadable xLoadable = UnoRuntime.queryInterface(XLoadable.class, xTextDocument); + xLoadable.initNew(); + + XModule xModule = UnoRuntime.queryInterface(XModule.class, + xTextDocument); + xModule.setIdentifier(_moduleIdentifier.getIdentifier()); + + // load the document into a blank frame + XDesktop xDesktop = Desktop.getDesktop(xMSF); + XComponentLoader xLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop); + PropertyValue[] loadArgs = new PropertyValue[] + { + new PropertyValue("Model", -1, xTextDocument, com.sun.star.beans.PropertyState.DIRECT_VALUE) + }; + xLoader.loadComponentFromURL("private:object", "_blank", 0, loadArgs); + + // remember some things for later usage + xFrame = xTextDocument.getCurrentController().getFrame(); + xComponent = UnoRuntime.queryInterface(XComponent.class, xTextDocument); + } + catch (Exception e) + { + // TODO: it seems the whole project does not really have an error handling. Other methods + // seem to generally silence errors, so we can't do anything else here... + e.printStackTrace(); + } + + if (bShowStatusIndicator) + { + showStatusIndicator(); + } + init(); + } + + //creates an instance of TextDocument from a given XTextDocument + public TextDocument(XMultiServiceFactory xMSF, XTextDocument _textDocument, boolean bshowStatusIndicator) + { + this.xMSF = xMSF; + xFrame = _textDocument.getCurrentController().getFrame(); + xComponent = UnoRuntime.queryInterface(XComponent.class, _textDocument); + xTextDocument = UnoRuntime.queryInterface(XTextDocument.class, xComponent); + //PosSize = xFrame.getComponentWindow().getPosSize(); + if (bshowStatusIndicator) + { + XStatusIndicatorFactory xStatusIndicatorFactory = UnoRuntime.queryInterface(XStatusIndicatorFactory.class, xFrame); + xProgressBar = xStatusIndicatorFactory.createStatusIndicator(); + xProgressBar.start(PropertyNames.EMPTY_STRING, 100); + xProgressBar.setValue(5); + } + xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xFrame.getComponentWindow()); + xMSFDoc = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + UnoRuntime.queryInterface(XNumberFormatsSupplier.class, xTextDocument); + + XDocumentPropertiesSupplier xDocPropsSuppl = UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument); + xDocPropsSuppl.getDocumentProperties(); + Helper.getUnoStructValue(xComponent, "CharLocale"); + xText = xTextDocument.getText(); + } + + private void init() + { + xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xFrame.getComponentWindow()); + xMSFDoc = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + UnoRuntime.queryInterface(XNumberFormatsSupplier.class, xTextDocument); + XDocumentPropertiesSupplier xDocPropsSuppl = UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument); + xDocPropsSuppl.getDocumentProperties(); + Helper.getUnoStructValue(xComponent, "CharLocale"); + UnoRuntime.queryInterface(XStorable.class, xTextDocument); + xText = xTextDocument.getText(); + } + + private void showStatusIndicator() + { + XStatusIndicatorFactory xStatusIndicatorFactory = UnoRuntime.queryInterface(XStatusIndicatorFactory.class, xFrame); + xProgressBar = xStatusIndicatorFactory.createStatusIndicator(); + xProgressBar.start(PropertyNames.EMPTY_STRING, 100); + xProgressBar.setValue(5); + } + + private XTextDocument loadAsPreview(String sDefaultTemplate, boolean asTemplate) + { + PropertyValue loadValues[] = new PropertyValue[3]; + // open document in the Preview mode + loadValues[0] = new PropertyValue(); + loadValues[0].Name = PropertyNames.READ_ONLY; + loadValues[0].Value = Boolean.TRUE; + loadValues[1] = new PropertyValue(); + loadValues[1].Name = "AsTemplate"; + loadValues[1].Value = asTemplate ? Boolean.TRUE : Boolean.FALSE; + loadValues[2] = new PropertyValue(); + loadValues[2].Name = "Preview"; + loadValues[2].Value = Boolean.TRUE; + + //set the preview document to non-modified mode in order to avoid the 'do u want to save' box + if (xTextDocument != null) + { + try + { + XModifiable xModi = UnoRuntime.queryInterface(XModifiable.class, xTextDocument); + xModi.setModified(false); + } + catch (PropertyVetoException e1) + { + e1.printStackTrace(System.err); + } + } + Object oDoc = OfficeDocument.load(xFrame, sDefaultTemplate, "_self", loadValues); + xTextDocument = (com.sun.star.text.XTextDocument) oDoc; + getPageSize(); + xMSFDoc = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + + ViewHandler myViewHandler = new ViewHandler(xTextDocument); + try + { + myViewHandler.setViewSetting("ZoomType", Short.valueOf(com.sun.star.view.DocumentZoomType.ENTIRE_PAGE)); + } + catch (Exception e) + { + e.printStackTrace(); + } + + TextFieldHandler myFieldHandler = new TextFieldHandler(xMSF, xTextDocument); + myFieldHandler.updateDocInfoFields(); + + return xTextDocument; + + } + + private Size getPageSize() + { + try + { + XStyleFamiliesSupplier xStyleFamiliesSupplier = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument); + com.sun.star.container.XNameAccess xNameAccess = null; + xNameAccess = xStyleFamiliesSupplier.getStyleFamilies(); + com.sun.star.container.XNameContainer xPageStyleCollection = null; + xPageStyleCollection = UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class, xNameAccess.getByName("PageStyles")); + XStyle xPageStyle = UnoRuntime.queryInterface(XStyle.class, xPageStyleCollection.getByName("First Page")); + return (Size) Helper.getUnoPropertyValue(xPageStyle, "Size"); + + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public static XTextCursor createTextCursor(Object oCursorContainer) + { + XSimpleText xText = UnoRuntime.queryInterface(XSimpleText.class, oCursorContainer); + return xText.createTextCursor(); + } + + // Todo: This method is unsecure because the last index is not necessarily the last section + + // Todo: This Routine should be modified, because I cannot rely on the last Table in the document to be the last in the TextTables sequence + // to make it really safe you must acquire the Tablenames before the insertion and after the insertion of the new Table. By comparing the + // two sequences of tablenames you can find out the tablename of the last inserted Table + + + + public void unlockallControllers() + { + while (xTextDocument.hasControllersLocked()) + { + xTextDocument.unlockControllers(); + } + } + +} diff --git a/wizards/com/sun/star/wizards/text/TextDocument.py b/wizards/com/sun/star/wizards/text/TextDocument.py new file mode 100644 index 0000000000..f975dad571 --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextDocument.py @@ -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) diff --git a/wizards/com/sun/star/wizards/text/TextElement.py b/wizards/com/sun/star/wizards/text/TextElement.py new file mode 100644 index 0000000000..57aa4ea268 --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextElement.py @@ -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 diff --git a/wizards/com/sun/star/wizards/text/TextFieldHandler.java b/wizards/com/sun/star/wizards/text/TextFieldHandler.java new file mode 100644 index 0000000000..da43b3d883 --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextFieldHandler.java @@ -0,0 +1,287 @@ +/* + * 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 . + */ +package com.sun.star.wizards.text; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.text.XDependentTextField; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFieldsSupplier; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.DateTime; +import com.sun.star.util.XRefreshable; +import com.sun.star.util.XUpdatable; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; + +public class TextFieldHandler +{ + + private XTextFieldsSupplier xTextFieldsSupplier; + private final XMultiServiceFactory xMSFDoc; + + /** + * Creates a new instance of TextFieldHandler + */ + public TextFieldHandler(XMultiServiceFactory xMSF, XTextDocument xTextDocument) + { + this.xMSFDoc = xMSF; + xTextFieldsSupplier = UnoRuntime.queryInterface(XTextFieldsSupplier.class, xTextDocument); + } + + private void refreshTextFields() + { + XRefreshable xUp = UnoRuntime.queryInterface(XRefreshable.class, xTextFieldsSupplier.getTextFields()); + xUp.refresh(); + } + + public String getUserFieldContent(XTextCursor xTextCursor) + { + try + { + XTextRange xTextRange = xTextCursor.getEnd(); + Object oTextField = Helper.getUnoPropertyValue(xTextRange, "TextField"); + if (com.sun.star.uno.AnyConverter.isVoid(oTextField)) + { + return PropertyNames.EMPTY_STRING; + } + else + { + XDependentTextField xDependent = UnoRuntime.queryInterface(XDependentTextField.class, oTextField); + XPropertySet xMaster = xDependent.getTextFieldMaster(); + return (String) xMaster.getPropertyValue("Content"); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + return PropertyNames.EMPTY_STRING; + } + + public void insertUserField(XTextCursor xTextCursor, String FieldName, String FieldTitle) + { + try + { + XInterface xField = (XInterface) xMSFDoc.createInstance("com.sun.star.text.TextField.User"); + XDependentTextField xDepField = UnoRuntime.queryInterface(XDependentTextField.class, xField); + XTextContent xFieldContent = UnoRuntime.queryInterface(XTextContent.class, xField); + if (xTextFieldsSupplier.getTextFieldMasters().hasByName("com.sun.star.text.FieldMaster.User." + FieldName)) + { + Object oMaster = xTextFieldsSupplier.getTextFieldMasters().getByName("com.sun.star.text.FieldMaster.User." + FieldName); + XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, oMaster); + xComponent.dispose(); + } + XPropertySet xPSet = createUserField(FieldName, FieldTitle); + xDepField.attachTextFieldMaster(xPSet); + xTextCursor.getText().insertTextContent(xTextCursor, xFieldContent, false); + + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private XPropertySet createUserField(String FieldName, String FieldTitle) throws com.sun.star.uno.Exception + { + Object oMaster = xMSFDoc.createInstance("com.sun.star.text.FieldMaster.User"); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oMaster); + xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, FieldName); + xPSet.setPropertyValue("Content", FieldTitle); + + return xPSet; + } + + private XDependentTextField[] getTextFieldsByProperty(String _PropertyName, Object _aPropertyValue, String _TypeName) + { + try + { + XDependentTextField[] xDependentFields; + ArrayList<XDependentTextField> xDependentVector = new ArrayList<XDependentTextField>(); + if (xTextFieldsSupplier.getTextFields().hasElements()) + { + XEnumeration xEnum = xTextFieldsSupplier.getTextFields().createEnumeration(); + while (xEnum.hasMoreElements()) + { + Object oTextField = xEnum.nextElement(); + XDependentTextField xDependent = UnoRuntime.queryInterface(XDependentTextField.class, oTextField); + XPropertySet xPropertySet = xDependent.getTextFieldMaster(); + if (xPropertySet.getPropertySetInfo().hasPropertyByName(_PropertyName)) + { + Object oValue = xPropertySet.getPropertyValue(_PropertyName); + // TODO replace the following comparison via com.sun.star.uno.Any.Type + if (AnyConverter.isString(oValue)) + { + if (_TypeName.equals("String")) + { + String sValue = AnyConverter.toString(oValue); + if (sValue.equals(_aPropertyValue)) + { + xDependentVector.add(xDependent); + } + } + } + else if (AnyConverter.isShort(oValue)) + { + if (_TypeName.equals("Short")) + { + short iShortParam = ((Short) _aPropertyValue).shortValue(); + short ishortValue = AnyConverter.toShort(oValue); + if (ishortValue == iShortParam) + { + xDependentVector.add(xDependent); + } + } + } + } + } + } + if (xDependentVector.size() > 0) + { + xDependentFields = new XDependentTextField[xDependentVector.size()]; + xDependentVector.toArray(xDependentFields); + return xDependentFields; + } + } + catch (Exception e) + { + // TODO Auto-generated catch block + e.printStackTrace(System.err); + } + return null; + } + + public void changeUserFieldContent(String _FieldName, String _FieldContent) + { + try + { + XDependentTextField[] xDependentTextFields = getTextFieldsByProperty(PropertyNames.PROPERTY_NAME, _FieldName, "String"); + if (xDependentTextFields != null) + { + for (int i = 0; i < xDependentTextFields.length; i++) + { + xDependentTextFields[i].getTextFieldMaster().setPropertyValue("Content", _FieldContent); + } + refreshTextFields(); + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + public void updateDocInfoFields() + { + try + { + XEnumeration xEnum = xTextFieldsSupplier.getTextFields().createEnumeration(); + while (xEnum.hasMoreElements()) + { + Object oTextField = xEnum.nextElement(); + XServiceInfo xSI = UnoRuntime.queryInterface(XServiceInfo.class, oTextField); + + if (xSI.supportsService("com.sun.star.text.TextField.ExtendedUser")) + { + XUpdatable xUp = UnoRuntime.queryInterface(XUpdatable.class, oTextField); + xUp.update(); + } + if (xSI.supportsService("com.sun.star.text.TextField.User")) + { + XUpdatable xUp = UnoRuntime.queryInterface(XUpdatable.class, oTextField); + xUp.update(); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updateDateFields() + { + try + { + XEnumeration xEnum = xTextFieldsSupplier.getTextFields().createEnumeration(); + Calendar cal = new GregorianCalendar(); + DateTime dt = new DateTime(); + dt.Day = (short) cal.get(Calendar.DAY_OF_MONTH); + dt.Year = (short) cal.get(Calendar.YEAR); + dt.Month = (short) cal.get(Calendar.MONTH); + dt.Month++; + + while (xEnum.hasMoreElements()) + { + Object oTextField = xEnum.nextElement(); + XServiceInfo xSI = UnoRuntime.queryInterface(XServiceInfo.class, oTextField); + + if (xSI.supportsService("com.sun.star.text.TextField.DateTime")) + { + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oTextField); + xPSet.setPropertyValue("IsFixed", Boolean.FALSE); + xPSet.setPropertyValue("DateTimeValue", dt); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void fixDateFields(boolean _bSetFixed) + { + try + { + XEnumeration xEnum = xTextFieldsSupplier.getTextFields().createEnumeration(); + while (xEnum.hasMoreElements()) + { + Object oTextField = xEnum.nextElement(); + XServiceInfo xSI = UnoRuntime.queryInterface(XServiceInfo.class, oTextField); + if (xSI.supportsService("com.sun.star.text.TextField.DateTime")) + { + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oTextField); + xPSet.setPropertyValue("IsFixed", Boolean.valueOf(_bSetFixed)); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + + + +} diff --git a/wizards/com/sun/star/wizards/text/TextFieldHandler.py b/wizards/com/sun/star/wizards/text/TextFieldHandler.py new file mode 100644 index 0000000000..c250e091eb --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextFieldHandler.py @@ -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() diff --git a/wizards/com/sun/star/wizards/text/TextSectionHandler.java b/wizards/com/sun/star/wizards/text/TextSectionHandler.java new file mode 100644 index 0000000000..14348b4556 --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextSectionHandler.java @@ -0,0 +1,245 @@ +/* + * 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 . + */ +package com.sun.star.wizards.text; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.SectionFileLink; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextSectionsSupplier; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; + +public class TextSectionHandler +{ + + public XTextSectionsSupplier xTextSectionsSupplier; + private final XMultiServiceFactory xMSFDoc; + private final XText xText; + + /** Creates a new instance of TextSectionHandler */ + public TextSectionHandler(XMultiServiceFactory xMSF, XTextDocument xTextDocument) + { + this.xMSFDoc = xMSF; + xText = xTextDocument.getText(); + xTextSectionsSupplier = UnoRuntime.queryInterface(XTextSectionsSupplier.class, xTextDocument); + } + + public void removeTextSectionbyName(String SectionName) + { + try + { + XNameAccess xAllTextSections = xTextSectionsSupplier.getTextSections(); + if (xAllTextSections.hasByName(SectionName)) + { + Object oTextSection = xTextSectionsSupplier.getTextSections().getByName(SectionName); + removeTextSection(oTextSection); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + + + public void removeLastTextSection() + { + try + { + XIndexAccess xAllTextSections = UnoRuntime.queryInterface(XIndexAccess.class, xTextSectionsSupplier.getTextSections()); + Object oTextSection = xAllTextSections.getByIndex(xAllTextSections.getCount() - 1); + removeTextSection(oTextSection); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void removeTextSection(Object _oTextSection) + { + try + { + XTextContent xTextContentTextSection = UnoRuntime.queryInterface(XTextContent.class, _oTextSection); + xText.removeTextContent(xTextContentTextSection); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void removeInvisibleTextSections() + { + try + { + XIndexAccess xAllTextSections = UnoRuntime.queryInterface(XIndexAccess.class, xTextSectionsSupplier.getTextSections()); + int TextSectionCount = xAllTextSections.getCount(); + for (int i = TextSectionCount - 1; i >= 0; i--) + { + XTextContent xTextContentTextSection = UnoRuntime.queryInterface(XTextContent.class, xAllTextSections.getByIndex(i)); + XPropertySet xTextSectionPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xTextContentTextSection); + boolean bRemoveTextSection = (!AnyConverter.toBoolean(xTextSectionPropertySet.getPropertyValue("IsVisible"))); + if (bRemoveTextSection) + { + xText.removeTextContent(xTextContentTextSection); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void removeAllTextSections() + { + try + { + XIndexAccess xAllTextSections = UnoRuntime.queryInterface(XIndexAccess.class, xTextSectionsSupplier.getTextSections()); + int TextSectionCount = xAllTextSections.getCount(); + for (int i = TextSectionCount - 1; i >= 0; i--) + { + XTextContent xTextContentTextSection = UnoRuntime.queryInterface(XTextContent.class, xAllTextSections.getByIndex(i)); + xText.removeTextContent(xTextContentTextSection); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void breakLinkofTextSections() + { + try + { + Object oTextSection; + XIndexAccess xAllTextSections = UnoRuntime.queryInterface(XIndexAccess.class, xTextSectionsSupplier.getTextSections()); + int iSectionCount = xAllTextSections.getCount(); + SectionFileLink oSectionLink = new SectionFileLink(); + oSectionLink.FileURL = PropertyNames.EMPTY_STRING; + for (int i = 0; i < iSectionCount; i++) + { + oTextSection = xAllTextSections.getByIndex(i); + Helper.setUnoPropertyValues(oTextSection, new String[] + { + "FileLink", "LinkRegion" + }, new Object[] + { + oSectionLink, PropertyNames.EMPTY_STRING + }); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + + + public void linkSectiontoTemplate(String TemplateName, String SectionName) + { + try + { + Object oTextSection = xTextSectionsSupplier.getTextSections().getByName(SectionName); + linkSectiontoTemplate(oTextSection, TemplateName, SectionName); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + private void linkSectiontoTemplate(Object oTextSection, String TemplateName, String SectionName) + { + SectionFileLink oSectionLink = new SectionFileLink(); + oSectionLink.FileURL = TemplateName; + Helper.setUnoPropertyValues(oTextSection, new String[] + { + "FileLink", "LinkRegion" + }, new Object[] + { + oSectionLink, SectionName + }); + XNamed xSectionName = UnoRuntime.queryInterface(XNamed.class, oTextSection); + String NewSectionName = xSectionName.getName(); + if (NewSectionName.compareTo(SectionName) != 0) + { + xSectionName.setName(SectionName); + } + } + + public void insertTextSection(String GroupName, String TemplateName, boolean _bAddParagraph) + { + try + { + if (_bAddParagraph) + { + XTextCursor xTextCursor = xText.createTextCursor(); + xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); + // Helper.setUnoPropertyValue(xTextCursor, "PageDescName", "First Page"); + xTextCursor.collapseToEnd(); + } + XTextCursor xSecondTextCursor = xText.createTextCursor(); + xSecondTextCursor.gotoEnd(false); + insertTextSection(GroupName, TemplateName, xSecondTextCursor); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + } + } + + private void insertTextSection(String sectionName, String templateName, XTextCursor position) + { + try + { + Object xTextSection; + if (xTextSectionsSupplier.getTextSections().hasByName(sectionName)) + { + xTextSection = xTextSectionsSupplier.getTextSections().getByName(sectionName); + } + else + { + xTextSection = xMSFDoc.createInstance("com.sun.star.text.TextSection"); + XTextContent xTextContentSection = UnoRuntime.queryInterface(XTextContent.class, xTextSection); + position.getText().insertTextContent(position, xTextContentSection, false); + } + linkSectiontoTemplate(xTextSection, templateName, sectionName); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } +} diff --git a/wizards/com/sun/star/wizards/text/TextSectionHandler.py b/wizards/com/sun/star/wizards/text/TextSectionHandler.py new file mode 100644 index 0000000000..e8d649a314 --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextSectionHandler.py @@ -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() + diff --git a/wizards/com/sun/star/wizards/text/TextStyleHandler.java b/wizards/com/sun/star/wizards/text/TextStyleHandler.java new file mode 100644 index 0000000000..c36bdc670e --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextStyleHandler.java @@ -0,0 +1,101 @@ +/* + * 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 . + */ +package com.sun.star.wizards.text; + +import com.sun.star.awt.Size; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.style.XStyleLoader; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.PropertyNames; + +public class TextStyleHandler +{ + + public XStyleFamiliesSupplier xStyleFamiliesSupplier; + + /** Creates a new instance of TextStyleHandler */ + public TextStyleHandler(XTextDocument xTextDocument) + { + xStyleFamiliesSupplier = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument); + } + + public void loadStyleTemplates(String sTemplateUrl, String OptionString) + { + try + { + XStyleLoader xStyleLoader = UnoRuntime.queryInterface(XStyleLoader.class, xStyleFamiliesSupplier.getStyleFamilies()); + com.sun.star.beans.PropertyValue[] StyleOptions = xStyleLoader.getStyleLoaderOptions(); + String CurOptionName = PropertyNames.EMPTY_STRING; + int PropCount = StyleOptions.length; + for (int i = 0; i < PropCount; i++) + { + CurOptionName = StyleOptions[i].Name; + StyleOptions[i].Value = Boolean.valueOf(CurOptionName.equals(OptionString) || CurOptionName.equals("OverwriteStyles")); + } + xStyleLoader.loadStylesFromURL(sTemplateUrl, StyleOptions); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public XPropertySet getStyleByName(String sStyleFamily, String sStyleName) + { + try + { + XPropertySet xPropertySet = null; + Object oStyleFamily = xStyleFamiliesSupplier.getStyleFamilies().getByName(sStyleFamily); + XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, oStyleFamily); + if (xNameAccess.hasByName(sStyleName)) + { + xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xNameAccess.getByName(sStyleName)); + } + return xPropertySet; + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return null; + } + + public Size changePageAlignment(XPropertySet _xPropPageStyle, boolean _bIsLandscape) + { + try + { + _xPropPageStyle.setPropertyValue("IsLandscape", Boolean.valueOf(_bIsLandscape)); + Size aPageSize = (Size) AnyConverter.toObject(Size.class, _xPropPageStyle.getPropertyValue("Size")); + int nPageWidth = aPageSize.Width; + int nPageHeight = aPageSize.Height; + Size aSize = new Size(nPageHeight, nPageWidth); + _xPropPageStyle.setPropertyValue("Size", aSize); + return (Size) AnyConverter.toObject(Size.class, _xPropPageStyle.getPropertyValue("Size")); + } + catch (Exception e) + { + e.printStackTrace(System.err); + return null; + } + } +} diff --git a/wizards/com/sun/star/wizards/text/TextTableHandler.java b/wizards/com/sun/star/wizards/text/TextTableHandler.java new file mode 100644 index 0000000000..74e8966392 --- /dev/null +++ b/wizards/com/sun/star/wizards/text/TextTableHandler.java @@ -0,0 +1,206 @@ +/* + * 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 . + */ +package com.sun.star.wizards.text; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.Locale; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.text.XTextTablesSupplier; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XNumberFormatsSupplier; +import com.sun.star.view.XSelectionSupplier; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.NumberFormatter; + +public class TextTableHandler +{ + + public XTextTablesSupplier xTextTablesSupplier; + private XTextDocument xTextDocument; + private NumberFormatter oNumberFormatter; + + /** Creates a new instance of TextTableHandler */ + public TextTableHandler(XTextDocument xTextDocument) + { + try + { + this.xTextDocument = xTextDocument; + xTextTablesSupplier = UnoRuntime.queryInterface(XTextTablesSupplier.class, xTextDocument); + UnoRuntime.queryInterface(XSimpleText.class, xTextDocument.getText()); + XNumberFormatsSupplier xNumberFormatsSupplier = UnoRuntime.queryInterface(XNumberFormatsSupplier.class, xTextDocument); + Locale aCharLocale = (Locale) Helper.getUnoStructValue(xTextDocument, "CharLocale"); + oNumberFormatter = new NumberFormatter(xNumberFormatsSupplier, aCharLocale); + } + catch (java.lang.Exception e) + { + e.printStackTrace(System.err); + } + } + + public NumberFormatter getNumberFormatter() + { + return oNumberFormatter; + } + + public XTextTable getByName(String _sTableName) + { + XTextTable xTextTable = null; + try + { + XNameAccess xAllTextTables = xTextTablesSupplier.getTextTables(); + if (xAllTextTables.hasByName(_sTableName)) + { + Object oTable = xAllTextTables.getByName(_sTableName); + xTextTable = UnoRuntime.queryInterface(XTextTable.class, oTable); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + return xTextTable; + } + + public com.sun.star.text.XTextTable getlastTextTable() + { + try + { + XIndexAccess xAllTextTables = UnoRuntime.queryInterface(XIndexAccess.class, xTextTablesSupplier.getTextTables()); + int MaxIndex = xAllTextTables.getCount() - 1; + Object oTable = xAllTextTables.getByIndex(MaxIndex); + return UnoRuntime.queryInterface(XTextTable.class, oTable); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + + + public void removeAllTextTables() + { + try + { + XIndexAccess xAllTextTables = UnoRuntime.queryInterface(XIndexAccess.class, xTextTablesSupplier.getTextTables()); + int TextTableCount = xAllTextTables.getCount(); + for (int i = TextTableCount - 1; i >= 0; i--) + { + removeTextTable(xAllTextTables.getByIndex(i)); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void removeLastTextTable() + { + try + { + XIndexAccess xAllTextTables = UnoRuntime.queryInterface(XIndexAccess.class, xTextTablesSupplier.getTextTables()); + Object oTextTable = xAllTextTables.getByIndex(xAllTextTables.getCount() - 1); + removeTextTable(oTextTable); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void removeTextTable(Object oTextTable) + { + try + { + XTextContent xTextContentTable = UnoRuntime.queryInterface(XTextContent.class, oTextTable); + xTextDocument.getText().removeTextContent(xTextContentTable); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void removeTextTablebyName(String TableName) + { + try + { + XNameAccess xAllTextTables = xTextTablesSupplier.getTextTables(); + if (xAllTextTables.hasByName(TableName)) + { + removeTextTable(xAllTextTables.getByName(TableName)); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void renameTextTable(String OldTableName, String NewTableName) + { + try + { + XNameAccess xTextTableNames = xTextTablesSupplier.getTextTables(); + if (xTextTableNames.hasByName(OldTableName)) + { + Object oTextTable = xTextTableNames.getByName(OldTableName); + XNamed xTextTableName = UnoRuntime.queryInterface(XNamed.class, oTextTable); + xTextTableName.setName(NewTableName); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void adjustOptimalTableWidths(XMultiServiceFactory _xMSF, XTextTable xTextTable) + { + try + { + XFrame xFrame = this.xTextDocument.getCurrentController().getFrame(); + int ColCount = xTextTable.getColumns().getCount(); + XCellRange xCellRange = UnoRuntime.queryInterface(XCellRange.class, xTextTable); + XCellRange xLocCellRange = xCellRange.getCellRangeByPosition(0, 0, ColCount - 1, 1); + short iHoriOrient = AnyConverter.toShort(Helper.getUnoPropertyValue(xTextTable, "HoriOrient")); + XSelectionSupplier xSelection = UnoRuntime.queryInterface(XSelectionSupplier.class, xTextDocument.getCurrentController()); + xSelection.select(xLocCellRange); + Desktop.dispatchURL(_xMSF, ".Uno:DistributeColumns", xFrame); + Desktop.dispatchURL(_xMSF, ".Uno:SetOptimalColumnWidth", xFrame); + Helper.setUnoPropertyValue(xTextTable, "HoriOrient", Short.valueOf(iHoriOrient)); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } +} diff --git a/wizards/com/sun/star/wizards/text/ViewHandler.java b/wizards/com/sun/star/wizards/text/ViewHandler.java new file mode 100644 index 0000000000..fc7842996a --- /dev/null +++ b/wizards/com/sun/star/wizards/text/ViewHandler.java @@ -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 . + */ +package com.sun.star.wizards.text; + +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XPageCursor; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextViewCursor; +import com.sun.star.text.XTextViewCursorSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.view.XViewSettingsSupplier; +import com.sun.star.wizards.common.Helper; + +public class ViewHandler +{ + + private final XTextViewCursorSupplier xTextViewCursorSupplier; + private final XStyleFamiliesSupplier xStyleFamiliesSupplier; + private final XViewSettingsSupplier xViewSettingsSupplier; + + /** Creates a new instance of View */ + public ViewHandler(XTextDocument xTextDocument) + { + xTextViewCursorSupplier = UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xTextDocument.getCurrentController()); + xViewSettingsSupplier = UnoRuntime.queryInterface(XViewSettingsSupplier.class, xTextDocument.getCurrentController()); + xStyleFamiliesSupplier = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument); + } + + public void selectFirstPage(TextTableHandler oTextTableHandler) + { + try + { + XPageCursor xPageCursor = UnoRuntime.queryInterface(XPageCursor.class, xTextViewCursorSupplier.getViewCursor()); + XTextCursor xViewTextCursor = UnoRuntime.queryInterface(XTextCursor.class, xPageCursor); + xPageCursor.jumpToFirstPage(); + xPageCursor.jumpToStartOfPage(); + Helper.setUnoPropertyValue(xPageCursor, "PageDescName", "First Page"); + Object oPageStyles = xStyleFamiliesSupplier.getStyleFamilies().getByName("PageStyles"); + XNameAccess xName = UnoRuntime.queryInterface(XNameAccess.class, oPageStyles); + Object oPageStyle = xName.getByName("First Page"); + XIndexAccess xAllTextTables = UnoRuntime.queryInterface(XIndexAccess.class, oTextTableHandler.xTextTablesSupplier.getTextTables()); + XTextContent xTextTable = UnoRuntime.queryInterface(XTextContent.class, xAllTextTables.getByIndex(0)); + XTextRange xRange = UnoRuntime.queryInterface(XTextRange.class, xTextTable.getAnchor().getText()); + xViewTextCursor.gotoRange(xRange, false); + XTextRange xHeaderRange = (XTextRange) Helper.getUnoPropertyValue(oPageStyle, "HeaderText", XTextRange.class); + if (!com.sun.star.uno.AnyConverter.isVoid(xHeaderRange)) + { + xViewTextCursor.gotoRange(xHeaderRange, false); + xViewTextCursor.collapseToStart(); + } + else + { + System.out.println("No Headertext available"); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void setViewSetting(String Setting, Object Value) throws UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException + { + xViewSettingsSupplier.getViewSettings().setPropertyValue(Setting, Value); + } + + public void collapseViewCursorToStart() + { + XTextViewCursor xTextViewCursor = xTextViewCursorSupplier.getViewCursor(); + xTextViewCursor.collapseToStart(); + } +} diff --git a/wizards/com/sun/star/wizards/text/__init__.py b/wizards/com/sun/star/wizards/text/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/text/__init__.py diff --git a/wizards/com/sun/star/wizards/ui/AggregateComponent.java b/wizards/com/sun/star/wizards/ui/AggregateComponent.java new file mode 100644 index 0000000000..c9f0659f38 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/AggregateComponent.java @@ -0,0 +1,575 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import java.util.ArrayList; + +import com.sun.star.awt.FontDescriptor; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XListBox; +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.EventObject; +import com.sun.star.sdbc.SQLException; +import com.sun.star.uno.AnyConverter; +import com.sun.star.wizards.common.HelpIds; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.db.QueryMetaData; + +public class AggregateComponent extends ControlScroller +{ + + private String[] sFunctions; + private String[] sFunctionOperators = new String[] + { + "SUM", "AVG", "MIN", "MAX", "COUNT" + }; + private QueryMetaData CurDBMetaData; + private String soptDetailQuery; + private String soptSummaryQuery; + private String slblAggregate; + private String slblFieldNames; + private String sDuplicateAggregateFunction; + private static final int SOADDROW = 1; + private static final int SOREMOVEROW = 2; + private ArrayList<ControlRow> ControlRowVector; + private int lastHelpIndex; + + /** Creates a new instance of AggregateComponent */ + public AggregateComponent(WizardDialog _CurUnoDialog, QueryMetaData _CurDBMetaData, int _iStep, int _iPosX, int _iPosY, int _iWidth, int _uitextfieldcount, int _firstHelpID) + { + super(_CurUnoDialog, _iStep, _iPosX + 10, _iPosY, _iWidth - 12, _uitextfieldcount, 18, _firstHelpID + 2); + try + { + this.CurDBMetaData = _CurDBMetaData; + CurUnoDialog.insertRadioButton("optDetailQuery", 0, new ActionListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + 8, HelpIds.getHelpIdString(_firstHelpID), soptDetailQuery, Integer.valueOf(_iPosX), Integer.valueOf(iCompPosY - 42), Short.valueOf((short) 1), IStep, Short.valueOf(curtabindex++), Integer.valueOf(iCompWidth) + }); + + CurUnoDialog.insertRadioButton("optSummaryQuery", 0, new ActionListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 16, HelpIds.getHelpIdString(_firstHelpID + 1), soptSummaryQuery, Boolean.TRUE, Integer.valueOf(_iPosX), Integer.valueOf(iCompPosY - 32), IStep, Short.valueOf(curtabindex++), Integer.valueOf(iCompWidth) + }); + CurUnoDialog.insertLabel("lblAggregate", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblAggregate, Integer.valueOf(iCompPosX + 5), Integer.valueOf(iCompPosY - 10), IStep, Short.valueOf(curtabindex++), 90 + }); + CurUnoDialog.insertLabel("lblFieldnames", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblFieldNames, Integer.valueOf(iCompPosX + 101), Integer.valueOf(iCompPosY - 10), IStep, Short.valueOf(curtabindex++), 90 + }); + this.setTotalFieldCount(1); + FontDescriptor oFontDescriptor = new FontDescriptor(); + oFontDescriptor.Weight = com.sun.star.awt.FontWeight.BOLD; + oFontDescriptor.Height = (short) 14; + + int iButtonPosY = iCompPosY + iCompHeight + 3; + CurUnoDialog.insertButton("btnplus", SOADDROW, new ActionListenerImpl(), + new String[] + { + PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + oFontDescriptor, 14, HelpIds.getHelpIdString(lastHelpIndex + 1), "+", Integer.valueOf(_iPosX + iCompWidth - 36), Integer.valueOf(iButtonPosY), IStep, Short.valueOf((curtabindex++)), 16 + }); + CurUnoDialog.insertButton("btnminus", SOREMOVEROW, new ActionListenerImpl(), + new String[] + { + PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + oFontDescriptor, 14, HelpIds.getHelpIdString(lastHelpIndex + 2), "-", Integer.valueOf(_iPosX + iCompWidth - 16), Integer.valueOf(iButtonPosY), IStep, Short.valueOf(curtabindex++), 16 + }); + CurDBMetaData.Type = getQueryType(); + } + catch (com.sun.star.uno.Exception exception) + { + Resource.showCommonResourceError(CurDBMetaData.xMSF); + } + } + + private int getQueryType() + { + if (((Short) CurUnoDialog.getControlProperty("optDetailQuery", PropertyNames.PROPERTY_STATE)).intValue() == 1) + { + return QueryMetaData.QueryType.SODETAILQUERY; + } + else + { + return QueryMetaData.QueryType.SOSUMMARYQUERY; + } + } + + private class ActionListenerImpl implements com.sun.star.awt.XActionListener + { + + public void disposing(EventObject eventObject) + { + } + + public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) + { + try + { + int iKey = CurUnoDialog.getControlKey(actionEvent.Source, CurUnoDialog.ControlList); + switch (iKey) + { + case SOADDROW: + addRow(); + break; + + case SOREMOVEROW: + removeRow(); + break; + + default: + toggleComponent(); + break; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + } + + @Override + protected void insertControlGroup(int i, int ypos) + { + if (i == 0) + { + soptDetailQuery = CurUnoDialog.m_oResource.getResText("RID_QUERY_11"); + soptSummaryQuery = CurUnoDialog.m_oResource.getResText("RID_QUERY_12"); + slblAggregate = CurUnoDialog.m_oResource.getResText("RID_QUERY_16"); + slblFieldNames = CurUnoDialog.m_oResource.getResText("RID_QUERY_17"); + sFunctions = new String[5]; + sFunctions[0] = CurUnoDialog.m_oResource.getResText("RID_QUERY_40"); + sFunctions[1] = CurUnoDialog.m_oResource.getResText("RID_QUERY_41"); + sFunctions[2] = CurUnoDialog.m_oResource.getResText("RID_QUERY_42"); + sFunctions[3] = CurUnoDialog.m_oResource.getResText("RID_QUERY_43"); + sFunctions[4] = CurUnoDialog.m_oResource.getResText("RID_QUERY_44"); + + sDuplicateAggregateFunction = CurUnoDialog.m_oResource.getResText("RID_QUERY_90"); + } + if (ControlRowVector == null) + { + ControlRowVector = new ArrayList<ControlRow>(); + } + int locHelpID = curHelpIndex + (i * 2); + ControlRow oControlRow = new ControlRow(i, ypos, locHelpID); + ControlRowVector.add(oControlRow); + } + + @Override + protected void setControlGroupVisible(int _index, boolean _bIsVisible) + { + ControlRow oControlRow = ControlRowVector.get(_index); + oControlRow.setVisible(_bIsVisible); + if (_index >= (this.CurDBMetaData.AggregateFieldNames.length)) + { + oControlRow.settovoid(); + } + } + + private void addRow() + { + int fieldcount = super.getTotalFieldCount(); + registerControlGroupAtIndex(fieldcount); + if (fieldcount < super.getBlockIncrementation()) + { + ControlRow oControlRow = ControlRowVector.get(fieldcount); + oControlRow.setVisible(true); + oControlRow.settovoid(); + } + else + { + ControlRow oControlRow = ControlRowVector.get(super.getBlockIncrementation() - 1); + super.setScrollValue(getScrollValue() + 1, (fieldcount + 1)); + oControlRow.settovoid(); + } + fieldcount++; + super.setTotalFieldCount(fieldcount); + toggleButtons(); + CurUnoDialog.repaintDialogStep(); + } + + private void removeRow() + { + int fieldcount = super.getTotalFieldCount(); + if (fieldcount > 0) + { + ControlRow oControlRow; + fieldcount--; + if ((fieldcount + 1) <= super.getBlockIncrementation()) + { + oControlRow = ControlRowVector.get(fieldcount); + oControlRow.setVisible(false); + } + super.setScrollValue(getScrollValue() - 1, fieldcount); + super.unregisterControlGroup(fieldcount); + + } + toggleButtons(); + CurUnoDialog.repaintDialogStep(); + } + + private void toggleButtons() + { + ControlRow curcontrolrow = null; + boolean biscomplete = true; + CurDBMetaData.Type = getQueryType(); + CurUnoDialog.setControlProperty("btnminus", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf((super.getTotalFieldCount() > 0) && (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY))); + int fieldcount = super.getCurFieldCount(); + if (fieldcount > 0) + { + curcontrolrow = ControlRowVector.get(super.getCurFieldCount() - 1); + biscomplete = curcontrolrow.isComplete(); + } + CurUnoDialog.setControlProperty("btnplus", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(biscomplete && (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY))); + togglefollowingDialogSteps(); + } + + private void toggleComponent() + { + CurDBMetaData.Type = getQueryType(); + boolean benableComponent = isAggregateComponentEnabled(); + CurUnoDialog.setControlProperty("lblAggregate", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benableComponent)); + CurUnoDialog.setControlProperty("lblFieldnames", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benableComponent)); + toggleButtons(); + super.toggleComponent(benableComponent); + super.toggleControls(benableComponent); + togglefollowingDialogSteps(); + } + + private boolean isAggregateComponentEnabled() + { + return (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY); + } + + public boolean isGroupingpossible() + { + try + { + boolean benableGroupPage = isAggregateComponentEnabled() && CurDBMetaData.xDBMetaData.supportsGroupBy() && hasonlycompletefunctions(); + String[][] sAggregateFieldNames = this.getAggregateFieldNames(); + if (benableGroupPage) + { + for (int i = 0; i < CurDBMetaData.NumericFieldNames.length; i++) + { + boolean bisthere = (JavaTools.FieldInTable(sAggregateFieldNames, CurDBMetaData.NumericFieldNames[i]) > -1); + if (!bisthere) + { + return true; + } + } + } + } + catch (SQLException e) + { + e.printStackTrace(System.err); + } + return false; + } + + private void togglefollowingDialogSteps() + { + boolean benabletherest = true; + boolean benableGroupPage = isGroupingpossible(); + CurUnoDialog.setStepEnabled(UIConsts.SOGROUPSELECTIONPAGE, benableGroupPage); + CurUnoDialog.setStepEnabled(UIConsts.SOGROUPFILTERPAGE, benableGroupPage && CurDBMetaData.GroupFieldNames.length > 0); + if (isAggregateComponentEnabled()) + { + benabletherest = hasonlycompletefunctions(); + } + CurUnoDialog.enablefromStep(UIConsts.SOTITLESPAGE, benabletherest); + CurUnoDialog.enableNextButton(benabletherest); + } + + private void hideControlRowsfromindex(int _index) + { + if (_index < this.ControlRowVector.size()) + { + for (int i = _index; i < ControlRowVector.size(); i++) + { + ControlRow oControlRow = ControlRowVector.get(i); + oControlRow.setVisible(false); + } + } + + } + + public String[][] getAggregateFieldNames() + { + try + { + CurDBMetaData.Type = getQueryType(); + if (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY) + { + ArrayList<String[]> aggregatevector = new ArrayList<String[]>(); + PropertyValue[][] aggregatelist = this.getScrollFieldValues(); + PropertyValue[] currowproperties; + if (CurDBMetaData.AggregateFieldNames != null) + { + for (int i = 0; i < aggregatelist.length; i++) + { + currowproperties = aggregatelist[i]; + if ((currowproperties[0].Value != null) && (currowproperties[1].Value != null)) + { + short[] iselfield = (short[]) AnyConverter.toArray(currowproperties[1].Value); + short[] iselfunction = (short[]) AnyConverter.toArray(currowproperties[0].Value); + if ((iselfield.length > 0) && (iselfunction.length > 0)) + { + String[] curaggregatename = new String[] { + CurDBMetaData.NumericFieldNames[iselfield[0]], + this.sFunctionOperators[iselfunction[0]] }; + aggregatevector.add(curaggregatename); + } + } + } + } + CurDBMetaData.AggregateFieldNames = new String[aggregatevector.size()][2]; + aggregatevector.toArray(CurDBMetaData.AggregateFieldNames); + } + + int iduplicate = JavaTools.getDuplicateFieldIndex(CurDBMetaData.AggregateFieldNames); + if (iduplicate != -1) + { + sDuplicateAggregateFunction = JavaTools.replaceSubString(sDuplicateAggregateFunction, CurDBMetaData.AggregateFieldNames[iduplicate][0], "<NUMERICFIELD>"); + int index = JavaTools.FieldInList(sFunctionOperators, CurDBMetaData.AggregateFieldNames[iduplicate][1]); + String sDisplayFunction = sFunctions[index]; + sDuplicateAggregateFunction = JavaTools.replaceSubString(sDuplicateAggregateFunction, sDisplayFunction, "<FUNCTION>"); + CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, sDuplicateAggregateFunction); + CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", 1, 2)); + return new String[][] + { + }; + } + else + { + return CurDBMetaData.AggregateFieldNames; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public void initialize() + { + CurDBMetaData.setNumericFields(); + initializeScrollFields(); + int icount = CurDBMetaData.AggregateFieldNames.length; + if (icount == 0) + { + super.initialize(1); + hideControlRowsfromindex(1); + } + else + { + super.initialize(icount); + hideControlRowsfromindex(icount); + } + toggleComponent(); + CurUnoDialog.repaintDialogStep(); + } + + @Override + protected void initializeScrollFields() + { + ControlRow curControlRow; + if (CurDBMetaData.AggregateFieldNames != null) + { + for (int i = 0; i < this.getBlockIncrementation(); i++) + { + curControlRow = ControlRowVector.get(i); + curControlRow.insertFieldNames(); + } + for (int i = 0; i <= CurDBMetaData.AggregateFieldNames.length; i++) + { + registerControlGroupAtIndex(i); + } + } + } + + private void registerControlGroupAtIndex(int _index) + { + short[] iselfunctionlist = new short[] + { + }; + short[] iselfieldslist = new short[] + { + }; + PropertyValue[] currowproperties = new PropertyValue[2]; + if (_index < CurDBMetaData.AggregateFieldNames.length) + { + short iselfieldsindex = (short) JavaTools.FieldInList(CurDBMetaData.NumericFieldNames, CurDBMetaData.AggregateFieldNames[_index][0]); + iselfieldslist = new short[] + { + iselfieldsindex + }; + short iselfunctionindex = (short) JavaTools.FieldInList(sFunctionOperators, CurDBMetaData.AggregateFieldNames[_index][1]); + iselfunctionlist = new short[] + { + iselfunctionindex + }; + } + currowproperties[0] = Properties.createProperty(getFunctionControlName(_index), iselfunctionlist, _index); + currowproperties[1] = Properties.createProperty(getFieldsControlName(_index), iselfieldslist, _index); //getTitleName(i) + super.registerControlGroup(currowproperties, _index); + } + + private String getFunctionControlName(int _index) + { + String namesuffix = "_" + (_index + 1); + return "lstfunctions" + namesuffix; + } + + private String getFieldsControlName(int _index) + { + String namesuffix = "_" + (_index + 1); + return "lstFieldnames" + namesuffix; + } + + private boolean hasonlycompletefunctions() + { + int maxfieldcount = super.getCurFieldCount(); + if (maxfieldcount > 0) + { + ControlRow curcontrolrow = this.ControlRowVector.get(maxfieldcount - 1); + return curcontrolrow.isComplete(); + } + else + { + return false; + } + } + + private class ControlRow + { + + private XListBox xFieldListBox; + private XListBox xFunctionListBox; + private int index; + + private ControlRow(int _index, int ypos, int _curHelpID) + { + try + { + this.index = _index; + xFunctionListBox = CurUnoDialog.insertListBox(getFunctionControlName(index), 1, null, new ItemListenerImpl(), + new String[] + { + "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, 12, HelpIds.getHelpIdString(_curHelpID++), Integer.valueOf(iCompPosX + 4), Integer.valueOf(ypos), UIConsts.INVISIBLESTEP, sFunctions, Short.valueOf(curtabindex++), 88 + }); + + xFieldListBox = CurUnoDialog.insertListBox(getFieldsControlName(index), 1, null, new ItemListenerImpl(), + new String[] + { + "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, 12, HelpIds.getHelpIdString(_curHelpID++), Integer.valueOf(iCompPosX + 98), Integer.valueOf(ypos), UIConsts.INVISIBLESTEP, Short.valueOf(curtabindex++), 86 + }); + lastHelpIndex = _curHelpID - 1; + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void setVisible(boolean _bvisible) + { + CurUnoDialog.setControlVisible(getFunctionControlName(index), _bvisible); + CurUnoDialog.setControlVisible(getFieldsControlName(index), _bvisible); + } + + private void insertFieldNames() + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xFieldListBox), PropertyNames.STRING_ITEM_LIST, CurDBMetaData.NumericFieldNames); + } + + private boolean isComplete() + { + boolean bfieldnameisselected = (Helper.getUnoArrayPropertyValue(UnoDialog.getModel(xFieldListBox), PropertyNames.SELECTED_ITEMS) != null); + boolean bfunctionisselected = (Helper.getUnoArrayPropertyValue(UnoDialog.getModel(xFunctionListBox), PropertyNames.SELECTED_ITEMS) != null); + return (bfieldnameisselected && bfunctionisselected); + } + + private void settovoid() + { + UnoDialog.deselectListBox(xFieldListBox); + UnoDialog.deselectListBox(xFunctionListBox); + } + + private class ItemListenerImpl implements com.sun.star.awt.XItemListener + { + + public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) + { + try + { + toggleButtons(); + togglefollowingDialogSteps(); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + } + } +} diff --git a/wizards/com/sun/star/wizards/ui/ButtonList.java b/wizards/com/sun/star/wizards/ui/ButtonList.java new file mode 100644 index 0000000000..a129fe97c8 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/ButtonList.java @@ -0,0 +1,627 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import javax.swing.ListModel; +import com.sun.star.awt.ActionEvent; +import com.sun.star.awt.Size; +import com.sun.star.awt.XActionListener; +import com.sun.star.awt.XButton; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XFixedText; +import com.sun.star.awt.XItemEventBroadcaster; +import com.sun.star.awt.XItemListener; +import com.sun.star.awt.XWindow; +import com.sun.star.lang.EventObject; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.HelpIds; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.IRenderer; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.PropertySetHelper; +import com.sun.star.wizards.ui.event.XActionListenerAdapter; + +public class ButtonList implements XItemEventBroadcaster, XActionListener +{ + + private XFixedText lblImageText; + private XButton btnBack; + private XButton btnNext; + private XFixedText lblCounter; + private XControl m_aButtons[]; + private boolean benabled = true; + private UnoDialog2 oUnoDialog; + private Size gap = new Size(4, 4); + private int cols = 4; + private int rows = 3; + private Size m_aButtonSize = new Size(20, 20); + private Size pos; + private boolean showButtons = true; + private Short step; + private static final boolean refreshOverNull = true; + private static final int imageTextLines = 1; + private boolean rowSelect = false; + public int tabIndex; + private String m_aControlName = "il"; + private int m_nCurrentSelection = -1; + private int pageStart = 0; + public int helpURL = 0; + private IRenderer renderer; + private ListModel listModel; + private IRenderer counterRenderer = new SimpleCounterRenderer(); + private static final int LINE_HEIGHT = 8; + + public void setName(String _sName) + { + m_aControlName = _sName; + } + + /** Setter for property m_aButtonSize. + * @param imageSize New value of property m_aButtonSize. + */ + public void setButtonSize(Size imageSize) + { + this.m_aButtonSize = imageSize; + } + + public void disposing(EventObject arg0) + { + } + + public void create(UnoDialog2 dialog) + { + oUnoDialog = dialog; + + int imageTextHeight = imageTextLines * LINE_HEIGHT; + + int nXPos = pos.Width + 1; + int nYPos = pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height; + int nWidth = cols * (m_aButtonSize.Width + gap.Width) + gap.Width - 2; + + lblImageText = dialog.insertLabel(m_aControlName + "_imageText", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Tabstop", + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Integer.valueOf(imageTextHeight), + PropertyNames.EMPTY_STRING, + "(1)", + Integer.valueOf(nXPos), + Integer.valueOf(nYPos), + step, + Short.valueOf((short) 0), + Boolean.FALSE, + Integer.valueOf(nWidth) + }); + + + if (showButtons) + { + final String[] pNames1 = new String[] + { + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Tabstop", + PropertyNames.PROPERTY_WIDTH + }; + + final Integer btnSize = Integer.valueOf(14); + +// TODO: if list of strings not the same length of list object, office will die. + btnBack = dialog.insertButton(m_aControlName + "_btnBack", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + prevPage(); + } + }, pNames1, new Object[] + { + btnSize, + HelpIds.getHelpIdString(helpURL++), + Integer.valueOf(pos.Width), + Integer.valueOf(pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + 1), + step, + Short.valueOf((short) (tabIndex + 1)), + Boolean.TRUE, + btnSize + }); + + btnNext = dialog.insertButton(m_aControlName + "_btnNext", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + nextPage(); + } + }, pNames1, new Object[] + { + btnSize, + HelpIds.getHelpIdString(helpURL++), + Integer.valueOf(pos.Width + (m_aButtonSize.Width + gap.Width) * cols + gap.Width - btnSize.intValue() + 1), + Integer.valueOf(pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + 1), + step, + Short.valueOf((short) (tabIndex + 2)), + Boolean.TRUE, + btnSize + }); + + lblCounter = dialog.insertLabel(m_aControlName + "_lblCounter", pNames1, new Object[] + { + Integer.valueOf(LINE_HEIGHT), + PropertyNames.EMPTY_STRING, + Integer.valueOf(pos.Width + btnSize.intValue() + 1), + Integer.valueOf(pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + ((btnSize.intValue() - LINE_HEIGHT) / 2)), + step, + Short.valueOf((short) 0), + Boolean.FALSE, + Integer.valueOf(cols * (m_aButtonSize.Width + gap.Width) + gap.Width - 2 * btnSize.intValue() - 1) + }); + + Helper.setUnoPropertyValue(getModel(lblCounter), PropertyNames.PROPERTY_ALIGN, Short.valueOf((short) 1)); + Helper.setUnoPropertyValue(getModel(btnBack), PropertyNames.PROPERTY_LABEL, "<"); + Helper.setUnoPropertyValue(getModel(btnNext), PropertyNames.PROPERTY_LABEL, ">"); + + + } + + m_tabIndex = Short.valueOf((short) tabIndex); + + m_aButtons = new XControl[rows * cols]; + + m_aButtonHeight = Integer.valueOf(m_aButtonSize.Height); + m_aButtonWidth = Integer.valueOf(m_aButtonSize.Width); + + for (int r = 0; r < rows; r++) + { + for (int c = 0; c < cols; c++) + { + XButton aButton = createButton(dialog, r, c); + XControl aControl = UnoRuntime.queryInterface(XControl.class, aButton); + m_aButtons[r * cols + c] = aControl; + } + } + refreshImages(); + } + + private Integer m_aButtonHeight; + private Integer m_aButtonWidth; + private Short m_tabIndex; + + private XButton createButton(UnoDialog2 dialog, int _row, int _col) + { + String sButtonName = m_aControlName + "_button" + (_row * cols + _col); + int nButtonX = getButtonPosX(_col); + int nButtonY = getButtonPosY(_row); + XButton aButton = dialog.insertImageButton(sButtonName, this, + new String[] + { + /* PropertyNames.PROPERTY_BORDER, */ + /* "BackgroundColor", */ + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + /* PropertyNames.PROPERTY_LABEL, */ + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + /* "ScaleImage", */ + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Tabstop", + "Toggle", + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + /* Short.valueOf((short) 1), */ /* NO_BORDER, */ + /* BACKGROUND_COLOR, */ + m_aButtonHeight, + HelpIds.getHelpIdString(helpURL++), + /* "Test", */ + Integer.valueOf(nButtonX), + Integer.valueOf(nButtonY), + /* scaleImages, */ + step, + m_tabIndex, + Boolean.TRUE, + Boolean.TRUE, /* Toggle */ + m_aButtonWidth + }); + + XWindow win = UnoRuntime.queryInterface(XWindow.class, aButton); + win.setEnable(true); + win.setVisible(true); + return aButton; + } + + private int getButtonPosX(int _col) + { + return pos.Width + _col * (m_aButtonSize.Width + gap.Width) + gap.Width; + } + + private int getButtonPosY(int _row) + { + return pos.Height + _row * (m_aButtonSize.Height + gap.Height) + gap.Height; + } + + private void refreshImages() + { + if (showButtons) + { + refreshCounterText(); + } + if (refreshOverNull) + { + for (int i = 0; i < m_aButtons.length; i++) + { + setVisible(m_aButtons[i], false); + } + } + for (int i = 0; i < m_aButtons.length; i++) + { + String oResource = getObjectFor(i); + if (oResource == null) + continue; + oUnoDialog.getPeerConfiguration().setImageUrl(m_aButtons[i].getModel(), oResource); + boolean bTabStop = Boolean.TRUE; // focusable ? Boolean.TRUE : Boolean.FALSE; + Helper.setUnoPropertyValue(m_aButtons[i].getModel(), "Tabstop", bTabStop); + if (refreshOverNull) + { + setVisible(m_aButtons[i], true); + } + } + } + + private void refreshCounterText() + { + Helper.setUnoPropertyValue(getModel(lblCounter), PropertyNames.PROPERTY_LABEL, counterRenderer.render(new Counter(pageStart + 1, pageEnd(), listModel.getSize()))); + } + + private int pageEnd() + { + int i = pageStart + cols * rows; + if (i > listModel.getSize() - 1) + { + return listModel.getSize(); + } + else + { + return i; + } + } + + /** Utility field holding list of ItemListeners. */ + private transient java.util.ArrayList<XItemListener> m_aItemListenerList; + private void setVisible(Object control, boolean visible) + { + final XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, control); + xWindow.setVisible(visible); + } + + /** + * @param i + * @return the String in the list model corresponding to the given image url + */ + private String getObjectFor(int i) + { + int ii = getIndexFor(i); + if (listModel.getSize() <= ii) + { + return null; + } + else + { + return (String)listModel.getElementAt(ii); + } + } + + /** + * @param i + * @return the index in the listModel for the given image index. + */ + private int getIndexFor(int i) + { + return pageStart + i; + } + + /** Registers ItemListener to receive events. + * @param listener The listener to register. + */ + public synchronized void addItemListener(XItemListener listener) + { + if (m_aItemListenerList == null) + { + m_aItemListenerList = new java.util.ArrayList<XItemListener>(); + } + m_aItemListenerList.add(listener); + } + + /** Removes ItemListener from the list of listeners. + * @param listener The listener to remove. + */ + public synchronized void removeItemListener(XItemListener listener) + { + if (m_aItemListenerList != null) + { + m_aItemListenerList.remove(listener); + } + } + + /** Notifies all registered listeners about the event. + * + */ + @SuppressWarnings("unchecked") + private void fireItemSelected() + { + java.util.ArrayList<XItemListener> list; + synchronized(this) + { + if (m_aItemListenerList == null) + { + return; + } + list = (java.util.ArrayList<XItemListener>) m_aItemListenerList.clone(); + } + for (int i = 0; i < list.size(); i++) + { + list.get(i).itemStateChanged(null); + } + } + + private ListModel getListModel() + { + return listModel; + } + + public int getSelected() + { + return m_nCurrentSelection; + } + + public void setCols(int i) + { + cols = i; + } + + public void setGap(Size size) + { + gap = size; + } + + public void setListModel(ListModel model) + { + listModel = model; + } + + public void setStep(Short short1) + { + step = short1; + } + + private void setPageStart(int i) + { + if (i == pageStart) + { + return; + } + pageStart = i; + enableButtons(); + refreshImages(); + } + + public void setPos(Size _size) + { + pos = _size; + } + + public void setRenderer(IRenderer _renderer) + { + this.renderer = _renderer; + } + + public void setRows(int i) + { + rows = i; + } + + public void setSelected(int i) + { + if (rowSelect && (i >= 0)) + { + i = (i / cols) * cols; + } + if (m_nCurrentSelection == i) + { + return; + } + m_nCurrentSelection = i; + refreshImageText(); + refreshSelection(); + fireItemSelected(); + } + + /** + * set the text under the button list + */ + private void refreshImageText() + { + String sText; + Object item = m_nCurrentSelection >= 0 ? getListModel().getElementAt(m_nCurrentSelection) : null; + if (item != null) { + sText = PropertyNames.SPACE + renderer.render(item); + } + else { + sText = ""; + } + Helper.setUnoPropertyValue(getModel(lblImageText), PropertyNames.PROPERTY_LABEL, sText); + } + + public void setShowButtons(boolean b) + { + showButtons = b; + } + + private void nextPage() + { + if (pageStart < getListModel().getSize() - rows * cols) + { + setPageStart(pageStart + rows * cols); + } + } + + private void prevPage() + { + if (pageStart == 0) + { + return; + } + int i = pageStart - rows * cols; + if (i < 0) + { + i = 0; + } + setPageStart(i); + } + + private void enableButtons() + { + enable(btnNext, Boolean.valueOf(pageStart + rows * cols < listModel.getSize())); + enable(btnBack, Boolean.valueOf(pageStart > 0)); + } + + private void enable(Object control, Boolean enable) + { + Helper.setUnoPropertyValue(getModel(control), PropertyNames.PROPERTY_ENABLED, enable); + } + + private Object getModel(Object control) + { + return UnoRuntime.queryInterface(XControl.class, control).getModel(); + } + + private static class SimpleCounterRenderer implements IRenderer + { + + public String render(Object counter) + { + return PropertyNames.EMPTY_STRING + ((Counter) counter).start + ".." + ((Counter) counter).end + "/" + ((Counter) counter).max; + } + } + + private static class Counter + { + + private int start, end, max; + + private Counter(int start_, int end_, int max_) + { + start = start_; + end = end_; + max = max_; + } + } + + public boolean isenabled() + { + return benabled; + } + + public void setenabled(boolean b) + { + + for (int i = 0; i < m_aButtons.length; i++) + { + UnoDialog2.setEnabled(m_aButtons[i], b); + } + UnoDialog2.setEnabled(lblImageText, b); + if (showButtons) + { + UnoDialog2.setEnabled(btnBack, b); + UnoDialog2.setEnabled(btnNext, b); + UnoDialog2.setEnabled(lblCounter, b); + } + benabled = b; + } + + /** + * refresh on all buttons, the selected button will get state pressed + */ + private void refreshSelection() + { + // reset all buttons to not set + for (int i = 0; i < m_aButtons.length; i++) + { + if (m_aButtons[i] != null) + { + XControlModel xModel = (XControlModel)UnoDialog2.getModel(m_aButtons[i]); + PropertySetHelper aHelper = new PropertySetHelper(xModel); + if (i == m_nCurrentSelection) + { + final short one = 1; + aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf(one)); + } + else + { + final short zero = 0; + aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf(zero)); + } + } + } + } + + /** + * implementation of XActionListener + * will call if a button from the m_aButtonList is pressed. + */ + public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) + { + XControlModel xModel = (XControlModel)UnoDialog2.getModel(actionEvent.Source); + PropertySetHelper aHelper = new PropertySetHelper(xModel); + + int nState = aHelper.getPropertyValueAsInteger(PropertyNames.PROPERTY_STATE, -1); + if (nState == 0) + { + // this will avoid a wrong state, if already pressed. + aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf((short)1)); + } + + // check which Button is pressed. + String sControlName = aHelper.getPropertyValueAsString(PropertyNames.PROPERTY_NAME, PropertyNames.EMPTY_STRING); + final String sButton = sControlName.substring(7 + m_aControlName.length()); + int nButton = Integer.parseInt(sButton); + + int index = getIndexFor(nButton); + if (index < listModel.getSize()) + { + setSelected(index); + } + + } + + +} diff --git a/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java b/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java new file mode 100644 index 0000000000..8cd37ee0ad --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java @@ -0,0 +1,428 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.db.*; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.sdb.CommandType; +import com.sun.star.uno.AnyConverter; +import com.sun.star.awt.*; +import com.sun.star.beans.PropertyValue; + +import java.text.Collator; +import java.util.Comparator; + +public class CommandFieldSelection extends FieldSelection implements Comparator<String> +{ + + private CommandMetaData CurDBMetaData; + private XListBox xTableListBox; + private XFixedText xlblTable; + private String sTableListBoxName; + private String sQueryPrefix; + private String sTablePrefix; + private short m_iSelPos = -1; + private short iOldSelPos = -1; + private boolean bgetQueries; + private final WizardDialog oWizardDialog; + private Collator aCollator = null; + + private class ItemListenerImpl implements com.sun.star.awt.XItemListener + { + + public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) + { + short[] SelItems = (short[]) CurUnoDialog.getControlProperty(sTableListBoxName, PropertyNames.SELECTED_ITEMS); + if (SelItems.length > 0) + { + iOldSelPos = m_iSelPos; + m_iSelPos = SelItems[0]; + if ((m_iSelPos > -1) && (m_iSelPos != iOldSelPos)) + { + if (!AppendMode) + { + oWizardDialog.enablefromStep(IStep.intValue() + 1, false); + } + fillUpFieldsListbox(); + } + } + } + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + } + + /** + * instantiates a CommandFieldSelection with a preselected command + */ + public CommandFieldSelection(WizardDialog _CurUnoDialog, CommandMetaData _CurDBMetaData, int iStep, int _iHeight, String _reslblFields, String _reslblSelFields, String _reslblTables, boolean _bgetQueries, int _ifirstHID) + { + super(_CurUnoDialog, iStep, 95, 57, 210, _iHeight, _reslblFields, _reslblSelFields, (_ifirstHID + 1), true); + insertControls(_CurDBMetaData, _bgetQueries, _reslblTables); + oWizardDialog = (WizardDialog) CurUnoDialog; + } + + /** + * instantiates a CommandFieldSelection with a preselected command + */ + public CommandFieldSelection(UnoDialog _CurUnoDialog, CommandMetaData _CurDBMetaData, int _iHeight, String _reslblFields, String _reslblSelFields, String _reslblTables, boolean _bgetQueries, int _ifirstHID) + { + super(_CurUnoDialog, 1, 95, 57, 210, _iHeight, _reslblFields, _reslblSelFields, (_ifirstHID + 1), true); + insertControls(_CurDBMetaData, _bgetQueries, _reslblTables); + oWizardDialog = (WizardDialog) CurUnoDialog; + } + + private void insertControls(CommandMetaData _CurDBMetaData, boolean _bgetQueries, String _reslblTables) + { + try + { + this.AppendMode = !_bgetQueries; + this.bgetQueries = _bgetQueries; + this.CurDBMetaData = _CurDBMetaData; + toggleListboxControls(Boolean.FALSE); + String sTableLabelName = "lblTables_" + super.sIncSuffix; + sTableListBoxName = "lstTables_" + super.sIncSuffix; + sTablePrefix = getTablePrefix(); + sQueryPrefix = getQueryPrefix(); + Integer LabelWidth = Integer.valueOf(getListboxWidth().intValue() + 6); + // Label 'Tables or Queries' + xlblTable = CurUnoDialog.insertLabel(sTableLabelName, + new String[] + { + 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 + }, + new Object[] + { + Boolean.FALSE, 8, _reslblTables, 95, 27, IStep, Short.valueOf((short) 3), LabelWidth + }); + // DropDown Listbox TableNames + xTableListBox = CurUnoDialog.insertListBox(sTableListBoxName, 0, null, new ItemListenerImpl(), + new String[] + { + "Dropdown", PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.TRUE, Boolean.FALSE, 12, HelpIds.getHelpIdString(super.FirstHelpIndex - 1), Short.valueOf(UnoDialog.getListBoxLineCount()), 95, 37, IStep, Short.valueOf((short) 4), getListboxWidth() + }); + fillupCommandListBox(); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + /** + * @return Returns the sQueryPrefix. + */ + private String getQueryPrefix() + { + if (sQueryPrefix == null) + { + sQueryPrefix = CurUnoDialog.m_oResource.getResText("RID_QUERY_22"); + } + return sQueryPrefix; + } + + private String getCommandPrefix(int _nCommandType) + { + if (_nCommandType == CommandType.TABLE) + { + return getTablePrefix(); + } + else if (_nCommandType == CommandType.QUERY) + { + return getQueryPrefix(); + } + else + { + return PropertyNames.EMPTY_STRING; + } + } + + /** + * @return Returns the sTablePrefix. + */ + private String getTablePrefix() + { + if (sTablePrefix == null) + { + sTablePrefix = CurUnoDialog.m_oResource.getResText("RID_QUERY_21"); + } + return sTablePrefix; + } + + private short getselectedItemPos() + { + short[] iSelPoses = ((short[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.SELECTED_ITEMS)); + if (iSelPoses.length > 0) + { + return iSelPoses[0]; + } + else + { + String[] sItemList = ((String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.STRING_ITEM_LIST)); + if (sItemList.length > 0) + { + return (short) 0; + } + return (short) -1; + } + } + + private void fillUpFieldsListbox() + { + try + { + boolean binitialize = false; + String curCommandName = PropertyNames.EMPTY_STRING; + //As the peer of the control might not yet exist we have to query the model for the SelectedItems + short iSelPos = getselectedItemPos(); + final String sSelectedTableName = xTableListBox.getItem(iSelPos); + if (!bgetQueries) + { + curCommandName = sSelectedTableName; // sLocList[iSelPos]; + CurDBMetaData.setTableByName(curCommandName); + binitialize = CurDBMetaData.getFieldNamesOfCommand(curCommandName, CommandType.TABLE); + } + else + { + if (sSelectedTableName.startsWith(sTablePrefix)) + { + CurDBMetaData.setCommandType(CommandType.TABLE); + curCommandName = JavaTools.replaceSubString(sSelectedTableName, PropertyNames.EMPTY_STRING, sTablePrefix); + CurDBMetaData.setTableByName(curCommandName); + binitialize = CurDBMetaData.getFieldNamesOfCommand(curCommandName, CommandType.TABLE); + } + else + { + CurDBMetaData.setCommandType(CommandType.QUERY); + curCommandName = JavaTools.replaceSubString(sSelectedTableName, PropertyNames.EMPTY_STRING, sQueryPrefix); + CurDBMetaData.setQueryByName(curCommandName); + binitialize = CurDBMetaData.getFieldNamesOfCommand(curCommandName, CommandType.QUERY); + } + } + if (binitialize) + { + CurDBMetaData.setCommandName(curCommandName); + if (CurDBMetaData.m_aAllFieldNames != null) + { + if (CurDBMetaData.m_aAllFieldNames.length > 0) + { + initialize(CurDBMetaData.m_aAllFieldNames, AppendMode, CurDBMetaData.getMaxColumnsInSelect()); + return; + } + } + } + emptyFieldsListBoxes(); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + /** returns the selected entry index in the commandListbox + * + * @return + * @throws com.sun.star.wizards.common.TerminateWizardException + */ + private short fillupCommandListBox() + { + short[] iSelArray = new short[0]; + boolean bgetFields = false; + String[] ContentList = new String[0]; + if (bgetQueries) + { + ContentList = new String[CurDBMetaData.getTableNames().length + CurDBMetaData.getQueryNames().length]; + System.arraycopy(CurDBMetaData.getQueryNames(), 0, ContentList, CurDBMetaData.getTableNames().length, CurDBMetaData.getQueryNames().length); + ContentList = setPrefixinArray(ContentList, sQueryPrefix, CurDBMetaData.getTableNames().length, CurDBMetaData.getQueryNames().length); + } + else + { + ContentList = new String[CurDBMetaData.getTableNames().length]; + } + System.arraycopy(CurDBMetaData.getTableNames(), 0, ContentList, 0, CurDBMetaData.getTableNames().length); + if (bgetQueries) + { + ContentList = setPrefixinArray(ContentList, sTablePrefix, 0, CurDBMetaData.getTableNames().length); + } + java.util.Arrays.sort(ContentList, this); + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.STRING_ITEM_LIST, ContentList); + short iSelPos = getselectedItemPos(); + if (iSelPos > -1) + { + bgetFields = true; + iSelArray = new short[] + { + iSelPos + }; + } + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.SELECTED_ITEMS, iSelArray); + toggleCommandListBox(true); + if (bgetFields) + { + fillUpFieldsListbox(); + } + return iSelPos; + } + + private Collator getCollator() + { + if (this.aCollator == null) + { + com.sun.star.lang.Locale aOfficeLocale = Configuration.getLocale(this.CurDBMetaData.xMSF); + java.util.Locale aJavaLocale = new java.util.Locale(aOfficeLocale.Language, aOfficeLocale.Country, aOfficeLocale.Variant); + //Get the Collator for US English and set its strength to PRIMARY + this.aCollator = Collator.getInstance(aJavaLocale); + aCollator.setStrength(Collator.TERTIARY); + } + return aCollator; + } + + public int compare(String _oObject1, String _oObject2) + { + return this.getCollator().compare(_oObject1, _oObject2); + } + + private String[] setPrefixinArray(String[] _ContentList, String _sprefix, int _startindex, int _nlen) + { + for (int i = _startindex; i < _startindex + _nlen; i++) + { + _ContentList[i] = _sprefix + _ContentList[i]; + } + return _ContentList; + } + + public void toggleCommandListBox(String[] _NewItems) + { + boolean bdoenable = QueryMetaData.getIncludedCommandNames(_NewItems).length < CurDBMetaData.getMaxTablesInSelect(); + toggleCommandListBox(bdoenable); + } + + private void toggleCommandListBox(boolean _bdoenable) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bdoenable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(xlblTable), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bdoenable)); + } + + public String getSelectedCommandName() + { + String sCommandname = xTableListBox.getSelectedItem(); + if (sCommandname.startsWith(this.sTablePrefix)) + { + return sCommandname.substring(sTablePrefix.length()); + } + else if (sCommandname.startsWith(this.sQueryPrefix)) + { + return sCommandname.substring(sQueryPrefix.length()); + } + else + { + return sCommandname; + } + } + + public int getSelectedCommandType() + { + String sCommandname = xTableListBox.getSelectedItem(); + if (sCommandname.startsWith(this.sTablePrefix)) + { + return CommandType.TABLE; + } + else + { + return CommandType.QUERY; + } + } + + public void preselectCommand(PropertyValue[] _aPropertyValue, boolean _bReadOnly) + { + try + { + if (Properties.hasPropertyValue(_aPropertyValue, PropertyNames.COMMAND_TYPE)) + { + int nCommandType = AnyConverter.toInt(Properties.getPropertyValue(_aPropertyValue, PropertyNames.COMMAND_TYPE)); + String sCommand = AnyConverter.toString(Properties.getPropertyValue(_aPropertyValue, PropertyNames.COMMAND)); + if (sCommand != null) + { + preselectCommand(sCommand, nCommandType, _bReadOnly); + } + } + } + catch (IllegalArgumentException e) + { + e.printStackTrace(); + } + } + + private void preselectCommand(String _selitem, int _nCommandType, boolean _bReadOnly) + { + if (_selitem.length() > 0) + { + String[] sitems = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.STRING_ITEM_LIST); + String sPrefix = getCommandPrefix(_nCommandType); + short iselpos = (short) JavaTools.FieldInList(sitems, sPrefix + _selitem); + if (iselpos > -1) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.SELECTED_ITEMS, new short[] + { + iselpos + }); + } + this.fillUpFieldsListbox(); + } + else + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.SELECTED_ITEMS, new short[] + { + }); + } + if (_bReadOnly) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.READ_ONLY, Boolean.valueOf(_selitem.length() > 0)); + } + } + + public void preselectCommand(String _selitem, boolean _bReadOnly) + { + if (_selitem.length() > 0) + { + String[] sitems = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.STRING_ITEM_LIST); + short iselpos = (short) JavaTools.FieldInList(sitems, getTablePrefix() + _selitem); + if (iselpos > -1) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.SELECTED_ITEMS, new short[] { iselpos }); + } + this.fillUpFieldsListbox(); + } + else + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.SELECTED_ITEMS, new short[] {} ); + this.fillUpFieldsListbox(); + } + if (_bReadOnly) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), PropertyNames.READ_ONLY, Boolean.valueOf(_selitem.length() > 0)); + } + toggleListboxButtons((short)-1,(short)-1); + } +} diff --git a/wizards/com/sun/star/wizards/ui/ControlScroller.java b/wizards/com/sun/star/wizards/ui/ControlScroller.java new file mode 100644 index 0000000000..df5131f7b5 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/ControlScroller.java @@ -0,0 +1,425 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import com.sun.star.beans.*; +import com.sun.star.awt.*; +import com.sun.star.wizards.common.*; + +import java.util.*; + +public abstract class ControlScroller +{ + + protected WizardDialog CurUnoDialog; + protected int ncurfieldcount; + private int nblockincrement; + private int nlineincrement; + private int nscrollvalue = 0; + private int ntotfieldcount; + private XScrollBar xScrollBar; + private ArrayList<PropertyValue[]> scrollfields; + protected int iCompPosX; + protected int iCompPosY; + protected int iCompWidth; + protected int iCompHeight; + protected short curtabindex; + protected Integer IStep; + int iScrollBarWidth = 10; + private int SORELFIRSTPOSY = 3; + protected int curHelpIndex; + private String sIncSuffix; + protected ArrayList<Object> ControlGroupVector = new ArrayList<Object>(); + + private class AdjustmentListenerImpl implements com.sun.star.awt.XAdjustmentListener + { + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + + public void adjustmentValueChanged(AdjustmentEvent AdjustEvent) + { + scrollControls(); + } + } + + /** + * + * @param _CurUnoDialog + * @param _iStep + * @param _iCompPosX + * @param _iCompPosY + * @param _iCompWidth + * @param _nblockincrement + * @param _firsthelpindex + */ + // TODO add parameters for tabindices and helpindex + protected ControlScroller(WizardDialog _CurUnoDialog, int _iStep, int _iCompPosX, int _iCompPosY, int _iCompWidth, int _nblockincrement, int _nlinedistance, int _firsthelpindex) + { + this.nblockincrement = _nblockincrement; + this.CurUnoDialog = _CurUnoDialog; + this.curHelpIndex = _firsthelpindex; + curtabindex = UnoDialog.setInitialTabindex(_iStep); + IStep = Integer.valueOf(_iStep); + this.iCompPosX = _iCompPosX; + this.iCompPosY = _iCompPosY; + this.iCompWidth = _iCompWidth; + this.iCompHeight = 2 * SORELFIRSTPOSY + nblockincrement * _nlinedistance; + int iStartPosY = iCompPosY + SORELFIRSTPOSY; + int ScrollHeight = iCompHeight - 2; + nlineincrement = 1; + sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "TitleScrollBar"); + xScrollBar = CurUnoDialog.insertScrollBar("TitleScrollBar" + sIncSuffix, 0, + new AdjustmentListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_BORDER, PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.ORIENTATION, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Short.valueOf((short) 0), Boolean.TRUE, Integer.valueOf(ScrollHeight), HelpIds.getHelpIdString(curHelpIndex), Integer.valueOf(ScrollBarOrientation.VERTICAL), Integer.valueOf(iCompPosX + iCompWidth - iScrollBarWidth - 1), Integer.valueOf(iCompPosY + 1), IStep, Integer.valueOf(iScrollBarWidth) + }); + scrollfields = new ArrayList<PropertyValue[]>(); + int ypos = iStartPosY + SORELFIRSTPOSY; + for (int i = 0; i < nblockincrement; i++) + { + insertControlGroup(i, ypos); + ypos += _nlinedistance; + } + } + + + + /** + * @param _ntotfieldcount The number of fields that are to be administered by the ControlScroller + */ + protected void initialize(int _ntotfieldcount) + { + try + { + ntotfieldcount = _ntotfieldcount; + setCurFieldCount(); + nscrollvalue = 0; + Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), "ScrollValue", Integer.valueOf(nscrollvalue)); + if (ntotfieldcount > nblockincrement) + { + Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[] + { + PropertyNames.PROPERTY_ENABLED, "BlockIncrement", "LineIncrement", "ScrollValue", "ScrollValueMax" + }, new Object[] + { + Boolean.TRUE, Integer.valueOf(nblockincrement), Integer.valueOf(nlineincrement), Integer.valueOf(nscrollvalue), Integer.valueOf(ntotfieldcount - nblockincrement) + }); + } + else + { + Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[] + { + PropertyNames.PROPERTY_ENABLED, "ScrollValue" + }, new Object[] + { + Boolean.FALSE, Integer.valueOf(nscrollvalue) + }); + } + fillupControls(true); + } + catch (java.lang.Exception ex) + { + ex.printStackTrace(); + } + } + + private void fillupControls(boolean binitialize) + { + for (int a = 0; a < this.nblockincrement; a++) + { + if (a < ncurfieldcount) + { + fillupControls(a); + } + if (binitialize) + { + setControlGroupVisible(a, (a < this.ncurfieldcount)); + } + } + if (binitialize) + { + CurUnoDialog.repaintDialogStep(); + } + } + + private void fillupControls(int guiRow) + { + PropertyValue[] nameProps = scrollfields.get(guiRow); + PropertyValue[] valueProps = scrollfields.get(guiRow + nscrollvalue); + for (int n = 0; n < nameProps.length; n++) + { + if (CurUnoDialog.getDlgNameAccess().hasByName(nameProps[n].Name)) + { + setControlData(nameProps[n].Name, valueProps[n].Value); + } + else + { + throw new IllegalArgumentException("No such control !"); + } + } + } + + private void setScrollValue(int _nscrollvalue) + { + if (_nscrollvalue >= 0) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), "ScrollValue", Integer.valueOf(_nscrollvalue)); + scrollControls(); + } + } + + protected void setScrollValue(int _nscrollvalue, int _ntotfieldcount) + { + setTotalFieldCount(_ntotfieldcount); + setScrollValue(_nscrollvalue); + } + + protected int getTotalFieldCount() + { + return ntotfieldcount; + } + + protected int getCurFieldCount() + { + return ncurfieldcount; + } + + private void setCurFieldCount() + { + if (ntotfieldcount > nblockincrement) + { + ncurfieldcount = nblockincrement; + } + else + { + ncurfieldcount = ntotfieldcount; + } + } + + protected void setTotalFieldCount(int _ntotfieldcount) + { + this.ntotfieldcount = _ntotfieldcount; + setCurFieldCount(); + if (ntotfieldcount > nblockincrement) + { + Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[] + { + PropertyNames.PROPERTY_ENABLED, "ScrollValueMax" + }, new Object[] + { + Boolean.TRUE, Integer.valueOf(ntotfieldcount - nblockincrement) + }); + } + else + { + Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + } + } + + protected void toggleComponent(boolean _bdoenable) + { + boolean bdoenable = _bdoenable && (ntotfieldcount > nblockincrement); + CurUnoDialog.setControlProperty("TitleScrollBar" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoenable)); + } + + protected void toggleControls(boolean _bdoenable) + { + for (int n = 0; n < scrollfields.size(); n++) + { + PropertyValue[] curproperties = scrollfields.get(n); + for (int m = 0; m < curproperties.length; m++) + { + PropertyValue curproperty = curproperties[m]; + CurUnoDialog.setControlProperty(curproperty.Name, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bdoenable)); + } + } + + } + + protected int getScrollValue() + { + return nscrollvalue; + } + + + + + + + + protected int getBlockIncrementation() + { + return nblockincrement; + } + + private void scrollControls() + { + try + { + scrollRowsInfo(); + nscrollvalue = ((Integer) Helper.getUnoPropertyValue(UnoDialog.getModel(xScrollBar), "ScrollValue")).intValue(); + if (nscrollvalue + nblockincrement >= ntotfieldcount) + { + nscrollvalue = (ntotfieldcount) - nblockincrement; + } + fillupControls(false); + } + catch (java.lang.Exception ex) + { + ex.printStackTrace(); + } + } + + private void scrollRowsInfo() + { + int cols = + scrollfields.size() > 0 + ? scrollfields.get(0).length + : 0; + for (int a = 0; a < ncurfieldcount; a++) + { + for (int n = 0; n < cols; n++) + { + fieldInfo(a, n); + } + } + } + + /** + * 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. + */ + private PropertyValue fieldInfo(int guiRow, int column) + { + if (guiRow + nscrollvalue < scrollfields.size()) + { + return fieldInfo( + scrollfields.get(guiRow + nscrollvalue)[column], + scrollfields.get(guiRow)[column]); + } + else + { + return null; + } + } + + private PropertyValue fieldInfo(PropertyValue valueProp, PropertyValue nameProp) + { + if (CurUnoDialog.getDlgNameAccess().hasByName(nameProp.Name)) + { + valueProp.Value = getControlData(nameProp.Name); + } + else + { + valueProp.Value = nameProp.Value; + } + return valueProp; + } + + protected void unregisterControlGroup(int _index) + { + scrollfields.remove(_index); + } + + protected void registerControlGroup(PropertyValue[] _currowproperties, int _i) + { + if (_i == 0) + { + scrollfields.clear(); + } + if (_i >= scrollfields.size()) + { + scrollfields.add(_currowproperties); + } + else + { + scrollfields.set(_i, _currowproperties); + } + } + + + + private void setControlData(String controlname, Object newvalue) + { + Object oControlModel = UnoDialog.getModel(CurUnoDialog.xDlgContainer.getControl(controlname)); + String propertyname = UnoDialog.getDisplayProperty(oControlModel); + if (!propertyname.equals(PropertyNames.EMPTY_STRING)) + { + CurUnoDialog.setControlProperty(controlname, propertyname, newvalue); + } + } + + private Object getControlData(String controlname) + { + Object oControlModel = UnoDialog.getModel(CurUnoDialog.xDlgContainer.getControl(controlname)); + String propertyname = UnoDialog.getDisplayProperty(oControlModel); + if (!propertyname.equals(PropertyNames.EMPTY_STRING)) + { + return CurUnoDialog.getControlProperty(controlname, propertyname); + } + else + { + return null; + } + } + + protected PropertyValue[][] getScrollFieldValues() + { + scrollRowsInfo(); + PropertyValue[] curproperties; + PropertyValue[][] retproperties; + retproperties = new PropertyValue[scrollfields.size()][]; + try + { + for (int i = 0; i < scrollfields.size(); i++) + { + curproperties = scrollfields.get(i); + retproperties[i] = curproperties; + } + return retproperties; + } + catch (java.lang.Exception ex) + { + ex.printStackTrace(System.err); + return null; + } + } + + protected abstract void initializeScrollFields(); + + /** inserts a group of controls into the component. The group may either be a row or a column of controls + * The controls should be put on Step 99 (means made invisible at first). All the controlrows that are needed are than + * made visible automatically when calling "initialize(_fieldcount)" + * @param _index The index of the control group + * @param npos Can be an x coordinate or an y coordinate which depends on the orientation of the scrollbar + */ + protected abstract void insertControlGroup(int _index, int npos); + + protected abstract void setControlGroupVisible(int _index, boolean _bIsVisible); +} diff --git a/wizards/com/sun/star/wizards/ui/ControlScroller.py b/wizards/com/sun/star/wizards/ui/ControlScroller.py new file mode 100644 index 0000000000..02eb86500a --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/ControlScroller.py @@ -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 diff --git a/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java b/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java new file mode 100644 index 0000000000..f7c8e942e1 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java @@ -0,0 +1,120 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import com.sun.star.awt.XListBox; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; + +/** + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public abstract class DBLimitedFieldSelection +{ + + protected WizardDialog CurUnoDialog; + private String sNoField; + protected Integer IStep; + protected static final int rowcount = 4; + private static final int MAXSELINDEX = rowcount - 1; + protected short curtabindex; + protected int iCurPosY; + protected int FirstHelpIndex; + + public DBLimitedFieldSelection(WizardDialog _CurUnoDialog, int iStep, int iCompPosY, int _FirstHelpIndex) + { + this.CurUnoDialog = _CurUnoDialog; + FirstHelpIndex = _FirstHelpIndex; + curtabindex = (short) (iStep * 100); + sNoField = CurUnoDialog.m_oResource.getResText("RID_REPORT_8"); + IStep = Integer.valueOf(iStep); + iCurPosY = iCompPosY; + for (int i = 0; i < rowcount; i++) + { + insertControlGroup(i); + } + } + + protected abstract void insertControlGroup(int index); + + protected abstract void toggleControlRow(int CurIndex, boolean bDoEnable); + + protected abstract void enableNextControlRow(int CurIndex); + + protected abstract void updateFromNextControlRow(int CurIndex); + + + protected abstract int getMaxSelIndex(); + + protected void moveupSelectedItems(int CurIndex, boolean bDoEnable) + { + if ((!bDoEnable) && (MAXSELINDEX > CurIndex)) + { + for (int i = CurIndex; i < MAXSELINDEX; i++) + { + updateFromNextControlRow(i); + } + if (getMaxSelIndex() < rowcount - 2) + { + toggleControlRow(getMaxSelIndex() + 2, false); + } + } + else + { + toggleControlRow(CurIndex + 1, bDoEnable); + } + } + + protected String[] addNoneFieldItemToList(String[] _FieldNames) + { + int FieldCount = _FieldNames.length; + String[] ViewFieldNames = new String[FieldCount + 1]; + ViewFieldNames[0] = sNoField; + System.arraycopy(_FieldNames, 0, ViewFieldNames, 1, FieldCount); + return ViewFieldNames; + } + + protected void initializeListBox(XListBox xListBox, String[] _AllFieldNames, String[] _SelFieldNames, int curindex) + { + short[] SelList = null; + Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), PropertyNames.STRING_ITEM_LIST, _AllFieldNames); + if (_SelFieldNames != null && curindex < _SelFieldNames.length) + { + int index = JavaTools.FieldInList(_AllFieldNames, _SelFieldNames[curindex]); + if (index > -1) + { + SelList = new short[] { (short) (index) }; + } + else + { + SelList = new short[] { (short) (0) }; + } + Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), PropertyNames.SELECTED_ITEMS, SelList); + return; + } + SelList = new short[] { (short) (0) }; + Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), PropertyNames.SELECTED_ITEMS, SelList); + + } + + +} + + diff --git a/wizards/com/sun/star/wizards/ui/DocumentPreview.py b/wizards/com/sun/star/wizards/ui/DocumentPreview.py new file mode 100644 index 0000000000..280fac6dff --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/DocumentPreview.py @@ -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() diff --git a/wizards/com/sun/star/wizards/ui/FieldSelection.java b/wizards/com/sun/star/wizards/ui/FieldSelection.java new file mode 100644 index 0000000000..2c192ca6f4 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/FieldSelection.java @@ -0,0 +1,640 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import com.sun.star.awt.FontDescriptor; +import com.sun.star.awt.XListBox; +import com.sun.star.wizards.common.*; + +import java.util.*; + +public class FieldSelection +{ + public XListBox xFieldsListBox; // Left ListBox + public XListBox xSelectedFieldsListBox; // right (selected) ListBox + + protected UnoDialog CurUnoDialog; + protected String sIncSuffix; + protected int FirstHelpIndex; + protected boolean AppendMode = false; + protected Integer IStep; + + private int CompPosY; + private int CompHeight; + + private XFieldSelectionListener xFieldSelection; + private int maxfieldcount = 10000000; + private String[] AllFieldNames; + private Integer ListBoxWidth; + + private boolean bisModified = false; + + private static final int SOCMDMOVESEL = 1; + private static final int SOCMDMOVEALL = 2; + private static final int SOCMDREMOVESEL = 3; + private static final int SOCMDREMOVEALL = 4; + private static final int SOCMDMOVEUP = 5; + private static final int SOCMDMOVEDOWN = 6; + private static final int SOFLDSLST = 7; + private static final int SOSELFLDSLST = 8; + + + private class ItemListenerImpl implements com.sun.star.awt.XItemListener + { + + public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) + { + com.sun.star.wizards.common.Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); + switch (iKey) + { + case SOFLDSLST: + case SOSELFLDSLST: + toggleListboxButtons((short) - 1, (short) - 1); + break; + + default: + break; + } + com.sun.star.wizards.common.Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + } + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + } + + private class ActionListenerImpl implements com.sun.star.awt.XActionListener + { + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + + public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) + { + try + { + int iKey = CurUnoDialog.getControlKey(actionEvent.Source, CurUnoDialog.ControlList); + switch (iKey) + { + case SOCMDMOVESEL: + case SOFLDSLST: + selectFields(false); + break; + + case SOCMDMOVEALL: + selectFields(true); + break; + + case SOCMDREMOVESEL: + case SOSELFLDSLST: + deselectFields(false); + break; + + case SOCMDREMOVEALL: + deselectFields(true); + break; + + case SOCMDMOVEUP: + changeSelectionOrder(-1); + break; + + case SOCMDMOVEDOWN: + changeSelectionOrder(1); + break; + + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + } + + public void addFieldSelectionListener(XFieldSelectionListener xFieldSelection) + { + this.xFieldSelection = xFieldSelection; + this.xFieldSelection.setID(sIncSuffix); + } + + public void setAppendMode(boolean _AppendMode) + { + AppendMode = _AppendMode; + } + + public FieldSelection(UnoDialog CurUnoDialog, int _iStep, int CompPosX, int CompPosY, int CompWidth, int CompHeight, String slblFields, String slblSelFields, int _FirstHelpIndex, boolean bshowFourButtons) + { + try + { + final String AccessTextMoveSelected = CurUnoDialog.m_oResource.getResText("RID_DB_COMMON_39"); + final String AccessTextRemoveSelected = CurUnoDialog.m_oResource.getResText("RID_DB_COMMON_40"); + final String AccessTextMoveAll = CurUnoDialog.m_oResource.getResText("RID_DB_COMMON_41"); + final String AccessTextRemoveAll = CurUnoDialog.m_oResource.getResText("RID_DB_COMMON_42"); + final String AccessMoveFieldUp = CurUnoDialog.m_oResource.getResText("RID_DB_COMMON_43"); + final String AccessMoveFieldDown = CurUnoDialog.m_oResource.getResText("RID_DB_COMMON_44"); + + FirstHelpIndex = _FirstHelpIndex; + short curtabindex = UnoDialog.setInitialTabindex(_iStep); + int ShiftButtonCount = 2; + int a = 0; + this.CurUnoDialog = CurUnoDialog; + this.CompPosY = CompPosY; + this.CompHeight = CompHeight; + Object btnmoveall = null; + Object btnremoveall = null; + + final int cmdButtonWidth = 16; + final int cmdButtonHoriDist = 4; + final int lblHeight = 8; + final int lblVertiDist = 2; + + ListBoxWidth = Integer.valueOf(((CompWidth - 3 * cmdButtonHoriDist - 2 * cmdButtonWidth) / 2)); + Integer cmdShiftButtonPosX = Integer.valueOf((CompPosX + ListBoxWidth.intValue() + cmdButtonHoriDist)); + Integer ListBoxPosY = Integer.valueOf(CompPosY + lblVertiDist + lblHeight); + Integer ListBoxHeight = Integer.valueOf(CompHeight - 8 - 2); + Integer SelListBoxPosX = Integer.valueOf(cmdShiftButtonPosX.intValue() + cmdButtonWidth + cmdButtonHoriDist); + + IStep = Integer.valueOf(_iStep); + if (bshowFourButtons) + { + ShiftButtonCount = 4; + } + Integer[] ShiftButtonPosY = getYButtonPositions(ShiftButtonCount); + Integer[] MoveButtonPosY = getYButtonPositions(2); + Integer cmdMoveButtonPosX = Integer.valueOf(SelListBoxPosX.intValue() + ListBoxWidth.intValue() + cmdButtonHoriDist); + + Integer CmdButtonWidth = Integer.valueOf(cmdButtonWidth); + + sIncSuffix = "_" + com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "lblFields_"); + + // Label + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblFields" + sIncSuffix, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblFields, Integer.valueOf(CompPosX), Integer.valueOf(CompPosY), IStep, Short.valueOf(curtabindex), 109 + }); + + // Listbox 'Available fields' + xFieldsListBox = CurUnoDialog.insertListBox("lstFields" + sIncSuffix, SOFLDSLST, new ActionListenerImpl(), new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "MultiSelection", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + ListBoxHeight, HelpIds.getHelpIdString(_FirstHelpIndex), Boolean.TRUE, Integer.valueOf(CompPosX), ListBoxPosY, IStep, Short.valueOf((curtabindex++)), ListBoxWidth + }); + + Object btnmoveselected = CurUnoDialog.insertButton("cmdMoveSelected" + sIncSuffix, SOCMDMOVESEL, new ActionListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + Boolean.FALSE, 14, HelpIds.getHelpIdString(_FirstHelpIndex + 1), ">", cmdShiftButtonPosX, ShiftButtonPosY[a++], IStep, Short.valueOf(curtabindex++), CmdButtonWidth + }); + + if (bshowFourButtons) + { + btnmoveall = CurUnoDialog.insertButton("cmdMoveAll" + sIncSuffix, SOCMDMOVEALL, new ActionListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + 14, HelpIds.getHelpIdString(_FirstHelpIndex + 2), ">>", cmdShiftButtonPosX, ShiftButtonPosY[a++], IStep, Short.valueOf(curtabindex++), CmdButtonWidth + }); + } + Object btnremoveselected = CurUnoDialog.insertButton("cmdRemoveSelected" + sIncSuffix, SOCMDREMOVESEL, new ActionListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + Boolean.FALSE, 14, HelpIds.getHelpIdString(_FirstHelpIndex + 3), "<", cmdShiftButtonPosX, ShiftButtonPosY[a++], IStep, Short.valueOf(curtabindex++), CmdButtonWidth + }); + + if (bshowFourButtons) + { + btnremoveall = CurUnoDialog.insertButton("cmdRemoveAll" + sIncSuffix, SOCMDREMOVEALL, new ActionListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + 14, HelpIds.getHelpIdString(_FirstHelpIndex + 4), "<<", cmdShiftButtonPosX, ShiftButtonPosY[a++], IStep, Short.valueOf(curtabindex++), CmdButtonWidth + }); + } + + FontDescriptor oFontDesc = new FontDescriptor(); + oFontDesc.Name = "StarSymbol"; + + // Label 'Fields in the form' + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblSelFields" + sIncSuffix, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblSelFields, SelListBoxPosX, Integer.valueOf(CompPosY), IStep, Short.valueOf(curtabindex++), ListBoxWidth + }); + + // ListBox 'Fields in the form' + xSelectedFieldsListBox = CurUnoDialog.insertListBox("lstSelFields" + sIncSuffix, SOSELFLDSLST, new ActionListenerImpl(), new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "MultiSelection", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + ListBoxHeight, HelpIds.getHelpIdString(_FirstHelpIndex + 5), Boolean.TRUE, SelListBoxPosX, ListBoxPosY, IStep, Short.valueOf(curtabindex++), ListBoxWidth + }); + + Object btnmoveup = CurUnoDialog.insertButton("cmdMoveUp" + sIncSuffix, SOCMDMOVEUP, new ActionListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + Boolean.FALSE, oFontDesc, 14, HelpIds.getHelpIdString(_FirstHelpIndex + 6), String.valueOf((char) 8743), cmdMoveButtonPosX, MoveButtonPosY[0], IStep, Short.valueOf(curtabindex++), CmdButtonWidth + }); + + Object btnmovedown = CurUnoDialog.insertButton("cmdMoveDown" + sIncSuffix, SOCMDMOVEDOWN, new ActionListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + Boolean.FALSE, oFontDesc, 14, HelpIds.getHelpIdString(_FirstHelpIndex + 7), String.valueOf((char) 8744), cmdMoveButtonPosX, MoveButtonPosY[1], IStep, Short.valueOf(curtabindex++), CmdButtonWidth + }); + + CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmoveselected, AccessTextMoveSelected); + CurUnoDialog.getPeerConfiguration().setAccessibleName(btnremoveselected, AccessTextRemoveSelected); + CurUnoDialog.getPeerConfiguration().setAccessibleName(xFieldsListBox, JavaTools.replaceSubString(slblFields, PropertyNames.EMPTY_STRING, "~")); + CurUnoDialog.getPeerConfiguration().setAccessibleName(xSelectedFieldsListBox, JavaTools.replaceSubString(slblSelFields, PropertyNames.EMPTY_STRING, "~")); + if (btnmoveall != null) + { + CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmoveall, AccessTextMoveAll); + } + if (btnremoveall != null) + { + CurUnoDialog.getPeerConfiguration().setAccessibleName(btnremoveall, AccessTextRemoveAll); + } + if (btnmoveup != null) + { + CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmoveup, AccessMoveFieldUp); + } + if (btnmovedown != null) + { + CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmovedown, AccessMoveFieldDown); + } + + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + // TODO: If Value is getting smaller than zero -> throw exception + private Integer[] getYButtonPositions(int ButtonCount) + { + Integer[] YPosArray; + if (ButtonCount > 0) + { + YPosArray = new Integer[ButtonCount]; + final int cmdButtonHeight = 14; + final int cmdButtonVertiDist = 2; + + YPosArray[0] = Integer.valueOf( (CompPosY + 10 + (((CompHeight - 10) - (ButtonCount * cmdButtonHeight) - ((ButtonCount - 1) * cmdButtonVertiDist)) / 2))); + if (ButtonCount > 1) + { + for (int i = 1; i < ButtonCount; i++) + { + YPosArray[i] = Integer.valueOf(YPosArray[i - 1].intValue() + cmdButtonHeight + cmdButtonVertiDist); + } + } + return YPosArray; + } + return null; + } + + public Integer getListboxWidth() + { + return this.ListBoxWidth; + } + + private void changeSelectionOrder(int iNeighbor) + { + short[] iSelIndices = xSelectedFieldsListBox.getSelectedItemsPos(); + // TODO: we are assuming that the array starts with the lowest index. Verify this assumption!!!!! + if (iSelIndices.length == 1) + { + short iSelIndex = iSelIndices[0]; + String[] NewItemList = xSelectedFieldsListBox.getItems(); + String CurItem = NewItemList[iSelIndex]; + String NeighborItem = NewItemList[iSelIndex + iNeighbor]; + NewItemList[iSelIndex + iNeighbor] = CurItem; + NewItemList[iSelIndex] = NeighborItem; + CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, PropertyNames.STRING_ITEM_LIST, NewItemList); + xSelectedFieldsListBox.selectItem(CurItem, true); + if (xFieldSelection != null) + { + if (iNeighbor < 0) + { + xFieldSelection.moveItemUp(CurItem); + } + else + { + xFieldSelection.moveItemDown(CurItem); + } + } + } + } + + public void toggleListboxControls(Boolean BDoEnable) + { + try + { + CurUnoDialog.setControlProperty("lblFields" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, BDoEnable); + CurUnoDialog.setControlProperty("lblSelFields" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, BDoEnable); + CurUnoDialog.setControlProperty("lstFields" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, BDoEnable); + CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, BDoEnable); + + if (BDoEnable.booleanValue()) + { + toggleListboxButtons((short) - 1, (short) - 1); + } + else + { + CurUnoDialog.setControlProperty("cmdRemoveAll" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, BDoEnable); + CurUnoDialog.setControlProperty("cmdRemoveSelected" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, BDoEnable); + toggleMoveButtons(BDoEnable.booleanValue(), BDoEnable.booleanValue()); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + // Enable or disable the buttons used for moving the available + // fields between the two list boxes. + protected void toggleListboxButtons(short iFieldsSelIndex, short iSelFieldsSelIndex) + { + try + { + boolean bmoveUpenabled = false; + boolean bmoveDownenabled = false; + CurUnoDialog.selectListBoxItem(xFieldsListBox, iFieldsSelIndex); + CurUnoDialog.selectListBoxItem(xSelectedFieldsListBox, iSelFieldsSelIndex); + int SelListBoxSelLength = xSelectedFieldsListBox.getSelectedItems().length; + int ListBoxSelLength = xFieldsListBox.getSelectedItems().length; + boolean bIsFieldSelected = (ListBoxSelLength > 0); + int FieldCount = xFieldsListBox.getItemCount(); + boolean bSelectSelected = (SelListBoxSelLength > 0); + int SelectCount = xSelectedFieldsListBox.getItemCount(); + if (bSelectSelected) + { + short[] iSelIndices = xSelectedFieldsListBox.getSelectedItemsPos(); + bmoveUpenabled = ((iSelIndices[0] > 0) && (iSelIndices.length == 1)); + bmoveDownenabled = (((iSelIndices[SelListBoxSelLength - 1]) < (short) (SelectCount - 1)) && (iSelIndices.length == 1)); + } + CurUnoDialog.setControlProperty("cmdRemoveAll" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(SelectCount >= 1)); + CurUnoDialog.setControlProperty("cmdRemoveSelected" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bSelectSelected)); + toggleMoveButtons((FieldCount >= 1), bIsFieldSelected); + CurUnoDialog.setControlProperty("cmdMoveUp" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bmoveUpenabled)); + CurUnoDialog.setControlProperty("cmdMoveDown" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bmoveDownenabled)); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + protected void toggleMoveButtons(boolean _btoggleMoveAll, boolean _btoggleMoveSelected) + { + boolean btoggleMoveAll = (((xFieldsListBox.getItemCount() + xSelectedFieldsListBox.getItemCount()) < maxfieldcount) && (_btoggleMoveAll)); + boolean btoggleMoveSelected = (((xFieldsListBox.getSelectedItems().length + xSelectedFieldsListBox.getItemCount()) < maxfieldcount) && (_btoggleMoveSelected)); + CurUnoDialog.setControlProperty("cmdMoveAll" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(btoggleMoveAll)); + CurUnoDialog.setControlProperty("cmdMoveSelected" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(btoggleMoveSelected)); + } + + public void setMultipleMode(boolean _bisMultiple) + { + xFieldsListBox.setMultipleMode(_bisMultiple); + xSelectedFieldsListBox.setMultipleMode(_bisMultiple); + } + + public void emptyFieldsListBoxes() + { + try + { + toggleListboxControls(Boolean.FALSE); + CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, PropertyNames.STRING_ITEM_LIST, new String[] + { + }); + CurUnoDialog.setControlProperty("lstFields" + sIncSuffix, PropertyNames.STRING_ITEM_LIST, new String[] + { + }); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + + + public void initializeSelectedFields(String[] _SelectedFieldNames) + { + xSelectedFieldsListBox.addItems(_SelectedFieldNames, xSelectedFieldsListBox.getItemCount()); + } + + private void removeAllItems(XListBox _xListBox) + { + _xListBox.removeItems((short) 0, _xListBox.getItemCount()); + } + + // Note Boolean Parameter + public void initialize(String[] _AllFieldNames, boolean _AppendMode) + { + AppendMode = _AppendMode; + removeAllItems(xFieldsListBox); + xFieldsListBox.addItems(_AllFieldNames, (short) 0); + AllFieldNames = xFieldsListBox.getItems(); + if ((xSelectedFieldsListBox.getItemCount() > 0) && (!AppendMode)) + { + removeAllItems(xSelectedFieldsListBox); + } + toggleListboxControls(Boolean.TRUE); + } + + + + public void initialize(String[] _AllFieldNames, boolean _AppendMode, int _maxfieldcount) + { + maxfieldcount = _maxfieldcount; + initialize(_AllFieldNames, _AppendMode); + } + + public void initialize(String[] _AllFieldNames, String[] _SelFieldNames, boolean _AppendMode) + { + removeAllItems(xSelectedFieldsListBox); + xSelectedFieldsListBox.addItems(_SelFieldNames, (short) 0); + initialize(_AllFieldNames, _AppendMode); + } + + public void selectFields(boolean bMoveAll) + { + short iFieldSelected = (short) - 1; + short iSelFieldSelected = (short) - 1; + String[] SelFieldItems; + if (bMoveAll) + { + SelFieldItems = xFieldsListBox.getItems(); + removeAllItems(xFieldsListBox); + if (!AppendMode) + { + removeAllItems(xSelectedFieldsListBox); + xSelectedFieldsListBox.addItems(AllFieldNames, (short) 0); + } + else + { + xSelectedFieldsListBox.addItems(SelFieldItems, xSelectedFieldsListBox.getItemCount()); + } + } + else + { + SelFieldItems = xFieldsListBox.getSelectedItems(); + int MaxSourceSelected = SelFieldItems.length; + if (MaxSourceSelected > 0) + { + iFieldSelected = xFieldsListBox.getSelectedItemPos(); + iSelFieldSelected = xSelectedFieldsListBox.getSelectedItemPos(); + xSelectedFieldsListBox.addItems(SelFieldItems, xSelectedFieldsListBox.getItemCount()); + CurUnoDialog.removeSelectedItems(xFieldsListBox); + xSelectedFieldsListBox.selectItemPos((short) 0, xSelectedFieldsListBox.getSelectedItems().length > 0); + } + } + toggleListboxButtons(iFieldSelected, iSelFieldSelected); + if (xFieldSelection != null) + { + xFieldSelection.shiftFromLeftToRight(SelFieldItems, xSelectedFieldsListBox.getItems()); + } + } + + private void deselectFields(boolean bMoveAll) + { + String SearchString; + short iOldFieldSelected = xFieldsListBox.getSelectedItemPos(); + short iOldSelFieldSelected = xSelectedFieldsListBox.getSelectedItemPos(); + String[] OldSelFieldItems = xSelectedFieldsListBox.getSelectedItems(); + if (bMoveAll) + { + OldSelFieldItems = xSelectedFieldsListBox.getItems(); + removeAllItems(xFieldsListBox); + xFieldsListBox.addItems(AllFieldNames, (short) 0); + removeAllItems(xSelectedFieldsListBox); + } + else + { + int MaxOriginalCount = AllFieldNames.length; + String[] SelList = xFieldsListBox.getItems(); + ArrayList<String> NewSourceVector = new ArrayList<String>(); + for (int i = 0; i < MaxOriginalCount; i++) + { + SearchString = AllFieldNames[i]; + if (JavaTools.FieldInList(SelList, SearchString) != -1) + { + NewSourceVector.add(SearchString); + } + else if (JavaTools.FieldInList(OldSelFieldItems, SearchString) != -1) + { + NewSourceVector.add(SearchString); + } + } + xFieldsListBox.removeItems((short) 0, xFieldsListBox.getItemCount()); + if (NewSourceVector.size() > 0) + { + String[] NewSourceList = new String[NewSourceVector.size()]; + NewSourceVector.toArray(NewSourceList); + xFieldsListBox.addItems(NewSourceList, (short) 0); + } + CurUnoDialog.removeSelectedItems(xSelectedFieldsListBox); + } + toggleListboxButtons(iOldFieldSelected, iOldSelFieldSelected); + String[] NewSelFieldItems = xSelectedFieldsListBox.getItems(); + if (xFieldSelection != null) + { + xFieldSelection.shiftFromRightToLeft(OldSelFieldItems, NewSelFieldItems); + } + } + + public void addItemsToFieldsListbox(String[] _sItems) + { + String[] sOldList = xFieldsListBox.getItems(); + for (int i = 0; i < _sItems.length; i++) + { + if (JavaTools.FieldInList(sOldList, _sItems[i]) < 0) + { + xFieldsListBox.addItem(_sItems[i], xFieldsListBox.getItemCount()); + } + } + } + + public String[] getSelectedFieldNames() + { + return (String[]) CurUnoDialog.getControlProperty("lstSelFields" + sIncSuffix, PropertyNames.STRING_ITEM_LIST); + } + + public void setSelectedFieldNames(String[] _sfieldnames) + { + CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, PropertyNames.STRING_ITEM_LIST, _sfieldnames); + String[] sleftboxfieldnames = JavaTools.removefromList(xFieldsListBox.getItems(), _sfieldnames); + CurUnoDialog.setControlProperty("lstFields" + sIncSuffix, PropertyNames.STRING_ITEM_LIST, sleftboxfieldnames); + } + + public void setModified(boolean _bModified) + { + bisModified = _bModified; + } + + public boolean isModified() + { + return bisModified; + } + + public void changeSelectedFieldNames(String[] _sfieldnames) + { + CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, PropertyNames.STRING_ITEM_LIST, _sfieldnames); + } +} diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java new file mode 100644 index 0000000000..f70714a319 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java @@ -0,0 +1,938 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertyContainer; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.sdb.SQLFilterOperator; +import com.sun.star.sdbc.DataType; +import com.sun.star.uno.Any; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.TypeClass; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.wizards.common.NumberFormatter; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.HelpIds; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.FieldColumn; +import com.sun.star.wizards.db.QueryMetaData; +import com.sun.star.wizards.db.SQLQueryComposer; + +import java.util.logging.Level; +import java.util.logging.Logger; + +public class FilterComponent +{ + + private final Integer IStep; + private final int RowCount; + private static String[] sLogicOperators; + private final XRadioButton optMatchAny; + private final String slblFieldNames; + private final String slblOperators; + private final String slblValue; + private WizardDialog CurUnoDialog; + private final String sIncSuffix; + private final ControlRow[] oControlRows; + private final String sDuplicateCondition; + private static final int SOOPTORMODE = 100; + private static final int SOOPTANDMODE = 101; + private QueryMetaData oQueryMetaData; + private int iDateFormat; + private int iTimeFormat; + private PropertyValue[][] filterconditions; + private short curtabindex; + private static final int SO_FIRSTFIELDNAME = 1; + private static final int SO_SECONDFIELDNAME = 2; + private static final int SO_THIRDFIELDNAME = 3; + private static final int SO_FOURTHFIELDNAME = 4; + private int[] SO_FIELDNAMELIST = new int[] + { + SO_FIRSTFIELDNAME, SO_SECONDFIELDNAME, SO_THIRDFIELDNAME, SO_FOURTHFIELDNAME + }; + private static final int SO_FIRSTCONDITION = 5; + private static final int SO_SECONDCONDITION = 6; + private static final int SO_THIRDCONDITION = 7; + private static final int SO_FOURTHCONDITION = 8; + private int[] SO_CONDITIONLIST = new int[] + { + SO_FIRSTCONDITION, SO_SECONDCONDITION, SO_THIRDCONDITION, SO_FOURTHCONDITION + }; + private static final int SO_FIRSTTEXTFIELD = 1; + private static final int SO_SECONDTEXTFIELD = 2; + private static final int SO_THIRDTEXTFIELD = 3; + private static final int SO_FOURTHTEXTFIELD = 4; + private int[] SO_TEXTFIELDLIST = new int[] + { + SO_FIRSTTEXTFIELD, SO_SECONDTEXTFIELD, SO_THIRDTEXTFIELD, SO_FOURTHTEXTFIELD + }; + private static final int SO_FIRSTBOOLFIELDNAME = 256 + 1; + private static final int SO_SECONDBOOLFIELDNAME = 256 + 2; + private static final int SO_THIRDBOOLFIELDNAME = 256 + 3; + private static final int SO_FOURTHBOOLFIELDNAME = 256 + 4; + private int SOI_MATCHALL = 0; + private int SOI_MATCHANY = 1; + + class ItemListenerImpl implements com.sun.star.awt.XItemListener + { + + public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) + { + if (EventObject == null) { + return; + } + + int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); + String sControlName = PropertyNames.EMPTY_STRING; + switch (iKey) + { + case SO_FIRSTFIELDNAME: + case SO_SECONDFIELDNAME: + case SO_THIRDFIELDNAME: + case SO_FOURTHFIELDNAME: + sControlName = getControlName(EventObject.Source); + String sControlNameSuffix = sIncSuffix + "_" + getIndexNumber(sControlName); + XListBox xCurFieldListBox = UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(sControlName)); + String CurDisplayFieldName = xCurFieldListBox.getSelectedItem(); + FieldColumn CurFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(CurDisplayFieldName); + + String sControlNameTextValue = "txtValue" + sControlNameSuffix; + XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue); + XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl); + Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", Boolean.valueOf(CurFieldColumn.isNumberFormat())); + final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter(); + aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.getDBFormatKey(), aNumberFormatter); + + break; + + case SO_FIRSTCONDITION: + case SO_SECONDCONDITION: + case SO_THIRDCONDITION: + case SO_FOURTHCONDITION: + case SO_FIRSTBOOLFIELDNAME: + case SO_SECONDBOOLFIELDNAME: + case SO_THIRDBOOLFIELDNAME: + case SO_FOURTHBOOLFIELDNAME: + sControlName = getControlName(EventObject.Source); + break; + + case SOOPTORMODE: + case SOOPTANDMODE: + return; + + default: + break; + } + togglefollowingControlRow(sControlName); + } + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + } + + class TextListenerImpl implements com.sun.star.awt.XTextListener + { + + public void textChanged(TextEvent EventObject) + { + String sName = getControlName(EventObject.Source); + togglefollowingControlRow(sName); + } + + public void disposing(EventObject eventObject) + { + } + + + } + + private static String getIndexNumber(String _sStr) + { + return _sStr.substring(_sStr.length() - 1, _sStr.length()); + } + + /** + * Enable the next ControlRow if the Condition is complete in the current line + * + * @param _scurName every control name ends with something like _1, _2, _3 this is the index number + * we try to interpret to check which line we currently use. (number - 1) + */ + private void togglefollowingControlRow(String _scurName) + { + int Index = Integer.parseInt(getIndexNumber(_scurName)); + if (Index < oControlRows.length) + { + boolean bValue = oControlRows[Index - 1].isConditionComplete(); + oControlRows[Index].setEnabled(bValue); + } + } + + private String getControlName(Object _oSourceevent) + { + try + { + XControl xControl = UnoRuntime.queryInterface(XControl.class, _oSourceevent); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel()); + return AnyConverter.toString(xPSet.getPropertyValue(PropertyNames.PROPERTY_NAME)); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return PropertyNames.EMPTY_STRING; + } + + public PropertyValue[][] getFilterConditions() + { + int nFilterCount = getFilterCount(); + if (nFilterCount > 0) + { + final SQLQueryComposer composer = oQueryMetaData.getSQLQueryComposer(); + try + { + final String serviceName = "com.sun.star.beans.PropertyBag"; + final XPropertyContainer column = UnoRuntime.queryInterface(XPropertyContainer.class, oQueryMetaData.xMSF.createInstance(serviceName)); + + column.addProperty("Type", PropertyAttribute.BOUND, DataType.VARCHAR); + column.addProperty(PropertyNames.PROPERTY_NAME, PropertyAttribute.BOUND, PropertyNames.EMPTY_STRING); + column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), null); + final XPropertySet columnSet = UnoRuntime.queryInterface(XPropertySet.class, column); + + if (composer.getQuery().length() == 0) + { + StringBuilder sql = new StringBuilder(); + sql.append(composer.getSelectClause(true)); + sql.append(' '); + sql.append(composer.getFromClause()); + composer.getQueryComposer().setElementaryQuery(sql.toString()); + } + composer.getQueryComposer().setStructuredFilter(new PropertyValue[][] + { + }); + for (int i = 0; i < RowCount; i++) + { + ControlRow currentControlRow = oControlRows[i]; + if (currentControlRow.isEnabled() && currentControlRow.isConditionComplete()) + { + String sFieldName = currentControlRow.getSelectedFieldName(); + int nOperator = currentControlRow.getSelectedOperator(); + FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName); + columnSet.setPropertyValue(PropertyNames.PROPERTY_NAME, aFieldColumn.getFieldName()); + columnSet.setPropertyValue("Type", aFieldColumn.getXColumnPropertySet().getPropertyValue("Type")); + Object value = currentControlRow.getValue(); + switch (aFieldColumn.getFieldType()) + { + case DataType.TIMESTAMP: + case DataType.DATE: + value = ((Double) value) - oQueryMetaData.getNullDateCorrection(); + break; + // TODO: TIME case? + } + column.removeProperty("Value"); + final short operator = currentControlRow.getSelectedOperator(); + if ((operator == SQLFilterOperator.SQLNULL) + || (operator == SQLFilterOperator.NOT_SQLNULL) + || AnyConverter.isVoid(value)) + { + column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), ""); + value = new Any(new Type(TypeClass.VOID), null); + } + else + { + column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), value); + } + columnSet.setPropertyValue("Value", value); + composer.getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL, nOperator); + } + } + filterconditions = composer.getQueryComposer().getStructuredFilter(); + int[] iduplicate = JavaTools.getDuplicateFieldIndex(filterconditions); + if (iduplicate[0] != -1) + { + PropertyValue aduplicatecondition = filterconditions[iduplicate[0]][iduplicate[1]]; + String smsgDuplicateCondition = getDisplayCondition(sDuplicateCondition, aduplicatecondition, null); + CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, smsgDuplicateCondition); + CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", Integer.valueOf(1), Integer.valueOf(2))); + return new PropertyValue[][] + { + }; + } + } + catch (Exception ex) + { + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); + } + } + else + { + filterconditions = new PropertyValue[0][0]; + } + return filterconditions; + } + + public static String getDisplayCondition(String _BaseString, PropertyValue _filtercondition, QueryMetaData _CurDBMetaData) + { + try + { + String FieldName; + if (_CurDBMetaData != null) + { + FieldColumn CurDBFieldColumn = _CurDBMetaData.getFieldColumnByFieldName(_filtercondition.Name); + FieldName = CurDBFieldColumn.getFieldTitle(); + } + else + { + FieldName = _filtercondition.Name; + } + String sreturn = JavaTools.replaceSubString(_BaseString, FieldName, "<FIELDNAME>"); + String soperator = sLogicOperators[_filtercondition.Handle - 1]; + sreturn = JavaTools.replaceSubString(sreturn, soperator, "<LOGICOPERATOR>"); + String sDisplayValue = PropertyNames.EMPTY_STRING; + if ((_filtercondition.Handle != SQLFilterOperator.SQLNULL) + && (_filtercondition.Handle != SQLFilterOperator.NOT_SQLNULL) + && !AnyConverter.isVoid(_filtercondition.Value)) + { + sDisplayValue = AnyConverter.toString(_filtercondition.Value); + } + sreturn = JavaTools.replaceSubString(sreturn, sDisplayValue, "<VALUE>"); + return sreturn; + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + } + return PropertyNames.EMPTY_STRING; + } + + private int getfilterstate() + { + boolean bisany = true; + int ifilterstate = SOI_MATCHALL; + bisany = this.optMatchAny.getState(); + if (bisany) + { + ifilterstate = SOI_MATCHANY; + } + else + { + ifilterstate = SOI_MATCHALL; + } + return ifilterstate; + } + + private int getFilterCount() + { + int a = 0; + for (int i = 0; i < RowCount; i++) + { + if (oControlRows[i].isEnabled() && oControlRows[i].isConditionComplete()) + { + a++; + } + } + return a; + } + + /** Creates a new instance of FilterComponent + */ + public FilterComponent(WizardDialog CurUnoDialog, int iStep, int iPosX, int iPosY, int FilterCount, QueryMetaData _oQueryMetaData, int _firstHelpID) + { + int curHelpID = _firstHelpID; + this.IStep = Integer.valueOf(iStep); + + curtabindex = UnoDialog.setInitialTabindex(iStep); + this.CurUnoDialog = CurUnoDialog; + this.RowCount = FilterCount; + this.oQueryMetaData = _oQueryMetaData; + boolean bEnabled; + sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "optMatchAll"); + + String soptMatchAll = CurUnoDialog.m_oResource.getResText("RID_QUERY_9"); + String soptMatchAny = CurUnoDialog.m_oResource.getResText("RID_QUERY_10"); + slblFieldNames = CurUnoDialog.m_oResource.getResText("RID_QUERY_17"); + slblOperators = CurUnoDialog.m_oResource.getResText("RID_QUERY_24"); + slblValue = CurUnoDialog.m_oResource.getResText("RID_QUERY_25"); + sLogicOperators = new String[10]; // =, <>, <, >, <=, >=, like, !like, is null, !is null + sLogicOperators[0] = CurUnoDialog.m_oResource.getResText("RID_QUERY_26"); + sLogicOperators[1] = CurUnoDialog.m_oResource.getResText("RID_QUERY_27"); + sLogicOperators[2] = CurUnoDialog.m_oResource.getResText("RID_QUERY_28"); + sLogicOperators[3] = CurUnoDialog.m_oResource.getResText("RID_QUERY_29"); + sLogicOperators[4] = CurUnoDialog.m_oResource.getResText("RID_QUERY_30"); + sLogicOperators[5] = CurUnoDialog.m_oResource.getResText("RID_QUERY_31"); + sLogicOperators[6] = CurUnoDialog.m_oResource.getResText("RID_QUERY_32"); + sLogicOperators[7] = CurUnoDialog.m_oResource.getResText("RID_QUERY_33"); + sLogicOperators[8] = CurUnoDialog.m_oResource.getResText("RID_QUERY_34"); + sLogicOperators[9] = CurUnoDialog.m_oResource.getResText("RID_QUERY_35"); + sDuplicateCondition = CurUnoDialog.m_oResource.getResText("RID_QUERY_89"); + + // create Radiobuttons + // * match all + // * match one + CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + Integer.valueOf(9), + HelpIds.getHelpIdString(curHelpID++), + soptMatchAll, + Integer.valueOf(iPosX), + Integer.valueOf(iPosY), + Short.valueOf((short) 1), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(203) + }); + optMatchAny = CurUnoDialog.insertRadioButton("optMatchAny" + sIncSuffix, SOOPTORMODE, new ItemListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + Integer.valueOf(9), + HelpIds.getHelpIdString(curHelpID++), + soptMatchAny, + Integer.valueOf(iPosX), + Integer.valueOf(iPosY + 12), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(203) + }); + getfilterstate(); + + oControlRows = new ControlRow[FilterCount]; + for (int i = 0; i < FilterCount; i++) + { + bEnabled = (i == 0); + oControlRows[i] = new ControlRow(iPosX, iPosY + 20, i, bEnabled, (curHelpID + (i * 3))); + iPosY += 43; + } + } + + public void initialize(PropertyValue[][] _filterconditions, String[] _fieldnames) + { + int i; + for (i = 0; i < RowCount; i++) + { + oControlRows[i].setFieldNames(_fieldnames); + // oControlRows[i].setFieldNames(aFieldNamesWithAdditionalEmpty); + } + this.filterconditions = _filterconditions; + PropertyValue[] curfilterconditions; + // int a; + if (_filterconditions.length == 1) + { + curfilterconditions = filterconditions[0]; + for (i = 0; i < curfilterconditions.length; i++) + { + oControlRows[i].setCondition(filterconditions[0][i]); + } + } + else + { + for (i = 0; i < filterconditions.length; i++) + { + oControlRows[i].setCondition(filterconditions[i][0]); + } + } + while (i < oControlRows.length) + { + oControlRows[i].settovoid(); + boolean bdoenable; + if (i > 0) + { + bdoenable = oControlRows[i - 1].isConditionComplete(); + } + else + { + bdoenable = true; + } + oControlRows[i].setEnabled(bdoenable); + i++; + } + } + + public void addNumberFormats() + { + iDateFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD"); + iTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("HH:MM:SS"); + oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD HH:MM:SS"); + } + + + + + + private final class ControlRow + { + + private static final int SOLSTFIELDNAME = 3; + private static final int SOLSTOPERATOR = 4; + private static final int SOTXTVALUE = 5; + private XInterface[] ControlElements = new XInterface[6]; + private boolean m_bEnabled; + private String[] FieldNames; + + private ControlRow(int iCompPosX, int iCompPosY, int Index, boolean _bEnabled, int _firstRowHelpID) + { + int nFieldWidth = 71; + int nOperatorWidth = 70; + int nValueWidth = 44; + + int nPosX1 = iCompPosX + 10; + int nPosX2 = iCompPosX + 10 + nFieldWidth + 6; // 87 + int nPosX3 = iCompPosX + 10 + nFieldWidth + 6 + nOperatorWidth + 6; + + + try + { + String sCompSuffix = sIncSuffix + "_" + (Index + 1); + m_bEnabled = _bEnabled; + + // Label Field + ControlElements[0] = CurUnoDialog.insertLabel("lblFieldNames" + sCompSuffix, + new String[] + { + 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 + }, + new Object[] + { + Boolean.valueOf(isEnabled()), + Integer.valueOf(9), + slblFieldNames, + Integer.valueOf(nPosX1), + Integer.valueOf(iCompPosY + 13), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(nFieldWidth) + }); + + // Label Operator + ControlElements[1] = CurUnoDialog.insertLabel("lblOperators" + sCompSuffix, + new String[] + { + 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 + }, + new Object[] + { + Boolean.valueOf(isEnabled()), + Integer.valueOf(9), + slblOperators, + Integer.valueOf(nPosX2), + Integer.valueOf(iCompPosY + 13), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(nOperatorWidth) + }); + + // Label Value + ControlElements[2] = CurUnoDialog.insertLabel("lblValue" + sCompSuffix, + new String[] + { + 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 + }, + new Object[] + { + Boolean.valueOf(isEnabled()), + Integer.valueOf(9), + slblValue, + Integer.valueOf(nPosX3), + Integer.valueOf(iCompPosY + 13), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(nValueWidth) + }); + + // Listbox Fields + ControlElements[SOLSTFIELDNAME] = CurUnoDialog.insertListBox("lstFieldName" + sCompSuffix, SO_FIELDNAMELIST[Index], null, new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_ENABLED, + "Dropdown", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + "LineCount", + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.valueOf(isEnabled()), + Boolean.TRUE, + Integer.valueOf(13), + HelpIds.getHelpIdString(_firstRowHelpID++), + Short.valueOf(UnoDialog.getListBoxLineCount() /* 7 */), + Integer.valueOf(nPosX1), + Integer.valueOf(iCompPosY + 23), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(nFieldWidth) + }); + + // Listbox Operators + ControlElements[SOLSTOPERATOR] = CurUnoDialog.insertListBox("lstOperator" + sCompSuffix, SO_CONDITIONLIST[Index], null, new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_ENABLED, + "Dropdown", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + "LineCount", + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.STRING_ITEM_LIST, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.valueOf(isEnabled()), + Boolean.TRUE, + Integer.valueOf(13), + HelpIds.getHelpIdString(_firstRowHelpID++), + Short.valueOf((short) sLogicOperators.length /* 7 */), + Integer.valueOf(nPosX2), + Integer.valueOf(iCompPosY + 23), + IStep, + sLogicOperators, + Short.valueOf(curtabindex++), + Integer.valueOf(nOperatorWidth) + }); + ControlElements[SOTXTVALUE] = CurUnoDialog.insertFormattedField("txtValue" + sCompSuffix, SO_TEXTFIELDLIST[Index], new TextListenerImpl(), + new String[] + { + 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 + }, + new Object[] + { + Boolean.valueOf(isEnabled()), + Integer.valueOf(13), + HelpIds.getHelpIdString(_firstRowHelpID++), + Integer.valueOf(nPosX3), + Integer.valueOf(iCompPosY + 23), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(nValueWidth) + }); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + /** + * @return true if the current condition is complete, all needed fields are filled with values. + * So we can enable the next. + */ + private boolean isConditionComplete() + { + try + { + short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTFIELDNAME]), PropertyNames.SELECTED_ITEMS)); + if (SelFields.length > 0) + { + int nSelOperator = getSelectedOperator(); + // short[] SelOperator = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), PropertyNames.SELECTED_ITEMS)); + if (nSelOperator == com.sun.star.sdb.SQLFilterOperator.SQLNULL + || /* is null */ nSelOperator == com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL) /* is not null */ + + { + // disable value field + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + + return true; + } + else + { + // enable value field + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + } + if (nSelOperator != -1) + { + Object oValue = Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue"); + if (!AnyConverter.isVoid(oValue)) + { + String sValue = String.valueOf(oValue); + return !sValue.equals(PropertyNames.EMPTY_STRING); + } + } + } + return false; + } + catch (IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + return false; + } + } + + private void setCondition(PropertyValue _filtercondition) + { + try + { + XListBox xFieldsListBox = UnoRuntime.queryInterface(XListBox.class, ControlElements[SOLSTFIELDNAME]); + xFieldsListBox.selectItem(_filtercondition.Name, true); + XListBox xOperatorListBox = UnoRuntime.queryInterface(XListBox.class, ControlElements[SOLSTOPERATOR]); + xOperatorListBox.selectItemPos((short) (_filtercondition.Handle - 1), true); + + if (AnyConverter.isString(_filtercondition.Value)) + { + String sValue = AnyConverter.toString(_filtercondition.Value); + if (sValue.indexOf("{D '") > -1) + { + // TODO: this seems to never happen? + sValue = JavaTools.replaceSubString(sValue, PropertyNames.EMPTY_STRING, "{D '"); + sValue = JavaTools.replaceSubString(sValue, PropertyNames.EMPTY_STRING, "' }"); + try + { + //Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", ); + oQueryMetaData.getNumberFormatter().convertStringToNumber(iDateFormat, sValue); + } + catch (java.lang.Exception ex) + { + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); + } + } + else if (sValue.indexOf("{T '") > -1) + { + // TODO: this seems to never happen? + sValue = JavaTools.replaceSubString(sValue, PropertyNames.EMPTY_STRING, "{T '"); + sValue = JavaTools.replaceSubString(sValue, PropertyNames.EMPTY_STRING, "' }"); + try + { + //Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", ); + oQueryMetaData.getNumberFormatter().convertStringToNumber(iTimeFormat, sValue); + } + catch (java.lang.Exception ex) + { + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); + } + } + // TODO: TS case? + //TODO: other datetime formats? + else + { + //Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", sValue); + } + } + else if (AnyConverter.isBoolean(_filtercondition.Value)) + { + boolean b = AnyConverter.toBoolean(_filtercondition.Value); + double nValue = 0.0; + if (b) + { + nValue = 1.0; + } + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", nValue); + } + else + { + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", _filtercondition.Value); + } + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + } + } + + private void setFieldNames(String[] _FieldNames) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTFIELDNAME]), PropertyNames.STRING_ITEM_LIST, _FieldNames); + FieldNames = _FieldNames; + } + + private boolean isEnabled() + { + return m_bEnabled; + } + + private void settovoid() + { + WizardDialog.deselectListBox(ControlElements[SOLSTFIELDNAME]); + WizardDialog.deselectListBox(ControlElements[SOLSTOPERATOR]); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", com.sun.star.uno.Any.VOID); + } + + private void setEnabled(boolean _bEnabled) + { + // enable all Controls Fieldname, operator, value + for (int i = 0; i < ControlElements.length; i++) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[i]), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bEnabled)); + } + m_bEnabled = _bEnabled; + if (isEnabled()) + { + short[] iselected = new short[] + { + }; + try + { + iselected = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), PropertyNames.SELECTED_ITEMS)); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + } + if ((iselected.length) == 0) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), PropertyNames.SELECTED_ITEMS, new short[] + { + 0 + }); + } + } + else if (!isConditionComplete()) + { + WizardDialog.deselectListBox(ControlElements[SOLSTOPERATOR]); + } + } + + private String getSelectedFieldName() + { + try + { + short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTFIELDNAME]), PropertyNames.SELECTED_ITEMS)); + return FieldNames[SelFields[0]]; + } + catch (IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + } + return null; + } + + // TODO: check if it is really useful to match the indices of the listbox the API constants + // =, <>, <, >, <=, >=, like, !like, is null, !is null + private short getSelectedOperator() + { + try + { + short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), PropertyNames.SELECTED_ITEMS)); + switch (SelFields[0]) + { + case 0: + return com.sun.star.sdb.SQLFilterOperator.EQUAL; + case 1: + return com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL; + case 2: + return com.sun.star.sdb.SQLFilterOperator.LESS; + case 3: + return com.sun.star.sdb.SQLFilterOperator.GREATER; + case 4: + return com.sun.star.sdb.SQLFilterOperator.LESS_EQUAL; + case 5: + return com.sun.star.sdb.SQLFilterOperator.GREATER_EQUAL; + case 6: + return com.sun.star.sdb.SQLFilterOperator.LIKE; + case 7: + return com.sun.star.sdb.SQLFilterOperator.NOT_LIKE; + case 8: + return com.sun.star.sdb.SQLFilterOperator.SQLNULL; + case 9: + return com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL; + default: + return -1; + } + } + catch (IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + } + return -1; + } + + // TODO make a difference between Text and Numbers + private Object getValue() + { + return Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue"); + } + + + + + } +} diff --git a/wizards/com/sun/star/wizards/ui/PathSelection.py b/wizards/com/sun/star/wizards/ui/PathSelection.py new file mode 100644 index 0000000000..1467085f9b --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/PathSelection.py @@ -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() diff --git a/wizards/com/sun/star/wizards/ui/PeerConfig.java b/wizards/com/sun/star/wizards/ui/PeerConfig.java new file mode 100644 index 0000000000..8f0e2680a8 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/PeerConfig.java @@ -0,0 +1,151 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import java.util.ArrayList; + +import com.sun.star.awt.WindowEvent; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XVclWindowPeer; +import com.sun.star.awt.XWindowListener; +import com.sun.star.lang.EventObject; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; + +public class PeerConfig implements XWindowListener +{ + + private final ArrayList<PeerTask> m_aPeerTasks = new ArrayList<PeerTask>(); + private ArrayList<ImageUrlTask> aImageUrlTasks = new ArrayList<ImageUrlTask>(); + private UnoDialog oUnoDialog = null; + + public PeerConfig(UnoDialog _oUnoDialog) + { + oUnoDialog = _oUnoDialog; + oUnoDialog.xWindow.addWindowListener(this); + } + + private static class PeerTask + { + + private XControl xControl; + private String[] propnames; + private Object[] propvalues; + + public PeerTask(XControl _xControl, String[] propNames_, Object[] propValues_) + { + propnames = propNames_; + propvalues = propValues_; + xControl = _xControl; + } + } + + private static class ImageUrlTask + { + Object oModel; + String oResource; + + public ImageUrlTask(Object _oModel, String _oResource) + { + oResource = _oResource; + oModel = _oModel; + } + } + + public void windowResized(WindowEvent arg0) + { + } + + public void windowMoved(WindowEvent arg0) + { + } + + public void windowShown(EventObject arg0) + { + try + { + for (int i = 0; i < this.m_aPeerTasks.size(); i++) + { + PeerTask aPeerTask = m_aPeerTasks.get(i); + XVclWindowPeer xVclWindowPeer = UnoRuntime.queryInterface(XVclWindowPeer.class, aPeerTask.xControl.getPeer()); + for (int n = 0; n < aPeerTask.propnames.length; n++) + { + xVclWindowPeer.setProperty(aPeerTask.propnames[n], aPeerTask.propvalues[n]); + } + } + for (int i = 0; i < this.aImageUrlTasks.size(); i++) + { + ImageUrlTask aImageUrlTask = aImageUrlTasks.get(i); + String sImageUrl = aImageUrlTask.oResource; + if (!sImageUrl.equals(PropertyNames.EMPTY_STRING)) + { + Helper.setUnoPropertyValue(aImageUrlTask.oModel, PropertyNames.PROPERTY_IMAGEURL, sImageUrl); + } + } + + } + catch (RuntimeException re) + { + re.printStackTrace(System.err); + throw re; + } + } + + public void windowHidden(EventObject arg0) + { + } + + public void disposing(EventObject arg0) + { + } + + /** + * @param oAPIControl an API control that the interface XControl can be derived from + */ + public void setAccessibleName(Object oAPIControl, String _saccessname) + { + XControl xControl = UnoRuntime.queryInterface(XControl.class, oAPIControl); + setPeerProperties(xControl, new String[] + { + "AccessibleName" + }, new String[] + { + _saccessname + }); + } + + + + private void setPeerProperties(XControl _xControl, String[] propnames, Object[] propvalues) + { + PeerTask oPeerTask = new PeerTask(_xControl, propnames, propvalues); + this.m_aPeerTasks.add(oPeerTask); + } + + /** + * Assigns an image to the property 'ImageUrl' of a dialog control. The image ids that the Resource urls point to + * may be assigned in a Resource file outside the wizards project + */ + public void setImageUrl(Object _ocontrolmodel, String _sResourceUrl) + { + ImageUrlTask oImageUrlTask = new ImageUrlTask(_ocontrolmodel, _sResourceUrl); + this.aImageUrlTasks.add(oImageUrlTask); + } +} diff --git a/wizards/com/sun/star/wizards/ui/PeerConfig.py b/wizards/com/sun/star/wizards/ui/PeerConfig.py new file mode 100644 index 0000000000..1383b283a6 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/PeerConfig.py @@ -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() diff --git a/wizards/com/sun/star/wizards/ui/SortingComponent.java b/wizards/com/sun/star/wizards/ui/SortingComponent.java new file mode 100644 index 0000000000..a08729fd9a --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/SortingComponent.java @@ -0,0 +1,336 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import java.beans.PropertyChangeEvent; + +import com.sun.star.wizards.common.*; +import com.sun.star.awt.*; + +import java.util.ArrayList; + +public class SortingComponent +{ + + private WizardDialog CurUnoDialog; + private int MaxSortIndex = -1; + private static String sNoSorting; + private static String sSortCriteriaisduplicate; + private static String[] sSortHeader = new String[4]; + private static String[] sSortAscend = new String[4]; + private static String[] sSortDescend = new String[4]; + private int MAXSORTCRITERIAINDEX = 3; + private static final int SOFIRSTSORTLST = 0; + private static final int SOSECSORTLST = 1; + private static final int SOTHIRDSORTLST = 2; + private static final int SOFOURTHSORTLST = 3; + private static final int[] SOSORTLST = new int[] + { + SOFIRSTSORTLST, SOSECSORTLST, SOTHIRDSORTLST, SOFOURTHSORTLST + }; + private XListBox[] xSortListBox = new XListBox[4]; + + class ItemListenerImpl implements com.sun.star.awt.XItemListener + { + + public void itemStateChanged(ItemEvent EventObject) + { + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + int ikey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); + enableNextSortListBox(ikey); + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + } + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + } + + public SortingComponent(WizardDialog CurUnoDialog, int iStep, int iCompPosX, int iCompPosY, int iCompWidth, int FirstHelpIndex) + { + try + { + this.CurUnoDialog = CurUnoDialog; + short curtabindex = UnoDialog.setInitialTabindex(iStep); + Integer IStep = Integer.valueOf(iStep); + Integer ICompPosX = Integer.valueOf(iCompPosX); + Integer ICompWidth = Integer.valueOf(iCompWidth); + + Integer IListBoxPosX = Integer.valueOf(iCompPosX + 6); + int iOptButtonWidth = 65; + Integer IOptButtonWidth = Integer.valueOf(iOptButtonWidth); + Integer IListBoxWidth = Integer.valueOf(iCompWidth - iOptButtonWidth - 12); + Integer IOptButtonPosX = Integer.valueOf(IListBoxPosX.intValue() + IListBoxWidth.intValue() + 6); + getResources(); + boolean bDoEnable; + String HIDString; + int iCurPosY = iCompPosY; + for (int i = 0; i < 4; i++) + { + bDoEnable = (i < 2); + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "lblSort" + Integer.toString(i + 1), new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.ORIENTATION, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, new Object[] + { + Boolean.valueOf(bDoEnable), 8, sSortHeader[i], 0, ICompPosX, Integer.valueOf(iCurPosY), IStep, Short.valueOf(curtabindex++), ICompWidth + }); + + HIDString = HelpIds.getHelpIdString(FirstHelpIndex); + xSortListBox[i] = CurUnoDialog.insertListBox("lstSort" + Integer.toString(i + 1), SOSORTLST[i], null, new ItemListenerImpl(), new String[] + { + "Dropdown", PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_NAME, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, new Object[] + { + true, bDoEnable, 12, HIDString, Short.valueOf(UnoDialog.getListBoxLineCount()), "lstSort" + Integer.valueOf(i + 1), IListBoxPosX, Integer.valueOf(iCurPosY + 14), IStep, Short.valueOf(curtabindex++), IListBoxWidth + }); //Short.valueOf((short) (17+i*4)) + + HIDString = HelpIds.getHelpIdString(FirstHelpIndex + 1); + CurUnoDialog.insertRadioButton("optAscend" + Integer.toString(i + 1), 0, new String[] + { + PropertyNames.PROPERTY_ENABLED, 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, "Tag", PropertyNames.PROPERTY_WIDTH + }, new Object[] + { + bDoEnable, 10, HIDString, sSortAscend[i], IOptButtonPosX, Integer.valueOf(iCurPosY + 10), Short.valueOf((short) 1), IStep, Short.valueOf(curtabindex++), PropertyNames.ASC, IOptButtonWidth + }); //, Short.valueOf((short) (18+i*4)) + + HIDString = HelpIds.getHelpIdString(FirstHelpIndex + 2); + CurUnoDialog.insertRadioButton("optDescend" + Integer.toString(i + 1), 0, new String[] + { + PropertyNames.PROPERTY_ENABLED, 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, "Tag", PropertyNames.PROPERTY_WIDTH + }, new Object[] + { + bDoEnable, 10, HIDString, sSortDescend[i], IOptButtonPosX, Integer.valueOf(iCurPosY + 24), Short.valueOf((short) 0), IStep, Short.valueOf(curtabindex++), "DESC", IOptButtonWidth + }); //, Short.valueOf((short) (19+i*4)) + iCurPosY = iCurPosY + 36; + FirstHelpIndex += 3; + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private boolean getResources() + { + sSortHeader[0] = CurUnoDialog.m_oResource.getResText("RID_REPORT_20"); + sSortHeader[1] = CurUnoDialog.m_oResource.getResText("RID_REPORT_21"); + sSortHeader[2] = CurUnoDialog.m_oResource.getResText("RID_REPORT_51"); + sSortHeader[3] = CurUnoDialog.m_oResource.getResText("RID_REPORT_52"); + sSortAscend[0] = CurUnoDialog.m_oResource.getResText("RID_REPORT_36"); + sSortAscend[1] = CurUnoDialog.m_oResource.getResText("RID_REPORT_53"); + sSortAscend[2] = CurUnoDialog.m_oResource.getResText("RID_REPORT_54"); + sSortAscend[3] = CurUnoDialog.m_oResource.getResText("RID_REPORT_55"); + sSortDescend[0] = CurUnoDialog.m_oResource.getResText("RID_REPORT_37"); + sSortDescend[1] = CurUnoDialog.m_oResource.getResText("RID_REPORT_56"); + sSortDescend[2] = CurUnoDialog.m_oResource.getResText("RID_REPORT_57"); + sSortDescend[3] = CurUnoDialog.m_oResource.getResText("RID_REPORT_58"); + sSortCriteriaisduplicate = CurUnoDialog.m_oResource.getResText("RID_REPORT_74"); + sNoSorting = CurUnoDialog.m_oResource.getResText("RID_REPORT_8"); + return true; + } + + public void initialize(String[] _FieldNames, String[][] _SortFieldNames) + { + int FieldCount = _FieldNames.length; + String[] ViewFieldNames = new String[FieldCount + 1]; + ViewFieldNames[0] = sNoSorting; + System.arraycopy(_FieldNames, 0, ViewFieldNames, 1, FieldCount); + short[] SelList = null; + for (int i = 0; i < 4; i++) + { + if (i < _SortFieldNames.length) + { + SelList = new short[] + { + (short) (JavaTools.FieldInList(_FieldNames, _SortFieldNames[i][0]) + 1) + }; + } + else + { + SelList = new short[] + { + (short) 0 + }; + } + CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 1), PropertyNames.STRING_ITEM_LIST, ViewFieldNames); + CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 1), PropertyNames.SELECTED_ITEMS, SelList); + toggleSortListBox(i, (i <= _SortFieldNames.length)); + } + } + + private void setMaxSortIndex() + { + MaxSortIndex = -1; + for (int i = 0; i <= MAXSORTCRITERIAINDEX; i++) + { + if (xSortListBox[i].getSelectedItemPos() > 0) + { + MaxSortIndex += 1; + } + } + } + + /** + * sets the controls of a Sorting criterion to readonly or not. + * @param _index index of the Sorting criterion + */ + private void setReadOnly(int _index, boolean _breadonly) + { + CurUnoDialog.setControlProperty("lstSort" + Integer.toString(_index + 1), PropertyNames.READ_ONLY, Boolean.valueOf(_breadonly)); + } + + /** + * + * @param _index the first Sorting criterion in which 'ReadOnly is set to 'false' + */ + public void setReadOnlyUntil(int _index) + { + for (int i = 0; i <= 4; i++) + { + boolean breadonly = i < _index; + setReadOnly(i, breadonly); + } + } + + private void enableNextSortListBox(int CurIndex) + { + try + { + setMaxSortIndex(); + boolean bDoEnable = (xSortListBox[CurIndex].getSelectedItemPos() != 0); + if (!bDoEnable) + { + moveupSortItems(CurIndex, bDoEnable); //disableListBoxesfromIndex(CurIndex); + } + else + { + toggleSortListBox(CurIndex + 1, true); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public String[][] getSortFieldNames() + { + try + { + short iCurState; + String CurFieldName; + setMaxSortIndex(); + ArrayList<String[]> SortFieldNames = new ArrayList<String[]>(); + ArrayList<String> SortDescriptions = new ArrayList<String>(); + for (int i = 0; i <= MaxSortIndex; i++) + { + CurFieldName = xSortListBox[i].getSelectedItem(); + SortDescriptions.add(CurFieldName); + iCurState = ((Short) CurUnoDialog.getControlProperty("optAscend" + Integer.toString(i + 1), PropertyNames.PROPERTY_STATE)).shortValue(); + SortFieldNames.add(new String[]{CurFieldName,iCurState == 1 ? PropertyNames.ASC :"DESC" }); + } + // When searching for a duplicate entry we can neglect whether the entries are to be sorted ascending or descending + // TODO for the future we should deliver a messagebox when two different sorting modes have been applied to one field + int iduplicate = JavaTools.getDuplicateFieldIndex(SortDescriptions.toArray(new String[SortDescriptions.size()])); + if (iduplicate != -1) + { + String sLocSortCriteriaisduplicate = JavaTools.replaceSubString(sSortCriteriaisduplicate, SortFieldNames.get(iduplicate)[0], "<FIELDNAME>"); + CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, sLocSortCriteriaisduplicate); + CurUnoDialog.vetoableChange(new PropertyChangeEvent(CurUnoDialog, "Steps", 1, 2)); + CurUnoDialog.setFocus("lstSort" + (iduplicate + 1)); + return new String[][] + { + }; + } + else + { + return SortFieldNames.toArray(new String[SortFieldNames.size()][2]); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + + + // The following code can be reactivated in a future version when task #100799 will be fixed + private void moveupSortItems(int CurIndex, boolean bDoEnable) + { + short iNextItemPos; + if ((!bDoEnable) && (MAXSORTCRITERIAINDEX > CurIndex)) + { + for (int i = CurIndex; i < MAXSORTCRITERIAINDEX; i++) + { + iNextItemPos = xSortListBox[i + 1].getSelectedItemPos(); + if (iNextItemPos != 0) + { + CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 1), PropertyNames.SELECTED_ITEMS, new short[] + { + iNextItemPos + }); + CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 2), PropertyNames.SELECTED_ITEMS, new short[] + { + }); + toggleSortListBox(i, true); + CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 2), PropertyNames.SELECTED_ITEMS, new short[] + { + 0 + }); + } + } + if (MaxSortIndex < xSortListBox.length - 2) + { + toggleSortListBox(MaxSortIndex + 2, false); + } + } + else + { + toggleSortListBox(CurIndex + 1, bDoEnable); + } + } + + private void toggleSortListBox(int CurIndex, boolean bDoEnable) + { + try + { + if (CurIndex < xSortListBox.length) + { + CurUnoDialog.setControlProperty("lblSort" + Integer.toString(CurIndex + 1), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable)); + CurUnoDialog.setControlProperty("lstSort" + Integer.toString(CurIndex + 1), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable)); + CurUnoDialog.setControlProperty("optAscend" + Integer.toString(CurIndex + 1), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable)); + CurUnoDialog.setControlProperty("optDescend" + Integer.toString(CurIndex + 1), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable)); + if (!bDoEnable) + { + CurUnoDialog.setControlProperty("lstSort" + Integer.toString(CurIndex + 1), PropertyNames.SELECTED_ITEMS, new short[] + { + 0 + }); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } +} diff --git a/wizards/com/sun/star/wizards/ui/TitlesComponent.java b/wizards/com/sun/star/wizards/ui/TitlesComponent.java new file mode 100644 index 0000000000..b9003f60d2 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/TitlesComponent.java @@ -0,0 +1,240 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.*; +import com.sun.star.beans.*; +import com.sun.star.awt.Size; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XTextListener; + +import java.util.*; + +public class TitlesComponent extends ControlScroller +{ + + private int iLabelPosX; + private static final int iRelLabelPosXDist = 6; + private String[] fieldnames; + private Map<String, String> fieldtitleset; + private String[] fieldtitles; + private static final String SOLABELPREFIX = "lblColumnName_"; + private static final String SOTITLEPREFIX = "lblTitleName_"; + + public TitlesComponent(WizardDialog _CurUnoDialog, int _iStep, int _iCompPosX, int _iCompPosY, int _iCompWidth, int _uitextfieldcount, String _slblColumnNames, String _slblColumnTitles, int _firsthelpindex) + { + super(_CurUnoDialog, _iStep, _iCompPosX, _iCompPosY, _iCompWidth, _uitextfieldcount, 18, _firsthelpindex); + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblColumnNames", new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, new Object[] + { + 8, _slblColumnNames, Integer.valueOf(iLabelPosX), Integer.valueOf(iCompPosY - 10), IStep, 60 + }); + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblColumnTitles", new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, new Object[] + { + 8, _slblColumnTitles, 90, Integer.valueOf(iCompPosY - 10), IStep, 152 + }); + } + + @Override + protected void insertControlGroup(int i, int ypos) + { + iLabelPosX = iCompPosX + iRelLabelPosXDist; + ControlRow oControlRow = new ControlRow(i, ypos); + ControlGroupVector.add(oControlRow); + + } + + @Override + protected void setControlGroupVisible(int _index, boolean _bIsVisible) + { + CurUnoDialog.setControlVisible(getColumnName(_index), _bIsVisible); + CurUnoDialog.setControlVisible(getTitleName(_index), _bIsVisible); + } + + public void addTextListener(XTextListener _xTextListener) + { + for (int i = 0; i < super.ControlGroupVector.size(); i++) + { + ControlRow curControlRow = (ControlRow) ControlGroupVector.get(i); + XTextComponent xTextBox = curControlRow.xTextComponent; + if ((xTextBox != null) && (_xTextListener != null)) + { + xTextBox.addTextListener(_xTextListener); + } + } + } + + class ControlRow + { + + private XTextComponent xTextComponent; + + public ControlRow(int _index, int _iCompPosY) + { + String slabelname = getColumnName(_index); + String stextfieldname = getTitleName(_index); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", slabelname, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 16, Boolean.TRUE, Integer.valueOf(iLabelPosX), Integer.valueOf(_iCompPosY + 1), UIConsts.INVISIBLESTEP, Short.valueOf(curtabindex++), 30 + }); + + xTextComponent = CurUnoDialog.insertTextField(stextfieldname, 0, null, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 12, HelpIds.getHelpIdString(curHelpIndex++), Integer.valueOf(iLabelPosX + 30), Integer.valueOf(_iCompPosY), UIConsts.INVISIBLESTEP, Short.valueOf(curtabindex++), Integer.valueOf(iCompWidth - 90 - 20) + }); + } + } + + private String getColumnName(int _index) + { + return SOLABELPREFIX + Integer.toString(_index + 1); + } + + private String getTitleName(int _index) + { + return SOTITLEPREFIX + Integer.toString(_index + 1); + } + + @Override + protected void initializeScrollFields() + { + for (int i = 0; i < fieldnames.length; i++) + { + PropertyValue[] currowproperties = new PropertyValue[2]; + currowproperties[0] = Properties.createProperty(getColumnName(i), fieldnames[i], i); + currowproperties[1] = Properties.createProperty(getTitleName(i), fieldtitles[i], i); //getTitleName(i) + registerControlGroup(currowproperties, i); + } + } + + private void adjustPosSizes() + { + String sLongestFieldName = JavaTools.getlongestArrayItem(fieldnames); + Size aSize = CurUnoDialog.getpreferredLabelSize(getColumnName(0), sLongestFieldName); + double dblMAPConversion = CurUnoDialog.getMAPConversionFactor(getColumnName(0)); + int iFieldNameWidth = getFieldNameWidth(aSize.Width, dblMAPConversion) + 10; + Integer FieldNameWidth = Integer.valueOf(iFieldNameWidth); + Integer TitlePosX = Integer.valueOf(iLabelPosX + iFieldNameWidth + 2); + Integer TitleWidth = Integer.valueOf(iCompPosX + iCompWidth - TitlePosX.intValue() - iScrollBarWidth - 6); + for (short i = 0; i <= ncurfieldcount; i++) + { + CurUnoDialog.setControlProperty(getColumnName(i), PropertyNames.PROPERTY_WIDTH, FieldNameWidth); + CurUnoDialog.setControlProperties(getTitleName(i), new String[] + { + PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_WIDTH + }, new Object[] + { + TitlePosX, TitleWidth + }); + } + CurUnoDialog.setControlProperty("lblColumnNames", PropertyNames.PROPERTY_WIDTH, FieldNameWidth); + CurUnoDialog.setControlProperty("lblColumnTitles", PropertyNames.PROPERTY_POSITION_X, TitlePosX); + } + + public void initialize(String[] _fieldnames, Map<String, String> _fieldtitleset) + { + this.fieldnames = _fieldnames; + this.fieldtitleset = _fieldtitleset; + setFieldTitles(); + initializeScrollFields(); + super.initialize(fieldnames.length); + adjustPosSizes(); + } + + private void setFieldTitles() + { + fieldtitles = new String[fieldnames.length]; + for (int i = 0; i < fieldnames.length; i++) + { + if (this.fieldtitleset.containsKey(fieldnames[i])) + { + Object curvalue = fieldtitleset.get(fieldnames[i]); + if (curvalue != null) + { + fieldtitles[i] = (String) curvalue; + } + else + { + fieldtitles[i] = fieldnames[i]; + } + } + else + { + fieldtitles[i] = fieldnames[i]; + } + } + } + + public String getFieldNameByTitleControl(Object _fieldtitlemodel) + { + String sTitleModelName = (String) Helper.getUnoPropertyValue(_fieldtitlemodel, PropertyNames.PROPERTY_NAME); + String sindex = JavaTools.getSuffixNumber(sTitleModelName); + return (String) CurUnoDialog.getControlProperty(SOLABELPREFIX + sindex, PropertyNames.PROPERTY_LABEL); + } + + public String[] getFieldTitles() + { + PropertyValue[][] titlelist = this.getScrollFieldValues(); + PropertyValue[] currowproperties; + PropertyValue curtitleproperty; + for (int i = 0; i < titlelist.length; i++) + { + currowproperties = titlelist[i]; + curtitleproperty = currowproperties[1]; + fieldtitles[i] = (String) curtitleproperty.Value; + } + refreshtitleset(); + return fieldtitles; + } + + private void refreshtitleset() + { + for (int i = 0; i < fieldnames.length; i++) + { + fieldtitleset.put(fieldnames[i], fieldtitles[i]); + } + } + + private int getFieldNameWidth(int iMAPControlWidth, double dblMAPConversion) + { + int iFieldNameWidth = (int) (1.15 * (iMAPControlWidth) / dblMAPConversion); + double dblAvailableWidth = (iCompWidth - iScrollBarWidth - iRelLabelPosXDist); + if (iFieldNameWidth > (0.5 * (dblAvailableWidth))) + { + iFieldNameWidth = (int) (0.5 * (dblAvailableWidth)); + } + return iFieldNameWidth; + } +} diff --git a/wizards/com/sun/star/wizards/ui/UIConsts.java b/wizards/com/sun/star/wizards/ui/UIConsts.java new file mode 100644 index 0000000000..eb57fefa86 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/UIConsts.java @@ -0,0 +1,66 @@ +/* + * 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 . + */ + +package com.sun.star.wizards.ui; + +public interface UIConsts +{ + Integer INVISIBLESTEP = 99; + String 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 + */ + short SOFIRSTWIZARDNAVITABINDEX = 30000; + Integer INTEGER_12 = 12; + /**Steps of the QueryWizard + * + */ + int SOGROUPSELECTIONPAGE = 5; + int SOGROUPFILTERPAGE = 6; + int SOTITLESPAGE = 7; + Integer[] INTEGERS = new Integer[] + { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + }; + + class CONTROLTYPE + { + + public static final int BUTTON = 1; + public static final int IMAGECONTROL = 2; + public static final int LISTBOX = 3; + public static final int COMBOBOX = 4; + public static final int CHECKBOX = 5; + public static final int RADIOBUTTON = 6; + public static final int DATEFIELD = 7; + public static final int EDITCONTROL = 8; + public static final int FIXEDLINE = 10; + public static final int FIXEDTEXT = 11; + public static final int FORMATTEDFIELD = 12; + public static final int HYPERTEXT = 14; + public static final int NUMERICFIELD = 15; + public static final int PATTERNFIELD = 16; + public static final int PROGRESSBAR = 17; + public static final int ROADMAP = 18; + public static final int SCROLLBAR = 19; + public static final int TIMEFIELD = 20; + public static final int CURRENCYFIELD = 21; + public static final int UNKNOWN = -1; + } +} diff --git a/wizards/com/sun/star/wizards/ui/UIConsts.py b/wizards/com/sun/star/wizards/ui/UIConsts.py new file mode 100644 index 0000000000..e5a4e25e29 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/UIConsts.py @@ -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 diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.java b/wizards/com/sun/star/wizards/ui/UnoDialog.java new file mode 100644 index 0000000000..404f3b619b --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/UnoDialog.java @@ -0,0 +1,836 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import com.sun.star.awt.*; +import com.sun.star.beans.XMultiPropertySet; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.*; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.*; +import com.sun.star.wizards.common.*; +import java.util.HashMap; + +public class UnoDialog +{ + + public XMultiServiceFactory xMSF; + XMultiServiceFactory MSFDialogModel; + private XNameContainer xDlgNames; + XControlContainer xDlgContainer; + private XNameAccess m_xDlgNameAccess; + public XControl xControl; + public XDialog xDialog; + public XReschedule xReschedule; + public XWindow xWindow; + public XComponent xComponent; + public XInterface xDialogModel; + private XInterface xUnoDialog; + private XVclWindowPeer xVclWindowPeer; + public HashMap<String, Integer> ControlList; + public Resource m_oResource; + public XWindowPeer xWindowPeer = null; + private PeerConfig m_oPeerConfig; + + public UnoDialog(XMultiServiceFactory xMSF) + { + try + { + this.xMSF = xMSF; + ControlList = new HashMap<String, Integer>(); + xDialogModel = (XInterface) xMSF.createInstance("com.sun.star.awt.UnoControlDialogModel"); + XMultiPropertySet xMultiPSetDlg = UnoRuntime.queryInterface(XMultiPropertySet.class, xDialogModel); + xMultiPSetDlg.setPropertyValues(new String[0], new Object[0]); + MSFDialogModel = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDialogModel); + xUnoDialog = (XInterface) xMSF.createInstance("com.sun.star.awt.UnoControlDialog"); + xControl = UnoRuntime.queryInterface(XControl.class, xUnoDialog); + XControlModel xControlModel = UnoRuntime.queryInterface(XControlModel.class, xDialogModel); + xControl.setModel(xControlModel); + UnoRuntime.queryInterface(XPropertySet.class, xDialogModel); + xDlgContainer = UnoRuntime.queryInterface(XControlContainer.class, xUnoDialog); + xDlgNames = UnoRuntime.queryInterface(XNameContainer.class, xDialogModel); + xComponent = UnoRuntime.queryInterface(XComponent.class, xUnoDialog); + xWindow = UnoRuntime.queryInterface(XWindow.class, xUnoDialog); + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public int getControlKey(Object EventObject, HashMap<String, Integer> ControlList) + { + int iKey; + XControl xContrl = UnoRuntime.queryInterface(XControl.class, EventObject); + XControlModel xControlModel = xContrl.getModel(); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel); + try + { + String sName = (String) xPSet.getPropertyValue(PropertyNames.PROPERTY_NAME); + Integer KeyObject = ControlList.get(sName); + iKey = KeyObject.intValue(); + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + iKey = 2000; + } + return iKey; + } + + private void createPeerConfiguration() + { + m_oPeerConfig = new PeerConfig(this); + } + + public PeerConfig getPeerConfiguration() + { + if (m_oPeerConfig == null) + { + createPeerConfiguration(); + } + return m_oPeerConfig; + } + + XNameAccess getDlgNameAccess() + { + if (m_xDlgNameAccess == null) + { + m_xDlgNameAccess = UnoRuntime.queryInterface(XNameAccess.class, xDialogModel); + } + return m_xDlgNameAccess; + } + public void setControlProperty(String ControlName, String PropertyName, Object PropertyValue) + { + try + { + if (PropertyValue != null) + { + if (!getDlgNameAccess().hasByName(ControlName)) + { + return; + } + Object xControlModel = getDlgNameAccess().getByName(ControlName); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel); + if (AnyConverter.isArray(PropertyValue)) + { + com.sun.star.uno.Type seqType = new com.sun.star.uno.Type(PropertyValue.getClass()); + PropertyValue = new com.sun.star.uno.Any(seqType, PropertyValue); + } + xPSet.setPropertyValue(PropertyName, PropertyValue); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public Resource getResource() + { + return m_oResource; + } + + public void setControlProperties(String ControlName, String[] PropertyNames, Object[] PropertyValues) + { + try + { + if (PropertyValues != null) + { + if (!getDlgNameAccess().hasByName(ControlName)) + { + return; + } + Object xControlModel = getDlgNameAccess().getByName(ControlName); + XMultiPropertySet xMultiPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, xControlModel); + xMultiPSet.setPropertyValues(PropertyNames, PropertyValues); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public Object getControlProperty(String ControlName, String PropertyName) + { + try + { + Object xControlModel = getDlgNameAccess().getByName(ControlName); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel); + return xPSet.getPropertyValue(PropertyName); + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + + + public double getMAPConversionFactor(String ControlName) + { + XControl xControl2 = xDlgContainer.getControl(ControlName); + XView xView = UnoRuntime.queryInterface(XView.class, xControl2); + Size aSize = xView.getSize(); + double dblMAPWidth = ((Integer) Helper.getUnoPropertyValue(xControl2.getModel(), PropertyNames.PROPERTY_WIDTH)).intValue(); + return ((aSize.Width) / dblMAPWidth); + } + + public Size getpreferredLabelSize(String LabelName, String sLabel) + { + XControl xControl2 = xDlgContainer.getControl(LabelName); + XFixedText xFixedText = UnoRuntime.queryInterface(XFixedText.class, xControl2); + String OldText = xFixedText.getText(); + xFixedText.setText(sLabel); + XLayoutConstrains xLayoutConstrains = UnoRuntime.queryInterface(XLayoutConstrains.class, xControl2); + Size aSize = xLayoutConstrains.getPreferredSize(); + xFixedText.setText(OldText); + return aSize; + } + + public void removeSelectedItems(XListBox xListBox) + { + short[] SelList = xListBox.getSelectedItemsPos(); + int Sellen = SelList.length; + for (int i = Sellen - 1; i >= 0; i--) + { + xListBox.removeItems(SelList[i], (short) 1); + } + } + + public static int getListBoxItemCount(XListBox _xListBox) + { + // This function may look ugly, but this is the only way to check the count + // of values in the model,which is always right. + // the control is only a view and could be right or not. + final String[] fieldnames = (String[]) Helper.getUnoPropertyValue(getModel(_xListBox), PropertyNames.STRING_ITEM_LIST); + return fieldnames.length; + } + + public static short getSelectedItemPos(XListBox _xListBox) + { + short ipos[] = (short[]) Helper.getUnoPropertyValue(getModel(_xListBox), PropertyNames.SELECTED_ITEMS); + return ipos[0]; + } + + public static boolean isListBoxSelected(XListBox _xListBox) + { + short ipos[] = (short[]) Helper.getUnoPropertyValue(getModel(_xListBox), PropertyNames.SELECTED_ITEMS); + return ipos.length > 0; + } + + + + public XFixedText insertLabel(String sName, String[] sPropNames, Object[] oPropValues) + { + try + { + Object oFixedText = insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", sName, sPropNames, oPropValues); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oFixedText); + xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, sName); + Object oLabel = xDlgContainer.getControl(sName); + return UnoRuntime.queryInterface(XFixedText.class, oLabel); + } + catch (java.lang.Exception ex) + { + ex.printStackTrace(); + return null; + } + } + + public XButton insertButton(String sName, int iControlKey, XActionListener xActionListener, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception + { + Object oButtonModel = insertControlModel("com.sun.star.awt.UnoControlButtonModel", sName, sProperties, sValues); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oButtonModel); + xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, sName); + Object objectButton = xDlgContainer.getControl(sName); + XButton xButton = UnoRuntime.queryInterface(XButton.class, objectButton); + if (xActionListener != null) + { + xButton.addActionListener(xActionListener); + } + Integer ControlKey = Integer.valueOf(iControlKey); + if (ControlList != null) + { + ControlList.put(sName, ControlKey); + } + return xButton; + } + + public XScrollBar insertScrollBar(String sName, int iControlKey, XAdjustmentListener xAdjustmentListener, String[] sProperties, Object[] sValues) + { + try + { + Object oScrollModel = insertControlModel("com.sun.star.awt.UnoControlScrollBarModel", sName, sProperties, sValues); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oScrollModel); + xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, sName); + Object oScrollBar = xDlgContainer.getControl(sName); + XScrollBar xScrollBar = UnoRuntime.queryInterface(XScrollBar.class, oScrollBar); + if (xAdjustmentListener != null) + { + xScrollBar.addAdjustmentListener(xAdjustmentListener); + } + Integer ControlKey = Integer.valueOf(iControlKey); + if (ControlList != null) + { + ControlList.put(sName, ControlKey); + } + return xScrollBar; + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public XTextComponent insertTextField(String sName, int iControlKey, XTextListener xTextListener, String[] sProperties, Object[] sValues) + { + return insertEditField("com.sun.star.awt.UnoControlEditModel", sName, iControlKey, xTextListener, sProperties, sValues); + } + + public XTextComponent insertFormattedField(String sName, int iControlKey, XTextListener xTextListener, String[] sProperties, Object[] sValues) + { + return insertEditField("com.sun.star.awt.UnoControlFormattedFieldModel", sName, iControlKey, xTextListener, sProperties, sValues); + } + + private XTextComponent insertEditField(String ServiceName, String sName, int iControlKey, XTextListener xTextListener, String[] sProperties, Object[] sValues) + { + try + { + XInterface xTextModel = insertControlModel(ServiceName, sName, sProperties, sValues); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xTextModel); + xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, sName); + XControl xTextField = xDlgContainer.getControl(sName); + XTextComponent xTextBox = UnoRuntime.queryInterface(XTextComponent.class, xTextField); + if (xTextListener != null) + { + xTextBox.addTextListener(xTextListener); + } + Integer ControlKey = Integer.valueOf(iControlKey); + ControlList.put(sName, ControlKey); + return xTextBox; + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public XListBox insertListBox(String sName, int iControlKey, XActionListener xActionListener, XItemListener xItemListener, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception + { + XInterface xListBoxModel = insertControlModel("com.sun.star.awt.UnoControlListBoxModel", sName, sProperties, sValues); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xListBoxModel); + xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, sName); + XControl xControlListBox = xDlgContainer.getControl(sName); + XListBox xListBox = UnoRuntime.queryInterface(XListBox.class, xControlListBox); + if (xItemListener != null) + { + xListBox.addItemListener(xItemListener); + } + if (xActionListener != null) + { + xListBox.addActionListener(xActionListener); + } + Integer ControlKey = Integer.valueOf(iControlKey); + ControlList.put(sName, ControlKey); + return xListBox; + } + + public XRadioButton insertRadioButton(String sName, int iControlKey, XItemListener xItemListener, String[] sProperties, Object[] sValues) + { + XRadioButton xRadioButton = insertRadioButton(sName, iControlKey, sProperties, sValues); + if (xItemListener != null) + { + xRadioButton.addItemListener(xItemListener); + } + return xRadioButton; + } + + public XButton insertRadioButton(String sName, int iControlKey, XActionListener xActionListener, String[] sProperties, Object[] sValues) + { + XRadioButton xRadioButton = insertRadioButton(sName, iControlKey, sProperties, sValues); + XButton xButton = UnoRuntime.queryInterface(XButton.class, xRadioButton); + if (xActionListener != null) + { + xButton.addActionListener(xActionListener); + } + return xButton; + } + + public XRadioButton insertRadioButton(String sName, int iControlKey, String[] sProperties, Object[] sValues) + { + XRadioButton xRadioButton = insertRadioButton(sName, sProperties, sValues); + Integer ControlKey = Integer.valueOf(iControlKey); + ControlList.put(sName, ControlKey); + return xRadioButton; + } + + public XRadioButton insertRadioButton(String sName, String[] sProperties, Object[] sValues) + { + try + { + XInterface oRadioButtonModel = insertControlModel("com.sun.star.awt.UnoControlRadioButtonModel", sName, sProperties, sValues); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oRadioButtonModel); + xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, sName); + XControl xControlRadioButton = xDlgContainer.getControl(sName); + return UnoRuntime.queryInterface(XRadioButton.class, xControlRadioButton); + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + /** + * The problem with setting the visibility of controls is that changing the current step + * of a dialog will automatically make all controls visible. The PropertyNames.PROPERTY_STEP property always wins against + * the property "visible". Therefore a control meant to be invisible is placed on a step far far away. + * Afterwards the step property of the dialog has to be set with "repaintDialogStep". As the performance + * of that method is very bad it should be used only once for all controls + * @param controlname the name of the control + * @param bIsVisible sets the control visible or invisible + */ + public void setControlVisible(String controlname, boolean bIsVisible) + { + try + { + int iCurDialogStep = AnyConverter.toInt(Helper.getUnoPropertyValue(this.xDialogModel, PropertyNames.PROPERTY_STEP)); + if (bIsVisible) + { + setControlProperty(controlname, PropertyNames.PROPERTY_STEP, Integer.valueOf(iCurDialogStep)); + } + else + { + setControlProperty(controlname, PropertyNames.PROPERTY_STEP, UIConsts.INVISIBLESTEP); + } + } + catch (com.sun.star.lang.IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + } + } + + /** + * repaints the currentDialogStep + */ + public void repaintDialogStep() + { + try + { + int ncurstep = AnyConverter.toInt(Helper.getUnoPropertyValue(this.xDialogModel, PropertyNames.PROPERTY_STEP)); + Helper.setUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP, 99); + Helper.setUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP, Integer.valueOf(ncurstep)); + } + catch (com.sun.star.lang.IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + } + } + + public XInterface insertControlModel(String ServiceName, String sName, String[] sProperties, Object[] sValues) + { + try + { + XInterface xControlModel = (XInterface) MSFDialogModel.createInstance(ServiceName); + Helper.setUnoPropertyValues(xControlModel, sProperties, sValues); + xDlgNames.insertByName(sName, xControlModel); + return xControlModel; + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public void setFocus(String ControlName) + { + Object oFocusControl = xDlgContainer.getControl(ControlName); + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, oFocusControl); + xWindow.setFocus(); + } + + public void selectListBoxItem(XListBox xListBox, short iFieldsSelIndex) + { + if (iFieldsSelIndex > -1) + { + int FieldCount = xListBox.getItemCount(); + if (FieldCount > 0) + { + if (iFieldsSelIndex < FieldCount) + { + xListBox.selectItemPos(iFieldsSelIndex, true); + } + else + { + xListBox.selectItemPos((short) (iFieldsSelIndex - 1), true); + } + } + } + } + + /** deselects a Listbox. MultipleMode is not supported + */ + public static void deselectListBox(XInterface _xBasisListBox) + { + Object oListBoxModel = getModel(_xBasisListBox); + Object sList = Helper.getUnoPropertyValue(oListBoxModel, PropertyNames.STRING_ITEM_LIST); + Helper.setUnoPropertyValue(oListBoxModel, PropertyNames.STRING_ITEM_LIST, new String[] + { + }); + Helper.setUnoPropertyValue(oListBoxModel, PropertyNames.STRING_ITEM_LIST, sList); + } + + public void calculateDialogPosition(Rectangle 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. + Rectangle CurPosSize = xWindow.getPosSize(); + int WindowHeight = FramePosSize.Height; + int WindowWidth = FramePosSize.Width; + int DialogWidth = CurPosSize.Width; + int DialogHeight = CurPosSize.Height; + int iXPos = ((WindowWidth / 2) - (DialogWidth / 2)); + int iYPos = ((WindowHeight / 2) - (DialogHeight / 2)); + xWindow.setPosSize(iXPos, iYPos, DialogWidth, DialogHeight, PosSize.POS); + } + + /** + * + * @return 0 for cancel, 1 for ok + */ + public short executeDialog(Rectangle FramePosSize) throws com.sun.star.uno.Exception + { + if (xControl.getPeer() == null) + { + throw new java.lang.IllegalArgumentException("Please create a peer, using your own frame"); + } + calculateDialogPosition(FramePosSize); + if (xWindowPeer == null) + { + createWindowPeer(); + } + xVclWindowPeer = UnoRuntime.queryInterface(XVclWindowPeer.class, xWindowPeer); + this.BisHighContrastModeActivated = Boolean.valueOf(this.isHighContrastModeActivated()); + xDialog = UnoRuntime.queryInterface(XDialog.class, xUnoDialog); + return xDialog.execute(); + } + + /** + * @return 0 for cancel, 1 for ok. + */ + public short executeDialog(XInterface xComponent) throws com.sun.star.uno.Exception + { + XFrame frame = UnoRuntime.queryInterface(XFrame.class, xComponent); + if (frame != null) + { + XWindow w = frame.getComponentWindow(); + if (w != null) + { + return executeDialog(w.getPosSize()); + } + } + + return executeDialog(new Rectangle(0, 0, 640, 400)); + } + + /** + * When possible, use the other executeDialog methods, since + * there may be problems retrieving the actual active frame, + * for example under linux. + * @return 0 for cancel, 1 for ok + */ + public short executeDialog() throws com.sun.star.uno.Exception + { + return executeDialog(Desktop.getActiveFrame(xMSF)); + } + + public void modifyFontWeight(String ControlName, float FontWeight) + { + FontDescriptor oFontDesc = new FontDescriptor(); + oFontDesc.Weight = FontWeight; + setControlProperty(ControlName, PropertyNames.FONT_DESCRIPTOR, oFontDesc); + } + + /** + * create a peer for this dialog, using the given peer as a parent. + */ + public XWindowPeer createWindowPeer(XWindowPeer parentPeer) throws com.sun.star.uno.Exception + { + xWindow.setVisible(false); + Object tk = xMSF.createInstance("com.sun.star.awt.Toolkit"); + if (parentPeer == null) + { + parentPeer = UnoRuntime.queryInterface(XToolkit.class, tk).getDesktopWindow(); + } + XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, tk); + xReschedule = UnoRuntime.queryInterface(XReschedule.class, xToolkit); + // TEUER! + xControl.createPeer(xToolkit, parentPeer); + xWindowPeer = xControl.getPeer(); + return xControl.getPeer(); + } + + /** + * Creates a peer for this dialog, using the active OO frame as the parent window. + */ + public XWindowPeer createWindowPeer() throws com.sun.star.uno.Exception + { + return createWindowPeer(null); + } + + public static Object getModel(Object control) + { + XControl xControl = UnoRuntime.queryInterface(XControl.class, control); + return xControl.getModel(); + } + + public static void setEnabled(Object control, boolean enabled) + { + setEnabled(control, enabled ? Boolean.TRUE : Boolean.FALSE); + } + + private static void setEnabled(Object control, Boolean enabled) + { + Helper.setUnoPropertyValue(getModel(control), PropertyNames.PROPERTY_ENABLED, enabled); + } + + /** + * @param oControlModel the model of a control + * @return the LabelType according to UIConsts.CONTROLTYPE + */ + private static int getControlModelType(Object oControlModel) + { + XServiceInfo xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, oControlModel); + if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlFixedTextModel")) + { + return UIConsts.CONTROLTYPE.FIXEDTEXT; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlButtonModel")) + { + return UIConsts.CONTROLTYPE.BUTTON; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlCurrencyFieldModel")) + { + return UIConsts.CONTROLTYPE.CURRENCYFIELD; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlDateFieldModel")) + { + return UIConsts.CONTROLTYPE.DATEFIELD; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlFixedLineModel")) + { + return UIConsts.CONTROLTYPE.FIXEDLINE; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlFormattedFieldModel")) + { + return UIConsts.CONTROLTYPE.FORMATTEDFIELD; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlRoadmapModel")) + { + return UIConsts.CONTROLTYPE.ROADMAP; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlNumericFieldModel")) + { + return UIConsts.CONTROLTYPE.NUMERICFIELD; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlPatternFieldModel")) + { + return UIConsts.CONTROLTYPE.PATTERNFIELD; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlHyperTextModel")) + { + return UIConsts.CONTROLTYPE.HYPERTEXT; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlProgressBarModel")) + { + return UIConsts.CONTROLTYPE.PROGRESSBAR; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlTimeFieldModel")) + { + return UIConsts.CONTROLTYPE.TIMEFIELD; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlImageControlModel")) + { + return UIConsts.CONTROLTYPE.IMAGECONTROL; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlRadioButtonModel")) + { + return UIConsts.CONTROLTYPE.RADIOBUTTON; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlCheckBoxModel")) + { + return UIConsts.CONTROLTYPE.CHECKBOX; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlEditModel")) + { + return UIConsts.CONTROLTYPE.EDITCONTROL; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlComboBoxModel")) + { + return UIConsts.CONTROLTYPE.COMBOBOX; + } + else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlListBoxModel")) // TODO Comboboxes?? + { + return UIConsts.CONTROLTYPE.LISTBOX; + } + else + { + return UIConsts.CONTROLTYPE.UNKNOWN; + } + } + + /** + * @return the name of the property that contains the value of a controlmodel + */ + public static String getDisplayProperty(Object oControlModel) + { + int itype = getControlModelType(oControlModel); + return getDisplayProperty(itype); + } + + /** + * @param itype The type of the control conforming to UIConst.ControlType + * @return the name of the property that contains the value of a controlmodel + */ + private static String getDisplayProperty(int itype) + { + switch (itype) + { + case UIConsts.CONTROLTYPE.FIXEDTEXT: + return PropertyNames.PROPERTY_LABEL; + case UIConsts.CONTROLTYPE.BUTTON: + return PropertyNames.PROPERTY_LABEL; + case UIConsts.CONTROLTYPE.FIXEDLINE: + return PropertyNames.PROPERTY_LABEL; + case UIConsts.CONTROLTYPE.NUMERICFIELD: + return "Value"; + case UIConsts.CONTROLTYPE.CURRENCYFIELD: + return "Value"; + case UIConsts.CONTROLTYPE.FORMATTEDFIELD: + return "EffectiveValue"; + case UIConsts.CONTROLTYPE.DATEFIELD: + return "Date"; + case UIConsts.CONTROLTYPE.TIMEFIELD: + return "Time"; + case UIConsts.CONTROLTYPE.SCROLLBAR: + return "ScrollValue"; + case UIConsts.CONTROLTYPE.PROGRESSBAR: + return "ProgressValue"; + case UIConsts.CONTROLTYPE.IMAGECONTROL: + return PropertyNames.PROPERTY_IMAGEURL; + case UIConsts.CONTROLTYPE.RADIOBUTTON: + return PropertyNames.PROPERTY_STATE; + case UIConsts.CONTROLTYPE.CHECKBOX: + return PropertyNames.PROPERTY_STATE; + case UIConsts.CONTROLTYPE.EDITCONTROL: + return "Text"; + case UIConsts.CONTROLTYPE.COMBOBOX: + return "Text"; + case UIConsts.CONTROLTYPE.PATTERNFIELD: + return "Text"; + case UIConsts.CONTROLTYPE.LISTBOX: + return PropertyNames.SELECTED_ITEMS; + default: + return PropertyNames.EMPTY_STRING; + } + } + + public void addResourceHandler() + { + m_oResource = new Resource(xMSF); + } + + public static short setInitialTabindex(int _istep) + { + return (short) (_istep * 100); + } + private Boolean BisHighContrastModeActivated = null; + + private boolean isHighContrastModeActivated() + { + if (xVclWindowPeer != null) + { + if (BisHighContrastModeActivated == null) + { + int nUIColor; + try + { + nUIColor = AnyConverter.toInt(this.xVclWindowPeer.getProperty("DisplayBackgroundColor")); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(System.err); + return false; + } + //TODO: The following methods could be wrapped in an own class implementation + int nRed = getRedColorShare(nUIColor); + int nGreen = getGreenColorShare(nUIColor); + int nBlue = getBlueColorShare(nUIColor); + int nLuminance = ((nBlue * 28 + nGreen * 151 + nRed * 77) / 256); + boolean bisactivated = (nLuminance <= 25); + BisHighContrastModeActivated = Boolean.valueOf(bisactivated); + return bisactivated; + } + else + { + return BisHighContrastModeActivated.booleanValue(); + } + } + else + { + return false; + } + } + + private static int getRedColorShare(int _nColor) + { + int nRed = _nColor / 65536; + return nRed; + } + + private static int getGreenColorShare(int _nColor) + { + int nRedModulo = _nColor % 65536; + int nGreen = nRedModulo / 256; + return nGreen; + } + + private static int getBlueColorShare(int _nColor) + { + int nRedModulo = _nColor % 65536; + int nGreenModulo = (nRedModulo % 256); + int nBlue = nGreenModulo; + return nBlue; + } + + public static short getListBoxLineCount() + { + return (short)20; + } +} diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.py b/wizards/com/sun/star/wizards/ui/UnoDialog.py new file mode 100644 index 0000000000..37376f1eec --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/UnoDialog.py @@ -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 diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog2.java b/wizards/com/sun/star/wizards/ui/UnoDialog2.java new file mode 100644 index 0000000000..24064585ae --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/UnoDialog2.java @@ -0,0 +1,195 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import com.sun.star.awt.XActionListener; +import com.sun.star.awt.XButton; +import com.sun.star.awt.XCheckBox; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XItemListener; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XTextListener; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.SystemDialog; + +/** + * This class contains convenience methods for inserting components to a dialog. + * <p>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.</p> + * <p>It uses an Event-Listener method, which calls a method through reflection + * when an event on a component is triggered. + * see the classes CommonListener, MethodInvocation for details.</p> + */ +public class UnoDialog2 extends UnoDialog +{ + + public UnoDialog2(XMultiServiceFactory xmsf) + { + super(xmsf); + } + + public XButton insertButton(String sName, XActionListener actionListener, String[] sPropNames, Object[] oPropValues) + { + XButton xButton = (XButton) insertControlModel2("com.sun.star.awt.UnoControlButtonModel", sName, sPropNames, oPropValues, XButton.class); + + if (actionListener != null) + { + xButton.addActionListener(actionListener); + } + return xButton; + } + + public XButton insertImageButton(String sName, com.sun.star.awt.XActionListener actionPerformed, String[] sPropNames, Object[] oPropValues) + { + XButton xButton = (XButton) insertControlModel2("com.sun.star.awt.UnoControlButtonModel", sName, sPropNames, oPropValues, XButton.class); + + if (actionPerformed != null) + { + xButton.addActionListener(actionPerformed); + } + return xButton; + } + + public XCheckBox insertCheckBox(String sName, XItemListener itemListener, String[] sPropNames, Object[] oPropValues) + { + XCheckBox xCheckBox = (XCheckBox) insertControlModel2("com.sun.star.awt.UnoControlCheckBoxModel", sName, sPropNames, oPropValues, XCheckBox.class); + + if (itemListener != null) + { + xCheckBox.addItemListener(itemListener); + } + return xCheckBox; + } + + public XListBox insertListBox(String sName, XActionListener actionListener, XItemListener itemListener, String[] sPropNames, Object[] oPropValues) + { + XListBox xListBox = (XListBox) insertControlModel2("com.sun.star.awt.UnoControlListBoxModel", sName, sPropNames, oPropValues, XListBox.class); + if (actionListener != null) + { + xListBox.addActionListener(actionListener); + } + if (itemListener != null) + { + xListBox.addItemListener(itemListener); + } + return xListBox; + } + + public XRadioButton insertRadioButton(String sName, XItemListener itemListener, String[] sPropNames, Object[] oPropValues) + { + XRadioButton xRadioButton = (XRadioButton) insertControlModel2("com.sun.star.awt.UnoControlRadioButtonModel", sName, sPropNames, oPropValues, XRadioButton.class); + if (itemListener != null) + { + xRadioButton.addItemListener(itemListener); + } + return xRadioButton; + } + + + + public XTextComponent insertTextField(String sName, XTextListener textListener, String[] sPropNames, Object[] oPropValues) + { + return (XTextComponent) insertEditField(sName, textListener, "com.sun.star.awt.UnoControlEditModel", sPropNames, oPropValues, XTextComponent.class); + } + + private XControl insertImage(String sName, String[] sPropNames, Object[] oPropValues) + { + return (XControl) insertControlModel2("com.sun.star.awt.UnoControlImageControlModel", sName, sPropNames, oPropValues, XControl.class); + } + + public XControl insertInfoImage(int _posx, int _posy, int _iStep) + { + XControl xImgControl = insertImage(Desktop.getUniqueName(getDlgNameAccess(), "imgHint"), + new String[] + { + PropertyNames.PROPERTY_BORDER, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_IMAGEURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, "ScaleImage", PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Short.valueOf((short) 0), 10, UIConsts.INFOIMAGEURL, Integer.valueOf(_posx), Integer.valueOf(_posy), Boolean.FALSE, Integer.valueOf(_iStep), 10 + }); + super.getPeerConfiguration().setImageUrl(getModel(xImgControl), UIConsts.INFOIMAGEURL); + return xImgControl; + } + + /** + * This method is used for creating Edit, Currency, Date, Formatted, Pattern, File + * and Time edit components. + */ + private Object insertEditField(String sName, XTextListener textListener, String sModelClass, String[] sPropNames, Object[] oPropValues, Class<? extends XInterface> type) + { + XTextComponent xField = (XTextComponent) insertControlModel2(sModelClass, sName, sPropNames, oPropValues, XTextComponent.class); + if (textListener != null) + { + xField.addTextListener(textListener); + } + return UnoRuntime.queryInterface(type, xField); + } + + public XControl insertFixedLine(String sName, String[] sPropNames, Object[] oPropValues) + { + Object oLine = insertControlModel2("com.sun.star.awt.UnoControlFixedLineModel", sName, sPropNames, oPropValues); + return UnoRuntime.queryInterface(XControl.class, oLine); + } + + + + + + + + private Object insertControlModel2(String serviceName, String componentName, String[] sPropNames, Object[] oPropValues) + { + try + { + XInterface xControlModel = insertControlModel(serviceName, componentName, new String[] + { + }, new Object[] + { + }); + Helper.setUnoPropertyValues(xControlModel, sPropNames, oPropValues); + Helper.setUnoPropertyValue(xControlModel, PropertyNames.PROPERTY_NAME, componentName); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + return xDlgContainer.getControl(componentName); + } + + private Object insertControlModel2(String serviceName, String componentName, String[] sPropNames, Object[] oPropValues, Class<? extends XInterface> type) + { + return UnoRuntime.queryInterface(type, insertControlModel2(serviceName, componentName, sPropNames, oPropValues)); + } + + + + + + public int showMessageBox(String windowServiceName, int windowAttribute, String MessageText) + { + return SystemDialog.showMessageBox(xMSF, this.xControl.getPeer(), windowServiceName, windowAttribute, MessageText); + } +} diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog2.py b/wizards/com/sun/star/wizards/ui/UnoDialog2.py new file mode 100644 index 0000000000..42aee8c5f5 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/UnoDialog2.py @@ -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) diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java new file mode 100644 index 0000000000..69fbf5ab76 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java @@ -0,0 +1,685 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui; + +import java.beans.VetoableChangeListener; +import com.sun.star.awt.ActionEvent; +import com.sun.star.awt.FontDescriptor; +import com.sun.star.awt.PushButtonType; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XItemEventBroadcaster; +import com.sun.star.awt.XTopWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexContainer; +import com.sun.star.frame.TerminationVetoException; +import com.sun.star.frame.XTerminateListener; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.HelpIds; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.ui.event.XActionListenerAdapter; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; + +public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeListener, XTerminateListener +{ + + private static final int iButtonWidth = 50; + private int nNewStep = 1; + private int nOldStep = 1; + private int nMaxStep = 1; + private String[] sRMItemLabels; + private Object oRoadmap; + private XSingleServiceFactory xSSFRoadmap; + public XIndexContainer xIndexContRoadmap; + private final Resource oWizardResource; + private final int hid; + private boolean bTerminateListenermustberemoved = true; + + /** 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 + */ + public WizardDialog(XMultiServiceFactory xMSF, int hid_) + { + super(xMSF); + hid = hid_; + oWizardResource = new Resource(xMSF); + oWizardResource.getResText("RID_DB_COMMON_33"); + } + + @Override + public Resource getResource() + { + return oWizardResource; + } + + private void activate() + { + try + { + XTopWindow top = UnoRuntime.queryInterface(XTopWindow.class, xWindow); + if (top != null) + { + top.toFront(); + } + } + catch (Exception ex) + { + // do nothing; + } + } + + public void setMaxStep(int i) + { + nMaxStep = i; + } + + public int getNewStep() + { + return nNewStep; + } + + /** + * @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent) + */ + public void vetoableChange(java.beans.PropertyChangeEvent arg0) + { + nNewStep = nOldStep; + } + + public void setRoadmapInteractive(boolean _bInteractive) + { + Helper.setUnoPropertyValue(oRoadmap, "Activated", Boolean.valueOf(_bInteractive)); + } + + public void setRoadmapComplete(boolean bComplete) + { + Helper.setUnoPropertyValue(oRoadmap, "Complete", Boolean.valueOf(bComplete)); + } + + private boolean isRoadmapComplete() + { + try + { + return AnyConverter.toBoolean(Helper.getUnoPropertyValue(oRoadmap, "Complete")); + } + catch (IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + return false; + } + } + + public void setCurrentRoadmapItemID(short ID) + { + if (oRoadmap != null) + { + int nCurItemID = getCurrentRoadmapItemID(); + if (nCurItemID != ID) + { + Helper.setUnoPropertyValue(oRoadmap, "CurrentItemID", Short.valueOf(ID)); + } + } + } + + private int getCurrentRoadmapItemID() + { + try + { + return AnyConverter.toInt(Helper.getUnoPropertyValue(oRoadmap, "CurrentItemID")); + } + catch (com.sun.star.lang.IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + return -1; + } + } + + public void addRoadmap() + { + try + { + int iDialogHeight = ((Integer) Helper.getUnoPropertyValue(this.xDialogModel, PropertyNames.PROPERTY_HEIGHT)).intValue(); + + // 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 + oRoadmap = insertControlModel("com.sun.star.awt.UnoControlRoadmapModel", "rdmNavi", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + "Tabstop", + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Integer.valueOf(iDialogHeight - 26), + 0, + 0, + 0, + Short.valueOf((short)0), + Boolean.TRUE, + 85 + }); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, oRoadmap); + xPSet.setPropertyValue(PropertyNames.PROPERTY_NAME, "rdmNavi"); + + xSSFRoadmap = UnoRuntime.queryInterface(XSingleServiceFactory.class, oRoadmap); + xIndexContRoadmap = UnoRuntime.queryInterface(XIndexContainer.class, oRoadmap); + + XControl xRoadmapControl = this.xDlgContainer.getControl("rdmNavi"); + XItemEventBroadcaster xRoadmapBroadcaster = UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRoadmapControl); + xRoadmapBroadcaster.addItemListener(new XItemListenerAdapter() { + @Override + public void itemStateChanged(com.sun.star.awt.ItemEvent itemEvent) { + try + { + nNewStep = itemEvent.ItemId; + nOldStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP)); + if (nNewStep != nOldStep) + { + switchToStep(); + } + } + catch (com.sun.star.lang.IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + } + } + }); + + Helper.setUnoPropertyValue(oRoadmap, "Text", oWizardResource.getResText("RID_COMMON_16")); + } + catch (java.lang.Exception jexception) + { + jexception.printStackTrace(System.err); + } + } + + public void setRMItemLabels(Resource _oResource) + { + sRMItemLabels = new String[nMaxStep]; + for (int i = 0; i < nMaxStep; ++i) { + sRMItemLabels[i] = _oResource.getResText("RID_QUERY_" + String.valueOf(i + 80)); + } + } + + public int insertRoadmapItem(int _Index, boolean _bEnabled, int _LabelID, int _CurItemID) + { + return insertRoadmapItem(_Index, _bEnabled, sRMItemLabels[_LabelID], _CurItemID); + } + + public int insertRoadmapItem(int Index, boolean _bEnabled, String _sLabel, int _CurItemID) + { + try + { + Object oRoadmapItem = xSSFRoadmap.createInstance(); + Helper.setUnoPropertyValue(oRoadmapItem, PropertyNames.PROPERTY_LABEL, _sLabel); + Helper.setUnoPropertyValue(oRoadmapItem, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bEnabled)); + Helper.setUnoPropertyValue(oRoadmapItem, "ID", Integer.valueOf(_CurItemID)); + xIndexContRoadmap.insertByIndex(Index, oRoadmapItem); + return Index + 1; + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + return -1; + } + } + + public int getRMItemCount() + { + return xIndexContRoadmap.getCount(); + } + + public XInterface getRoadmapItemByID(int _ID) + { + try + { + int CurID; + XInterface CurRoadmapItem; + for (int i = 0; i < xIndexContRoadmap.getCount(); i++) + { + CurRoadmapItem = (XInterface) xIndexContRoadmap.getByIndex(i); + CurID = AnyConverter.toInt(Helper.getUnoPropertyValue(CurRoadmapItem, "ID")); + if (CurID == _ID) + { + return CurRoadmapItem; + } + } + return null; + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + return null; + } + } + + public boolean switchToStep(int _nOldStep, int _nNewStep) + { + nOldStep = _nOldStep; + nNewStep = _nNewStep; + return switchToStep(); + } + + private boolean switchToStep() + { + leaveStep(nOldStep, nNewStep); + if (nNewStep != nOldStep) + { + if (nNewStep == nMaxStep) + { + setControlProperty("btnWizardNext", "DefaultButton", Boolean.FALSE); + setControlProperty("btnWizardFinish", "DefaultButton", Boolean.TRUE); + } + else + { + setControlProperty("btnWizardNext", "DefaultButton", Boolean.TRUE); + setControlProperty("btnWizardFinish", "DefaultButton", Boolean.FALSE); + } + changeToStep(nNewStep); + enterStep(nOldStep, nNewStep); + return true; + } + return false; + } + + abstract protected void leaveStep(int nOldStep, int nNewStep); + + abstract protected void enterStep(int nOldStep, int nNewStep); + + private void changeToStep(int nNewStep) + { + Helper.setUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP, Integer.valueOf(nNewStep)); + setCurrentRoadmapItemID((short) (nNewStep)); + enableNextButton(getNextAvailableStep() > 0); + enableBackButton(nNewStep != 1); + } + + + public void drawNaviBar() + { + + try + { + short curtabindex = UIConsts.SOFIRSTWIZARDNAVITABINDEX; + Integer IButtonWidth = Integer.valueOf(iButtonWidth); + int iButtonHeight = 14; + Integer IButtonHeight = Integer.valueOf(iButtonHeight); + Integer ICurStep = 0; + int iDialogHeight = ((Integer) Helper.getUnoPropertyValue(this.xDialogModel, PropertyNames.PROPERTY_HEIGHT)).intValue(); + int iDialogWidth = ((Integer) Helper.getUnoPropertyValue(this.xDialogModel, PropertyNames.PROPERTY_WIDTH)).intValue(); + int iHelpPosX = 8; + int iBtnPosY = iDialogHeight - iButtonHeight - 6; + int iCancelPosX = iDialogWidth - iButtonWidth - 6; + int iFinishPosX = iCancelPosX - 6 - iButtonWidth; + int iNextPosX = iFinishPosX - 6 - iButtonWidth; + int iBackPosX = iNextPosX - 3 - iButtonWidth; + + insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "lnNaviSep", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.ORIENTATION, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 1, 0, 0, Integer.valueOf(iDialogHeight - 26), ICurStep, Integer.valueOf(iDialogWidth) + }); + + insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "lnRoadSep", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.ORIENTATION, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Integer.valueOf(iBtnPosY - 6), 1, 85, 0, ICurStep, 1 + }); + + String[] propNames = new String[] + { + 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 + }; + + Helper.setUnoPropertyValue(super.xDialogModel, PropertyNames.PROPERTY_HELPURL, HelpIds.getHelpIdString(hid)); + insertButton("btnWizardHelp", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + callHelp(); + } + }, new String[] + { + 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 + }, + new Object[] + { + true, IButtonHeight, oWizardResource.getResText("RID_COMMON_15"), Integer.valueOf(iHelpPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.HELP_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth + }); + insertButton("btnWizardBack", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + gotoPreviousAvailableStep(); + } + }, propNames, + new Object[] + { + false, IButtonHeight, HelpIds.getHelpIdString(hid + 2), oWizardResource.getResText("RID_COMMON_13"), Integer.valueOf(iBackPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.STANDARD_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth + }); + + insertButton("btnWizardNext", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + gotoNextAvailableStep(); + } + }, propNames, + new Object[] + { + true, IButtonHeight, HelpIds.getHelpIdString(hid + 3), oWizardResource.getResText("RID_COMMON_14"), Integer.valueOf(iNextPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.STANDARD_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth + }); + + insertButton("btnWizardFinish", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + finishWizard_1(); + } + }, propNames, + new Object[] + { + true, IButtonHeight, HelpIds.getHelpIdString(hid + 4), oWizardResource.getResText("RID_COMMON_12"), Integer.valueOf(iFinishPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.STANDARD_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth + }); + + insertButton("btnWizardCancel", new XActionListenerAdapter() { + @Override + public void actionPerformed(ActionEvent event) { + cancelWizard_1(); + } + }, propNames, + new Object[] + { + true, IButtonHeight, HelpIds.getHelpIdString(hid + 5), oWizardResource.getResText("RID_COMMON_11"), Integer.valueOf(iCancelPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.STANDARD_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth + }); + + setControlProperty("btnWizardNext", "DefaultButton", Boolean.TRUE); + } + catch (java.lang.Exception jexception) + { + jexception.printStackTrace(System.err); + } + } + + + + public void enableNavigationButtons(boolean _bEnableBack, boolean _bEnableNext, boolean _bEnableFinish) + { + enableBackButton(_bEnableBack); + enableNextButton(_bEnableNext); + enableFinishButton(_bEnableFinish); + } + + private void enableBackButton(boolean enabled) + { + setControlProperty("btnWizardBack", PropertyNames.PROPERTY_ENABLED, enabled ? Boolean.TRUE : Boolean.FALSE); + } + + public void enableNextButton(boolean enabled) + { + setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, enabled ? Boolean.TRUE : Boolean.FALSE); + } + + public void enableFinishButton(boolean enabled) + { + setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, enabled ? Boolean.TRUE : Boolean.FALSE); + } + + public void setStepEnabled(int _nStep, boolean bEnabled) + { + XInterface xRoadmapItem = getRoadmapItemByID(_nStep); + if (xRoadmapItem != null) + { + Helper.setUnoPropertyValue(xRoadmapItem, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); + } + } + + public void enablefromStep(int _iStep, boolean _bDoEnable) + { + if (_iStep <= this.nMaxStep) + { + for (int i = _iStep; i <= nMaxStep; i++) + { + setStepEnabled(i, _bDoEnable); + } + enableFinishButton(_bDoEnable); + if (!_bDoEnable) + { + enableNextButton(_iStep > getCurrentStep() + 1); + } + else + { + enableNextButton(getCurrentStep() != nMaxStep); + } + } + } + + private boolean isStepEnabled(int _nStep) + { + try + { + boolean bIsEnabled; + XInterface xRoadmapItem = getRoadmapItemByID(_nStep); + if (xRoadmapItem == null) + // Todo: In this case an exception should be thrown + { + return false; + } + bIsEnabled = AnyConverter.toBoolean(Helper.getUnoPropertyValue(xRoadmapItem, PropertyNames.PROPERTY_ENABLED)); + return bIsEnabled; + } + catch (com.sun.star.lang.IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + return false; + } + } + + private synchronized void gotoPreviousAvailableStep() + { + boolean bIsEnabled; + if (nNewStep > 1) + { + nOldStep = nNewStep; + nNewStep--; + while (nNewStep > 0) + { + bIsEnabled = isStepEnabled(nNewStep); + if (bIsEnabled) + { + break; + } + nNewStep--; + } + if (nNewStep == 0) // Exception??? + { + nNewStep = nOldStep; + } + switchToStep(); + } + } + + //TODO discuss with rp + private int getNextAvailableStep() + { + if (isRoadmapComplete()) + { + for (int i = nNewStep + 1; i <= nMaxStep; i++) + { + if (isStepEnabled(i)) + { + return i; + } + } + } + return -1; + } + + private synchronized void gotoNextAvailableStep() + { + nOldStep = nNewStep; + nNewStep = getNextAvailableStep(); + if (nNewStep > -1) + { + switchToStep(); + } + } + + public abstract boolean finishWizard(); + + /** + * This function will call if the finish button is pressed on the UI. + */ + private void finishWizard_1() + { + enableFinishButton(false); + boolean success = false; + try + { + success = finishWizard(); + } + finally + { + if ( !success ) + enableFinishButton( true ); + } + if ( success ) + removeTerminateListener(); + } + + public int getCurrentStep() + { + try + { + return AnyConverter.toInt(Helper.getUnoPropertyValue(this.MSFDialogModel, PropertyNames.PROPERTY_STEP)); + } + catch (com.sun.star.lang.IllegalArgumentException exception) + { + exception.printStackTrace(System.err); + return -1; + } + } + + public void setCurrentStep(int _nNewstep) + { + nNewStep = _nNewstep; + changeToStep(nNewStep); + } + + public void setRightPaneHeaders(Resource _oResource, String ResNameBase, int StartResID, int _nMaxStep) + { + String[] sRightPaneHeaders = new String[_nMaxStep]; + for (int i = 0; i < _nMaxStep; ++i) { + sRightPaneHeaders[i] = _oResource.getResText(ResNameBase + String.valueOf(i + StartResID)); + } + setRightPaneHeaders(sRightPaneHeaders); + } + + public void setRightPaneHeaders(String[] _sRightPaneHeaders) + { + this.nMaxStep = _sRightPaneHeaders.length; + FontDescriptor oFontDesc = new FontDescriptor(); + oFontDesc.Weight = com.sun.star.awt.FontWeight.BOLD; + + for (int i = 0; i < _sRightPaneHeaders.length; i++) + { + insertLabel("lblQueryTitle" + i, + new String[] + { + PropertyNames.FONT_DESCRIPTOR, 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 + }, + new Object[] + { + oFontDesc, 16, _sRightPaneHeaders[i], Boolean.TRUE, 91, 8, Integer.valueOf(i + 1), Short.valueOf((short) 12), 212 + }); + } + } + + public void cancelWizard() + { + //can be overridden by extending class + xDialog.endExecute(); + } + + private void callHelp() + { + //should be overridden by extending class + } + + private void removeTerminateListener() + { + if (bTerminateListenermustberemoved) + { + Desktop.getDesktop(xMSF).removeTerminateListener(this); + bTerminateListenermustberemoved = false; + } + } + + /** + * called by the cancel button and + * by the window hidden event. + * if this method was not called before, + * perform a cancel. + */ + private void cancelWizard_1() + { + cancelWizard(); + removeTerminateListener(); + } + + public void notifyTermination(EventObject arg0) + { + cancelWizard_1(); + } + + public void queryTermination(EventObject arg0) + throws TerminationVetoException + { + activate(); + throw new TerminationVetoException(); + } + + public void disposing(EventObject arg0) + { + cancelWizard_1(); + } +} diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.py b/wizards/com/sun/star/wizards/ui/WizardDialog.py new file mode 100644 index 0000000000..e597053514 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/WizardDialog.py @@ -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 diff --git a/wizards/com/sun/star/wizards/ui/XFieldSelectionListener.java b/wizards/com/sun/star/wizards/ui/XFieldSelectionListener.java new file mode 100644 index 0000000000..4a592b3a7a --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/XFieldSelectionListener.java @@ -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 . + */ + +package com.sun.star.wizards.ui; + +public interface XFieldSelectionListener +{ + + void shiftFromLeftToRight(String[] SelItems, String[] NewItems); + + void shiftFromRightToLeft(String[] OldSelItems, String[] NewItems); + + void moveItemUp(String Selitem); + + void moveItemDown(String Selitem); + + void setID(String sIncSuffix); + + +} diff --git a/wizards/com/sun/star/wizards/ui/__init__.py b/wizards/com/sun/star/wizards/ui/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/__init__.py diff --git a/wizards/com/sun/star/wizards/ui/event/CommonListener.py b/wizards/com/sun/star/wizards/ui/event/CommonListener.py new file mode 100644 index 0000000000..c131195711 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/CommonListener.py @@ -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 diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.py b/wizards/com/sun/star/wizards/ui/event/DataAware.py new file mode 100644 index 0000000000..e062b48bd2 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/DataAware.py @@ -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() diff --git a/wizards/com/sun/star/wizards/ui/event/EventListenerList.py b/wizards/com/sun/star/wizards/ui/event/EventListenerList.py new file mode 100644 index 0000000000..e30536044b --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/EventListenerList.py @@ -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) diff --git a/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py b/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py new file mode 100644 index 0000000000..a6f13e77df --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py @@ -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() diff --git a/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py b/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py new file mode 100644 index 0000000000..67ba0ceb82 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py @@ -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 diff --git a/wizards/com/sun/star/wizards/ui/event/Task.py b/wizards/com/sun/star/wizards/ui/event/Task.py new file mode 100644 index 0000000000..aa44ed314e --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/Task.py @@ -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) diff --git a/wizards/com/sun/star/wizards/ui/event/TaskEvent.py b/wizards/com/sun/star/wizards/ui/event/TaskEvent.py new file mode 100644 index 0000000000..765bb07c94 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/TaskEvent.py @@ -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_ diff --git a/wizards/com/sun/star/wizards/ui/event/TaskListener.py b/wizards/com/sun/star/wizards/ui/event/TaskListener.py new file mode 100644 index 0000000000..210bac4db7 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/TaskListener.py @@ -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 diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py new file mode 100644 index 0000000000..945c2cef23 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py @@ -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 diff --git a/wizards/com/sun/star/wizards/ui/event/XActionListenerAdapter.java b/wizards/com/sun/star/wizards/ui/event/XActionListenerAdapter.java new file mode 100644 index 0000000000..b7dfddbb8d --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/XActionListenerAdapter.java @@ -0,0 +1,32 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui.event; + +import com.sun.star.awt.ActionEvent; +import com.sun.star.awt.XActionListener; +import com.sun.star.lang.EventObject; + +public class XActionListenerAdapter implements XActionListener { + + public void disposing(EventObject event) { + } + + public void actionPerformed(ActionEvent event) { + } + +} diff --git a/wizards/com/sun/star/wizards/ui/event/XItemListenerAdapter.java b/wizards/com/sun/star/wizards/ui/event/XItemListenerAdapter.java new file mode 100644 index 0000000000..160ecdb4fd --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/XItemListenerAdapter.java @@ -0,0 +1,32 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui.event; + +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.XItemListener; +import com.sun.star.lang.EventObject; + +public class XItemListenerAdapter implements XItemListener { + + public void disposing(EventObject event) { + } + + public void itemStateChanged(ItemEvent event) { + } + +} diff --git a/wizards/com/sun/star/wizards/ui/event/XTextListenerAdapter.java b/wizards/com/sun/star/wizards/ui/event/XTextListenerAdapter.java new file mode 100644 index 0000000000..af95771af0 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/XTextListenerAdapter.java @@ -0,0 +1,32 @@ +/* + * 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 . + */ +package com.sun.star.wizards.ui.event; + +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.XTextListener; +import com.sun.star.lang.EventObject; + +public class XTextListenerAdapter implements XTextListener { + + public void disposing(EventObject event) { + } + + public void textChanged(TextEvent event) { + } + +} diff --git a/wizards/com/sun/star/wizards/ui/event/__init__.py b/wizards/com/sun/star/wizards/ui/event/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/__init__.py |