diff options
author | Xisco Fauli <anistenis@gmail.com> | 2011-08-08 19:34:04 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-08-18 02:57:44 +0200 |
commit | 9ad82442fb37f42d3f2797b9594c7021aeb34de4 (patch) | |
tree | abfd71bb04b74d992f21d57dc1cc5574068493d7 /wizards | |
parent | 3f92e275dafc0a54160937710cf77a9995c08cb5 (diff) |
first attempt to create the web wizard
Diffstat (limited to 'wizards')
41 files changed, 4017 insertions, 195 deletions
diff --git a/wizards/com/sun/star/wizards/agenda/CGAgenda.py b/wizards/com/sun/star/wizards/agenda/CGAgenda.py index 2e699d9ff4e8..112ef041df25 100644 --- a/wizards/com/sun/star/wizards/agenda/CGAgenda.py +++ b/wizards/com/sun/star/wizards/agenda/CGAgenda.py @@ -1,4 +1,4 @@ -from common.ConfigGroup import * +from common.ConfigGroup import ConfigGroup from common.ConfigSet import ConfigSet from CGTopic import CGTopic diff --git a/wizards/com/sun/star/wizards/common/ConfigGroup.py b/wizards/com/sun/star/wizards/common/ConfigGroup.py index ca1b60a4de0d..d7a24ad6b5c0 100644 --- a/wizards/com/sun/star/wizards/common/ConfigGroup.py +++ b/wizards/com/sun/star/wizards/common/ConfigGroup.py @@ -5,8 +5,6 @@ import inspect class ConfigGroup(ConfigNode): - root = None - def writeConfiguration(self, configurationView, param): for name,data in inspect.getmembers(self): if name.startswith(param): @@ -16,7 +14,6 @@ class ConfigGroup(ConfigNode): propertyName = field[len(prefix):] child = getattr(self, field) if isinstance(child, ConfigNode): - child.setRoot(self.root) child.writeConfiguration(configView.getByName(propertyName), prefix) else: @@ -31,7 +28,6 @@ class ConfigGroup(ConfigNode): propertyName = field[len(prefix):] child = getattr(self, field) if isinstance(child, ConfigNode): - child.setRoot(self.root) child.readConfiguration(configView.getByName(propertyName), prefix) else: diff --git a/wizards/com/sun/star/wizards/common/ConfigNode.py b/wizards/com/sun/star/wizards/common/ConfigNode.py index d97ac1b646c4..0dc38c018d9a 100644 --- a/wizards/com/sun/star/wizards/common/ConfigNode.py +++ b/wizards/com/sun/star/wizards/common/ConfigNode.py @@ -9,7 +9,3 @@ class ConfigNode(object): @abstractmethod def writeConfiguration(self, configurationView, param): pass - - @abstractmethod - def setRoot(self, root): - pass diff --git a/wizards/com/sun/star/wizards/common/ConfigSet.py b/wizards/com/sun/star/wizards/common/ConfigSet.py index ca3a2da1d4dd..7851fea45556 100644 --- a/wizards/com/sun/star/wizards/common/ConfigSet.py +++ b/wizards/com/sun/star/wizards/common/ConfigSet.py @@ -24,17 +24,73 @@ class ConfigSet(ConfigNode): i = name self.childrenList.insert(i, o) else: - i = o.cp_Index - oldSize = self.getSize() - if oldSize <= i: - newSize = i - oldSize - self.childrenList += [None] * newSize - self.noNulls = True - else: - self.noNulls = False - self.childrenList.insert(i, o); - if oldSize > i: - oldSize = i + try: + i = o.cp_Index + oldSize = self.getSize() + if oldSize <= i: + newSize = i - oldSize + self.childrenList += [None] * newSize + self.noNulls = True + else: + self.noNulls = False + self.childrenList.insert(i, o); + if oldSize > i: + oldSize = i + except Exception: + self.childrenList.append(o) + + def writeConfiguration(self, configView, param): + names = self.childrenMap.keys() + if isinstance(self.childClass, ConfigNode): + #first I remove all the children from the configuration. + children = configView.ElementNames + if children: + for i in children: + try: + Configuration.removeNode(configView, i) + except Exception: + traceback.print_exc() + + # and add them new. + for i in names: + try: + child = self.getElement(i) + childView = configView.getByName(i) + child.writeConfiguration(childView, param) + except Exception: + traceback.print_exc() + else: + raise AttributeError ( + "Unable to write primitive sets to configuration (not implemented)") + + def readConfiguration(self, configurationView, param): + names = configurationView.ElementNames + if isinstance(self.childClass, ConfigNode): + if names: + for i in names: + try: + child = type(self.childClass)() + child.readConfiguration( + configurationView.getByName(i), param) + self.add(i, child) + except Exception, ex: + traceback.print_exc() + #remove any nulls from the list + if self.noNulls: + i = 0 + while i < len(self.childrenList): + if self.childrenList[i] is None: + del self.childrenList[i] + i -= 1 + i += 1 + + else: + for i in names: + try: + child = configurationView.getByName(i) + self.add(i, child) + except Exception, ex: + traceback.print_exc() def remove(self, obj): key = getKey(obj) @@ -62,9 +118,6 @@ class ConfigSet(ConfigNode): i += 1 return parent - def items(self): - return self.childrenList.toArray() - def getKey(self, object): i = self.childrenMap.entrySet().iterator() while i.hasNext(): @@ -86,9 +139,6 @@ class ConfigSet(ConfigNode): else: return getKey(getElementAt(c - 1)) - def setRoot(self, newRoot): - self.root = newRoot - def getElementAt(self, i): return self.childrenList[i] @@ -147,4 +197,4 @@ class ConfigSet(ConfigNode): i += 1 def sort(self, comparator): - Collections.sort(self.childrenList, comparator) + self.childrenList.sort(comparator) diff --git a/wizards/com/sun/star/wizards/common/FileAccess.py b/wizards/com/sun/star/wizards/common/FileAccess.py index 1f6f741ad5dc..5c288a7c149b 100644 --- a/wizards/com/sun/star/wizards/common/FileAccess.py +++ b/wizards/com/sun/star/wizards/common/FileAccess.py @@ -287,88 +287,11 @@ class FileAccess(object): return True return False - except CommandAbortedException, exception: - sMsgNoDir = JavaTools.replaceSubString(sNoDirCreation, Path, "%1") - SystemDialog.showMessageBox(xMSF, "ErrorBox", OK, sMsgNoDir) - return False - except com.sun.star.uno.Exception, Exception: + except Exception: sMsgNoDir = JavaTools.replaceSubString(sNoDirCreation, Path, "%1") SystemDialog.showMessageBox(xMSF, "ErrorBox", OK, sMsgNoDir) return False - ''' - checks if the root of a path exists. if the parameter - xWindowPeer is not null then also the directory is - created when it does not exists and the user - ''' - - @classmethod - def PathisValid(self, xMSF, Path, sMsgFilePathInvalid, - baskbeforeOverwrite): - try: - SubDirPath = "" - bSubDirexists = True - NewPath = Path - xInterface = xMSF.createInstance( - "com.sun.star.ucb.SimpleFileAccess") - if baskbeforeOverwrite: - if xInterface.exists(Path): - oResource = Resource.Resource_unknown(xMSF, - "ImportWizard", "imp") - sFileexists = oResource.getResText(1053) - NewString = JavaTools.convertfromURLNotation(Path) - sFileexists = JavaTools.replaceSubString(sFileexists, - NewString, "<1>") - sFileexists = JavaTools.replaceSubString(sFileexists, - str(13), "<CR>") - iLeave = SystemDialog.showMessageBox(xMSF, "QueryBox", - YES_NO, sFileexists) - if iLeave == 3: - return False - - DirArray = JavaTools.ArrayoutofString(Path, "/") - MaxIndex = DirArray.length - 1 - if MaxIndex > 0: - i = MaxIndex - while i >= 0: - SubDir = DirArray[i] - SubLen = SubDir.length() - NewLen = NewPath.length() - RestLen = NewLen - SubLen - if RestLen > 0: - NewPath = NewPath.substring(0, NewLen - SubLen - 1) - if i == MaxIndex: - SubDirPath = NewPath - - bexists = xSimpleFileAccess.exists(NewPath) - if bexists: - LowerCasePath = NewPath.toLowerCase() - bexists = (((LowerCasePath.equals("file:#/")) or - (LowerCasePath.equals("file:#")) or - (LowerCasePath.equals("file:/")) or - (LowerCasePath.equals("file:"))) == False) - - if bexists: - if bSubDirexists == False: - bSubDiriscreated = createSubDirectory(xMSF, - xSimpleFileAccess, SubDirPath) - return bSubDiriscreated - - return True - else: - bSubDirexists = False - - i -= 1 - - SystemDialog.showMessageBox(xMSF, "ErrorBox", OK, - sMsgFilePathInvalid) - return False - except com.sun.star.uno.Exception, exception: - traceback.print_exc() - SystemDialog.showMessageBox(xMSF, "ErrorBox", OK, - sMsgFilePathInvalid) - return False - @classmethod def getFolderTitles(self, xMSF, FilterName, FolderName): LocLayoutFiles = [[2],[]] @@ -453,7 +376,7 @@ class FileAccess(object): sFoundFile = sPath i += 1 - except com.sun.star.uno.Exception, e: + except Exception, e: pass return sFoundFile @@ -482,11 +405,7 @@ class FileAccess(object): def getURL(self, path, childPath=None): try: - if childPath is not None: - path = self.filenameConverter.getSystemPathFromFileURL(path) - f = open(path,childPath, 'w') - else: - f = open(path, 'w') + f = open(path, 'w') r = self.filenameConverter.getFileURLFromSystemPath(path, osPath.abspath(path)) @@ -530,9 +449,7 @@ class FileAccess(object): try: self.fileAccess.createFolder(s) return True - except CommandAbortedException, cax: - traceback.print_exc() - except com.sun.star.uno.Exception, ex: + except Exception: traceback.print_exc() return False @@ -548,12 +465,10 @@ class FileAccess(object): def exists(self, filename, defe): try: return self.fileAccess.exists(filename) - except CommandAbortedException, cax: - pass except Exception: - pass + traceback.print_exc() - return defe + #return defe ''' @author rpiterman @@ -564,10 +479,8 @@ class FileAccess(object): def isDirectory(self, filename): try: return self.fileAccess.isFolder(filename) - except CommandAbortedException, cax: - pass - except com.sun.star.uno.Exception, ex: - pass + except Exception: + traceback.print_exc() return False @@ -582,10 +495,8 @@ class FileAccess(object): def listFiles(self, dir, includeFolders): try: return self.fileAccess.getFolderContents(dir, includeFolders) - except CommandAbortedException, cax: - pass - except com.sun.star.uno.Exception, ex: - pass + except Exception: + traceback.print_exc() return range(0) @@ -599,9 +510,7 @@ class FileAccess(object): try: self.fileAccess.kill(file) return True - except CommandAbortedException, cax: - traceback.print_exc() - except com.sun.star.uno.Exception, ex: + except Exception: traceback.print_exc() return False @@ -647,20 +556,16 @@ class FileAccess(object): try: self.fileAccess.copy(source, target) return True - except CommandAbortedException, cax: - pass - except com.sun.star.uno.Exception, ex: - pass + except Exception: + traceback.print_exc() return False def getLastModified(self, url): try: return self.fileAccess.getDateTimeModified(url) - except CommandAbortedException, cax: - pass - except com.sun.star.uno.Exception, ex: - pass + except Exception: + traceback.print_exc() return None @@ -677,32 +582,32 @@ class FileAccess(object): return url[:url.rfind("/")] def createNewDir(self, parentDir, name): - s = getNewFile(parentDir, name, "") - if mkdir(s): + s = self.getNewFile(parentDir, name, "") + if self.mkdir(s): return s else: return None def getNewFile(self, parentDir, name, extension): i = 0 - tmp_do_var2 = True - while tmp_do_var2: - filename = filename(name, extension, (i + 1)) - u = getURL(parentDir, filename) - url = u - tmp_do_var2 = exists(url, True) + temp = True + while temp: + filename = self.filename(name, extension, i) + url = parentDir + "/" + filename + temp = self.exists(url, True) + i += 1 return url @classmethod def filename(self, name, ext, i): stringI = "" stringExt = "" - if i is not 0: + if i != 0: stringI = str(i) - if ext is not "": + if ext != "": stringExt = "." + ext - return name + stringI + StringExt + return name + stringI + stringExt def getSize(self, url): try: diff --git a/wizards/com/sun/star/wizards/common/Helper.py b/wizards/com/sun/star/wizards/common/Helper.py index fa0793a9a5b6..a31a6376fe8d 100644 --- a/wizards/com/sun/star/wizards/common/Helper.py +++ b/wizards/com/sun/star/wizards/common/Helper.py @@ -88,7 +88,7 @@ class Helper(object): self.setUnoPropertyValue( xMultiPSetLst, PropertyNames[index], workwith) - except Exception, e: + except Exception: traceback.print_exc() ''' diff --git a/wizards/com/sun/star/wizards/common/Properties.py b/wizards/com/sun/star/wizards/common/Properties.py index fc0abe99ff13..4a906ed27d79 100644 --- a/wizards/com/sun/star/wizards/common/Properties.py +++ b/wizards/com/sun/star/wizards/common/Properties.py @@ -27,13 +27,10 @@ class Properties(dict): return False @classmethod - def getProperties(self, _map=None): - if _map is None: - _map = self - pv = PropertyValue[_map.size()] - it = _map.keySet().iterator() - while i in pv: - i = createProperty(it.next(), _map) + def getProperties(self, _map): + pv = [] + for k,v in _map.items(): + pv.append(self.createProperty(k, v)) return pv @classmethod diff --git a/wizards/com/sun/star/wizards/document/OfficeDocument.py b/wizards/com/sun/star/wizards/document/OfficeDocument.py index 70e6487b594d..62f385a61265 100644 --- a/wizards/com/sun/star/wizards/document/OfficeDocument.py +++ b/wizards/com/sun/star/wizards/document/OfficeDocument.py @@ -66,6 +66,7 @@ class OfficeDocument(object): (implements XComponent) object ( XTextDocument, or XSpreadsheedDocument ) ''' + @classmethod def createNewDocument(self, frame, sDocumentType, preview, readonly): loadValues = range(2) loadValues[0] = uno.createUnoStruct( @@ -83,13 +84,13 @@ class OfficeDocument(object): loadValues[1].Value = True else: loadValues[1].Value = False - sURL = "private:factory/" + sDocumentType + xComponent = None try: xComponent = frame.loadComponentFromURL( - sURL, "_self", 0, loadValues) + sURL, "_self", 0, tuple(loadValues)) - except Exception, exception: + except Exception: traceback.print_exc() return xComponent @@ -255,6 +256,7 @@ class OfficeDocument(object): else: return typeDetect.getByName(type) + @classmethod def getTypeMediaDescriptor(self, xmsf, type): typeDetect = xmsf.createInstance( "com.sun.star.document.TypeDetection") 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 000000000000..b3842b85b7ae --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/DocumentPreview.py @@ -0,0 +1,85 @@ +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 + +''' +@author rpiterman +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.getProperties(ps)) + + def reload(self, xmsf): + self.closeFrame() + self.createPreviewFrame(xmsf, self.xControl) + self.setDocument(self.url, self.loadArgs) + + def closeFrame(self): + if self.xFrame is not None: + self.xFrame.close(False) + + ''' + create a new frame with a new container window inside, + which isnt part of the global frame tree. + + Attention: + a) This frame wont 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. Dont 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/PeerConfig.py b/wizards/com/sun/star/wizards/ui/PeerConfig.py index 9026debc73c0..b43d8bd5cc13 100644 --- a/wizards/com/sun/star/wizards/ui/PeerConfig.py +++ b/wizards/com/sun/star/wizards/ui/PeerConfig.py @@ -13,20 +13,36 @@ class PeerConfig(object): 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_ + def __init__(self, _xControl, _propNames, _propValues): + self.propnames = _propNames + self.propvalues = _propValues self.xControl = _xControl + class ImageUrlTask(object): + + def __init__(self, _oModel, _oResource, _oHCResource): + self.oModel = _oModel + self.oResource = _oResource + self.oHCResource = _oHCResource + def windowShown(self): try: for i in self.m_aPeerTasks: xVclWindowPeer = i.xControl.Peer xVclWindowPeer.setProperty(i.propnames, i.propvalues) + for i in self.aImageUrlTasks: + if isinstance(aImageUrlTask.oResource, int): + sImageUrl = oUnoDialog.getWizardImageUrl(aImageUrlTask.oResource, aImageUrlTask.oHCResource) + elif isinstance(aImageUrlTask.oResource, str): + sImageUrl = oUnoDialog.getImageUrl(aImageUrlTask.oResource, aImageUrlTask.oHCResource) + if sImageUrl != "": + Helper.setUnoPropertyValue(aImageUrlTask.oModel, PropertyNames.PROPERTY_IMAGEURL, sImageUrl) + except Exception: traceback.print_exc() @@ -40,3 +56,7 @@ class PeerConfig(object): def setPeerProperties(self, _xControl, propnames, propvalues): oPeerTask = self.PeerTask(_xControl, propnames, propvalues) self.m_aPeerTasks.append(oPeerTask) + + def setImageUrl(self, _ocontrolmodel, _oResource, _oHCResource): + oImageUrlTask = self.ImageUrlTask(_ocontrolmodel, _oResource, _oHCResource) + self.aImageUrlTasks.append(oImageUrlTask) diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.py b/wizards/com/sun/star/wizards/ui/UnoDialog.py index 8568d88d5aa2..514978af692f 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog.py +++ b/wizards/com/sun/star/wizards/ui/UnoDialog.py @@ -128,25 +128,6 @@ class UnoDialog(object): xListBox.selectItemPos(iSelIndex, True) ''' - 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". Therfor a control meant - to be invisible is placed on a step far far away. - @param the name of the control - @param iStep change the step if you want to make the control invisible - ''' - - def setControlVisible(self, controlname, iStep): - try: - iCurStep = int(getControlProperty( - controlname, PropertyNames.PROPERTY_STEP)) - setControlProperty( - controlname, PropertyNames.PROPERTY_STEP, iStep) - except com.sun.star.uno.Exception, exception: - traceback.print_exc() - - ''' 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 @@ -297,11 +278,6 @@ class UnoDialog(object): return self.executeDialog( Rectangle (0, 0, 640, 400)) - def setAutoMnemonic(self, ControlName, bValue): - self.xUnoDialog = self.xUnoDialog.getControl(ControlName) - xVclWindowPedsfer = self.xUnoDialog.getPeer() - self.xContainerWindow.setProperty("AutoMnemonics", bValue) - def modifyFontWeight(self, ControlName, FontWeight): oFontDesc = FontDescriptor.FontDescriptor() oFontDesc.Weight = FontWeight @@ -339,11 +315,6 @@ class UnoDialog(object): setControlProperty(ListBoxName, "SelectedItems", [SelPos]) xListBox.selectItemPos((short)(SelPos - 1), True) - def setPeerProperty(self, ControlName, PropertyName, PropertyValue): - xControl = self.xUnoDialog.getControl(ControlName) - xVclWindowPeer = self.xControl.getPeer() - self.xContainerWindow.setProperty(PropertyName, PropertyValue) - @classmethod def setEnabled(self, control, enabled): Helper.setUnoPropertyValue( diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.py b/wizards/com/sun/star/wizards/ui/WizardDialog.py index d29366ab9b91..8d5907dd6737 100644 --- a/wizards/com/sun/star/wizards/ui/WizardDialog.py +++ b/wizards/com/sun/star/wizards/ui/WizardDialog.py @@ -47,9 +47,6 @@ class WizardDialog(UnoDialog2): UIConsts.RID_DB_COMMON + 33) self.oRoadmap = None - def getResource(self): - return self.__oWizardResource - def itemStateChanged(self, itemEvent): try: self.nNewStep = itemEvent.ItemId @@ -445,7 +442,7 @@ class WizardDialog(UnoDialog2): def cancelWizard(self): #can be overwritten by extending class - xDialog.endExecute() + self.xUnoDialog.endExecute() def removeTerminateListener(self): if self.__bTerminateListenermustberemoved: diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.py b/wizards/com/sun/star/wizards/ui/event/DataAware.py index 83f7845e8bf5..b611c3a79069 100644 --- a/wizards/com/sun/star/wizards/ui/event/DataAware.py +++ b/wizards/com/sun/star/wizards/ui/event/DataAware.py @@ -32,6 +32,9 @@ class DataAware(object): self._dataObject = dataObject_ self._field = field_ + def enableControls(self, value): + pass + ''' sets the given value to the UI control @param newValue the value to set to the ui control. @@ -63,6 +66,7 @@ class DataAware(object): except Exception, ex: traceback.print_exc() #TODO tell user... + self.enableControls(data) ''' updates the DataObject according to @@ -78,5 +82,6 @@ class DataAware(object): #Selected Element listbox ui = ui[0] setattr(self._dataObject, self._field, ui) + self.enableControls(ui) except Exception: traceback.print_exc() 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 000000000000..183bab050139 --- /dev/null +++ b/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py @@ -0,0 +1,75 @@ +from common.Helper import Helper + +class ListModelBinder(object): + + def __init__(self, unoListBox, listModel_): + self.unoList = unoListBox + self.unoListModel = unoListBox.Model + #COMMENTED + #self.setListModel(listModel_) + + def setListModel(self, newListModel): + if self.listModel is not None: + self.listModel.removeListDataListener(self) + + self.listModel = newListModel + self.listModel.addListDataListener(this) + + def contentsChanged(self, lde): + selected = getSelectedItems() + i = lde.getIndex0() + while i <= lde.getIndex1(): + update(i) + i += 1 + setSelectedItems(selected) + + def update(self, i): + remove(i, i) + insert(i) + + def remove(self, i1, i2): + self.unoList.removeItems(i1, i2 - i1 + 1) + + def insert(self, i): + self.unoList.addItem(getItemString(i), i) + + def getItemString(self, i): + return getItemString(self.listModel.getElementAt(i)) + + def getItemString(self, item): + return self.renderer.render(item) + + def getSelectedItems(self): + return Helper.getUnoPropertyValue(self.unoListModel, "SelectedItems") + + def setSelectedItems(self, selected): + Helper.setUnoPropertyValue(self.unoListModel, "SelectedItems", selected) + + def intervalAdded(self, lde): + for i in xrange(lde.Index0, lde.Index1): + insert(i) + + def intervalRemoved(self, lde): + remove(lde.Index0, lde.Index1) + + @classmethod + def fillList(self, xlist, items, renderer): + Helper.setUnoPropertyValue(xlist.Model, "StringItemList", ()) + for index,item in enumerate(items): + if item is not None: + if renderer is not None: + aux = renderer.render(index) + else: + aux = item.cp_Name + xlist.addItem(aux, index) + + @classmethod + def fillComboBox(self, xComboBox, items, renderer): + Helper.setUnoPropertyValue(xComboBox.Model, "StringItemList", ()) + for index,item in enumerate(items): + if item is not None: + if renderer is not None: + aux = renderer.render(index) + else: + aux = item.toString() + xComboBox.addItem(aux, index) diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py index ba1e6e92a924..83c61db5a6a1 100644 --- a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py +++ b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py @@ -14,6 +14,8 @@ For those controls, static convenience methods are offered, to simplify use. class UnoDataAware(DataAware): + disableObjects = [] + def __init__(self, dataObject, field, unoObject_, unoPropName_, isShort=False): super(UnoDataAware,self).__init__(dataObject, field) self.unoControl = unoObject_ @@ -21,6 +23,11 @@ class UnoDataAware(DataAware): self.unoPropName = unoPropName_ self.isShort = isShort + def enableControls(self, value): + for i in self.disableObjects: + Helper.setUnoPropertyValue( + i.Model, PropertyNames.PROPERTY_ENABLED, value) + def setToUI(self, value): if self.isShort: value = uno.Any("[]short", (value,)) diff --git a/wizards/com/sun/star/wizards/web/StylePreview.py b/wizards/com/sun/star/wizards/web/StylePreview.py new file mode 100644 index 000000000000..1ad6f9561cda --- /dev/null +++ b/wizards/com/sun/star/wizards/web/StylePreview.py @@ -0,0 +1,76 @@ +from common.FileAccess import FileAccess +import traceback + +''' +@author rpiterman +the style preview, which is a OOo Document Preview in +an Image Control. +This class copies the files needed for this +preview from the web wizard work directory +to a given temporary directory, and updates them +on request, according to the current style/background selection +of the user. +''' + +class StylePreview(object): + + ''' + copies the html file to the temp directory, and calculates the + destination names of the background and css files. + @param wwRoot is the root directory of the web wizard files ( + usually [oo]/share/template/[lang]/wizard/web + ''' + + def __init__(self, xmsf, wwRoot_): + self.fileAccess = FileAccess(xmsf) + self.tempDir = self.createTempDir(xmsf) + self.htmlFilename = FileAccess.connectURLs( + self.tempDir, "wwpreview.html") + self.cssFilename = FileAccess.connectURLs(self.tempDir, "style.css") + self.backgroundFilename = FileAccess.connectURLs( + self.tempDir, "images/background.gif") + self.wwRoot = wwRoot_ + self.fileAccess.copy(FileAccess.connectURLs( + self.wwRoot, "preview.html"), self.htmlFilename) + + ''' + copies the given style and background files to the temporary + directory. + @param style + @param background + @throws Exception + ''' + + def refresh(self, style, background): + css = FileAccess.connectURLs(self.wwRoot, "styles/" + style.cp_CssHref) + if background is None or background == "": + #delete the background image + if self.fileAccess.exists(self.backgroundFilename, False): + self.fileAccess.delete(self.backgroundFilename) + else: + # a solaris bug workaround + # TODO + #copy the background image to the temp directory. + self.fileAccess.copy(background, self.backgroundFilename) + + #copy the actual css to the temp directory + self.fileAccess.copy(css, self.cssFilename) + + def cleanup(self): + try: + self.fileAccess.delete(self.tempDir) + except Exception: + traceback.print_exc() + + ''' + creates a temporary directory. + @param xmsf + @return the url of the new directory. + @throws Exception + ''' + + def createTempDir(self, xmsf): + tempPath = FileAccess.getOfficePath2(xmsf, "Temp", "", "") + s = self.fileAccess.createNewDir(tempPath, "wwiz") + self.fileAccess.createNewDir(s, "images") + return s diff --git a/wizards/com/sun/star/wizards/web/WWD_Events.py b/wizards/com/sun/star/wizards/web/WWD_Events.py new file mode 100644 index 000000000000..447a0b6b29dc --- /dev/null +++ b/wizards/com/sun/star/wizards/web/WWD_Events.py @@ -0,0 +1,854 @@ +import traceback +from common.Desktop import Desktop +from WWD_Startup import WWD_Startup + +''' +This class implements the ui-events of the +web wizard. +it is therfore sorted to steps. +not much application-logic here - just plain +methods which react to events. +The only exception are the finish methods with the save +session methods. +''' + +class WWD_Events(WWD_Startup): + EMPTY_SHORT_ARRAY = range(0) + EMPTY_STRING_ARRAY = range(0) + + ''' + He - my constructor ! + I add a window listener, which, when + the window closes, deltes the temp directory. + ''' + + def __init__(self, xmsf): + super(WWD_Events, self).__init__(xmsf) + self.chkFTP.addKeyListener(None) + self.chkLocalDir.addKeyListener(None) + self.chkZip.addKeyListener(None) + self.currentSession = "" + self.exitOnCreate = True + self.time = 0 + self.count = 0 + + @classmethod + def main(self, args): + ConnectStr = \ + "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" + try: + xmsf = Desktop.connect(ConnectStr) + ww = WWD_Events(xmsf) + ww.show() + ww.cleanup() + except Exception: + traceback.print_exc() + + def leaveStep(self, nOldStep, nNewStep): + pass + + def enterStep(self, old, newStep): + if (old == 1): + sessionToLoad = "" + s = Helper.getUnoPropertyValue(lstLoadSettings.Model, "SelectedItems") + if s.length == 0 or s[0] == 0: + sessionToLoad = "" + else: + sessionToLoad = \ + settings.cp_SavedSessions.getElementAt(s[0]).cp_Name + + if not sessionToLoad.equals(self.currentSession): + loadSession(sessionToLoad) + + ''' + ************** + STEP 1 + ************** + ''' + + ''' + Called from the Uno event dispatcher when the + user selects a saved session. + ''' + def sessionSelected(self): + s = Helper.getUnoPropertyValue(getModel(lstLoadSettings), "SelectedItems") + setEnabled(btnDelSession, s.length > 0 and s[0] > 0) + + ''' + Ha ! the session should be loaded :-) + ''' + + def loadSession(self, sessionToLoad): + try: + sd = self.getStatusDialog() + task = Task("LoadDocs", "", 10) + sd.execute(this, task, resources.resLoadingSession) + task.start() + setSelectedDoc(WWD_Events.EMPTY_SHORT_ARRAY) + Helper.setUnoPropertyValue( + lstDocuments.Model, "SelectedItems", WWD_Events.EMPTY_SHORT_ARRAY) + Helper.setUnoPropertyValue( + lstDocuments.Model, "StringItemList", WWD_Events.EMPTY_STRING_ARRAY) + if not sessionToLoad: + view = Configuration.getConfigurationRoot( + xMSF, CONFIG_PATH + "/DefaultSession", False) + else: + view = Configuration.getConfigurationRoot( + xMSF, CONFIG_PATH + "/SavedSessions", False) + view = Configuration.getNode(sessionToLoad, view) + + session = CGSession.CGSession() + session.setRoot(settings) + session.readConfiguration(view, CONFIG_READ_PARAM) + task.setMax(session.cp_Content.cp_Documents.getSize() * 5 + 7) + task.advance(True) + if sessionToLoad.equals(""): + setSaveSessionName(session) + + mount(session, task, False, sd.xControl) + checkSteps() + self.currentSession = sessionToLoad + while task.getStatus() <= task.getMax(): + task.advance(False) + task.removeTaskListener(sd) + except Exception, ex: + unexpectedError(ex) + + try: + refreshStylePreview() + updateIconsetText() + except Exception, e: + # TODO Auto-generated catch block + e.printStackTrace() + + ''' + hmm. the user clicked the delete button. + ''' + + def delSession(self): + selected = Helper.getUnoPropertyValue( + lstLoadSettings.Model, "SelectedItems") + if selected.length == 0: + return + + if selected[0] == 0: + return + + confirm = AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, resources.resDelSessionConfirm, + ErrorHandler.ERROR_QUESTION_NO) + if confirm: + try: + name = settings.cp_SavedSessions.getKey(selected[0]) + # first delete the session from the registry/configuration. + Configuration.removeNode( + self.xMSF, CONFIG_PATH + "/SavedSessions", name) + # then delete settings.cp_SavedSessions + settings.cp_SavedSessions.remove(selected[0]) + settings.savedSessions.remove(selected[0] - 1) + nextSelected = [0] + # We try to select the same item index again, if possible + if settings.cp_SavedSessions.getSize() > selected[0]: + nextSelected[0] = selected[0] + else: + # this will always be available because + # the user can not remove item 0. + nextSelected[0] = (short)(selected[0] - 1) + # if the <none> session will + # be selected, disable the remove button... + if nextSelected[0] == 0: + Helper.setUnoPropertyValue( + btnDelSession.Model, + PropertyNames.PROPERTY_ENABLED, False) + # select... + + Helper.setUnoPropertyValue( + lstLoadSettings.Model, "SelectedItems", nextSelected) + + except Exception, ex: + ex.printStackTrace() + unexpectedError(ex) + + ''' + ************** + STEP 2 + ************** + ''' + + ''' + when the user clicks another document + in the listbox, this method is called, + and couses the display in + the textboxes title,description, author and export format + to change + ''' + + def setSelectedDoc(self, s): + oldDoc = getDoc(selectedDoc) + doc = getDoc(s) + if doc == None: + fillExportList(WWD_Events.EMPTY_STRING_ARRAY) + #I try to avoid refreshing the export list if + #the same type of document is chosen. + elif oldDoc == None or (not oldDoc.appType.equals(doc.appType)): + fillExportList(settings.getExporters(doc.appType)) + else: + + # do nothing + selectedDoc = s + mount(doc, docAware) + disableDocUpDown() + + ''' + The user clicks the "Add" button. + This will open a "FileOpen" dialog, + and, if the user chooses more than one file, + will open a status dialog, when validating each document. + ''' + + def addDocument(self): + files = getDocAddDialog().callOpenDialog( + True, settings.cp_DefaultSession.cp_InDirectory) + if files is None: + return + + task = Task.Task_unknown("", "", files.length * 5) + ''' + If more than a certain number + of documents have been added, + open the status dialog. + ''' + if (files.length > MIN_ADD_FILES_FOR_DIALOG): + sd = getStatusDialog() + sd.setLabel(resources.resValidatingDocuments) + sd.execute(this, task, resources.prodName) + # new LoadDocs( sd.xControl, files, task ) + oLoadDocs = LoadDocs.LoadDocs_unknown(self.xControl, files, task) + oLoadDocs.loadDocuments() + task.removeTaskListener(sd) + else: + ''' + When adding a single document, do not use a + status dialog... + ''' + oLoadDocs = LoadDocs.LoadDocs_unknown(self.xControl, files, task) + oLoadDocs.loadDocuments() + + ''' + The user clicked delete. + ''' + + def removeDocument(self): + if selectedDoc.length == 0: + return + + settings.cp_DefaultSession.cp_Content.cp_Documents.remove( + selectedDoc[0]) + # update the selected document + while selectedDoc[0] >= getDocsCount(): + selectedDoc[0] -= 1 + # if there are no documents... + if selectedDoc[0] == -1: + selectedDoc = WWD_Events.EMPTY_SHORT_ARRAY + # update the list to show the right selection. + + docListDA.updateUI() + # disables all the next steps, if the list of docuemnts + # is empty. + checkSteps() + + ''' + doc up. + ''' + + def docUp(self): + doc = settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt( + selectedDoc[0]) + settings.cp_DefaultSession.cp_Content.cp_Documents.remove( + selectedDoc[0]) + settings.cp_DefaultSession.cp_Content.cp_Documents.add( + selectedDoc[0] - 1, doc) + docListDA.updateUI() + disableDocUpDown() + + ''' + doc down + ''' + + def docDown(self): + doc = settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt( + selectedDoc[0]) + settings.cp_DefaultSession.cp_Content.cp_Documents.remove( + selectedDoc[0]) + settings.cp_DefaultSession.cp_Content.cp_Documents.add( + (selectedDoc[0] + 1), doc) + docListDA.updateUI() + disableDocUpDown() + + ''' + ************** + STEP 5 + ************** + ''' + + ''' + the user clicked the "backgrounds" button + ''' + + def chooseBackground(self): + try: + setEnabled(btnBackgrounds, False) + if self.bgDialog == None: + self.bgDialog = BackgroundsDialog( + self.xMSF, settings.cp_BackgroundImages, resources) + self.bgDialog.createWindowPeer(xControl.Peer) + + self.bgDialog.setSelected( + settings.cp_DefaultSession.cp_Design.cp_BackgroundImage) + i = self.bgDialog.executeDialog(WWD_Events.this) + if i == 1: + #ok + setBackground(self.bgDialog.getSelected()) + except Exception, ex: + ex.printStackTrace() + finally: + setEnabled(btnBackgrounds, True) + + ''' + invoked when the BackgorundsDialog is "OKed". + ''' + + def setBackground(self, background): + if background == None: + background = "" + + settings.cp_DefaultSession.cp_Design.cp_BackgroundImage = background + refreshStylePreview() + + ''' + is called when the user clicks "Icon sets" button. + ''' + + def chooseIconset(self): + try: + setEnabled(btnIconSets, False) + if self.iconsDialog == None: + self.iconsDialog = IconsDialog( + self.xMSF, settings.cp_IconSets, resources) + self.iconsDialog.createWindowPeer(xControl.Peer) + + self.iconsDialog.setIconset( + settings.cp_DefaultSession.cp_Design.cp_IconSet) + i = self.iconsDialog.executeDialog(WWD_Events.this) + if i == 1: + #ok + setIconset(self.iconsDialog.getIconset()) + except Exception, ex: + ex.printStackTrace() + finally: + setEnabled(btnIconSets, True) + + ''' + invoked when the Iconsets Dialog is OKed. + ''' + + def setIconset(self, icon): + settings.cp_DefaultSession.cp_Design.cp_IconSet = icon + updateIconsetText() + + ''' + ************** + STEP 7 + ************** + ''' + + ''' + sets the publishing url of either a local/zip or ftp publisher. + updates the ui.... + ''' + def setPublishUrl(self, publisher, url, number): + if url == None: + return None + + p = getPublisher(publisher) + p.cp_URL = url + p.cp_Publish = True + updatePublishUI(number) + p.overwriteApproved = True + return p + + ''' + updates the ui of a certain publisher + (the text box url) + @param number + ''' + + def updatePublishUI(self, number): + (pubAware.get(number)).updateUI() + (pubAware.get(number + 1)).updateUI() + checkPublish() + + ''' + The user clicks the local "..." button. + ''' + + def setPublishLocalDir(self): + dir = showFolderDialog( + "Local destination directory", "", + settings.cp_DefaultSession.cp_OutDirectory) + #if ok was pressed... + setPublishUrl(LOCAL_PUBLISHER, dir, 0) + + ''' + The user clicks the "Configure" FTP button. + ''' + + def setFTPPublish(self): + if showFTPDialog(getPublisher(FTP_PUBLISHER)): + getPublisher + (FTP_PUBLISHER).cp_Publish = True + updatePublishUI(2) + + ''' + show the ftp dialog + @param pub + @return true if OK was pressed, otherwise false. + ''' + + def showFTPDialog(self, pub): + try: + return getFTPDialog(pub).execute(this) == 1 + except Exception, ex: + ex.printStackTrace() + return False + + ''' + the user clicks the zip "..." button. + Choose a zip file... + ''' + + def setZipFilename(self): + sd = getZipDialog() + zipFile = sd.callStoreDialog( + settings.cp_DefaultSession.cp_OutDirectory, + resources.resDefaultArchiveFilename) + setPublishUrl(ZIP_PUBLISHER, zipFile, 4) + getPublisher + (ZIP_PUBLISHER).overwriteApproved = True + + ''' + the user clicks the "Preview" button. + ''' + + def documentPreview(self): + try: + if self.docPreview == None: + self.docPreview = TOCPreview( + self.xMSF, settings, resources, + stylePreview.tempDir, myFrame) + + self.docPreview.refresh(settings) + except Exception, ex: + unexpectedError(ex) + + ''' + ************** + FINISH + ************** + ''' + + ''' + This method checks if the given target's path, + added the pathExtension argument, exists, + and asks the user what to do about it. + If the user says its all fine, then the target will + be replaced. + @return true if "create" should continue. false if "create" should abort. + ''' + def publishTargetApproved(self): + result = True + # 1. check local publish target + p = getPublisher(LOCAL_PUBLISHER) + # should publish ? + if (p.cp_Publish): + path = getFileAccess().getPath(p.url, None) + # target exists? + if getFileAccess().exists(p.url, False): + #if its a directory + if getFileAccess().isDirectory(p.url): + #check if its empty + files = getFileAccess().listFiles(p.url, True) + if files.length > 0: + ''' + it is not empty :-( + it either a local publisher or an ftp + (zip uses no directories as target...) + ''' + message = resources.resLocalTragetNotEmpty.replace( + "%FILENAME", path) + result = AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.MESSAGE_WARNING, + ErrorHandler.BUTTONS_YES_NO, ErrorHandler.DEF_NO, + ErrorHandler.RESULT_YES) + if not result: + return result + + else: + #not a directory, but still exists + message = resources.resLocalTargetExistsAsfile.replace( + "%FILENAME", path) + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_PROCESS_FATAL) + return False + + # try to write to the path... + else: + # the local target directory does not exist. + message = resources.resLocalTargetCreate.replace( + "%FILENAME", path) + try: + result = AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_QUESTION_YES) + except Exception, ex: + ex.printStackTrace() + + if not result: + return result + # try to create the directory... + + try: + getFileAccess().fileAccess.createFolder(p.cp_URL) + except Exception, ex: + message = resources.resLocalTargetCouldNotCreate.replace( + "%FILENAME", path) + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_PROCESS_FATAL) + return False + + p = getPublisher(ZIP_PUBLISHER) + if p.cp_Publish: + path = getFileAccess().getPath(p.cp_URL, None) + # target exists? + if getFileAccess().exists(p.cp_URL, False): + #if its a directory + if getFileAccess().isDirectory(p.cp_URL): + message = resources.resZipTargetIsDir.replace( + "%FILENAME", path) + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_PROCESS_FATAL) + return False + else: + #not a directory, but still exists ( a file...) + if not p.overwriteApproved: + message = resources.resZipTargetExists.replace( + "%FILENAME", path) + result = AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_QUESTION_YES) + if not result: + return False + # 3. check FTP + + p = getPublisher(FTP_PUBLISHER) + # should publish ? + if p.cp_Publish: + path = getFileAccess().getPath(p.cp_URL, None) + # target exists? + if getFileAccess().exists(p.url, False): + #if its a directory + if getFileAccess().isDirectory(p.url): + #check if its empty + files = getFileAccess().listFiles(p.url, True) + if files.length > 0: + ''' + it is not empty :-( + it either a local publisher or an ftp + (zip uses no directories as target...) + ''' + message = resources.resFTPTargetNotEmpty.replace( + "%FILENAME", path) + result = AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_QUESTION_CANCEL) + if not result: + return result + + else: + #not a directory, but still exists (as a file) + message = resources.resFTPTargetExistsAsfile.replace( + "%FILENAME", path) + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_PROCESS_FATAL) + return False + + # try to write to the path... + else: + # the ftp target directory does not exist. + message = resources.resFTPTargetCreate.replace( + "%FILENAME", path) + result = AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_QUESTION_YES) + if not result: + return result + # try to create the directory... + + try: + getFileAccess().fileAccess.createFolder(p.url) + except Exception, ex: + message = resources.resFTPTargetCouldNotCreate.replace( + "%FILENAME", path) + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, + ErrorHandler.ERROR_PROCESS_FATAL) + return False + + return True + + ''' + return false if "create" should be aborted. true if everything is fine. + ''' + + def saveSession(self): + try: + node = None + name = getSessionSaveName() + #set documents index field. + docs = settings.cp_DefaultSession.cp_Content.cp_Documents + i = 0 + while i < docs.getSize(): + (docs.getElementAt(i)).cp_Index = i + i += 1 + conf = Configuration.getConfigurationRoot( + self.xMSF, CONFIG_PATH + "/SavedSessions", True) + # first I check if a session with the given name exists + try: + node = Configuration.getNode(name, conf) + if node != None: + if not AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, + resources.resSessionExists.replace("${NAME}", name), + ErrorHandler.ERROR_NORMAL_IGNORE): + return False + #remove the old session + + Configuration.removeNode(conf, name) + except NoSuchElementException, nsex: + traceb + + settings.cp_DefaultSession.cp_Index = 0; + node = Configuration.addConfigNode(conf, name) + settings.cp_DefaultSession.cp_Name = name; + settings.cp_DefaultSession.writeConfiguration( + node, CONFIG_READ_PARAM) + settings.cp_SavedSessions.reindexSet(conf, name, "Index") + Configuration.commit(conf) + # now I reload the sessions to actualize the list/combo + # boxes load/save sessions. + settings.cp_SavedSessions.clear() + confView = Configuration.getConfigurationRoot( + self.xMSF, CONFIG_PATH + "/SavedSessions", False) + settings.cp_SavedSessions.readConfiguration( + confView, CONFIG_READ_PARAM) + settings.cp_LastSavedSession = name; + self.currentSession = name + # now save the name of the last saved session... + settings.cp_LastSavedSession = name; + # TODO add the <none> session... + prepareSessionLists() + ListModelBinder.fillList( + lstLoadSettings, settings.cp_SavedSessions.items(), None) + ListModelBinder.fillComboBox( + cbSaveSettings, settings.savedSessions.items(), None) + selectSession() + self.currentSession = settings.cp_LastSavedSession + return True + except Exception, ex: + ex.printStackTrace() + return False + + def targetStringFor(self, publisher): + p = getPublisher(publisher) + if p.cp_Publish: + return "\n" + getFileAccess().getPath(p.cp_URL, None) + else: + return "" + + ''' + this method will be called when the Status Dialog + is hidden. + It checks if the "Process" was successfull, and if so, + it closes the wizard dialog. + ''' + + def finishWizardFinished(self): + if self.process.getResult(): + targets = targetStringFor(LOCAL_PUBLISHER) + \ + targetStringFor(ZIP_PUBLISHER) + \ + targetStringFor(FTP_PUBLISHER) + message = resources.resFinishedSuccess.replace( + "%FILENAME", targets) + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, message, ErrorHandler.ERROR_MESSAGE) + if self.exitOnCreate: + self.xDialog.endExecute() + + else: + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, resources.resFinishedNoSuccess, + ErrorHandler.ERROR_WARNING) + + def cancel(self): + xDialog.endExecute() + + ''' + the user clicks the finish/create button. + ''' + + def finishWizard(self): + finishWizard(True) + return True + + ''' + finish the wizard + @param exitOnCreate_ should the wizard close after + a successfull create. + Default is true, + I have a hidden feature which enables false here + ''' + + def finishWizard(self, exitOnCreate_): + self.exitOnCreate = exitOnCreate_ + ''' + First I check if ftp password was set, if not - the ftp dialog pops up + This may happen when a session is loaded, since the + session saves the ftp url and username, but not the password. + ''' + p = getPublisher(FTP_PUBLISHER) + # if ftp is checked, and no proxies are set, and password is empty... + if p.cp_Publish and not proxies and p.password == None or \ + p.password == "": + if showFTPDialog(p): + updatePublishUI(2) + #now continue... + finishWizard2() + + else: + finishWizard2() + + ''' + this method is only called + if ftp-password was eather set, or + the user entered one in the FTP Dialog which + popped up when clicking "Create". + ''' + + def finishWizard2(self): + p = getPublisher(LOCAL_PUBLISHER) + p.url = p.cp_URL + ''' + zip publisher is using another url form... + ''' + p = getPublisher(ZIP_PUBLISHER) + #replace the '%' with '%25' + url1 = JavaTools.replaceSubString(p.cp_URL, "%25", "%") + #replace all '/' with '%2F' + url1 = JavaTools.replaceSubString(url1, "%2F", "/") + p.url = "vnd.sun.star.zip:#" + url1 + "/"; + ''' + and now ftp... + ''' + p = getPublisher(FTP_PUBLISHER) + p.url = FTPDialog.getFullURL(p); + ''' first we check the publishing targets. If they exist we warn and + ask what to do. a False here means the user said "cancel" + (or rather:clicked) + ''' + if not publishTargetApproved(): + return + ''' + In order to save the session correctly, + I return the value of the ftp publisher cp_Publish + property to its original value... + ''' + + p.cp_Publish = __ftp; + #if the "save settings" checkbox is on... + + if isSaveSession(): + # if canceled by user + if not saveSession(): + return + + else: + settings.cp_LastSavedSession = "" + + try: + conf = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH, True) + Configuration.set( + settings.cp_LastSavedSession, "LastSavedSession", conf) + Configuration.commit(conf) + except Exception, ex: + ex.printStackTrace() + + ''' + again, if proxies are on, I disable ftp before the creation process + starts. + ''' + if proxies: + p.cp_Publish = False + ''' + There is currently a bug, which crashes office when + writing folders to an existing zip file, after deleting + its content, so I "manually" delete it here... + ''' + + p = getPublisher(ZIP_PUBLISHER) + if getFileAccess().exists(p.cp_URL, False): + getFileAccess().delete(p.cp_URL) + + try: + eh = ProcessErrorHandler(xMSF, xControl.Peer, resources) + self.process = Process(settings, xMSF, eh) + pd = getStatusDialog() + pd.setRenderer(ProcessStatusRenderer (resources)) + pd.execute(self, self.process.myTask, resources.prodName) + #process, + self.process.runProcess() + finishWizardFinished() + self.process.myTask.removeTaskListener(pd) + except Exception, ex: + ex.printStackTrace() + + ''' + is called on the WindowHidden event, + deletes the temporary directory. + ''' + + def cleanup(self): + try: + self.dpStylePreview.dispose() + self.stylePreview.cleanup() + + if self.bgDialog is not None: + self.bgDialog.xComponent.dispose() + + if self.iconsDialog is not None: + self.iconsDialog.xComponent.dispose() + + if ftpDialog is not None: + ftpDialog.xComponent.dispose() + + xComponent.dispose() + + if ProcessStatusRenderer is not None: + ProcessStatusRenderer.close(False) + + except Exception, ex: + traceback.print_exc() diff --git a/wizards/com/sun/star/wizards/web/WWD_General.py b/wizards/com/sun/star/wizards/web/WWD_General.py new file mode 100644 index 000000000000..356268d6b2e2 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/WWD_General.py @@ -0,0 +1,266 @@ +from WebWizardDialog import * +from common.SystemDialog import SystemDialog + +''' +@author rpiterman +This class implements general methods, used by different sub-classes +(either WWD_Sturtup, or WWD_Events) or both. +''' + +class WWD_General(WebWizardDialog): + + ''' + @param xmsf + ''' + + def __init__(self, xmsf): + super(WWD_General, self).__init__(xmsf) + self.xStringSubstitution = SystemDialog.createStringSubstitution(xmsf) + + def getStatusDialog(self): + statusDialog = StatusDialog( + self.xMSF, StatusDialog.STANDARD_WIDTH, + resources.resLoadingSession, False, + [resources.prodName, "", "", "", "", ""], + HelpIds.getHelpIdString(HID0_STATUS_DIALOG)) + try: + statusDialog.createWindowPeer(xControl.Peer) + except Exception, e: + e.printStackTrace() + + return statusDialog + + ''' + File Dialog methods + ''' + + def getDocAddDialog(self): + self.docAddDialog = SystemDialog.createOpenDialog(xMSF) + i = 0 + while i < self.settings.cp_Filters.getSize(): + f = (self.settings.cp_Filters.getElementAt(i)) + self.docAddDialog.addFilter( + f.cp_Name.replace("%PRODNAME", resources.prodName), + f.cp_Filter, i == 0) + i += 1 + return self.docAddDialog + + def getZipDialog(self): + if self.zipDialog is None: + self.zipDialog = SystemDialog.createStoreDialog(xMSF) + self.zipDialog.addFilter(resources.resZipFiles, "*.zip", True) + + return self.zipDialog + + def getFTPDialog(self, pub): + if self.ftpDialog is None: + try: + self.ftpDialog = FTPDialog.FTPDialog_unknown(xMSF, pub) + self.ftpDialog.createWindowPeer(xControl.getPeer()) + except Exception, ex: + ex.printStackTrace() + + return self.ftpDialog + + def showFolderDialog(self, title, description, dir): + if self.folderDialog is None: + self.folderDialog = SystemDialog.createFolderDialog(xMSF) + + return self.folderDialog.callFolderDialog(title, description, dir) + + def getFileAccess(self): + if self.fileAccess is None: + try: + self.fileAccess = FileAccess(xMSF) + except Exception, ex: + ex.printStackTrace() + + return self.fileAccess + + ''' + returns the document specified + by the given short array. + @param s + @return + ''' + + def getDoc(self, s): + if s.length == 0: + return None + elif self.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() <= s[0]: + return None + else: + return self.settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt(s[0]) + + ''' + how many documents are in the list? + @return the number of documents in the docs list. + ''' + + def getDocsCount(self): + return self.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() + + ''' + fills the export listbox. + @param listContent + ''' + + def fillExportList(self, listContent): + ListModelBinder.fillList(lstDocTargetType, listContent, None) + + ''' + returns a publisher object for the given name + @param name one of the WebWizardConst constants : FTP + @return + ''' + + def getPublisher(self, name): + return self.settings.cp_DefaultSession.cp_Publishing.getElement(name) + + ''' + @return true if the checkbox "save session" is checked. + ''' + + def isSaveSession(self): + return int(Helper.getUnoPropertyValue( + chkSaveSettings.Model, PropertyNames.PROPERTY_STATE) == 1) + + ''' + @return the name to save the session (step 7) + ''' + + def getSessionSaveName(self): + return Helper.getUnoPropertyValue(getModel(cbSaveSettings), "Text") + + ''' + This method checks the status of the wizards and + enables or disables the 'next' and the 'create' button. + ''' + + def checkSteps(self): + ''' + first I check the document list. + If it is empty, then step3 and on are disabled. + ''' + if self.checkDocList(): + self.checkPublish() + + ''' + enables/disables the steps 3 to 7) + @param enabled true = enabled, false = disabled. + ''' + + def enableSteps(self, enabled): + if not enabled and not self.isStepEnabled(3): + #disbale steps 3-7 + return + + for i in xrange(3,8): + self.setStepEnabled(i, enabled, True) + ''' + in this place i just disable the finish button. + later, in the checkPublish, which is only performed if + this one is true, it will be enabled (if the check + is positive) + ''' + + if not enabled: + self.enableFinishButton(False) + + ''' + Checks if the documents list is + empty. If it is, disables the steps 3-7, and the + create button. + @return + ''' + + def checkDocList(self): + if self.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() \ + == 0: + self.enableSteps(False) + return False + else: + self.enableSteps(True) + return True + + ''' + check if the save-settings input is ok. + (eather the checkbox is unmarked, or, + if it is marked, a session name exists. + ''' + + def checkSaveSession(self): + return (not isSaveSession() or not getSessionSaveName() == "") + + ''' + @return false if this publisher is not active, or, if it + active, returns true if the url is not empty... + if the url is empty, throws an exception + ''' + + def checkPublish2(self, s, text, _property): + p = self.getPublisher(s) + if p.cp_Publish: + url = Helper.getUnoPropertyValue(text.Model, _property) + if url is None or url == "": + raise IllegalArgumentException () + else: + return True + + else: + return False + + ''' + + @return false either if publishing input is wrong or there + are no publishing targets chosen. returns true when at least + one target is chosen, *and* all + which are chosen are legal. + If proxies are on, ftp publisher is ignored. + ''' + + def checkPublish_(self): + try: + return \ + self.checkPublish2(LOCAL_PUBLISHER, self.txtLocalDir, "Text") \ + or (not self.proxies and self.checkPublish( + FTP_PUBLISHER, lblFTP, PropertyNames.PROPERTY_LABEL) \ + or self.checkPublish2(ZIP_PUBLISHER, self.txtZip, "Text")) \ + and self.checkSaveSession() + except IllegalArgumentException, ex: + return False + + ''' + This method checks if the publishing + input is ok, and enables and disables + the 'create' button. + public because it is called from + an event listener object. + ''' + + def checkPublish(self): + self.enableFinishButton(self.checkPublish_()) + + ''' + shows a message box "Unexpected Error... " :-) + @param ex + ''' + + def unexpectedError(self, ex): + ex.printStackTrace() + peer = xControl.getPeer() + AbstractErrorHandler.showMessage( + self.xMSF, peer, resources.resErrUnexpected, + ErrorHandler.ERROR_PROCESS_FATAL) + + ''' + substitutes path variables with the corresponding values. + @param path a path, which might contain OOo path variables. + @return the path, after substituing path variables. + ''' + + def substitute(self, path): + try: + return self.xStringSubstitution.substituteVariables(path, False) + except Exception, ex: + return path diff --git a/wizards/com/sun/star/wizards/web/WWD_Startup.py b/wizards/com/sun/star/wizards/web/WWD_Startup.py new file mode 100644 index 000000000000..5709de9125e0 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/WWD_Startup.py @@ -0,0 +1,623 @@ +from WWD_General import * +from common.Configuration import Configuration +from common.FileAccess import FileAccess +from data.CGSettings import CGSettings +from data.CGSessionName import CGSessionName +from ui.event.ListModelBinder import ListModelBinder +from ui.event.UnoDataAware import UnoDataAware +from ui.event.RadioDataAware import RadioDataAware +from data.CGDocument import CGDocument +from ui.DocumentPreview import DocumentPreview +from StylePreview import StylePreview + +''' +Web Wizard Dialog implementation : Startup. +This class contains the startup implementation and session mounting methods. +<h2> Data Aware Concept </h2> +<p> I use DataAware objects, which synchronize +UI and Data. A DataAware object a kind of interface +between a Value and a UI element. +</P> +<p> +A Value is either a JavaBean property with +a Getter and a Setter or a public class Memeber. +</P> +When the UI Control changes, the Value changes correspondingly. +This depends on WWD_Startup.settings a Listener which calls the updateData() +method od the DataAware object. +When the Value changes, the UI Control changes respopndingly. +This also depends on WWD_Startup.settings a Listener which calls the updateUI +method of the DataAware object. +</P> +<P> +here I use only UI Listeners, and keep calling +the updateUI() method whenever I change the Value. +</P> +To contain the Data, I use the Configuration Data Objects +which read themselfs out of the Configuration. they are all located under +the data package. +<p/> +Different groups of DataAware objects are grouped into vectors. +Each group (all elements of a vector) uses the same DataObject, +so when I change the underlying dataObject, I change the whole vector's +DataObject, thus actualizing UI.<br/> +This is what happends when a session loads: I Load the session into +a tree of DataObjects, and change the DataAware's DataObject. <br/> +One could also look at this as a kind of "View-Model" relationship. +The controls are the View, The DataObjects are the Model, containing the +Data rad directly from the configuration, and the DataAware objects +are the controller inbetween. + +@author rpiterman +''' + +class WWD_Startup(WWD_General): + + settings = None + + ''' + He - my constructor ! + I call/do here in this order: <br/> + Check if ftp http proxy is set, and warn user he can not use + ftp if it is.<br/> + draw NaviBar and steps 1 to 7, incl. Step X, + which is the Layouts ImageList on step 3.<br/> + load the WWD_Startup.settings from the configuration. <br/> + set the default save session name to the first + available one (sessionX or something like that). <br/> + set the Layouts ImageList ListModel, and call + its "create()" method. <br/> + check the content (documents) specified in the default session.<br/> + fill the list boxes (saved sessions, styles, combobox save session). <br/> + make data aware. <br/> + updateUI (refreshes the display to crrespond to the data in + the default session.)<br/> + fill the documents listbox. <br/> + if proxies are set, disable the ftp controls in step 7. + ''' + + def __init__(self, xmsf): + super(WWD_Startup, self).__init__(xmsf) + self.sda = None + self.selectedDoc = 0 + self.proxies = self.getOOProxies() + soTemplateDir = FileAccess.getOfficePath2( + xmsf, "Template", "share", "/wizard") + exclamationURL = FileAccess.connectURLs( + soTemplateDir, "../wizard/bitmap/caution_16.png") + self.drawNaviBar() + self.buildStep1() + self.buildStep2() + self.buildStep3() + self.buildStep4() + self.buildStep5() + self.buildStep6() + self.buildStep7(self.proxies, exclamationURL) + self.buildStepX() + self.xMSF = xmsf + xDesktop = Desktop.getDesktop(xmsf) + self.myFrame = OfficeDocument.createNewFrame(xmsf, self) + doc = OfficeDocument.createNewDocument( + self.myFrame, "swriter", False, True) + self.loadSettings(doc) + self.setSaveSessionName(WWD_Startup.settings.cp_DefaultSession) + self.ilLayouts.listModel = WWD_Startup.settings.cp_Layouts + self.ilLayouts.create(self) + #COMMENTED + #self.checkContent(WWD_Startup.settings.cp_DefaultSession.cp_Content, Task ("", "", 99999), self.xControl) + #saved sessions, styles, combobox save session. + # also set the chosen saved session... + self.fillLists() + self.makeDataAware() + + self.checkPublish() + + # fill the documents listbox. + #COMMENTED + #self.mount(self.settings.cp_DefaultSession.cp_Content) + if self.proxies: + self.setEnabled(btnFTP, False) + self.setEnabled(chkFTP, False) + + ''' + return true if http proxies or other proxies + which do not enable ftp to function correctly are set. + @return true if (http) proxies are on. + @throws Exception + ''' + + def getOOProxies(self): + node = Configuration.getConfigurationRoot( + self.xMSF, "org.openoffice.Inet/Settings", False) + i = int(node.getByName("ooInetProxyType")) + if i== 0: + #no proxies + return False + elif i == 2: + #http proxies + return True + else: + return True + + ''' + calculates the first available session name, + and sets the current session name to it. + The combobox text in step 7 will be updated + automatically when updateUI() is called. + ''' + + def setSaveSessionName(self, session): + maxValue = 0 + length = self.resources.resSessionName + # traverse between the sessions and find the one that + # has the biggest number. + for i in xrange(WWD_Startup.settings.cp_SavedSessions.getSize()): + sessionName = \ + WWD_Startup.settings.cp_SavedSessions.getElementAt(i).cp_Name + if sessionName.startswith(self.resources.resSessionName): + maxValue = max(maxValue, int(sessionName[length:])) + + ''' + fills the road map, and sets the necessary properties, + like MaxStep, Complete, Interactive- + Disables the finbihButton. + ''' + + def addRoadMapItems(self): + self.insertRoadMapItems( + [True, True, False, False, False, False, False], + [self.resources.resStep1, self.resources.resStep2, + self.resources.resStep3, self.resources.resStep4, + self.resources.resStep5, self.resources.resStep6, + self.resources.resStep7]) + self.setRoadmapInteractive(True) + self.setRoadmapComplete(True) + self.setCurrentRoadmapItemID(1) + self.nMaxStep = 7 + self.enableFinishButton(False) + + ''' + create the peer, add roadmap, + add roadmap items, add style-preview, + disable the steps 3 to 7 if no documents are + on the list, and... show the dialog! + ''' + + def show(self): + try: + xContainerWindow = self.myFrame.getComponentWindow() + self.createWindowPeer(xContainerWindow) + self.addRoadmap() + self.addRoadMapItems() + self.addStylePreview() + self.checkSteps() + self.executeDialogFromComponent(self.myFrame) + self.removeTerminateListener() + except Exception: + traceback.print_exc() + + ''' + initializes the style preview. + ''' + + def addStylePreview(self): + try: + self.dpStylePreview = DocumentPreview(self.xMSF, self.imgPreview) + self.stylePreview = StylePreview( + self.xMSF, WWD_Startup.settings.workPath) + self.stylePreview.refresh( + WWD_Startup.settings.cp_DefaultSession.getStyle( + WWD_Startup.settings.cp_Styles), + WWD_Startup.settings.cp_DefaultSession.cp_Design.cp_BackgroundImage) + self.dpStylePreview.setDocument( + self.stylePreview.htmlFilename, DocumentPreview.PREVIEW_MODE) + except Exception: + traceback.print_exc() + + ''' + Loads the web wizard WWD_Startup.settings from the registry. + ''' + + def loadSettings(self, document): + try: + # instanciate + WWD_Startup.settingsResources = \ + [self.resources.resPages, self.resources.resSlides, + self.resources.resCreatedTemplate, + self.resources.resUpdatedTemplate, + self.resources.resSizeTemplate] + + WWD_Startup.settings = CGSettings( + self.xMSF, WWD_Startup.settingsResources, document) + # get configuration view + confRoot = Configuration.getConfigurationRoot( + self.xMSF, CONFIG_PATH, False) + # read + WWD_Startup.settings.readConfiguration( + confRoot, CONFIG_READ_PARAM) + configSet = WWD_Startup.settings.cp_DefaultSession.cp_Publishing + # now if path variables are used in publisher pathes, they + # are getting replaced here... + for i in xrange(configSet.getSize()): + p = configSet.getElementAt(i) + p.cp_URL = self.substitute(p.cp_URL) + # initialize the WWD_Startup.settings. + WWD_Startup.settings.configure(self.xMSF) + # set resource needed for web page. + # sort the styles alphabetically + #COMMENTED + WWD_Startup.settings.cp_Styles.sort(None) + self.prepareSessionLists() + if self.proxies: + self.__ftp = self.getPublisher(FTP_PUBLISHER).cp_Publish + self.getPublisher(FTP_PUBLISHER).cp_Publish = False + + except Exception: + traceback.print_exc() + + def prepareSessionLists(self): + # now copy the sessions list... + sessions = WWD_Startup.settings.cp_SavedSessions.childrenList + + WWD_Startup.settings.savedSessions.clear() + for index,item in enumerate(sessions): + WWD_Startup.settings.savedSessions.add(index, item) + # add an empty session to the saved session + # list which apears in step 1 + sn = CGSessionName() + sn.cp_Name = self.resources.resSessionNameNone + WWD_Startup.settings.cp_SavedSessions.add(0, sn) + + ''' + fills the saved session list, the styles list, + and save session combo box. + Also set the selected "load" session to the last session + which was saved. + ''' + + def fillLists(self): + # fill the saved session list. + + ListModelBinder.fillList(self.lstLoadSettings, + WWD_Startup.settings.cp_SavedSessions.childrenList, None) + # set the selected session to load. (step 1) + self.selectSession() + # fill the styles list. + ListModelBinder.fillList(self.lstStyles, + WWD_Startup.settings.cp_Styles.childrenList, None) + # fill the save session combobox (step 7) + ListModelBinder.fillComboBox(self.cbSaveSettings, + WWD_Startup.settings.savedSessions.childrenList, None) + + def selectSession(self): + selectedSession = 0 + if WWD_Startup.settings.cp_LastSavedSession is not None \ + and not WWD_Startup.settings.cp_LastSavedSession == "": + ses = WWD_Startup.settings.cp_SavedSessions.getElement( + settings.cp_LastSavedSession) + if ses is not None: + selectedSession = \ + WWD_Startup.settings.cp_SavedSessions.getIndexOf(ses) + + Helper.setUnoPropertyValue( + self.lstLoadSettings.Model, "SelectedItems", (selectedSession,)) + + ''' + attaches to each ui-data-control (like checkbox, groupbox or + textbox, no buttons though), a DataObject's JavaBean Property, + or class member. + ''' + + def makeDataAware(self): + #page 1 + ListModelBinder( + self.lstLoadSettings, WWD_Startup.settings.cp_SavedSessions) + #page 2 : document properties + self.docListDA = UnoDataAware.attachListBox( + self, "selectedDoc", self.lstDocuments, False) + self.docListDA.disableObjects = \ + [self.lnDocsInfo, self.btnRemoveDoc, self.lblDocTitle, + self.txtDocTitle, self.lblDocInfo, self.txtDocInfo, + self.lblDocAuthor, self.txtDocAuthor, self.lblDocExportFormat, + self.lstDocTargetType] + self.docListDA.updateUI() + doc = CGDocument + #dummy + self.docsBinder = ListModelBinder(self.lstDocuments, + WWD_Startup.settings.cp_DefaultSession.cp_Content.cp_Documents) + UnoDataAware.attachEditControl( + doc, "cp_Title", self.txtDocTitle, True) + UnoDataAware.attachEditControl( + doc, "cp_Description", self.txtDocInfo, True) + UnoDataAware.attachEditControl( + doc, "cp_Author", self.txtDocAuthor, True) + UnoDataAware.attachListBox( + doc, "Exporter", self.lstDocTargetType, False) + #page 3 : Layout + design = WWD_Startup.settings.cp_DefaultSession.cp_Design + + #COMMENTED + #self.sda = SimpleDataAware.SimpleDataAware_unknown(design, DataAware.PropertyValue ("Layout", design), ilLayouts, DataAware.PropertyValue ("Selected", ilLayouts)) + + #self.ilLayouts.addItemListener(None) + #page 4 : layout 2 + UnoDataAware.attachCheckBox( + design, "cp_DisplayDescription", self.chbDocDesc, True) + UnoDataAware.attachCheckBox( + design, "cp_DisplayAuthor", self.chbDocAuthor, True) + UnoDataAware.attachCheckBox( + design, "cp_DisplayCreateDate", self.chkDocCreated, True) + UnoDataAware.attachCheckBox( + design, "cp_DisplayUpdateDate", self.chkDocChanged, True) + UnoDataAware.attachCheckBox( + design, "cp_DisplayFilename", self.chkDocFilename, True) + UnoDataAware.attachCheckBox( + design, "cp_DisplayFileFormat", self.chkDocFormat, True) + UnoDataAware.attachCheckBox( + design, "cp_DisplayFormatIcon", self.chkDocFormatIcon, True) + UnoDataAware.attachCheckBox( + design, "cp_DisplayPages", self.chkDocPages, True) + UnoDataAware.attachCheckBox( + design, "cp_DisplaySize", self.chkDocSize, True) + RadioDataAware.attachRadioButtons( + WWD_Startup.settings.cp_DefaultSession.cp_Design, + "cp_OptimizeDisplaySize", + (self.optOptimize640x480, self.optOptimize800x600, + self.optOptimize1024x768), True) + #page 5 : Style + ''' + note : on style change, i do not call here refresh ,but rather on + a special method which will perform some display, background and Iconsets changes. + ''' + UnoDataAware.attachListBox( + WWD_Startup.settings.cp_DefaultSession.cp_Design, + "Style", self.lstStyles, False) + #page 6 : site general props + UnoDataAware.attachEditControl( + WWD_Startup.settings.cp_DefaultSession.cp_GeneralInfo, + "cp_Title", self.txtSiteTitle, True) + UnoDataAware.attachEditControl( + WWD_Startup.settings.cp_DefaultSession.cp_GeneralInfo, + "cp_Description", self.txtSiteDesc, True) + UnoDataAware.attachDateControl( + WWD_Startup.settings.cp_DefaultSession.cp_GeneralInfo, + "CreationDate", self.dateSiteCreated, False) + UnoDataAware.attachDateControl( + WWD_Startup.settings.cp_DefaultSession.cp_GeneralInfo, + "UpdateDate", self.dateSiteUpdate, False) + UnoDataAware.attachEditControl( + WWD_Startup.settings.cp_DefaultSession.cp_GeneralInfo, + "cp_Email", self.txtEmail, True) + UnoDataAware.attachEditControl( + WWD_Startup.settings.cp_DefaultSession.cp_GeneralInfo, + "cp_Copyright", self.txtCopyright, True) + #page 7 : publishing + self.pubAware( + LOCAL_PUBLISHER, self.chkLocalDir, self.txtLocalDir, False) + self.pubAware( + FTP_PUBLISHER, self.chkFTP, self.lblFTP, True) + self.pubAware( + ZIP_PUBLISHER, self.chkZip, self.txtZip, False) + self.sessionNameDA = UnoDataAware.attachEditControl( + WWD_Startup.settings.cp_DefaultSession, "cp_Name", + self.cbSaveSettings, True) + + ''' + A help method to attach a Checkbox and a TextBox to + a CGPublish object properties/class members, + @param publish + @param checkbox + @param textbox + ''' + + def pubAware(self, publish, checkbox, textbox, isLabel): + p = WWD_Startup.settings.cp_DefaultSession.cp_Publishing.getElement(publish) + uda = UnoDataAware.attachCheckBox(p, "cp_Publish", checkbox, True) + uda.Inverse = True + uda.disableObjects = [textbox] + #COMMENTED + '''if isLabel: + aux = UnoDataAware.attachLabel(p, "URL", textbox, False) + else: + aux = UnoDataAware.attachEditControl(p, "URL", textbox, False)''' + + ''' + Session load methods + (are used both on the start of the wizard and + when the user loads a session) + + Is called when a new session/settings is + loaded. <br/> + Checks the documents (validate), fills the + documents listbox, and changes the + DataAware data objects to the + new session's objects.<br/> + Task advances 4 times in the mount method, + and ??? times for each document in the session. + ''' + + def mount(self, session, task, refreshStyle, xC): + ''' + This checks the documents. If the user + chooses to cancel, the session is not loaded. + ''' + checkContent(session.cp_Content, task, xC) + settings.cp_DefaultSession = session; + mount(session.cp_Content) + task.advance(True) + mount(session.cp_Design, self.designAware) + mount(session.cp_GeneralInfo, self.genAware) + task.advance(True) + mount(session.cp_Publishing.getElement(LOCAL_PUBLISHER), 0) + mount(session.cp_Publishing.getElement(FTP_PUBLISHER), 1) + mount(session.cp_Publishing.getElement(ZIP_PUBLISHER), 2) + task.advance(True) + self.sessionNameDA.setDataObject(session, True) + Helper.setUnoPropertyValue( + chkSaveSettings.Model, PropertyNames.PROPERTY_STATE, 1) + self.docListDA.updateUI() + task.advance(True) + if refreshStyle: + self.refreshStylePreview() + self.updateIconsetText() + + ''' + used to mount the publishing objects. This is somehow cryptic - + there are 6 DataAware objects, 2 for each Publishing Object (CGPublish). + All 6 reside on one Vector (pubAware). + Since, otherwise than other DataAware objects, different + Objects on the same Vector need different DataObjectBinding, + I use this method... + @param data the CGPublish object + @param i the number of the object (0 = local, 1 = ftp, 2 = zip) + ''' + + def mount(self, data, i): + (self.pubAware.get(i * 2)).setDataObject(data, True) + (self.pubAware.get(i * 2 + 1)).setDataObject(data, True) + + ''' + Fills the documents listbox. + @param root the CGContent object + that contains the documents (a ListModel) + ''' + + def mount(self, root): + ListModelBinder.fillList(lstDocuments, root.cp_Documents.items(), None) + self.docsBinder.setListModel(root.cp_Documents) + disableDocUpDown() + + ''' + changes the DataAwares Objects' (in + the gioen list) DataObject to the + @param data + @param list + ''' + + def mount(self, data, list): + i = 0 + while i < list.size(): + (list.get(i)).setDataObject(data, True) + i += 1 + + ''' + Checks if the document specified by the given CGDocument + object (cp_URL) exists. Calls also the validate(...) method + of this document. + If the document does not exist, it asks the user whether + to specify a new URL, or forget about this document. + @param doc the document to check. + @param task while loading a session, a status is + displayed, using the Task object to monitor progress. + @return true if the document is ok (a file exists in the given url). + ''' + + def checkDocument(self, doc, task, xC): + try: + doc.validate(xMSF, task) + return True + except FileNotFoundException, ex: + relocate = SystemDialog.showMessageBox( + self.xMSF, xC.Peer, "WarningBox", + VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, + getFileAccess().getPath(doc.cp_URL, "") + "\n\n" + \ + self.resources.resSpecifyNewFileLocation) + if relocate == 2: + file = getDocAddDialog().callOpenDialog( + False, FileAccess.getParentDir(doc.cp_URL)) + if file is None: + return False + else: + doc.cp_URL = file[0] + return checkDocument(doc, task, xC) + + else: + return False + + except IllegalArgumentException, iaex: + #file is a directory + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, + self.resources.resErrIsDirectory.replace( + "%FILENAME", getFileAccess().getPath(doc.cp_URL, "")), + ErrorHandler.ERROR_PROCESS_FATAL) + return False + except Exceptionp: + #something went wrong. + exp.printStackTrace() + AbstractErrorHandler.showMessage( + self.xMSF, xControl.Peer, + self.resources.resErrDocValidate.replace( + "%FILENAME", getFileAccess().getPath(doc.cp_URL, "")), + ErrorHandler.ERROR_PROCESS_FATAL) + return False + + ''' + Checks the documents contained in this content. + @param content + @param task + ''' + + def checkContent(self, content, task, xC): + i = 0 + while i < content.cp_Documents.getSize(): + if not checkDocument(content.cp_Documents.getElementAt(i), task, xC): + # I use here 'i--' since, when the document is removed + # an index change accures + content.cp_Documents.remove(i) + i -= 1 + i += 1 + + ''' + Disables/enables the docUpDown buttons (step 2) + according to the currently selected document + (no doc selected - both disbaled, last doc selected, + down disabled and so on...) + ''' + + def disableDocUpDown(self): + try: + '''setEnabled(btnDocUp, self.selectedDoc.length == 0 ? Boolean.FALSE : (self.selectedDoc[0] == 0 ? Boolean.FALSE : Boolean.TRUE)) + setEnabled(btnDocDown, self.selectedDoc.length == 0 ? Boolean.FALSE : (self.selectedDoc[0] + 1 < WWD_Startup.settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() ? Boolean.TRUE : Boolean.FALSE))''' + except Exception, e: + e.printStackTrace() + + def updateBackgroundText(self): + bg = \ + WWD_Startup.settings.cp_DefaultSession.cp_Design.cp_BackgroundImage + if bg is None or bg.equals(""): + bg = self.resources.resBackgroundNone + else: + bg = FileAccess.getPathFilename(getFileAccess().getPath(bg, None)) + + Helper.setUnoPropertyValue( + txtBackground.Model, PropertyNames.PROPERTY_LABEL, bg) + + def updateIconsetText(self): + iconset = WWD_Startup.settings.cp_DefaultSession.cp_Design.cp_IconSet + if iconset is None or iconset.equals(""): + iconsetName = self.resources.resIconsetNone + else: + IconSet = WWD_Startup.settings.cp_IconSets.getElement(iconset) + if IconSet is None: + iconsetName = self.resources.resIconsetNone + else: + iconsetName = IconSet.cp_Name + + Helper.setUnoPropertyValue( + txtIconset.Model, PropertyNames.PROPERTY_LABEL, iconsetName) + + ''' + refreshes the style preview. + I also call here "updateBackgroundtext", because always + when the background is changed, this method + has to be called, so I am walking on the safe side here... + ''' + + def refreshStylePreview(self): + try: + updateBackgroundText() + self.stylePreview.refresh(settings.cp_DefaultSession.getStyle(), WWD_Startup.settings.cp_DefaultSession.cp_Design.cp_BackgroundImage) + self.dpStylePreview.reload(xMSF) + except Exception: + ex.printStackTrace() diff --git a/wizards/com/sun/star/wizards/web/WWHID.py b/wizards/com/sun/star/wizards/web/WWHID.py new file mode 100644 index 000000000000..28b3aaaa892e --- /dev/null +++ b/wizards/com/sun/star/wizards/web/WWHID.py @@ -0,0 +1,140 @@ +HID0_WEBWIZARD = 34200 + 0 +HID0_HELP = 34200 + 1 +HID0_NEXT = 34200 + 2 +HID0_PREV = 34200 + 3 +HID0_CREATE = 34200 + 4 +HID0_CANCEL = 34200 + 5 +HID0_STATUS_DIALOG = 34200 + 6 #step 1 +HID1_LST_SESSIONS = 34200 + 7 +HID1_BTN_DEL_SES = 34200 + 9 #step 2 +HID2_LST_DOCS = 34200 + 10 +HID2_BTN_ADD_DOC = 34200 + 11 +HID2_BTN_REM_DOC = 34200 + 12 +HID2_BTN_DOC_UP = 34200 + 13 +HID2_BTN_DOC_DOWN = 34200 + 14 +HID2_TXT_DOC_TITLE = 34200 + 15 +HID2_TXT_DOC_DESC = 34200 + 16 +HID2_TXT_DOC_AUTHOR = 34200 + 17 +HID2_LST_DOC_EXPORT = 34200 + 18 +HID2_STATUS_ADD_DOCS = 34200 + 19 #step 3 +HID3_IL_LAYOUTS_IMG1 = 34200 + 20 +HID3_IL_LAYOUTS_IMG2 = 34200 + 21 +HID3_IL_LAYOUTS_IMG3 = 34200 + 22 +HID3_IL_LAYOUTS_IMG4 = 34200 + 23 +HID3_IL_LAYOUTS_IMG5 = 34200 + 24 +HID3_IL_LAYOUTS_IMG6 = 34200 + 25 +HID3_IL_LAYOUTS_IMG7 = 34200 + 26 +HID3_IL_LAYOUTS_IMG8 = 34200 + 27 +HID3_IL_LAYOUTS_IMG9 = 34200 + 28 +HID3_IL_LAYOUTS_IMG10 = 34200 + 29 +HID3_IL_LAYOUTS_IMG11 = 34200 + 30 +HID3_IL_LAYOUTS_IMG12 = 34200 + 31 +HID3_IL_LAYOUTS_IMG13 = 34200 + 32 +HID3_IL_LAYOUTS_IMG14 = 34200 + 33 +HID3_IL_LAYOUTS_IMG15 = 34200 + 34 #step 4 +HID4_CHK_DISPLAY_FILENAME = 34200 + 35 +HID4_CHK_DISPLAY_DESCRIPTION = 34200 + 36 +HID4_CHK_DISPLAY_AUTHOR = 34200 + 37 +HID4_CHK_DISPLAY_CR_DATE = 34200 + 38 +HID4_CHK_DISPLAY_UP_DATE = 34200 + 39 +HID4_CHK_DISPLAY_FORMAT = 34200 + 40 +HID4_CHK_DISPLAY_F_ICON = 34200 + 41 +HID4_CHK_DISPLAY_PAGES = 34200 + 42 +HID4_CHK_DISPLAY_SIZE = 34200 + 43 +HID4_GRP_OPTIMAIZE_640 = 34200 + 44 +HID4_GRP_OPTIMAIZE_800 = 34200 + 45 +HID4_GRP_OPTIMAIZE_1024 = 34200 + 46 #step 5 +HID5_LST_STYLES = 34200 + 47 +HID5_BTN_BACKGND = 34200 + 48 +HID5_BTN_ICONS = 34200 + 49 #step 6 +HID6_TXT_SITE_TITLE = 34200 + 50 +HID6_TXT_SITE_ICON = 34200 + 51 +HID6_BTN_SITE_ICON = 34200 + 52 +HID6_TXT_SITE_DESC = 34200 + 53 +HID6_TXT_SITE_KEYWRDS = 34200 + 54 +HID6_DATE_SITE_CREATED = 34200 + 55 +HID6_DATE_SITE_UPDATED = 34200 + 56 +HID6_NUM_SITE_REVISTS = 34200 + 57 +HID6_TXT_SITE_EMAIL = 34200 + 58 +HID6_TXT_SITE_COPYRIGHT = 34200 + 59 #step 7 +HID7_BTN_PREVIEW = 34200 + 60 +HID7_CHK_PUBLISH_LOCAL = 34200 + 61 +HID7_TXT_LOCAL = 34200 + 62 +HID7_BTN_LOCAL = 34200 + 63 +HID7_CHK_PUBLISH_ZIP = 34200 + 64 +HID7_TXT_ZIP = 34200 + 65 +HID7_BTN_ZIP = 34200 + 66 +HID7_CHK_PUBLISH_FTP = 34200 + 67 +HID7_BTN_FTP = 34200 + 69 +HID7_CHK_SAVE = 34200 + 70 +HID7_TXT_SAVE = 34200 + 71 #web wizard backgrounds dialog +HID_BG = 34200 + 90 +HID_BG_BTN_OTHER = 34200 + 91 +HID_BG_BTN_NONE = 34200 + 92 +HID_BG_BTN_OK = 34200 + 93 +HID_BG_BTN_CANCEL = 34200 + 94 +HID_BG_BTN_BACK = 34200 + 95 +HID_BG_BTN_FW = 34200 + 96 +HID_BG_BTN_IMG1 = 34200 + 97 +HID_BG_BTN_IMG2 = 34200 + 98 +HID_BG_BTN_IMG3 = 34200 + 99 +HID_BG_BTN_IMG4 = 34200 + 100 +HID_BG_BTN_IMG5 = 34200 + 101 +HID_BG_BTN_IMG6 = 34200 + 102 +HID_BG_BTN_IMG7 = 34200 + 103 +HID_BG_BTN_IMG8 = 34200 + 104 +HID_BG_BTN_IMG9 = 34200 + 105 +HID_BG_BTN_IMG10 = 34200 + 106 +HID_BG_BTN_IMG11 = 34200 + 107 +HID_BG_BTN_IMG12 = 34200 + 108 +HID_BG_BTN_IMG13 = 34200 + 109 +HID_BG_BTN_IMG14 = 34200 + 100 +HID_BG_BTN_IMG15 = 34200 + 111 +HID_BG_BTN_IMG16 = 34200 + 112 #web wizard icons sets dialog +HID_IS = 41000 + 0 +HID_IS_ICONSETS = 41000 + 1 +HID_IS_BTN_NONE = 41000 + 2 +HID_IS_BTN_OK = 41000 + 3 +HID_IS_BTN_IMG1 = 41000 + 5 +HID_IS_BTN_IMG2 = 41000 + 6 +HID_IS_BTN_IMG3 = 41000 + 7 +HID_IS_BTN_IMG4 = 41000 + 8 +HID_IS_BTN_IMG5 = 41000 + 9 +HID_IS_BTN_IMG6 = 41000 + 10 +HID_IS_BTN_IMG7 = 41000 + 11 +HID_IS_BTN_IMG8 = 41000 + 12 +HID_IS_BTN_IMG9 = 41000 + 13 +HID_IS_BTN_IMG10 = 41000 + 14 +HID_IS_BTN_IMG11 = 41000 + 15 +HID_IS_BTN_IMG12 = 41000 + 16 +HID_IS_BTN_IMG13 = 41000 + 17 +HID_IS_BTN_IMG14 = 41000 + 18 +HID_IS_BTN_IMG15 = 41000 + 19 +HID_IS_BTN_IMG16 = 41000 + 20 +HID_IS_BTN_IMG17 = 41000 + 21 +HID_IS_BTN_IMG18 = 41000 + 22 +HID_IS_BTN_IMG19 = 41000 + 23 +HID_IS_BTN_IMG20 = 41000 + 24 +HID_IS_BTN_IMG21 = 41000 + 25 +HID_IS_BTN_IMG22 = 41000 + 26 +HID_IS_BTN_IMG23 = 41000 + 27 +HID_IS_BTN_IMG24 = 41000 + 28 +HID_IS_BTN_IMG25 = 41000 + 29 +HID_IS_BTN_IMG26 = 41000 + 30 +HID_IS_BTN_IMG27 = 41000 + 31 +HID_IS_BTN_IMG28 = 41000 + 32 +HID_IS_BTN_IMG29 = 41000 + 33 +HID_IS_BTN_IMG30 = 41000 + 34 +HID_IS_BTN_IMG31 = 41000 + 35 +HID_IS_BTN_IMG32 = 41000 + 36 + +# web wizard ftp dialog +HID_FTP = 41000 + 40 +HID_FTP_SERVER = 41000 + 41 +HID_FTP_USERNAME = 41000 + 42 +HID_FTP_PASS = 41000 + 43 +HID_FTP_TEST = 41000 + 44 +HID_FTP_TXT_PATH = 41000 + 45 +HID_FTP_BTN_PATH = 41000 + 46 +HID_FTP_OK = 41000 + 47 +HID_FTP_CANCEL = 41000 + 48 diff --git a/wizards/com/sun/star/wizards/web/WebWizardConst.py b/wizards/com/sun/star/wizards/web/WebWizardConst.py new file mode 100644 index 000000000000..1903dcbcd01a --- /dev/null +++ b/wizards/com/sun/star/wizards/web/WebWizardConst.py @@ -0,0 +1,39 @@ +LSTLOADSETTINGS_ITEM_CHANGED = "sessionSelected" # "lstLoadSettingsItemChanged" +BTNLOADSESSION_ACTION_PERFORMED = "loadSession" # "btnLoadSessionActionPerformed" +BTNDELSESSION_ACTION_PERFORMED = "delSession" # "btnDelSessionActionPerformed" +BTNADDDOC_ACTION_PERFORMED = "addDocument" # "btnAddDocActionPerformed" +BTNREMOVEDOC_ACTION_PERFORMED = "removeDocument" # "btnRemoveDocActionPerformed" +BTNDOCUP_ACTION_PERFORMED = "docUp" # "btnDocUpActionPerformed" +BTNDOCDOWN_ACTION_PERFORMED = "docDown" # "btnDocDownActionPerformed" +LSTSTYLES_ITEM_CHANGED = "refreshStylePreview" # "lstStylesItemChanged" +BTNBACKGROUNDS_ACTION_PERFORMED = "chooseBackground" # "btnBackgroundsActionPerformed" +BTNICONSETS_ACTION_PERFORMED = "chooseIconset" # "btnIconSetsActionPerformed" +BTNFAVICON_ACTION_PERFORMED = "chooseFavIcon" # "btnFavIconActionPerformed" +BTNPREVIEW_ACTION_PERFORMED = "documentPreview" # "btnPreviewActionPerformed" +BTNFTP_ACTION_PERFORMED = "setFTPPublish" # "btnFTPActionPerformed" +CHKLOCALDIR_ITEM_CHANGED = "checkPublish" # "chkLocalDirItemChanged" +CHKSAVESETTINGS_ITEM_CHANGED = "checkPublish" # "chkSaveSettingsItemChanged" +TXTSAVESETTINGS_TEXT_CHANGED = "checkPublish" # "txtSaveSettingsTextChanged" +BTNLOCALDIR_ACTION_PERFORMED = "setPublishLocalDir" # "btnLocalDirActionPerformed" +BTNZIP_ACTION_PERFORMED = "setZipFilename" # "btnZipActionPerformed" +CONFIG_PATH = "/org.openoffice.Office.WebWizard/WebWizard" +CONFIG_READ_PARAM = "cp_" +TASK = "WWIZ" +TASK_PREPARE = "t-prep" +LOCAL_PUBLISHER = "local" +FTP_PUBLISHER = "ftp" +ZIP_PUBLISHER = "zip" +TASK_EXPORT = "t_exp" +TASK_EXPORT_PREPARE = "t_exp_prep" +TASK_EXPORT_DOCUMENTS = "t_exp_docs" +TASK_GENERATE_PREPARE = "t_gen_prep" +TASK_GENERATE_XSL = "t_gen_x" +TASK_GENERATE_COPY = "t_gen_cp" +TASK_PUBLISH_PREPARE = "t_pub_prep" +TASK_FINISH = "t_fin" + +''' +when the user adds more than this number +of documents to the list, a status dialog opens. +''' +MIN_ADD_FILES_FOR_DIALOG = 2 diff --git a/wizards/com/sun/star/wizards/web/WebWizardDialog.py b/wizards/com/sun/star/wizards/web/WebWizardDialog.py new file mode 100644 index 000000000000..fde61980fe26 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/WebWizardDialog.py @@ -0,0 +1,713 @@ +from ui.WizardDialog import * +from WebWizardDialogResources import WebWizardDialogResources +from WebWizardConst import * +from WWHID import * +from ui.ImageList import ImageList +from com.sun.star.awt import Size +from com.sun.star.awt.FontUnderline import SINGLE +from com.sun.star.awt.FontFamily import ROMAN +from com.sun.star.awt.FontSlant import ITALIC +from com.sun.star.awt.ImageAlign import LEFT + +class WebWizardDialog(WizardDialog): + PROPNAMES_LBL = (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) + PROPNAMES_CHKBOX = (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) + PROPNAMES_BUTTON = (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) + PROPNAMES_TXT = (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) + PROPNAMES_TXT_2 = (PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, "ReadOnly", + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH) + PROPNAMES_TITLE = ("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) + + def __init__(self, xmsf): + super(WebWizardDialog, self).__init__(xmsf, HID0_WEBWIZARD) + #Load Resources + self.resources = WebWizardDialogResources(xmsf) + #set dialog properties... + Helper.setUnoPropertyValues(self.xDialogModel,( + "Closeable", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, "Moveable", + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, "Title", + PropertyNames.PROPERTY_WIDTH), + (True, 210, HelpIds.getHelpIdString(HID0_WEBWIZARD), True, + "WebWizardDialog", 102, 52, 1, 6, + self.resources.resWebWizardDialog_title, 330)) + self.fontDescriptor0 = \ + uno.createUnoStruct('com.sun.star.awt.FontDescriptor') + self.fontDescriptor1 = \ + uno.createUnoStruct('com.sun.star.awt.FontDescriptor') + self.fontDescriptor4 = \ + uno.createUnoStruct('com.sun.star.awt.FontDescriptor') + self.fontDescriptor5 = \ + uno.createUnoStruct('com.sun.star.awt.FontDescriptor') + self.fontDescriptor6 = \ + uno.createUnoStruct('com.sun.star.awt.FontDescriptor') + self.fontDescriptor7 = \ + uno.createUnoStruct('com.sun.star.awt.FontDescriptor') + self.imgIconsPrev = range(8) + #Set member- self.fontDescriptors... + self.fontDescriptor0.Weight = 100 + self.fontDescriptor1.Weight = 150 + self.fontDescriptor1.Underline = SINGLE + self.fontDescriptor4.Weight = 150 + self.fontDescriptor5.Name = "Angsana New" + self.fontDescriptor5.Height = 16 + self.fontDescriptor5.StyleName = "Regular" + self.fontDescriptor5.Family = ROMAN + self.fontDescriptor5.Weight = 100 + self.fontDescriptor6.Name = "Andalus" + self.fontDescriptor6.Height = 22 + self.fontDescriptor6.StyleName = "Bold Italic" + self.fontDescriptor6.Weight = 150 + self.fontDescriptor6.Slant = ITALIC + self.fontDescriptor7.Name = "StarSymbol" + self.fontDescriptor7.Height = 9 + self.fontDescriptor7.StyleName = "Regular" + self.fontDescriptor7.Weight = 100 + + #build components + + def buildStep1(self): + tabIndex = 100 + self.insertLabel("lbIntroTitle", WebWizardDialog.PROPNAMES_TITLE, + (self.fontDescriptor4, 16, self.resources.reslbIntroTitle_value, + True, "lbIntroTitle", 91, 8, 1, tabIndex + 1, 232)) + 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), + (119, self.resources.reslblIntroduction_value, True, + "lblIntroduction", 97, 28, 1, tabIndex + 1, 226)) + self.insertFixedLine("lnLoadSettings", WebWizardDialog.PROPNAMES_TXT, + (2, "", "lnLoadSettings", 91, 147, 1, tabIndex + 1, 234)) + self.lblLoadSettings = self.insertLabel("lblLoadSettings", + (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), + (8, self.resources.reslblLoadSettings_value, True, + "lblLoadSettings", 97, 153, 1, tabIndex + 1, 226)) + self.lstLoadSettings = self.insertListBox( + "lstLoadSettings", None, LSTLOADSETTINGS_ITEM_CHANGED,("Dropdown", + 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), + (True, 12, HelpIds.getHelpIdString(HID1_LST_SESSIONS), 14, + "lstLoadSettings", 97, 165, 1, tabIndex + 1, 173), self) + self.btnDelSession = self.insertButton( + "btnDelSession", BTNDELSESSION_ACTION_PERFORMED, + (PropertyNames.PROPERTY_ENABLED, + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, "ImageAlign", + PropertyNames.PROPERTY_LABEL, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (False, 14, HelpIds.getHelpIdString(HID1_BTN_DEL_SES), LEFT, + self.resources.resbtnDelSession_value, "btnDelSession", + 274, 164, 1, tabIndex + 1, 50), self) + + def buildStep2(self): + tabIndex = 200 + self.lblContentTitle = self.insertLabel( + "lblContentTitle", WebWizardDialog.PROPNAMES_TITLE, + (self.fontDescriptor4, 16, self.resources.reslblContentTitle_value, + True, "lblContentTitle", 91, 8, 2, tabIndex + 1, 232)) + self.lblSiteContent = self.insertLabel( + "lblSiteContent", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblSiteContent_value, + "lblSiteContent", 97, 28, 2, tabIndex + 1, 105)) + self.lstDocuments = self.insertListBox( + "lstDocuments", None, None, + (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), + (123, HelpIds.getHelpIdString(HID2_LST_DOCS), + 9, "lstDocuments", 97, 38, 2, tabIndex + 1, 103), self) + self.btnAddDoc = self.insertButton( + "btnAddDoc", BTNADDDOC_ACTION_PERFORMED, + WebWizardDialog.PROPNAMES_BUTTON, + (14, HelpIds.getHelpIdString(HID2_BTN_ADD_DOC), + self.resources.resbtnAddDoc_value, "btnAddDoc", 97, 165, 2, + tabIndex + 1, 50), self) + self.btnRemoveDoc = self.insertButton( + "btnRemoveDoc", BTNREMOVEDOC_ACTION_PERFORMED, + WebWizardDialog.PROPNAMES_BUTTON, + (14, HelpIds.getHelpIdString(HID2_BTN_REM_DOC), + self.resources.resbtnRemoveDoc_value, "btnRemoveDoc", 150, 165, + 2, tabIndex + 1, 50), self) + self.btnDocUp = self.insertButton( + "btnDocUp", BTNDOCUP_ACTION_PERFORMED, + ("FontDescriptor", + 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), + (self.fontDescriptor7, 14, HelpIds.getHelpIdString(HID2_BTN_DOC_UP), + self.resources.resbtnDocUp_value, "btnDocUp", + 205, 87, 2, tabIndex + 1, 18), self) + self.btnDocDown = self.insertButton( + "btnDocDown", BTNDOCDOWN_ACTION_PERFORMED,( + "FontDescriptor", + 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), + (self.fontDescriptor7, 14, HelpIds.getHelpIdString(HID2_BTN_DOC_DOWN), + self.resources.resbtnDocDown_value, "btnDocDown", 205, + 105, 2, tabIndex + 1, 18), self) + self.lblDocExportFormat = self.insertLabel( + "lblDocExportFormat", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblDocExportFormat_value, + "lblDocExportFormat", 235, 28, 2, tabIndex + 1, 89)) + self.lstDocTargetType = self.insertListBox("lstDocTargetType", None, None, + ("Dropdown", + 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), + (True, 12, HelpIds.getHelpIdString(HID2_LST_DOC_EXPORT), 14, + "lstDocTargetType", 235, 38, 2, tabIndex + 1, 89), self) + self.lnDocsInfo = self.insertFixedLine( + "lnDocsInfo", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslnDocsInfo_value, "lnDocsInfo", + 235, 66, 2, tabIndex + 1, 90)) + self.lblDocTitle = self.insertLabel( + "lblDocTitle", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblDocTitle_value, "lblDocTitle", + 235, 78, 2, tabIndex + 1, 89)) + self.txtDocTitle = self.insertTextField( + "txtDocTitle", None, WebWizardDialog.PROPNAMES_TXT, + (12, HelpIds.getHelpIdString(HID2_TXT_DOC_TITLE), "txtDocTitle", + 235, 88, 2, tabIndex + 1, 89), self) + self.lblDocInfo = self.insertLabel( + "lblDocInfo", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblDocInfo_value, "lblDocInfo", + 235, 103, 2, tabIndex + 1, 89)) + self.txtDocInfo = self.insertTextField( + "txtDocInfo", None,(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), + (40, HelpIds.getHelpIdString(HID2_TXT_DOC_DESC), True, + "txtDocInfo", 235, 113, 2, tabIndex + 1, 89), self) + self.lblDocAuthor = self.insertLabel( + "lblDocAuthor", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblDocAuthor_value, "lblDocAuthor", + 235, 155, 2, tabIndex + 1, 89)) + self.txtDocAuthor = self.insertTextField( + "txtDocAuthor", None, WebWizardDialog.PROPNAMES_TXT, + (12, HelpIds.getHelpIdString(HID2_TXT_DOC_AUTHOR), + "txtDocAuthor", 235, 165, 2, tabIndex + 1, 89), self) + + def buildStep3(self): + self.insertLabel("lblLayoutTitle", WebWizardDialog.PROPNAMES_TITLE, + (self.fontDescriptor4, 16, self.resources.reslblLayoutTitle_value, + True, "lblLayoutTitle", 91, 8, 3, 29, 232)) + self.lblLayouts = self.insertLabel("lblLayouts", + WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblLayouts_value, "lblLayouts", + 97, 28, 3, 30, 206)) + + def buildStep4(self): + self.insertLabel("lblLayout2Title", WebWizardDialog.PROPNAMES_TITLE, + (self.fontDescriptor4, 16, self.resources.reslblLayout2Title_value, + True, "lblLayout2Title", 91, 8, 4, 33, 232)) + self.lnDisplay = self.insertLabel("lblDisplay", + (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), + (16, self.resources.reslblDisplay_value, True, + "lblDisplay", 97, 28, 4, 34, 226)) + self.chkDocFilename = self.insertCheckBox("chkDocFilename", None, + WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_FILENAME), + self.resources.reschkDocFilename_value, "chkDocFilename", + 103, 50, 0, 4, 35, 99), self) + self.chbDocDesc = self.insertCheckBox( + "chbDocDesc", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_DESCRIPTION), + self.resources.reschbDocDesc_value, "chbDocDesc", + 103, 60, 0, 4, 36, 99), self) + self.chbDocAuthor = self.insertCheckBox( + "chbDocAuthor", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_AUTHOR), + self.resources.reschbDocAuthor_value, "chbDocAuthor", + 103, 70, 0, 4, 37, 99), self) + self.chkDocCreated = self.insertCheckBox( + "chkDocCreated", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_CR_DATE), + self.resources.reschkDocCreated_value, "chkDocCreated", + 103, 80, 0, 4, 38, 99), self) + self.chkDocChanged = self.insertCheckBox( + "chkDocChanged", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_UP_DATE), + self.resources.reschkDocChanged_value, "chkDocChanged", + 103, 90, 0, 4, 39, 99), self) + self.chkDocFormat = self.insertCheckBox( + "chkDocFormat", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_FORMAT), + self.resources.reschkDocFormat_value, "chkDocFormat", + 200, 50, 0, 4, 40, 110), self) + self.chkDocFormatIcon = self.insertCheckBox( + "chkDocFormatIcon", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_F_ICON), + self.resources.reschkDocFormatIcon_value, "chkDocFormatIcon", + 200, 60, 0, 4, 41, 110), self) + self.chkDocPages = self.insertCheckBox( + "chkDocPages", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_PAGES), + self.resources.reschkDocPages_value, "chkDocPages", + 200,70, 0, 4, 42, 110), self) + self.chkDocSize = self.insertCheckBox( + "chkDocSize", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID4_CHK_DISPLAY_SIZE), + self.resources.reschkDocSize_value, "chkDocSize", + 200, 80, 0, 4, 43, 110), self) + self.insertLabel("lblOptimizeFor", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblOptimizeFor_value, "lblOptimizeFor", + 97, 113, 4, 44, 226)) + self.optOptimize640x480 = self.insertRadioButton( + "optOptimize640x480", None, WebWizardDialog.PROPNAMES_BUTTON, + (10, HelpIds.getHelpIdString(HID4_GRP_OPTIMAIZE_640), + self.resources.resoptOptimize640x480_value, + "optOptimize640x480", 103, 133, 4, 45, 44), self) + self.optOptimize800x600 = self.insertRadioButton( + "optOptimize800x600", None, WebWizardDialog.PROPNAMES_BUTTON, + (10, HelpIds.getHelpIdString(HID4_GRP_OPTIMAIZE_800), + self.resources.resoptOptimize800x600_value, + "optOptimize800x600", 103, 146, 4, 46, 44), self) + self.optOptimize1024x768 = self.insertRadioButton( + "optOptimize1024x768", None, WebWizardDialog.PROPNAMES_BUTTON, + (10, HelpIds.getHelpIdString(HID4_GRP_OPTIMAIZE_1024), + self.resources.resoptOptimize1024x768_value, + "optOptimize1024x768", 103, 158, 4, 47, 44), self) + + def buildStep5(self): + self.lblStyleTitle = self.insertLabel( + "lblStyleTitle", WebWizardDialog.PROPNAMES_TITLE, + (self.fontDescriptor4, 16, self.resources.reslblStyleTitle_value, + True, "lblStyleTitle", 91, 8, 5, 50, 232)) + self.lblStyle = self.insertLabel( + "lblStyle", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblStyle_value, + "lblStyle", 97, 28, 5, 51, 80)) + self.lstStyles = self.insertListBox( + "lstStyles", None, LSTSTYLES_ITEM_CHANGED,( + "Dropdown", + 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), + (True, 12, HelpIds.getHelpIdString(HID5_LST_STYLES), + 14, "lstStyles", 179, 26, 5, 52, 145), self) + self.insertLabel("lblBackground", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblBackground, "lblBackground", + 97, 46, 5, 51, 70)) + self.insertLabel("txtBackground", + ("Border", + 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), + (1, 12, self.resources.resBackgroundNone, + "txtBackground", 179, 44, 5, 52, 90)) + self.btnBackgrounds = self.insertButton( + "btnBackgrounds", BTNBACKGROUNDS_ACTION_PERFORMED, + WebWizardDialog.PROPNAMES_BUTTON, + (14, HelpIds.getHelpIdString(HID5_BTN_BACKGND), + self.resources.resBtnChooseBackground, "btnBackgrounds", + 274, 43, 5, 53, 50), self) + self.insertLabel("lblIconset", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblIconset, "lblIconset", 97, 64, 5, 51, 70)) + self.insertLabel("txtIconset", + ("Border", + 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), + (1, 12, self.resources.resIconsetNone, "txtIconset", + 179, 62, 5, 52, 90)) + self.btnIconSets = self.insertButton( + "btnIconSets", BTNICONSETS_ACTION_PERFORMED, + WebWizardDialog.PROPNAMES_BUTTON, + (14, HelpIds.getHelpIdString(HID5_BTN_ICONS), + self.resources.resBtnChooseIconset, "btnIconSets", + 274, 61, 5, 54, 50), self) + self.insertLabel("lblIconsetInfo", + (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), + (16, self.resources.reslblIconSetInfo, True, "lblIconsetInfo", + 179, 78, 5, 51, 145)) + self.imgPreview = self.insertImage("imgPreview", + ("BackgroundColor", + PropertyNames.PROPERTY_ENABLED, + 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, False, 78, "", "imgPreview", 91, 100, False, 5, 55, 232)) + + def buildStep6(self): + tabIndex = 60 + self.insertLabel("lblTitleGeneralPage", + WebWizardDialog.PROPNAMES_TITLE, + (self.fontDescriptor4, 8, + self.resources.reslblTitleGeneralPage_value, True, + "lblTitleGeneralPage", 90, 9, 6, tabIndex + 1, 232)) + self.insertLabel("lblSiteTitle", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblSiteTitle_value, "lblSiteTitle", + 97, 28, 6, tabIndex + 1, 80)) + self.txtSiteTitle = self.insertTextField( + "txtSiteTitle", None, WebWizardDialog.PROPNAMES_TXT, + (12, HelpIds.getHelpIdString(HID6_TXT_SITE_TITLE), + "txtSiteTitle", 179, 26, 6, tabIndex + 1, 145), self) + self.insertFixedLine( + "FixedLineMetaData", WebWizardDialog.PROPNAMES_LBL, + (9, self.resources.reslblMetaData, "FixedLineMetaData", + 97, 56, 6, tabIndex + 1, 228)) + self.insertLabel("lblSiteDesc", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblSiteDesc_value, "lblSiteDesc", + 103, 72, 6, tabIndex + 1, 80)) + self.txtSiteDesc = self.insertTextField( + "txtSiteDesc", None, WebWizardDialog.PROPNAMES_TXT, + (12, HelpIds.getHelpIdString(HID6_TXT_SITE_DESC), "txtSiteDesc", + 179, 70, 6, tabIndex + 1, 145), self) + self.insertLabel( + "lblEmail", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblEmail_value, "lblEmail", + 103, 90, 6, tabIndex + 1, 80)) + self.txtEmail = self.insertTextField( + "txtEmail", None, WebWizardDialog.PROPNAMES_TXT, + (12, HelpIds.getHelpIdString(HID6_TXT_SITE_EMAIL), "txtEmail", + 179, 87, 6, tabIndex + 1, 145), self) + self.insertLabel("lblCopyright", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblCopyright_value, "lblCopyright", + 103, 108, 6, tabIndex + 1, 80)) + self.txtCopyright = self.insertTextField( + "txtCopyright", None, WebWizardDialog.PROPNAMES_TXT, + (12, HelpIds.getHelpIdString(HID6_TXT_SITE_COPYRIGHT), + "txtCopyright", 179, 106, 6, tabIndex + 1, 145), self) + self.insertLabel("lblSiteCreated", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblSiteCreated_value, "lblSiteCreated", + 103, 126, 6, tabIndex + 1, 80)) + self.dateSiteCreated = self.insertDateField("dateSiteCreated", None, + ("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(HID6_DATE_SITE_CREATED), + "dateSiteCreated", 179, 124, 6, tabIndex + 1, 49), self) + self.insertLabel("lblSiteUpdated", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblSiteUpdated_value, "lblSiteUpdated", + 103, 144, 6, tabIndex + 1, 80)) + self.dateSiteUpdate = self.insertDateField("dateSiteUpdate", None, + ("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(HID6_DATE_SITE_UPDATED), + "dateSiteUpdate", 179, 142, 6, tabIndex + 1, 49), self) + + def buildStep7(self, disableFTP, exclamationURL): + tabIndex = 700 + self.lblTitlePublish = self.insertLabel( + "lblTitlePublish", WebWizardDialog.PROPNAMES_TITLE, + (self.fontDescriptor4, 16, self.resources.reslblTitlePublish_value, + True, "lblTitlePublish", 91, 8, 7, tabIndex + 1, 232)) + self.FixedLine1 = self.insertFixedLine( + "FixedLine1", WebWizardDialog.PROPNAMES_LBL, + (9, self.resources.resFixedLine1_value, "FixedLine1", + 97, 28, 7, tabIndex + 1, 228)) + self.btnPreview = self.insertButton( + "btnPreview", BTNPREVIEW_ACTION_PERFORMED, + WebWizardDialog.PROPNAMES_BUTTON, + (14, HelpIds.getHelpIdString(HID7_BTN_PREVIEW), + self.resources.resbtnPreview_value, "btnPreview", + 103, 40, 7, tabIndex + 1, 50), self) + self.insertFixedLine( + "lblCreateSite", WebWizardDialog.PROPNAMES_LBL, + (9, self.resources.reslblCreateSite_value, "lblCreateSite", + 97, 56, 7, tabIndex + 1, 228)) + self.chkLocalDir = self.insertCheckBox( + "chkLocalDir", CHKLOCALDIR_ITEM_CHANGED, + WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID7_CHK_PUBLISH_LOCAL), + self.resources.reschkLocalDir_value, "chkLocalDir", + 103, 68, 0, 7, tabIndex + 1, 215), self) + self.txtLocalDir = self.insertTextField( + "txtLocalDir", None, WebWizardDialog.PROPNAMES_TXT, + (12, HelpIds.getHelpIdString(HID7_TXT_LOCAL), "txtLocalDir", + 113, 78, 7, tabIndex + 1, 190), self) + self.btnLocalDir = self.insertButton( + "btnLocalDir", BTNLOCALDIR_ACTION_PERFORMED, + WebWizardDialog.PROPNAMES_BUTTON, + (14, HelpIds.getHelpIdString(HID7_BTN_LOCAL), + self.resources.resbtnLocalDir_value, "btnLocalDir", + 308, 77, 7, tabIndex + 1, 16), self) + self.chkZip = self.insertCheckBox( + "chkZip", None, WebWizardDialog.PROPNAMES_CHKBOX, + (9, HelpIds.getHelpIdString(HID7_CHK_PUBLISH_ZIP), + self.resources.reschkZip_value, "chkZip", 103, 96, 0, 7, + tabIndex + 1, 215), self) + self.txtZip = self.insertTextField( + "txtZip", None, WebWizardDialog.PROPNAMES_TXT, + (12, HelpIds.getHelpIdString(HID7_TXT_ZIP), "txtZip", + 113, 108, 7, tabIndex + 1, 190), self) + self.btnZip = self.insertButton( + "btnZip", BTNZIP_ACTION_PERFORMED, + WebWizardDialog.PROPNAMES_BUTTON, + (14, HelpIds.getHelpIdString(HID7_BTN_ZIP), + self.resources.resbtnZip_value, "btnZip", 308, 107, 7, + tabIndex + 1, 16), self) + self.chkFTP = self.insertCheckBox( + "chkFTP", None, WebWizardDialog.PROPNAMES_CHKBOX, + (8, HelpIds.getHelpIdString(HID7_CHK_PUBLISH_FTP), + self.resources.reschkFTP_value, "chkFTP", 103, 124, 0, 7, + tabIndex + 1, 215), self) + if disableFTP: + FTP_STEP = 99 + else: + FTP_STEP = 7 + + self.lblFTP = self.insertLabel( + "lblFTP", ("Border", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH), + (1, 12, "txtFTP", 113, 134, FTP_STEP, tabIndex + 1, 156)) + self.btnFTP = self.insertButton( + "btnFTP", BTNFTP_ACTION_PERFORMED, + WebWizardDialog.PROPNAMES_BUTTON, + (14, HelpIds.getHelpIdString(HID7_BTN_FTP), + self.resources.resbtnFTP_value, "btnFTP", 274, 133, + FTP_STEP, tabIndex + 1, 50), self) + if disableFTP: + self.insertImage( + "imgFTPDisabled",("BackgroundColor", "Border", + PropertyNames.PROPERTY_ENABLED, + 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), + (-1, 0, False, 10, exclamationURL, "imgFTPDisabled", 115, + 135, False, 7, tabIndex + 1, 8)) + self.insertLabel( + "lblFTPDisabled",("BackgroundColor", + 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), + (-1, 8, self.resources.reslblFTPDisabled, True, + "lblFTPDisabled", 125, 136, 7, tabIndex + 1, 226)) + + self.insertFixedLine( + "lnSaveSetting", WebWizardDialog.PROPNAMES_TXT, + (2, "", "lnSaveSetting", 97, 151, 7, tabIndex + 1, 228)) + self.chkSaveSettings = self.insertCheckBox( + "chkSaveSettings", CHKSAVESETTINGS_ITEM_CHANGED, + WebWizardDialog.PROPNAMES_CHKBOX, + (9, HelpIds.getHelpIdString(HID7_CHK_SAVE), + self.resources.reschkSaveSettings_value, "chkSaveSettings", + 97, 157, 1, 7, tabIndex + 1, 215), self) + self.insertLabel( + "lblSaveSettings", WebWizardDialog.PROPNAMES_LBL, + (8, self.resources.reslblSaveSettings_value, "lblSaveSettings", + 107, 169, 7, tabIndex + 1, 45)) + self.cbSaveSettings = self.insertComboBox( + "txtSaveSettings", TXTSAVESETTINGS_TEXT_CHANGED, + TXTSAVESETTINGS_TEXT_CHANGED, TXTSAVESETTINGS_TEXT_CHANGED, + ("Autocomplete", "Dropdown", + 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), + (True, True, 12, HelpIds.getHelpIdString(HID7_TXT_SAVE), + 14, "txtSaveSettings", 179, 167, 7, tabIndex + 1, 145), self) + + ''' + builds the layouts image list. + ''' + + def buildStepX(self): + self.ilLayouts = ImageList() + self.ilLayouts.pos = Size (97, 38) + self.ilLayouts.imageSize = Size (34, 30) + self.ilLayouts.cols = 5 + self.ilLayouts.rows = 3 + self.ilLayouts.step = 3 + self.ilLayouts.showButtons = False + self.ilLayouts.renderer = self.LayoutRenderer() + self.ilLayouts.scaleImages = False + self.ilLayouts.tabIndex = 31 + self.ilLayouts.helpURL = HID3_IL_LAYOUTS_IMG1 + + + ''' + renders the images and titles of + the layouts + @author rpiterman + ''' + + class LayoutRenderer: + + def getImageUrls(self, listItem): + oResIds = None + if listItem != None: + oResIds = listItem.getImageUrls() + + return oResIds + + def render(self, listItem): + print "implementar" + #return listItem == None ? "" : (listItem).cp_Name diff --git a/wizards/com/sun/star/wizards/web/WebWizardDialogResources.py b/wizards/com/sun/star/wizards/web/WebWizardDialogResources.py new file mode 100644 index 000000000000..f52f1517f183 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/WebWizardDialogResources.py @@ -0,0 +1,298 @@ +import traceback +from common.Resource import Resource +from common.Configuration import Configuration +from common.Properties import Properties +from document.OfficeDocument import OfficeDocument + +class WebWizardDialogResources(Resource): + UNIT_NAME = "dbwizres" + MODULE_NAME = "dbw" + RID_WEBWIZARDDIALOG_START = 4000 + RID_COMMON_START = 500 + RID_DB_COMMON_START = 1000 + + def __init__(self, xmsf): + super(WebWizardDialogResources,self).__init__(xmsf, + WebWizardDialogResources.MODULE_NAME) + self.resbtnDocUp_value = str(8743) + self.resbtnDocDown_value = str(8744) + + #Delete the String, uncomment the getResText method + self.resWebWizardDialog_title = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 1) + self.reslblIntroduction_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 2) + self.resbtnDelSession_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 4) + self.reslbIntroTitle_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 5) + self.reslblContentTitle_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 6) + self.reslnDocsInfo_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 8) + self.reslblDocTitle_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 9) + self.reslblDocInfo_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 10) + self.reslblDocAuthor_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 11) + self.reslblDocExportFormat_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 12) + self.reslblTitleGeneralPage_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 13) + self.reslblSiteTitle_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 14) + self.reslblSiteDesc_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 16) + self.reslblSiteCreated_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 18) + self.reslblEmail_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 20) + self.reslblCopyright_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 21) + self.reslblSiteUpdated_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 22) + self.resbtnPreview_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 24) + self.reslblTitlePublish_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 25) + self.reslblCreateSite_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 26) + self.reschkLocalDir_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 27) + self.resbtnLocalDir_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 28) + self.reschkFTP_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 29) + + self.resbtnFTP_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 31) + self.reschkZip_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 32) + self.resbtnZip_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 33) + self.reschkSaveSettings_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 34) + self.reslblSaveSettings_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 35) + self.reslblLoadSettings_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 36) + self.reslblSiteContent_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 37) + self.resbtnAddDoc_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 38) + self.resbtnRemoveDoc_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 39) + self.reslblLayoutTitle_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 40) + self.reslblStyleTitle_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 41) + self.reslblStyle_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 42) + + self.reslblLayouts_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 48) + + self.reschbDocDesc_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 50) + self.reschbDocAuthor_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 51) + self.reschkDocCreated_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 52) + self.reschkDocChanged_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 53) + self.reschkDocFilename_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 54) + self.reschkDocFormat_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 55) + self.reschkDocFormatIcon_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 56) + self.reschkDocPages_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 57) + self.reschkDocSize_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 58) + self.resFixedLine1_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 59) + self.reslblLayout2Title_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 60) + self.reslblDisplay_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 61) + self.reslblOptimizeFor_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 62) + self.resoptOptimize640x480_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 64) + self.resoptOptimize800x600_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 65) + self.resoptOptimize1024x768_value = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 66) + + self.resStatusDialogTitle = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 70) + self.resCounter = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 71) + self.resPublishDir = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 72) + self.resFTPTargetExistsAsfile = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 73) + self.resLocalTargetExistsAsfile = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 74) + self.resZipTargetExists = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 75) + self.resFTPTargetNotEmpty = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 76) + self.resLocalTragetNotEmpty = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 77) + self.resSessionExists = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 78) + self.resTaskExportDocs = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 79) + self.resTaskExportPrepare = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 80) + self.resTaskGenerateCopy = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 81) + self.resTaskGeneratePrepare = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 82) + self.resTaskGenerateXsl = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 83) + self.resTaskPrepare = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 84) + self.resTaskPublishPrepare = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 86) + self.resTaskPublishLocal = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 87) + self.resTaskPublishFTP = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 88) + self.resTaskPublishZip = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 89) + self.resTaskFinish = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 90) + + self.resImages = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 94) + self.resAllFiles = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 95) + self.resZipFiles = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 96) + self.resBackgroundsDialog = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 98) + self.resBackgroundsDialogCaption = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 99) + self.resIconsDialog = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 100) + self.resIconsDialogCaption = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 101) + self.resOther = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 102) + self.resDeselect = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 103) + self.resFinishedSuccess = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 104) + self.resFinishedNoSuccess = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 105) + self.resErrTOC = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 106) + self.resErrTOCMedia = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 107) + self.resErrDocInfo = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 108) + self.resErrDocExport = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 109) + self.resErrMkDir = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 110) + self.resErrSecurity = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 111) + self.resErrExportIO = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 112) + self.resErrPublishMedia = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 113) + self.resErrPublish = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 114) + self.resErrUnknown = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 115) + self.resErrDocValidate = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 116) + self.resErrIsDirectory = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 117) + self.resLoadingSession = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 118) + self.resErrUnexpected = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 119) + self.resValidatingDocuments = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 120) + self.resDefaultArchiveFilename = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 121) + self.resStep1 = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 122) + self.resStep2 = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 123) + self.resStep3 = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 124) + self.resStep4 = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 125) + self.resStep5 = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 126) + self.resStep6 = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 127) + self.resStep7 = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 128) + self.resDelSessionConfirm = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 130) + self.resPages = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 131) + self.resSlides = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 132) + self.resCreatedTemplate = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 133) + self.resUpdatedTemplate = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 134) + self.resSessionName = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 135) + self.reslblBackground = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 136) + self.reslblIconset = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 137) + self.reslblIconSetInfo = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 138) + self.reslblMetaData = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 139) + self.resBtnChooseBackground = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 140) + self.resBtnChooseIconset = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 141) + self.resSessionNameNone = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 142) + self.reslblFTPDisabled = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 143) + self.resBackgroundNone = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 144) + self.resIconsetNone = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 145) + self.resFTPTargetCouldNotCreate = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 146) + self.resFTPTargetCreate = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 147) + self.resZipTargetIsDir = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 148) + self.resLocalTargetCouldNotCreate = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 149) + self.resLocalTargetCreate = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 150) + self.resSizeTemplate = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 151) + self.resSpecifyNewFileLocation = self.getResText( + WebWizardDialogResources.RID_WEBWIZARDDIALOG_START + 152) + self.resClose = self.getResText( + WebWizardDialogResources.RID_COMMON_START + 17) + self.resCancel = self.getResText( + WebWizardDialogResources.RID_COMMON_START + 11) + self.resOK = self.getResText( + WebWizardDialogResources.RID_COMMON_START + 18) + self.resHelp = self.getResText( + WebWizardDialogResources.RID_COMMON_START + 15) + try: + self.prodName = Configuration.getProductName(xmsf) + self.resGifFiles = Properties.getPropertyValue( + OfficeDocument.getTypeMediaDescriptor( + xmsf, "gif_Graphics_Interchange"), "UIName") + except Exception, ex: + traceback.print_exc() diff --git a/wizards/com/sun/star/wizards/web/__init__.py b/wizards/com/sun/star/wizards/web/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/__init__.py diff --git a/wizards/com/sun/star/wizards/web/data/CGArgument.py b/wizards/com/sun/star/wizards/web/data/CGArgument.py new file mode 100644 index 000000000000..bb8d3c2b494a --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGArgument.py @@ -0,0 +1,4 @@ +from common.ConfigGroup import ConfigGroup + +class CGArgument(ConfigGroup): + cp_Value = str() diff --git a/wizards/com/sun/star/wizards/web/data/CGContent.py b/wizards/com/sun/star/wizards/web/data/CGContent.py new file mode 100644 index 000000000000..407cf53cb716 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGContent.py @@ -0,0 +1,21 @@ +from common.ConfigGroup import ConfigGroup +from common.ConfigSet import ConfigSet +from CGDocument import CGDocument + +class CGContent(ConfigGroup): + + cp_Index = -1 + dirName = str() + cp_Name = str() + cp_Description = str() + #COMMENTED + #cp_Contents = ConfigSet(CGContent) + cp_Documents = ConfigSet(CGDocument()) + + def createDOM(self, parent): + myElement = XMLHelper.addElement( + parent, "content", + ["name", "directory-name", "description", "directory"], + [self.cp_Name, self.dirName, self.cp_Description, self.dirName]) + self.cp_Documents.createDOM(myElement) + return myElement diff --git a/wizards/com/sun/star/wizards/web/data/CGDesign.py b/wizards/com/sun/star/wizards/web/data/CGDesign.py new file mode 100644 index 000000000000..cc873a2395cc --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGDesign.py @@ -0,0 +1,38 @@ +from common.ConfigGroup import ConfigGroup + +class CGDesign(ConfigGroup): + + cp_Layout = str() + cp_Style = str() + cp_BackgroundImage = str() + cp_IconSet = str() + cp_DisplayTitle = bool() + cp_DisplayDescription = bool() + cp_DisplayAuthor = bool() + cp_DisplayCreateDate = bool() + cp_DisplayUpdateDate = bool() + cp_DisplayFilename = bool() + cp_DisplayFileFormat = bool() + cp_DisplayFormatIcon = bool() + cp_DisplayPages = bool() + cp_DisplaySize = bool() + cp_OptimizeDisplaySize = int() + + def createDOM(self, parent): + return XMLHelper.addElement(parent, "design", (0,), (0,)) + + def getStyle(self): + style = root.cp_Styles.getElement(self.cp_Style) + return [root.cp_Styles.getIndexOf(style)] + + def setStyle(self, newStyle): + o = root.cp_Styles.getElementAt(newStyle[0]) + self.cp_Style = root.cp_Styles.getKey(o) + + def getLayout(self): + layout = root.cp_Layouts.getElement(self.cp_Layout) + return layout.cp_Index + + def setLayout(self, layoutIndex): + layout = root.cp_Layouts.getElementAt(layoutIndex) + self.cp_Layout = root.cp_Layouts.getKey(layout) diff --git a/wizards/com/sun/star/wizards/web/data/CGDocument.py b/wizards/com/sun/star/wizards/web/data/CGDocument.py new file mode 100644 index 000000000000..cc8ff9818f34 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGDocument.py @@ -0,0 +1,260 @@ +from common.ConfigGroup import ConfigGroup + +''' +About the member fields Title, Decription and Author: +There is an ambiguicy in handling these fields. +On the one hand, the user can set those fields to a custom value, +relevant only for the web-wizard. +On the other-hand, the web-wizard can read those fields automatically +from SO documents. +In order to avoid conflict by saving, I use two fields: "cp_title", which +should be read from the configuratin (saved session), and "title" which is +the value read from the document. +The *cp_title* "overrides" *title*, if exists. if not, *title* is used. +The same is valid for *description* and *author*. +@author rpiterman +''' + +class CGDocument(ConfigGroup): + cp_Index = -1 + PAGE_TYPE_PAGE = 1 + PAGE_TYPE_SLIDE = 2 + cp_Title = "" + cp_Description = "" + cp_Author = "" + localFilename = "" + urlFilename = "" + title = "" + description = "" + author = "" + sizeBytes = -1 + pages = -1 + valid = False + + ''' + the task will advance 5 times during validate. + @param xmsf + @param task + @throws Exception + ''' + + def validate(self, xmsf, task): + if not getSettings().getFileAccess(xmsf).exists(self.cp_URL, False): + raise FileNotFoundException ( + "The given URL does not point to a file"); + + if getSettings().getFileAccess(xmsf).isDirectory(self.cp_URL): + raise IllegalArgumentException ( + "The given URL points to a directory"); + #create a TypeDetection service + + mediaDescriptor = OfficeDocument.getFileMediaDecriptor( + xmsf, self.cp_URL) + task.advance(True) + #1 + analyzeFileType(self.mediaDescriptor) + task.advance(True) + #2 + path = getSettings().getFileAccess(xmsf).getPath(self.cp_URL, "") + localFilename = FileAccess.getFilename(path, File.separator) + ''' + if the type is a star office convertable document + We try to open the document to get some properties + ''' + xProps = None + task.advance(True) + #3 + if self.isSOOpenable: + # for documents which are openable through SO, + # use DocumentProperties service. + desktop = Desktop.getDesktop(xmsf) + props = range(3) + props[0] = Properties.createProperty("Hidden", True) + props[1] = Properties.createProperty( + "MacroExecutionMode", MacroExecMode.NEVER_EXECUTE) + props[2] = Properties.createProperty( + "UpdateDocMode", UpdateDocMode.NO_UPDATE) + component = desktop.loadComponentFromURL( + self.cp_URL, "_default", 0, props) + xProps = component.getDocumentProperties() + + task.advance(True) + #4 + #now use the object to read some document properties. + if xProps != None: + title = xProps.getTitle() + description = xProps.getDescription() + author = xProps.getAuthor() + createDate = xProps.getCreationDate() + updateDate = xProps.getModificationDate() + else: + + #get some information from OS. + title = self.localFilename + updateDate = \ + getSettings().getFileAccess(xmsf).getLastModified(self.cp_URL) + + task.advance(True) + #5 + valid = True + if self.cp_Title.equals(""): + cp_Title = self.title + + if self.cp_Title.equals(""): + cp_Title = self.localFilename + + if self.cp_Description.equals(""): + cp_Description = self.description + + if self.cp_Author.equals(""): + cp_Author = self.author + + if self.cp_Exporter == None or self.cp_Exporter == "": + cp_Exporter = \ + getSettings().cp_Exporters.getKey(getSettings().getExporters(self.appType)[0]) + + ''' + Analyzes a type-detection string, returned from the TypeDetection service, + and sets the appType, isSOOpenable and isSODocument members. + ''' + + def analyzeFileType(self, mediaDesc): + if mediaDesc is None: + media = "" + else: + mediaProperties.getPropertyValue( + self.mediaDescriptor, PropertyNames.PROPERTY_NAME) + appType = getDocType(media) + isSOOpenable = (self.appType == TypeDetection.WRITER_DOC or self.appType == TypeDetection.CALC_DOC or self.appType == TypeDetection.IMPRESS_DOC or self.appType == TypeDetection.DRAW_DOC) or self.appType == TypeDetection.HTML_DOC + parts = JavaTools.ArrayoutofString(media, "_") + if parts.length < 2: + isSODocument = False + else: + isSODocument = self.isSOOpenable and (parts[1].startsWith("Star")) + + ''' + @param media is the media description string returned by an UNO TypeDetection object. + @return one of the constants in the interface TypeDetection. + + ''' + + def getDocType(self, media): + if media.equals(""): + return TypeDetection.NO_TYPE + + if media.startsWith("writer"): + if media.startsWith("writer_web_HTML"): + return TypeDetection.HTML_DOC + else: + return TypeDetection.WRITER_DOC + + elif media.startsWith("calc"): + return TypeDetection.CALC_DOC + elif media.startsWith("draw"): + return TypeDetection.DRAW_DOC + elif media.startsWith("impress"): + return TypeDetection.IMPRESS_DOC + elif media.startsWith("pdf"): + return TypeDetection.PDF_DOC + elif media.startsWith("gif") or media.startsWith("jpg"): + return TypeDetection.WEB_GRAPHICS + elif media.startsWith("wav"): + return TypeDetection.SOUND_FILE + else: + return TypeDetection.NO_TYPE + + def createDOM(self, parent): + d = getSettings().cp_DefaultSession.cp_Design + exp = getSettings().cp_Exporters.getElement(self.cp_Exporter) + '''return XMLHelper.addElement(parent, "document", ["title", "description", "author", "format", "filename", "create-date", "update-date", "pages", "size", "icon", "dir", "fn"], [d.cp_DisplayTitle ? self.cp_Title : "", d.cp_DisplayDescription ? self.cp_Description : "", d.cp_DisplayAuthor ? self.cp_Author : "", d.cp_DisplayFileFormat ? getTargetTypeName(exp) : "", d.cp_DisplayFilename ? self.localFilename : "", d.cp_DisplayCreateDate ? self.createDate() : "", d.cp_DisplayUpdateDate ? self.updateDate() : "", d.cp_DisplayPages and (self.pages > -1) ? "" + self.pages() : "", #TODO when do i calculate pages? + d.cp_DisplaySize ? sizeKB() : "", #TODO when do i calculate size? + d.cp_DisplayFormatIcon ? getIcon(exp) : "", self.dirName, self.urlFilename])''' + + def updateDate(self): + if self.updateDate == None: + return "" + + return getSettings().formatter.formatCreated(self.updateDate) + + def createDate(self): + if self.createDate == None: + return "" + + return getSettings().formatter.formatCreated(self.createDate) + + def sizeKB(self): + if self.sizeBytes == -1: + return "" + else: + return getSettings().formatter.formatFileSize(self.sizeBytes) + + def pages(self): + if self.pages == -1: + return "" + else: + return pagesTemplate().replace("%NUMBER", "" + self.pages) + + def pagesTemplate(self): + pagesType = \ + getSettings().cp_Exporters.getElement(self.cp_Exporter).cp_PageType + if pagesType == PAGE_TYPE_PAGE: + return \ + getSettings().resources[CGSettings.RESOURCE_PAGES_TEMPLATE] + elif pagesType == PAGE_TYPE_SLIDE: + return \ + getSettings().resources[CGSettings.RESOURCE_SLIDES_TEMPLATE] + else: + return "" + + def getTargetTypeName(self, exp): + if exp.targetTypeName == "": + return Properties.getPropertyValue(self.mediaDescriptor, "UIName") + else: + return exp.targetTypeName + + def getIcon(self, exporter): + if exporter.cp_Icon == "": + return getIcon(self.appType) + else: + return exporter.cp_Icon + + def getIcon(self, appType): + return appType + ".gif" + + ''' + This method is used by the DataAware model + and returns the index of the exporter of + this document, <b>in the list of the + exporters available for this type of document</b> + @return + ''' + + def getExporter(self): + return [getExporterIndex()] + + ''' + @see getExporter() + ''' + + def setExporter(self, exporter_): + exp = getSettings().getExporters(self.appType)[exporter_[0]] + cp_Exporter = getSettings().cp_Exporters.getKey(exp) + + ''' + @see getExporter() + @return + ''' + + def getExporterIndex(self): + if self.cp_Exporter == None: + return 0 + + exporter = getSettings().cp_Exporters.getElement(self.cp_Exporter) + exporters = getSettings().getExporters(self.appType) + i = 0 + while i < exporters.length: + if exporters[i] == exporter: + return i + + i += 1 + return -1 diff --git a/wizards/com/sun/star/wizards/web/data/CGExporter.py b/wizards/com/sun/star/wizards/web/data/CGExporter.py new file mode 100644 index 000000000000..dee2165be79f --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGExporter.py @@ -0,0 +1,23 @@ +from common.ConfigSet import ConfigSet +from CGArgument import CGArgument +from common.ConfigGroup import ConfigGroup + +class CGExporter(ConfigGroup): + cp_Index = -1 + cp_Name = str() + cp_ExporterClass = str() + cp_OwnDirectory = bool() + cp_SupportsFilename = bool() + cp_DefaultFilename = str() + cp_Extension = str() + cp_SupportedMimeTypes = str() + cp_Icon = str() + cp_TargetType = str() + cp_Binary = bool() + cp_PageType = int() + targetTypeName = "" + cp_Arguments = ConfigSet(CGArgument()) + + def supports(self, mime): + return cp_SupportedMimeTypes == "" or \ + cp_SupportedMimeTypes.index(mime) > -1 diff --git a/wizards/com/sun/star/wizards/web/data/CGFilter.py b/wizards/com/sun/star/wizards/web/data/CGFilter.py new file mode 100644 index 000000000000..8f64bb0339fe --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGFilter.py @@ -0,0 +1,6 @@ +from common.ConfigGroup import ConfigGroup + +class CGFilter(ConfigGroup): + cp_Index = -1 + cp_Name = str() + cp_Filter = str() diff --git a/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.py b/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.py new file mode 100644 index 000000000000..fb2a62994adb --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.py @@ -0,0 +1,42 @@ +from common.ConfigGroup import ConfigGroup + +class CGGeneralInfo(ConfigGroup): + + cp_Title = str() + cp_Description = str() + cp_Author = str() + cp_CreationDate = int() + cp_UpdateDate = int() + cp_Email = str() + cp_Copyright = str() + + def createDOM(self, parent): + return XMLHelper.addElement( + parent, "general-info", + ["title", "author", "description", "creation-date", + "update-date", "email", "copyright"], + [self.cp_Title, self.cp_Author, self.cp_Description, + str(self.cp_CreationDate), str(self.cp_UpdateDate), + self.cp_Email, self.cp_Copyright]) + + def getCreationDate(self): + if self.cp_CreationDate == 0: + self.cp_CreationDate = currentDate() + + return self.cp_CreationDate + + def getUpdateDate(self): + if self.cp_UpdateDate == 0: + self.cp_UpdateDate = currentDate() + + return self.cp_UpdateDate + + def setCreationDate(self, i): + self.cp_CreationDate = i.intValue() + + def setUpdateDate(self, i): + self.cp_UpdateDate = i.intValue() + + def currentDate(self): + dt = JavaTools.getDateTime(System.currentTimeMillis()) + return dt.Day + dt.Month * 100 + dt.Year * 10000 diff --git a/wizards/com/sun/star/wizards/web/data/CGIconSet.py b/wizards/com/sun/star/wizards/web/data/CGIconSet.py new file mode 100644 index 000000000000..085d7953623e --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGIconSet.py @@ -0,0 +1,7 @@ +from common.ConfigGroup import ConfigGroup + +class CGIconSet(ConfigGroup): + cp_Index = -1 + cp_FNPrefix = str() + cp_FNPostfix = str() + cp_Name = str() diff --git a/wizards/com/sun/star/wizards/web/data/CGImage.py b/wizards/com/sun/star/wizards/web/data/CGImage.py new file mode 100644 index 000000000000..7772dc7b7482 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGImage.py @@ -0,0 +1,4 @@ +from common.ConfigGroup import ConfigGroup + +class CGImage(ConfigGroup): + cp_Href = str() diff --git a/wizards/com/sun/star/wizards/web/data/CGLayout.py b/wizards/com/sun/star/wizards/web/data/CGLayout.py new file mode 100644 index 000000000000..e6e9835020eb --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGLayout.py @@ -0,0 +1,33 @@ +from common.ConfigGroup import ConfigGroup +from ui.UIConsts import RID_IMG_WEB + +class CGLayout(ConfigGroup): + + cp_Index = -1 + cp_Name = str() + cp_FSName = str() + + def createTemplates(self, xmsf): + self.templates = {} + tf = TransformerFactory.newInstance() + workPath = getSettings().workPath + fa = FileAccess(xmsf) + stylesheetPath = fa.getURL( + getSettings().workPath, "layouts/" + self.cp_FSName) + files = fa.listFiles(stylesheetPath, False) + i = 0 + while i < files.length: + if FileAccess.getExtension(files[i]).equals("xsl"): + self.templates.put( + FileAccess.getFilename(files[i]), + tf.newTemplates(StreamSource (files[i]))) + i += 1 + + def getImageUrls(self): + sRetUrls = range(1) + ResId = RID_IMG_WEB + (self.cp_Index * 2) + return [ResId, ResId + 1] + + def getTemplates(self, xmsf): + self.createTemplates(xmsf) + return self.templates diff --git a/wizards/com/sun/star/wizards/web/data/CGPublish.py b/wizards/com/sun/star/wizards/web/data/CGPublish.py new file mode 100644 index 000000000000..fe2eb5b2c127 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGPublish.py @@ -0,0 +1,34 @@ +from common.ConfigGroup import ConfigGroup + +''' +A Class which describes the publishing arguments +in a session. +Each session can contain different publishers, which are configured +through such a CGPublish object. +''' + +class CGPublish(ConfigGroup): + + cp_Publish = bool() + cp_URL = str() + cp_Username = str() + password = str() + + def setURL(self, path): + try: + self.cp_URL = (self.root).getFileAccess().getURL(path) + self.overwriteApproved = False + except Exception, ex: + ex.printStackTrace() + + def getURL(self): + try: + return (self.root).getFileAccess().getPath(self.cp_URL, None) + except Exception, e: + e.printStackTrace() + return "" + + def ftpURL(self): + pass + #COMMENTED + #return "ftp://" + self.cp_Username + ((self.password != None and self.password.length() > 0) ? ":" + self.password : "") + "@" + self.cp_URL.substring(7) diff --git a/wizards/com/sun/star/wizards/web/data/CGSession.py b/wizards/com/sun/star/wizards/web/data/CGSession.py new file mode 100644 index 000000000000..3d7263f09cd1 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGSession.py @@ -0,0 +1,49 @@ +from common.ConfigGroup import ConfigGroup +from common.ConfigSet import ConfigSet +from CGContent import CGContent +from CGDesign import CGDesign +from CGGeneralInfo import CGGeneralInfo +from CGPublish import CGPublish + +class CGSession(ConfigGroup): + + cp_Index = -1 + cp_InDirectory = str() + cp_OutDirectory = str() + cp_Name = str() + cp_Content = CGContent() + cp_Design = CGDesign() + cp_GeneralInfo = CGGeneralInfo() + cp_Publishing = ConfigSet(CGPublish()) + valid = False + + def createDOM(self, parent): + root = XMLHelper.addElement( + parent, "session", ["name", "screen-size"], + [self.cp_Name, getScreenSize()]) + self.cp_GeneralInfo.createDOM(root) + self.cp_Content.createDOM(root) + return root + + def getScreenSize(self): + tmp_switch_var1 = self.cp_Design.cp_OptimizeDisplaySize + if tmp_switch_var1 == 0: + return "640" + elif tmp_switch_var1 == 1: + return "800" + elif tmp_switch_var1 == 2: + return "1024" + else: + return "800" + + def getLayout(self, layouts): + return layouts.getElement(self.cp_Design.cp_Layout) + + def getStyle(self, styles): + return styles.getElement(self.cp_Design.cp_Style) + + def createDOM(self): + factory = DocumentBuilderFactory.newInstance() + doc = factory.newDocumentBuilder().newDocument() + createDOM(doc) + return doc diff --git a/wizards/com/sun/star/wizards/web/data/CGSessionName.py b/wizards/com/sun/star/wizards/web/data/CGSessionName.py new file mode 100644 index 000000000000..3e573f5cf53a --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGSessionName.py @@ -0,0 +1,5 @@ +from common.ConfigGroup import ConfigGroup + +class CGSessionName(ConfigGroup): + cp_Index = -1 + cp_Name = str() diff --git a/wizards/com/sun/star/wizards/web/data/CGSettings.py b/wizards/com/sun/star/wizards/web/data/CGSettings.py new file mode 100644 index 000000000000..919145a2a5e0 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGSettings.py @@ -0,0 +1,129 @@ +import traceback +from common.FileAccess import FileAccess +from common.ConfigGroup import ConfigGroup +from common.ConfigSet import ConfigSet +from CGExporter import CGExporter +from CGLayout import CGLayout +from CGStyle import CGStyle +from CGIconSet import CGIconSet +from CGImage import CGImage +from CGFilter import CGFilter +from common.Helper import Helper +from CGSessionName import CGSessionName +from CGSession import CGSession +from common.Properties import Properties + +from com.sun.star.i18n.NumberFormatIndex import DATE_SYS_DMMMYYYY +from com.sun.star.i18n.NumberFormatIndex import NUMBER_1000DEC2 + +class CGSettings(ConfigGroup): + + RESOURCE_PAGES_TEMPLATE = 0 + RESOURCE_SLIDES_TEMPLATE = 1 + RESOURCE_CREATED_TEMPLATE = 2 + RESOURCE_UPDATED_TEMPLATE = 3 + RESOURCE_SIZE_TEMPLATE = 4 + + cp_WorkDir = str() + cp_Exporters = ConfigSet(CGExporter()) + cp_Layouts = ConfigSet(CGLayout()) + cp_Styles = ConfigSet(CGStyle()) + cp_IconSets = ConfigSet(CGIconSet()) + cp_BackgroundImages = ConfigSet(CGImage()) + cp_SavedSessions = ConfigSet(CGSessionName()) + cp_Filters = ConfigSet(CGFilter()) + savedSessions = ConfigSet(CGSessionName()) + cp_DefaultSession = CGSession() + cp_LastSavedSession = str() + + def __init__(self, xmsf_, resources_, document): + self.xmsf = xmsf_ + try: + self.soTemplateDir = FileAccess.getOfficePath2( + self.xmsf, "Config", "", "") + self.soGalleryDir = FileAccess.getOfficePath2( + self.xmsf, "Gallery", "share", "") + root = self + self.formatter = self.Formatter(self.xmsf, document) + self.resources = resources_ + self.workPath = None + self.exportersMap = {} + except Exception: + traceback.print_exc() + + def getExporters(self, mime): + exps = self.exportersMap.get(mime) + if exps is None: + self.exportersMap.put(mime, exps = createExporters(mime)) + + return exps + + def createExporters(self, mime): + exporters = self.cp_Exporters.items() + v = Vector.Vector() + i = 0 + while i < exporters.length: + if (exporters[i]).supports(mime): + try: + v.add(exporters[i]) + except Exception, ex: + ex.printStackTrace() + + i += 1 + return v.toArray(self.__class__.EMPTY_ARRAY_1) + + ''' + call after read. + @param xmsf + @param document the background document. used for date/number formatting. + ''' + + def configure(self, xmsf): + self.workPath = FileAccess.connectURLs( + self.soTemplateDir, self.cp_WorkDir) + #COMMENTED + #self.calcExportersTargetTypeNames(xmsf) + + def calcExportersTargetTypeNames(self, xmsf): + typeDetect = xmsf.createInstance( + "com.sun.star.document.TypeDetection") + for i in xrange(self.cp_Exporters.getSize()): + self.calcExporterTargetTypeName( + typeDetect, self.cp_Exporters.getElementAt(i)) + + def calcExporterTargetTypeName(self, typeDetect, exporter): + if not exporter.cp_TargetType == "": + exporter.targetTypeName = Properties.getPropertyValue( + typeDetect.getByName(exporter.cp_TargetType), "UIName") + + @classmethod + def getFileAccess(self, xmsf = None): + if xmsf is None: + xmsf = self.xmsf + if self.fileAccess is None: + self.fileAccess = FileAccess.FileAccess_unknown(xmsf) + + return self.fileAccess + + class Formatter(object): + def __init__(self, xmsf, document): + self.dateUtils = Helper.DateUtils(xmsf, document) + self.dateFormat = self.dateUtils.getFormat(DATE_SYS_DMMMYYYY) + self.numberFormat = self.dateUtils.getFormat(NUMBER_1000DEC2) + + def formatCreated(self, date): + sDate = self.dateUtils.format(dateFormat, date) + return resources[CGSettings.RESOURCE_CREATED_TEMPLATE].replace( + "%DATE", sDate) + + def formatUpdated(self, date): + sDate = self.dateUtils.format(dateFormat, date); + return resources[CGSettings.RESOURCE_UPDATED_TEMPLATE].replace( + "%DATE", sDate) + + def formatFileSize(self, size): + sizeInKB = size / float(1024) + sSize = self.dateUtils.getFormatter().convertNumberToString( + numberFormat, sizeInKB) + return resources[CGSettings.RESOURCE_SIZE_TEMPLATE].replace( + "%NUMBER", sSize) diff --git a/wizards/com/sun/star/wizards/web/data/CGStyle.py b/wizards/com/sun/star/wizards/web/data/CGStyle.py new file mode 100644 index 000000000000..e8a7a5615b2b --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/CGStyle.py @@ -0,0 +1,15 @@ +from common.ConfigGroup import ConfigGroup + +class CGStyle(ConfigGroup): + cp_Index = -1 + cp_Name = str() + cp_CssHref = str() + cp_BackgroundImage = str() + cp_IconSet = str() + + def getBackgroundUrl(self): + if CGStyle.cp_BackgroundImage is None \ + or CGStyle.cp_BackgroundImage == "": + return None + else: + return CGStyle.cp_BackgroundImage diff --git a/wizards/com/sun/star/wizards/web/data/TypeDetection.py b/wizards/com/sun/star/wizards/web/data/TypeDetection.py new file mode 100644 index 000000000000..f07983e90611 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/TypeDetection.py @@ -0,0 +1,37 @@ +''' +a document which will open in writer. +''' +WRITER_DOC = "writer" +''' +a document which will open in calc. +''' +CALC_DOC = "calc" +''' +a document which will open in impress. +''' +IMPRESS_DOC = "impress" +''' +a document which will open in draw. +''' +DRAW_DOC = "draw" +''' +an HTML document +''' +HTML_DOC = "html" +''' +a GIF or an JPG file. +''' +WEB_GRAPHICS = "graphics" +''' +a PDF document. +''' +PDF_DOC = "pdf" +''' +a Sound file (mp3/wav ect.) +''' +SOUND_FILE = "sound" +''' +a File which can not be handled by neither SO or a Web browser +(exe, jar, zip ect.) +''' +NO_TYPE = "other" diff --git a/wizards/com/sun/star/wizards/web/data/__init__.py b/wizards/com/sun/star/wizards/web/data/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/wizards/com/sun/star/wizards/web/data/__init__.py |