summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/web/data/CGDocument.py
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/com/sun/star/wizards/web/data/CGDocument.py')
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGDocument.py124
1 files changed, 68 insertions, 56 deletions
diff --git a/wizards/com/sun/star/wizards/web/data/CGDocument.py b/wizards/com/sun/star/wizards/web/data/CGDocument.py
index cc8ff9818f34..11f6daedabbf 100644
--- a/wizards/com/sun/star/wizards/web/data/CGDocument.py
+++ b/wizards/com/sun/star/wizards/web/data/CGDocument.py
@@ -1,4 +1,14 @@
+from os import sep as separator
from common.ConfigGroup import ConfigGroup
+from document.OfficeDocument import OfficeDocument
+from common.Properties import Properties
+from common.PropertyNames import PropertyNames
+from common.FileAccess import FileAccess
+from TypeDetection import *
+from common.Desktop import Desktop
+
+from com.sun.star.document.MacroExecMode import NEVER_EXECUTE
+from com.sun.star.document.UpdateDocMode import NO_UPDATE
'''
About the member fields Title, Decription and Author:
@@ -16,6 +26,7 @@ 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
@@ -30,6 +41,7 @@ class CGDocument(ConfigGroup):
sizeBytes = -1
pages = -1
valid = False
+ appType = None
'''
the task will advance 5 times during validate.
@@ -39,30 +51,30 @@ class CGDocument(ConfigGroup):
'''
def validate(self, xmsf, task):
- if not getSettings().getFileAccess(xmsf).exists(self.cp_URL, False):
+ if not self.root.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):
+ if self.root.getFileAccess(xmsf).isDirectory(self.cp_URL):
raise IllegalArgumentException (
"The given URL points to a directory");
#create a TypeDetection service
- mediaDescriptor = OfficeDocument.getFileMediaDecriptor(
+ self.mediaDescriptor = OfficeDocument.getFileMediaDecriptor(
xmsf, self.cp_URL)
- task.advance(True)
+ #task.advance(True)
#1
- analyzeFileType(self.mediaDescriptor)
- task.advance(True)
+ self.analyzeFileType(self.mediaDescriptor)
+ #task.advance(True)
#2
- path = getSettings().getFileAccess(xmsf).getPath(self.cp_URL, "")
- localFilename = FileAccess.getFilename(path, File.separator)
+ path = self.root.getFileAccess(xmsf).getPath(self.cp_URL, "")
+ localFilename = FileAccess.getFilename(path, 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)
+ #task.advance(True)
#3
if self.isSOOpenable:
# for documents which are openable through SO,
@@ -71,22 +83,22 @@ class CGDocument(ConfigGroup):
props = range(3)
props[0] = Properties.createProperty("Hidden", True)
props[1] = Properties.createProperty(
- "MacroExecutionMode", MacroExecMode.NEVER_EXECUTE)
+ "MacroExecutionMode", NEVER_EXECUTE)
props[2] = Properties.createProperty(
- "UpdateDocMode", UpdateDocMode.NO_UPDATE)
+ "UpdateDocMode", NO_UPDATE)
component = desktop.loadComponentFromURL(
- self.cp_URL, "_default", 0, props)
- xProps = component.getDocumentProperties()
+ self.cp_URL, "_default", 0, tuple(props))
+ xProps = component.DocumentProperties
- task.advance(True)
+ #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()
+ title = xProps.Title
+ description = xProps.Description
+ author = xProps.Author
+ createDate = xProps.CreationDate
+ updateDate = xProps.ModificationDate
else:
#get some information from OS.
@@ -94,24 +106,24 @@ class CGDocument(ConfigGroup):
updateDate = \
getSettings().getFileAccess(xmsf).getLastModified(self.cp_URL)
- task.advance(True)
+ #task.advance(True)
#5
valid = True
- if self.cp_Title.equals(""):
+ if self.cp_Title == "":
cp_Title = self.title
- if self.cp_Title.equals(""):
+ if self.cp_Title == "":
cp_Title = self.localFilename
- if self.cp_Description.equals(""):
+ if self.cp_Description == "":
cp_Description = self.description
- if self.cp_Author.equals(""):
+ if self.cp_Author == "":
cp_Author = self.author
if self.cp_Exporter == None or self.cp_Exporter == "":
cp_Exporter = \
- getSettings().cp_Exporters.getKey(getSettings().getExporters(self.appType)[0])
+ self.root.cp_Exporters.getKey(self.root.getExporters(CGDocument.appType))
'''
Analyzes a type-detection string, returned from the TypeDetection service,
@@ -122,46 +134,46 @@ class CGDocument(ConfigGroup):
if mediaDesc is None:
media = ""
else:
- mediaProperties.getPropertyValue(
+ media = Properties.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
+ CGDocument.appType = self.getDocType(media)
+ 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
+ parts = media.split("_")
+ if len(parts) < 2:
+ self.isSODocument = False
else:
- isSODocument = self.isSOOpenable and (parts[1].startsWith("Star"))
+ self.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.
+ @return one of the constants in the interface
'''
def getDocType(self, media):
- if media.equals(""):
- return TypeDetection.NO_TYPE
+ if media == "":
+ return NO_TYPE
- if media.startsWith("writer"):
- if media.startsWith("writer_web_HTML"):
- return TypeDetection.HTML_DOC
+ if media.startswith("writer"):
+ if media.startswith("writer_web_HTML"):
+ return 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
+ return WRITER_DOC
+
+ elif media.startswith("calc"):
+ return CALC_DOC
+ elif media.startswith("draw"):
+ return DRAW_DOC
+ elif media.startswith("impress"):
+ return IMPRESS_DOC
+ elif media.startswith("pdf"):
+ return PDF_DOC
+ elif media.startswith("gif") or media.startswith("jpg"):
+ return WEB_GRAPHICS
+ elif media.startswith("wav"):
+ return SOUND_FILE
else:
- return TypeDetection.NO_TYPE
+ return NO_TYPE
def createDOM(self, parent):
d = getSettings().cp_DefaultSession.cp_Design
@@ -214,7 +226,7 @@ class CGDocument(ConfigGroup):
def getIcon(self, exporter):
if exporter.cp_Icon == "":
- return getIcon(self.appType)
+ return getIcon(CGDocument.appType)
else:
return exporter.cp_Icon
@@ -237,7 +249,7 @@ class CGDocument(ConfigGroup):
'''
def setExporter(self, exporter_):
- exp = getSettings().getExporters(self.appType)[exporter_[0]]
+ exp = getSettings().getExporters(CGDocument.appType)[exporter_[0]]
cp_Exporter = getSettings().cp_Exporters.getKey(exp)
'''
@@ -250,7 +262,7 @@ class CGDocument(ConfigGroup):
return 0
exporter = getSettings().cp_Exporters.getElement(self.cp_Exporter)
- exporters = getSettings().getExporters(self.appType)
+ exporters = getSettings().getExporters(CGDocument.appType)
i = 0
while i < exporters.length:
if exporters[i] == exporter: