[Libreoffice-commits] ooxml-strict/impress ooxml-strict/impress.py ooxml-strict/Makefile

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Wed Dec 15 08:44:56 PST 2010


 ooxml-strict/Makefile                           |   33 ++++++++-
 ooxml-strict/impress.py                         |   87 ++++++++++++++++++++++++
 ooxml-strict/impress/background_solid.pptx      |binary
 ooxml-strict/impress/background_solid.py        |   25 ++++++
 ooxml-strict/impress/placeholders.pptx          |binary
 ooxml-strict/impress/placeholders.py            |   25 ++++++
 ooxml-strict/impress/textbox_align.pptx         |binary
 ooxml-strict/impress/textbox_align.py           |   25 ++++++
 ooxml-strict/impress/textbox_char_props.pptx    |binary
 ooxml-strict/impress/textbox_color.pptx         |binary
 ooxml-strict/impress/textbox_color.py           |   25 ++++++
 ooxml-strict/impress/textbox_list.pptx          |binary
 ooxml-strict/impress/textbox_numbered_list.pptx |binary
 13 files changed, 219 insertions(+), 1 deletion(-)

New commits:
commit acb2503014623489ab8dc46c6383cbf640d304fc
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Wed Dec 15 17:44:31 2010 +0100

    Added Radek's pptx tests

diff --git a/ooxml-strict/Makefile b/ooxml-strict/Makefile
index 63dc775..596e1d1 100755
--- a/ooxml-strict/Makefile
+++ b/ooxml-strict/Makefile
@@ -100,16 +100,47 @@ $(TMP)/parapr: $(WRITER).py $(WRITER)/parapr.py $(WRITER_TEMPLATES)/parapr.docx
 #
 # Impress tests
 #
-IMPRESS_TESTS=title-and-subtitle-formatted
+IMPRESS_TESTS=title-and-subtitle-formatted \
+			  placeholders \
+			  background_solid \
+			  textbox_align \
+			  textbox_color \
+
+IMPRESS=impress
 
 test-pml: $(IMPRESS_TESTS)
 	$(ECHO) "Generated PML tests"
 
 title-and-subtitle-formatted: $(TMP)/title-and-subtitle-formatted
 $(TMP)/title-and-subtitle-formatted: dumpsample.py pptxpatterns.py title-and-subtitle-formatted.pptx
+	$(ECHO) "Generating title-and-subtitle-formatted"
 	$(PYTHON) dumpsample.py pptxpatterns title-and-subtitle-formatted.pptx $(TMP)
 	$(TOUCH) $@
 
+placeholders: $(TMP)/placeholders
+$(TMP)/placeholders: $(IMPRESS).py $(IMPRESS)/placeholders.py $(IMPRESS)/placeholders.pptx
+	$(ECHO) "Generating placeholders"
+	$(PYTHON) $(IMPRESS).py $(IMPRESS).placeholders $(TMP)
+	$(TOUCH) $@
+
+background_solid: $(TMP)/background_solid
+$(TMP)/background_solid: $(IMPRESS).py $(IMPRESS)/background_solid.py $(IMPRESS)/background_solid.pptx
+	$(ECHO) "Generating background_solid"
+	$(PYTHON) $(IMPRESS).py $(IMPRESS).background_solid $(TMP)
+	$(TOUCH) $@
+
+textbox_align: $(TMP)/textbox_align
+$(TMP)/textbox_align: $(IMPRESS).py $(IMPRESS)/textbox_align.py $(IMPRESS)/textbox_align.pptx
+	$(ECHO) "Generating textbox_align"
+	$(PYTHON) $(IMPRESS).py $(IMPRESS).textbox_align $(TMP)
+	$(TOUCH) $@
+
+textbox_color: $(TMP)/textbox_color
+$(TMP)/textbox_color: $(IMPRESS).py $(IMPRESS)/textbox_color.py $(IMPRESS)/textbox_color.pptx
+	$(ECHO) "Generating textbox_color"
+	$(PYTHON) $(IMPRESS).py $(IMPRESS).textbox_color $(TMP)
+	$(TOUCH) $@
+
 #
 # Calc tests
 #
