summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Fernandez <jfernandez@igalia.com>2013-05-04 11:43:28 +0000
committerJavier Fernandez <jfernandez@igalia.com>2013-05-08 09:36:41 +0000
commitccd34249719614146e2f581e6c3826524745b425 (patch)
treea2b51f41e8ad5ea24961f616898772d3637a8e45
parent0170bb1e7803359439a3c238e1e336d5a9bf6d64 (diff)
PyWebWizard: Fixing bugs and implementation of mising features.
CGXX classes must use instance attributes, instead of static. Change-Id: Ic76a37b6530e19f6ffcd5ccd995880b3a8741363
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGArgument.py4
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGContent.py14
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGDesign.py31
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGDocument.py126
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGExporter.py37
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGGeneralInfo.py15
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGIconSet.py10
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGLayout.py7
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGPublish.py22
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGSession.py19
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGSessionName.py9
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGSettings.py92
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGStyle.py3
13 files changed, 193 insertions, 196 deletions
diff --git a/wizards/com/sun/star/wizards/web/data/CGArgument.py b/wizards/com/sun/star/wizards/web/data/CGArgument.py
index ee532deac50d..9a66144de647 100644
--- a/wizards/com/sun/star/wizards/web/data/CGArgument.py
+++ b/wizards/com/sun/star/wizards/web/data/CGArgument.py
@@ -18,4 +18,6 @@
from ...common.ConfigGroup import ConfigGroup
class CGArgument(ConfigGroup):
- cp_Value = str()
+
+ def __init__(self):
+ self.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
index 49e3aba0400c..94a668a82ecf 100644
--- a/wizards/com/sun/star/wizards/web/data/CGContent.py
+++ b/wizards/com/sun/star/wizards/web/data/CGContent.py
@@ -22,13 +22,13 @@ from .CGDocument import CGDocument
class CGContent(ConfigGroup):
- cp_Index = -1
- dirName = str()
- cp_Name = str()
- cp_Description = str()
- #COMMENTED
- #cp_Contents = WebConfigSet(CGContent)
- cp_Documents = WebConfigSet(CGDocument())
+ def __init__(self):
+ self.cp_Index = -1
+ self.dirName = str()
+ self.cp_Name = str()
+ self.cp_Description = str()
+ self.cp_Documents = WebConfigSet(CGDocument)
+ self.cp_Contents = WebConfigSet(CGContent)
def createDOM(self, parent):
myElement = XMLHelper.addElement(
diff --git a/wizards/com/sun/star/wizards/web/data/CGDesign.py b/wizards/com/sun/star/wizards/web/data/CGDesign.py
index 4887bf74982b..7e0dff05c998 100644
--- a/wizards/com/sun/star/wizards/web/data/CGDesign.py
+++ b/wizards/com/sun/star/wizards/web/data/CGDesign.py
@@ -19,21 +19,22 @@ 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 __init__(self):
+ self.cp_Layout = str()
+ self.cp_Style = str()
+ self.cp_BackgroundImage = str()
+ self.cp_IconSet = str()
+ self.cp_DisplayTitle = bool()
+ self.cp_DisplayDescription = bool()
+ self.cp_DisplayAuthor = bool()
+ self.cp_DisplayCreateDate = bool()
+ self.cp_DisplayUpdateDate = bool()
+ self.cp_DisplayFilename = bool()
+ self.cp_DisplayFileFormat = bool()
+ self.cp_DisplayFormatIcon = bool()
+ self.cp_DisplayPages = bool()
+ self.cp_DisplaySize = bool()
+ self.cp_OptimizeDisplaySize = int()
def createDOM(self, parent):
return XMLHelper.addElement(parent, "design", (0,), (0,))
diff --git a/wizards/com/sun/star/wizards/web/data/CGDocument.py b/wizards/com/sun/star/wizards/web/data/CGDocument.py
index 9215b70a9e97..4221188f502a 100644
--- a/wizards/com/sun/star/wizards/web/data/CGDocument.py
+++ b/wizards/com/sun/star/wizards/web/data/CGDocument.py
@@ -45,34 +45,38 @@ The same is valid for *description* and *author*.
'''
class CGDocument(ConfigGroup):
- cp_Exporter = None
- cp_Index = -1
+
PAGE_TYPE_PAGE = 1
PAGE_TYPE_SLIDE = 2
- cp_Title = ""
- cp_Description = ""
- cp_URL = ""
- cp_Author = ""
- localFilename = ""
- urlFilename = ""
- title = ""
- description = ""
- author = ""
- sizeBytes = -1
- pages = -1
- valid = False
- appType = None
-
- def __init__(self, url = "", xmsf = None, Task = None):
+
+ def __init__(self, url = "", xmsf = None, task = None):
+ self.cp_URL = ""
+ self.cp_Exporter = None
+ self.cp_Index = -1
+ self.cp_Title = ""
+ self.cp_Description = ""
+ self.cp_Author = ""
+ self.localFilename = ""
+ self.urlFilename = ""
+ self.title = ""
+ self.description = ""
+ self.author = ""
+ self.dirName = ""
+ self.createdDate = None
+ self.updatedDate = None
+ self.sizeBytes = -1
+ self.pages = -1
+ self.valid = False
+ self.appType = ""
if (xmsf is None):
return
- cp_URL = self.getSettings().getFileAccess(xmsf).getURL(url);
+ self.cp_URL = self.getSettings().getFileAccess(xmsf).getURL(url)
if (task is None):
task = Task("", "", 5)
- self.validate(xmsf, task);
+ self.validate(xmsf, task)
def getSettings(self):
- return ConfigGroup.root
+ return self.root
'''
the task will advance 5 times during validate.
@@ -82,15 +86,12 @@ class CGDocument(ConfigGroup):
'''
def validate(self, xmsf, task):
- print ("WARNING !!! VALIDATING DOCUMENT ....")
- if not self.root.getFileAccess(xmsf).exists(self.cp_URL, False):
+ if not self.getSettings().getFileAccess(xmsf).exists(self.cp_URL, False):
raise FileNotFoundException (
- "The given URL does not point to a file");
+ "The given URL does not point to a file")
- if self.root.getFileAccess(xmsf).isDirectory(self.cp_URL):
- raise IllegalArgumentException (
- "The given URL points to a directory");
- #create a TypeDetection service
+ if self.getSettings().getFileAccess(xmsf).isDirectory(self.cp_URL):
+ raise IllegalArgumentException ("The given URL points to a directory") #create a TypeDetection service
self.mediaDescriptor = OfficeDocument.getFileMediaDecriptor(
xmsf, self.cp_URL)
@@ -99,7 +100,7 @@ class CGDocument(ConfigGroup):
self.analyzeFileType(self.mediaDescriptor)
task.advance(True)
#2
- path = self.root.getFileAccess(xmsf).getPath(self.cp_URL, "")
+ path = self.getSettings().getFileAccess(xmsf).getPath(self.cp_URL, "")
self.localFilename = FileAccess.getFilename(path, separator)
'''
if the type is a star office convertible document
@@ -118,7 +119,6 @@ class CGDocument(ConfigGroup):
"MacroExecutionMode", NEVER_EXECUTE))
props.append(Properties.createProperty(
"UpdateDocMode", NO_UPDATE))
- print ("DEBUG !!! validate -- URL: ", self.cp_URL)
component = desktop.loadComponentFromURL(
self.cp_URL, "_default", 0, tuple(props))
xProps = component.DocumentProperties
@@ -127,41 +127,37 @@ class CGDocument(ConfigGroup):
#4
#now use the object to read some document properties.
if xProps is not None:
- title = xProps.Title
- description = xProps.Description
- author = xProps.Author
- createDate = xProps.CreationDate
- updateDate = xProps.ModificationDate
+ self.title = xProps.Title
+ self.description = xProps.Description
+ self.author = xProps.Author
+ self.createdDate = xProps.CreationDate
+ self.updatedDate = xProps.ModificationDate
else:
#get some information from OS.
- title = self.localFilename
- updateDate = \
+ self.title = self.localFilename
+ self.updatedDate = \
self.getSettings().getFileAccess(xmsf).getLastModified(self.cp_URL)
task.advance(True)
#5
valid = True
if self.cp_Title == "":
- cp_Title = self.title
+ self.cp_Title = self.title
if self.cp_Title == "":
- cp_Title = self.localFilename
+ self.cp_Title = self.localFilename
if self.cp_Description == "":
- cp_Description = self.description
+ self.cp_Description = self.description
if self.cp_Author == "":
- cp_Author = self.author
+ self.cp_Author = self.author
if self.cp_Exporter is None or self.cp_Exporter == "":
- print ("WARNING !!! settign exporter for key:", CGDocument.appType)
- exp = self.root.getExporters(CGDocument.appType)
- print ("WARNING !!! got N exporters:", len(exp))
- print ("WARNING !!! got exporter:", exp[0])
+ exp = self.getSettings().getExporters(self.appType)
self.cp_Exporter = \
- self.root.cp_Exporters.getKey(exp[0])
- print ("WARNING !!! exporter: ", self.cp_Exporter)
+ self.getSettings().cp_Exporters.getKey(exp[0])
'''
Analyzes a type-detection string, returned from the TypeDetection service,
@@ -169,28 +165,18 @@ class CGDocument(ConfigGroup):
'''
def analyzeFileType(self, mediaDesc):
- print ("DEBUG !!! analyzeFileType -- mediaDesc : ", mediaDesc)
if mediaDesc is None:
media = ""
else:
media = Properties.getPropertyValue(
self.mediaDescriptor, PropertyNames.PROPERTY_NAME)
- CGDocument.appType = self.getDocType(media)
- print ("DEBUG !!! analyzeFileType -- appType: ", CGDocument.appType)
- self.isSOOpenable = (CGDocument.appType == WRITER_DOC or CGDocument.appType == CALC_DOC or CGDocument.appType == IMPRESS_DOC or CGDocument.appType == DRAW_DOC) or CGDocument.appType == HTML_DOC
- if (self.isSOOpenable):
- print ("DEBUG !!! analyzeFileType -- isSOOpenable .")
- else:
- print ("DEBUG !!! analyzeFileType -- NOT isSOOpenable .")
+ self.appType = self.getDocType(media)
+ self.isSOOpenable = (self.appType == WRITER_DOC or self.appType == CALC_DOC or self.appType == IMPRESS_DOC or self.appType == DRAW_DOC) or self.appType == HTML_DOC
parts = media.split("_")
if len(parts) < 2:
self.isSODocument = False
else:
self.isSODocument = self.isSOOpenable and (parts[1].startswith("Star"))
- if (self.isSODocument):
- print ("DEBUG !!! analyzeFileType -- isSODocument .")
- else:
- print ("DEBUG !!! analyzeFileType -- NOT isSODocument .")
'''
@param media is the media description string returned by an UNO TypeDetection object.
@@ -199,7 +185,6 @@ class CGDocument(ConfigGroup):
'''
def getDocType(self, media):
- print ("DEBUG !!! getDocType -- media: ", media)
if media == "":
return NO_TYPE
elif media.startswith("generic_HTML"):
@@ -229,16 +214,16 @@ class CGDocument(ConfigGroup):
d.cp_DisplayFormatIcon ? getIcon(exp) : "", self.dirName, self.urlFilename])'''
def updateDate(self):
- if self.updateDate is None:
+ if self.updatedDate is None:
return ""
- return self.getSettings().formatter.formatCreated(self.updateDate)
+ return self.getSettings().formatter.formatCreated(self.updatedDate)
def createDate(self):
- if self.createDate is None:
+ if self.createdDate is None:
return ""
- return self.getSettings().formatter.formatCreated(self.createDate)
+ return self.getSettings().formatter.formatCreated(self.createdDate)
def sizeKB(self):
if self.sizeBytes == -1:
@@ -246,11 +231,11 @@ class CGDocument(ConfigGroup):
else:
return self.getSettings().formatter.formatFileSize(self.sizeBytes)
- def pages(self):
+ def getPages(self):
if self.pages == -1:
return ""
else:
- return pagesTemplate().replace("%NUMBER", "" + self.pages)
+ return self.pagesTemplate().replace("%NUMBER", "" + self.pages)
def pagesTemplate(self):
pagesType = \
@@ -272,11 +257,11 @@ class CGDocument(ConfigGroup):
def getIcon(self, exporter):
if exporter.cp_Icon == "":
- return getIcon(CGDocument.appType)
+ return self.getIcon1(self.appType)
else:
return exporter.cp_Icon
- def getIcon(self, appType):
+ def getIcon1(self, appType):
return appType + ".gif"
'''
@@ -295,7 +280,7 @@ class CGDocument(ConfigGroup):
'''
def setExporter(self, exporter_):
- exp = self.getSettings().getExporters(CGDocument.appType)[exporter_[0]]
+ exp = self.getSettings().getExporters(self.appType)[exporter_[0]]
self.cp_Exporter = self.getSettings().cp_Exporters.getKey(exp)
'''
@@ -308,7 +293,7 @@ class CGDocument(ConfigGroup):
return 0
exporter = self.getSettings().cp_Exporters.getElement(self.cp_Exporter)
- exporters = self.getSettings().getExporters(CGDocument.appType)
+ exporters = self.getSettings().getExporters(self.appType)
i = 0
while i < len(exporters):
if exporters[i] == exporter:
@@ -316,3 +301,6 @@ class CGDocument(ConfigGroup):
i += 1
return -1
+
+ def toString(self):
+ return self.localFilename
diff --git a/wizards/com/sun/star/wizards/web/data/CGExporter.py b/wizards/com/sun/star/wizards/web/data/CGExporter.py
index 0368d0eeab97..daddbcbd21f2 100644
--- a/wizards/com/sun/star/wizards/web/data/CGExporter.py
+++ b/wizards/com/sun/star/wizards/web/data/CGExporter.py
@@ -20,21 +20,26 @@ from ...common.ConfigGroup import ConfigGroup
from .CGArgument import CGArgument
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 = WebConfigSet(CGArgument)
+
+ def __init__(self):
+ self.cp_Index = -1
+ self.cp_Name = str()
+ self.cp_ExporterClass = str()
+ self.cp_OwnDirectory = bool()
+ self.cp_SupportsFilename = bool()
+ self.cp_DefaultFilename = str()
+ self.cp_Extension = str()
+ self.cp_SupportedMimeTypes = str()
+ self.cp_Icon = str()
+ self.cp_TargetType = str()
+ self.cp_Binary = bool()
+ self.cp_PageType = int()
+ self.targetTypeName = ""
+ self.cp_Arguments = WebConfigSet(CGArgument)
+
+ def toString(self):
+ return self.cp_Name
def supports(self, mime):
- return CGExporter.cp_SupportedMimeTypes == "" or \
- CGExporter.cp_SupportedMimeTypes.find(mime) > -1
+ return self.cp_SupportedMimeTypes == "" or \
+ self.cp_SupportedMimeTypes.find(mime) > -1
diff --git a/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.py b/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.py
index bdfdae6dfbd6..4fcbd60b9d00 100644
--- a/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.py
+++ b/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.py
@@ -20,13 +20,14 @@ from ...common.XMLHelper import XMLHelper
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 __init__(self):
+ self.cp_Title = str()
+ self.cp_Description = str()
+ self.cp_Author = str()
+ self.cp_CreationDate = int()
+ self.cp_UpdateDate = int()
+ self.cp_Email = str()
+ self.cp_Copyright = str()
def createDOM(self, parent):
return XMLHelper.addElement(
diff --git a/wizards/com/sun/star/wizards/web/data/CGIconSet.py b/wizards/com/sun/star/wizards/web/data/CGIconSet.py
index 6f8c88fab0f0..c63f4274bd10 100644
--- a/wizards/com/sun/star/wizards/web/data/CGIconSet.py
+++ b/wizards/com/sun/star/wizards/web/data/CGIconSet.py
@@ -18,7 +18,9 @@
from ...common.ConfigGroup import ConfigGroup
class CGIconSet(ConfigGroup):
- cp_Index = -1
- cp_FNPrefix = str()
- cp_FNPostfix = str()
- cp_Name = str()
+
+ def __init__(self):
+ self.cp_Index = -1
+ self.cp_FNPrefix = str()
+ self.cp_FNPostfix = str()
+ self.cp_Name = str()
diff --git a/wizards/com/sun/star/wizards/web/data/CGLayout.py b/wizards/com/sun/star/wizards/web/data/CGLayout.py
index 5bc919bfb6c6..99396a2e241a 100644
--- a/wizards/com/sun/star/wizards/web/data/CGLayout.py
+++ b/wizards/com/sun/star/wizards/web/data/CGLayout.py
@@ -21,9 +21,10 @@ from ...ui.UIConsts import UIConsts
class CGLayout(ConfigGroup):
- cp_Index = -1
- cp_Name = str()
- cp_FSName = str()
+ def __init__(self):
+ self.cp_Index = -1
+ self.cp_Name = str()
+ self.cp_FSName = str()
def getSettings(self):
return self.root
diff --git a/wizards/com/sun/star/wizards/web/data/CGPublish.py b/wizards/com/sun/star/wizards/web/data/CGPublish.py
index 6a5c92f4dd93..47bd6e525824 100644
--- a/wizards/com/sun/star/wizards/web/data/CGPublish.py
+++ b/wizards/com/sun/star/wizards/web/data/CGPublish.py
@@ -26,28 +26,24 @@ through such a CGPublish object.
class CGPublish(ConfigGroup):
- cp_Publish = bool()
- cp_URL = str()
- cp_Username = str()
- password = str()
- overwriteApproved = bool()
- url = str()
+ def __init__(self):
+ self.cp_Publish = bool()
+ self.cp_URL = str()
+ self.cp_Username = str()
+ self.password = str()
+ self.overwriteApproved = bool()
+ self.url = str()
def setURL(self, path):
try:
- self.cp_URL = (self.root).getFileAccess().getURL(path)
+ self.cp_URL = self.root.getFileAccess().getURL(path)
self.overwriteApproved = False
except Exception as ex:
ex.printStackTrace()
def getURL(self):
try:
- return (self.root).getFileAccess().getPath(self.cp_URL, None)
+ return self.root.getFileAccess().getPath(self.cp_URL, None)
except Exception as 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
index a2c32d1d06ac..c0fdf004e7c6 100644
--- a/wizards/com/sun/star/wizards/web/data/CGSession.py
+++ b/wizards/com/sun/star/wizards/web/data/CGSession.py
@@ -29,15 +29,16 @@ from xml.dom.minidom import Document
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 = WebConfigSet(CGPublish)
- valid = False
+ def __init__(self):
+ self.cp_Index = -1
+ self.cp_InDirectory = str()
+ self.cp_OutDirectory = str()
+ self.cp_Name = str()
+ self.cp_Content = CGContent()
+ self.cp_Design = CGDesign()
+ self.cp_GeneralInfo = CGGeneralInfo()
+ self.cp_Publishing = WebConfigSet(CGPublish)
+ self.valid = False
def createDOM(self, parent):
root = XMLHelper.addElement(
diff --git a/wizards/com/sun/star/wizards/web/data/CGSessionName.py b/wizards/com/sun/star/wizards/web/data/CGSessionName.py
index 283eaac2a600..13a5267ed500 100644
--- a/wizards/com/sun/star/wizards/web/data/CGSessionName.py
+++ b/wizards/com/sun/star/wizards/web/data/CGSessionName.py
@@ -18,5 +18,10 @@
from ...common.ConfigGroup import ConfigGroup
class CGSessionName(ConfigGroup):
- cp_Index = -1
- cp_Name = str()
+
+ def __init__(self):
+ self.cp_Index = -1
+ self.cp_Name = str()
+
+ def toString(self):
+ return self.cp_Name
diff --git a/wizards/com/sun/star/wizards/web/data/CGSettings.py b/wizards/com/sun/star/wizards/web/data/CGSettings.py
index 5a8a85f6f4fe..19e5e0ee53c2 100644
--- a/wizards/com/sun/star/wizards/web/data/CGSettings.py
+++ b/wizards/com/sun/star/wizards/web/data/CGSettings.py
@@ -35,6 +35,7 @@ from .CGSession import CGSession
from com.sun.star.i18n.NumberFormatIndex import DATE_SYS_DMMMYYYY
from com.sun.star.i18n.NumberFormatIndex import NUMBER_1000DEC2
+from com.sun.star.util import DateTime
class CGSettings(ConfigGroup):
@@ -44,28 +45,27 @@ class CGSettings(ConfigGroup):
RESOURCE_UPDATED_TEMPLATE = 3
RESOURCE_SIZE_TEMPLATE = 4
- cp_WorkDir = str()
- cp_Exporters = WebConfigSet(CGExporter)
- cp_Layouts = WebConfigSet(CGLayout)
- cp_Styles = WebConfigSet(CGStyle)
- cp_IconSets = WebConfigSet(CGIconSet)
- cp_BackgroundImages = WebConfigSet(CGImage)
- cp_SavedSessions = WebConfigSet(CGSessionName)
- cp_Filters = WebConfigSet(CGFilter)
- savedSessions = WebConfigSet(CGSessionName)
- cp_DefaultSession = CGSession()
- cp_LastSavedSession = str()
- fileAccess = None
-
def __init__(self, xmsf_, resources_, document):
+ self.cp_WorkDir = str()
+ self.cp_Exporters = WebConfigSet(CGExporter)
+ self.cp_Layouts = WebConfigSet(CGLayout)
+ self.cp_Styles = WebConfigSet(CGStyle)
+ self.cp_IconSets = WebConfigSet(CGIconSet)
+ self.cp_BackgroundImages = WebConfigSet(CGImage)
+ self.cp_SavedSessions = WebConfigSet(CGSessionName)
+ self.cp_Filters = WebConfigSet(CGFilter)
+ self.savedSessions = WebConfigSet(CGSessionName)
+ self.cp_DefaultSession = CGSession()
+ self.cp_LastSavedSession = str()
+ self.fileAccess = None
+ self.workPath = None
self.xmsf = xmsf_
try:
self.soTemplateDir = FileAccess.getOfficePath2(self.xmsf, "Config", "", "");
self.soGalleryDir = FileAccess.getOfficePath2(self.xmsf, "Gallery", "share", "");
- ConfigGroup.root = self
- self.formatter = self.Formatter(self.xmsf, document)
+ self.setRoot(self)
+ self.formatter = self.Formatter(self.xmsf, document, resources_)
self.resources = resources_
- self.workPath = None
self.exportersMap = {}
except Exception:
traceback.print_exc()
@@ -75,21 +75,17 @@ class CGSettings(ConfigGroup):
if exps is None:
exps = self.createExporters(mime)
self.exportersMap[mime] = exps
-
return exps
def createExporters(self, mime):
exporters = self.cp_Exporters.childrenList
v = []
for i in exporters:
- if i is not None:
- if i.supports(mime):
- try:
- v.append(i)
- except Exception:
- traceback.print_exc()
- else:
- print ("DEBUG !!! Exporter is None")
+ if i.supports(mime):
+ try:
+ v.append(i)
+ except Exception:
+ traceback.print_exc()
return v
'''
@@ -99,37 +95,28 @@ class CGSettings(ConfigGroup):
'''
def configure(self, xmsf):
- self.workPath = FileAccess.connectURLs(
- self.soTemplateDir, self.cp_WorkDir)
- #COMMENTED
+ self.workPath = FileAccess.connectURLs(self.soTemplateDir, self.cp_WorkDir)
self.calcExportersTargetTypeNames(xmsf)
def calcExportersTargetTypeNames(self, xmsf):
- typeDetect = xmsf.createInstance(
- "com.sun.star.document.TypeDetection")
+ typeDetect = xmsf.createInstance("com.sun.star.document.TypeDetection")
for i in range(self.cp_Exporters.getSize()):
- self.calcExporterTargetTypeName(
- typeDetect, self.cp_Exporters.getElementAt(i))
+ self.calcExporterTargetTypeName(typeDetect, self.cp_Exporters.getElementAt(i))
def calcExporterTargetTypeName(self, typeDetect, exporter):
if (exporter is None):
- print ("WARNING !!!! calcExporterTargetTypeName - received None as exporter argument.")
return
- print ("WARNING !!!! calcExporterTargetTypeName - targetType: ", exporter.cp_TargetType)
if not (exporter.cp_TargetType == "" or exporter.cp_TargetType is None):
targetTypeName = Properties.getPropertyValue(
typeDetect.getByName(exporter.cp_TargetType), "UIName")
- print ("WARNING !!!! calcExporterTargetTypeName - targetTypeName: ", targetTypeName)
exporter.cp_targetTypeName = targetTypeName
- @classmethod
def getFileAccess(self, xmsf = None):
if xmsf is None:
xmsf = self.xmsf
- if CGSettings.fileAccess is None:
- CGSettings.fileAccess = FileAccess(xmsf)
-
- return CGSettings.fileAccess
+ if self.fileAccess is None:
+ self.fileAccess = FileAccess(xmsf)
+ return self.fileAccess
class Formatter(object):
class DateUtils(object):
@@ -145,35 +132,40 @@ class CGSettings(ConfigGroup):
@param format a constant of the enumeration NumberFormatIndex
@return
'''
- def getFormat(self, format):
- return NumberFormatter.getNumberFormatterKey(self.formatSupplier, format)
+ def getFormat(self, f):
+ return NumberFormatter.getNumberFormatterKey(self.formatSupplier, f)
'''
@param date a VCL date in form of 20041231
@return a document relative date
'''
def format(self, formatIndex, date):
- difference = date - self.calendar
+ dateTime = dateTimeObject(date.Year, date.Month, date.Day)
+ difference = dateTime - self.calendar
return self.formatter.convertNumberToString(formatIndex, difference.days)
- def __init__(self, xmsf, document):
+ def getFormatter(self):
+ return self.formatter
+
+ def __init__(self, xmsf, document, resources):
self.dateUtils = self.DateUtils(xmsf, document)
self.dateFormat = self.dateUtils.getFormat(DATE_SYS_DMMMYYYY)
self.numberFormat = self.dateUtils.getFormat(NUMBER_1000DEC2)
+ self.resources = resources
def formatCreated(self, date):
- sDate = self.dateUtils.format(dateFormat, date)
- return resources[CGSettings.RESOURCE_CREATED_TEMPLATE].replace(
+ sDate = self.dateUtils.format(self.dateFormat, date)
+ return self.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(
+ sDate = self.dateUtils.format(self.dateFormat, date);
+ return self.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(
+ self.numberFormat, sizeInKB)
+ return self.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
index 2de5fdde14a4..27e33c62bf38 100644
--- a/wizards/com/sun/star/wizards/web/data/CGStyle.py
+++ b/wizards/com/sun/star/wizards/web/data/CGStyle.py
@@ -24,6 +24,9 @@ class CGStyle(ConfigGroup):
cp_BackgroundImage = str()
cp_IconSet = str()
+ def toString(self):
+ return self.cp_Name
+
def getBackgroundUrl(self):
if CGStyle.cp_BackgroundImage is None \
or CGStyle.cp_BackgroundImage == "":