Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: experimental/PdfViewer/spec2def.py

Issue 21125002: pdfviewer: more plumming for soft masks (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkPdfObject.h ('k') | gyp/pdfviewer.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/spec2def.py
===================================================================
--- experimental/PdfViewer/spec2def.py (revision 10402)
+++ experimental/PdfViewer/spec2def.py (working copy)
@@ -116,9 +116,9 @@
'TABLE 6.5': ['Type10HalftoneDictionary', 'Additional entries specific to a type 10 halftone dictionary'],
'TABLE 6.6': ['Type16HalftoneDictionary', 'Additional entries specific to a type 16 halftone dictionary'],
'TABLE 6.7': ['Type5HalftoneDictionary', 'Entries in a type 5 halftone dictionary'],
-'TABLE 7.10': ['SoftMaskDictionary', 'Entries in a soft-mask dictionary'],
-'TABLE 7.12': ['SoftMaskImageDictionary', 'Additional entry in a soft-mask image dictionary'],
-'TABLE 7.13': ['TransparencyGroupDictionary', 'Additional entries specific to a transparency group attributes dictionary'],
+'TABLE 7.10': ['SoftMaskDictionary', 'Entries in a soft-mask dictionary', '', {'S': '[datatypes.PdfName(\'Alpha\'), datatypes.PdfName(\'Luminosity\')]'}],
+'TABLE 7.12': ['SoftMaskImageDictionary', 'Additional entry in a soft-mask image dictionary', 'ImageDictionary', {'Subtype': '[datatypes.PdfName(\'Image\')]', 'ColorSpace': '[datatypes.PdfName(\'DeviceGray\'), datatypes.PdfName(\'Gray\')]'}],
+'TABLE 7.13': ['TransparencyGroupDictionary', 'Additional entries specific to a transparency group attributes dictionary', 'XObjectDictionary', {'S': '[datatypes.PdfName(\'Transparency\')]'}],
'TABLE 8.1': ['ViewerPreferencesDictionary', 'Entries in a viewer preferences dictionary'],
'TABLE 8.3': ['OutlineDictionary', 'Entries in the outline dictionary'],
'TABLE 8.4': ['OutlineItemDictionary', 'Entries in an outline item dictionary'],
@@ -222,6 +222,9 @@
'TABLE 9.49': ['OpiVersionDictionary', 'Entry in an OPI version dictionary'],
}
+classTree = {
+}
+
def buildKnownDictionaries():
global tableToClassName
global knownTypes
@@ -297,7 +300,10 @@
global emitedDitionaryName
global table
global tableToClassName
+ global classTree
+ global tableKey
+
if columnValues == None:
return
@@ -392,10 +398,13 @@
emitedDitionaryName = tableToClassName[tableKey][0]
comment = fix(tableToClassName[tableKey][1])
+
if len(tableToClassName[tableKey]) >= 3 and tableToClassName[tableKey][2] != '':
fspecPy.write(' pdfspec.addClass(\'' + emitedDitionaryName + '\', \'' + tableToClassName[tableKey][2] + '\', \'' + comment + '\')\\\n')
+ classTree[emitedDitionaryName] = [tableToClassName[tableKey][2], {}]
else:
fspecPy.write(' pdfspec.addClass(\'' + emitedDitionaryName + '\', \'Dictionary\', \'' + comment + '\')\\\n')
+ classTree[emitedDitionaryName] = ['Dictionary', {}]
if len(tableToClassName[tableKey]) >= 4 and columnValues[0] in tableToClassName[tableKey][3]:
required = True
@@ -409,6 +418,12 @@
fspecPy.write(' .name(\'' + columnValues[0] + '\')\\\n')
fspecPy.write(' .type(\'' + columnValues[1] + '\')\\\n')
fspecPy.write(' .comment(\'' + columnValues[2] + '\')\\\n')
+
+ classTree[emitedDitionaryName][1][columnValues[0]] = ' .field(\'' + columnValues[0] + '\')\\\n' + \
+ ' .name(\'' + columnValues[0] + '\')\\\n' + \
+ ' .type(\'' + columnValues[1] + '\')\\\n' + \
+ ' .comment(\'\')\\\n'
+
if len(tableToClassName[tableKey]) >= 4 and columnValues[0] in tableToClassName[tableKey][3]:
fspecPy.write(' .must(' + tableToClassName[tableKey][3][columnValues[0]] + ')\\\n')
@@ -461,11 +476,39 @@
def stopTable(fspecPy):
global tableHeaderFound
global emitedDitionaryName
-
+ global tableKey
+ global classTree
+
if not inTable():
return
commitRow(fspecPy)
+
+ #print tableKey
+
+ # TODO(edisonn): iterate on all requited key in the def, and if not on the definition, get definition from parent and export them
+ if len(tableToClassName[tableKey]) >= 4:
+ for field in tableToClassName[tableKey][3]:
+ #print field
+ if not field in classTree[emitedDitionaryName][1]:
+ fieldDef = ''
+ searchKey = classTree[emitedDitionaryName][0]
+ while searchKey != 'Dictionary' and (not field in classTree[searchKey][1]):
+ searchKey = classTree[searchKey][0]
+
+ if searchKey != 'Dictionary' and (field in classTree[searchKey][1]):
+ #print tableToClassName[tableKey][3][field]
+ #print classTree[searchKey][1][field]
+ # TODO(edisonns): hack - for required fields, they need to be downgraded to only a type
+ classTree[searchKey][1][field] = classTree[searchKey][1][field].replace(' or array', '')
+ classTree[searchKey][1][field] = classTree[searchKey][1][field].replace(' or distionary', '')
+ fspecPy.write(' .required(\'NULL\')\\\n')
+ fspecPy.write(classTree[searchKey][1][field])
+ fspecPy.write(' .must(' + tableToClassName[tableKey][3][field] + ')\\\n')
+ fspecPy.write(' .done().done()\\\n')
+ else:
+ print 'ERROR' + tableKey + '.' + field;
+
tableHeaderFound = False
emitedDitionaryName = ''
fspecPy.write(' .done()\n')
@@ -569,7 +612,7 @@
return False
if first != '' and second != '' and third[0] != '(':
- stopTable()
+ stopTable(fspecPy)
return False
if first == '' and second != '' and second[0] == ' ':
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkPdfObject.h ('k') | gyp/pdfviewer.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698