diff --git a/ooxml-strict/impress.py b/ooxml-strict/impress.py
new file mode 100644
index 0000000..9cff8a5
--- /dev/null
+++ b/ooxml-strict/impress.py
@@ -0,0 +1,87 @@
+# Copyright 2010, Thorsten Behrens, Radek Doulik, Novell Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain a
+# copy of the License at:
+#
+#            http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import sys, os, StringIO
+
+import pyxb.binding.saxer
+
+import re
+import opc
+import dml.dml, pml.pml, pml._msocompat, props.props, sml.sml, wml.wml
+
+if len(sys.argv) < 3:
+    print "Usage: impress.py <tests.py> <output_dir>"
+    sys.exit(1)
+else:
+    exec "import "+sys.argv[1]+" as worklist"
+
+    inFile = None;
+    mimetypes = None;
+
+    outDir = sys.argv[2]
+
+    if len(sys.argv) > 3:
+        fileMatch = re.compile('.*' + sys.argv[3] + '.*')
+    else:
+        fileMatch = re.compile('.*')
+
+    for test in worklist.tests:
+        if 'mimetypes' in test:
+            mimetypes = test['mimetypes']
+
+        if mimetypes == None:
+            print "no mimetypes specified"
+            sys.exit(1)
+
+        if 'input' in test:
+            inFile = test['input']
+            iteration=1
+
+        if inFile == None:
+            print "no input file specified"
+            sys.exit(1)
+
+        if fileMatch.match(inFile) is None:
+            continue
+
+        atOnce = False;
+        if 'atOnce' in test:
+            atOnce = True;
+
+        inFile = "impress/" + inFile
+        (inFileName,inFileExt) = os.path.splitext(os.path.basename(inFile))
+        package = opc.OPCPackage(inFile)
+
+        for (fragment, mimetype, schema, reltype) in package.files(mimetypes):
+
+            saxer = pyxb.binding.saxer.make_parser(location_base=fragment)
+            handler = saxer.getContentHandler()
+            saxer.parse(StringIO.StringIO(package.read(fragment)))
+            sax_instance = handler.rootObject()
+
+            if not atOnce:
+                for contentIter in sax_instance.iterateBinding(test['patterns']):
+                    # iterate content n times
+                    for i in range(test['iterations']):
+                        contentIter()
+                        currOutFile = outDir+"/"+inFileName+str(iteration)+inFileExt
+                        package.copyWithReplace(currOutFile,{fragment: sax_instance.toxml().encode('utf-8')})
+                        iteration += 1
+            else:
+                for i in range(test['iterations']):
+                    for contentIter in sax_instance.iterateBinding(test['patterns']):
+                        contentIter()
+                    currOutFile = outDir+"/"+inFileName+str(iteration)+inFileExt
+                    package.copyWithReplace(currOutFile,{fragment: sax_instance.toxml().encode('utf-8')})
+                    iteration += 1
diff --git a/ooxml-strict/impress/__init__.py b/ooxml-strict/impress/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/ooxml-strict/impress/background_solid.pptx b/ooxml-strict/impress/background_solid.pptx
new file mode 100755
index 0000000..f9612c1
Binary files /dev/null and b/ooxml-strict/impress/background_solid.pptx differ
diff --git a/ooxml-strict/impress/background_solid.py b/ooxml-strict/impress/background_solid.py
new file mode 100644
index 0000000..e354b73
--- /dev/null
+++ b/ooxml-strict/impress/background_solid.py
@@ -0,0 +1,25 @@
+# Copyright 2010, Radek Doulik, Novell Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain a
+# copy of the License at:
+#
+#            http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import re
+from opc import ALL_OOXML as ALL_OOXML
+
+tests = [
+    {
+        "mimetypes"  : [ "application/vnd.openxmlformats-officedocument.presentationml.slide+xml" ],
+        "input"      : "background_solid.pptx",
+        "iterations" : 4,
+        "patterns"   : [re.compile('.*CT_SRgbColor.*'), re.compile('.*val.*')]
+    }
+]
diff --git a/ooxml-strict/impress/placeholders.pptx b/ooxml-strict/impress/placeholders.pptx
new file mode 100644
index 0000000..659967f
Binary files /dev/null and b/ooxml-strict/impress/placeholders.pptx differ
diff --git a/ooxml-strict/impress/placeholders.py b/ooxml-strict/impress/placeholders.py
new file mode 100644
index 0000000..b3af178
--- /dev/null
+++ b/ooxml-strict/impress/placeholders.py
@@ -0,0 +1,25 @@
+# Copyright 2010, Radek Doulik, Novell Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain a
+# copy of the License at:
+#
+#            http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import re
+from opc import ALL_OOXML as ALL_OOXML
+
+tests = [
+    {
+        "mimetypes"  : [ "application/vnd.openxmlformats-officedocument.presentationml.slide+xml" ],
+        "input"      : "placeholders.pptx",
+        "iterations" : 16,
+        "patterns"   : [re.compile('.*type.*')]
+    }
+]
diff --git a/ooxml-strict/impress/textbox_align.pptx b/ooxml-strict/impress/textbox_align.pptx
new file mode 100755
index 0000000..2a3e3d4
Binary files /dev/null and b/ooxml-strict/impress/textbox_align.pptx differ
diff --git a/ooxml-strict/impress/textbox_align.py b/ooxml-strict/impress/textbox_align.py
new file mode 100644
index 0000000..4e6df43
--- /dev/null
+++ b/ooxml-strict/impress/textbox_align.py
@@ -0,0 +1,25 @@
+# Copyright 2010, Radek Doulik, Novell Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain a
+# copy of the License at:
+#
+#            http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import re
+from opc import ALL_OOXML as ALL_OOXML
+
+tests = [
+    {
+        "mimetypes"  : [ "application/vnd.openxmlformats-officedocument.presentationml.slide+xml" ],
+        "input"      : "textbox_align.pptx",
+        "iterations" : 7,
+        "patterns"   : [re.compile('.*CT_TextParagraphProperties.*'), re.compile('.*algn.*')]
+    }
+]
diff --git a/ooxml-strict/impress/textbox_char_props.pptx b/ooxml-strict/impress/textbox_char_props.pptx
new file mode 100755
index 0000000..8dee1bf
Binary files /dev/null and b/ooxml-strict/impress/textbox_char_props.pptx differ
diff --git a/ooxml-strict/impress/textbox_color.pptx b/ooxml-strict/impress/textbox_color.pptx
new file mode 100755
index 0000000..32e5a0b
Binary files /dev/null and b/ooxml-strict/impress/textbox_color.pptx differ
diff --git a/ooxml-strict/impress/textbox_color.py b/ooxml-strict/impress/textbox_color.py
new file mode 100644
index 0000000..20c1f6c
--- /dev/null
+++ b/ooxml-strict/impress/textbox_color.py
@@ -0,0 +1,25 @@
+# Copyright 2010, Radek Doulik, Novell Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain a
+# copy of the License at:
+#
+#            http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import re
+from opc import ALL_OOXML as ALL_OOXML
+
+tests = [
+    {
+        "mimetypes"  : [ "application/vnd.openxmlformats-officedocument.presentationml.slide+xml" ],
+        "input"      : "textbox_color.pptx",
+        "iterations" : 2,
+        "patterns"   : [re.compile(".*CT_SchemeColor.*"), re.compile(".*lumMod.*"), re.compile(".*val.*")]
+    }
+]
diff --git a/ooxml-strict/impress/textbox_list.pptx b/ooxml-strict/impress/textbox_list.pptx
new file mode 100755
index 0000000..7912c80
Binary files /dev/null and b/ooxml-strict/impress/textbox_list.pptx differ
diff --git a/ooxml-strict/impress/textbox_numbered_list.pptx b/ooxml-strict/impress/textbox_numbered_list.pptx
new file mode 100755
index 0000000..e221755
Binary files /dev/null and b/ooxml-strict/impress/textbox_numbered_list.pptx differ


More information about the Libreoffice-commits mailing list