~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to plugins/chartshape/tests/odf/create-test

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
pwd | grep "koffice/plugins/chartshape/tests/odf$" > /dev/null
 
4
# If grep returns 1 (instead of 0), the string wasn't found in pwd's output
 
5
if [ $? -eq 1 ]; then
 
6
    echo "Error: This script must be run from koffice/plugins/chartshape/tests/odf"
 
7
    exit
 
8
fi
 
9
if [ -z $2 ]; then
 
10
    echo "Usage: $0 test-document.[odt|ods|odp] test-name"
 
11
    exit
 
12
fi
 
13
 
 
14
# The document to create the test case from, e.g. "/path/to/test-doc.odt"
 
15
doc=$1
 
16
# Extract document name
 
17
doc_name=`echo $doc | sed "s/.*\///"`
 
18
# The name of the test case, e.g. "mytest"
 
19
name=$2
 
20
uppercase_name=`echo $name | tr [:lower:] [:upper:] | tr - _`
 
21
 
 
22
if [ -d $name ]; then
 
23
        echo "A test case with the name \"$name\" already exists. Aborting."
 
24
        exit
 
25
fi
 
26
 
 
27
echo $name | grep -v [\ \;\,\\\/] > /dev/null
 
28
if [ $? -eq 1 ]; then
 
29
        echo "The test name must not contain spaces or any other special characters. Aborting"
 
30
        exit
 
31
fi
 
32
 
 
33
# 1) Create new test folder from template/
 
34
cp -r template/ "$name"
 
35
 
 
36
# 2) TODO: Replace template's placeholders
 
37
sed -i "" "s/@@NAME@@/$name/g" "$name/CMakeLists.txt"
 
38
sed -i "" "s/@@UPPERCASE_NAME@@/$uppercase_name/g" "$name/TestLoading.h"
 
39
 
 
40
echo "========= Info ========="
 
41
echo "Don't forget to fill in @@COPYRIGHT@@ in TestLoading.h and TestLoading.cpp."
 
42
 
 
43
# 3) Keep a copy or original document
 
44
cp "$doc" "$name/"
 
45
 
 
46
doc_path="$name/doc"
 
47
mkdir $doc_path
 
48
 
 
49
echo "add_subdirectory( $name )" >> CMakeLists.txt
 
50
 
 
51
echo ""
 
52
echo "========= Added test case to ./CMakeLists.txt ========="
 
53
 
 
54
echo ""
 
55
echo "========= Extracting $doc_name ========="
 
56
# 4) Unzip document
 
57
unzip "$doc" -d "$doc_path/orig"
 
58
 
 
59
# Remove object replacements, we don't need them and the directory name
 
60
# "ObjectReplacements" gets in the way of looking for objects with the pattern Object*
 
61
rm -rf "$doc_path/orig/ObjectReplacements"
 
62
 
 
63
# 5) Find chart document
 
64
# If Chart* or Object* is expended to a valid directory name, this means there is only
 
65
# one embedded object, which we will assume is the chart.
 
66
chart_doc_path=`echo "$doc_path/orig/"Chart*`
 
67
 
 
68
if [ ! -d "$chart_doc_path" ]; then
 
69
        chart_doc_path=`echo "$doc_path/orig/"Object*`
 
70
fi
 
71
 
 
72
if [ -d "$chart_doc_path" ]; then
 
73
        mv "$chart_doc_path/content.xml" "$doc_path/content.xml"
 
74
        mv "$chart_doc_path/styles.xml" "$doc_path/styles.xml"
 
75
        if [ -e "$chart_doc_path/meta.xml" ]; then
 
76
                mv "$chart_doc_path/meta.xml" "$doc_path/meta.xml"
 
77
        else
 
78
                if [ -e "$doc_path/orig/meta.xml" ]; then
 
79
                        mv "$doc_path/orig/meta.xml" "$doc_path/meta.xml"
 
80
                        echo "Warning: No meta.xml found in chart document. Instead the embedding document's meta.xml was used. This should work, but might lead to problems in the loading process."
 
81
                else
 
82
                        echo "Warning: No meta.xml found. Workarounds for ODF bugs in other office suites don't work if the document's creator is unknown."
 
83
                fi
 
84
        fi
 
85
else
 
86
        echo ""
 
87
        echo "========= Process not yet completed ========="
 
88
        echo "There is more than one embedded object in this document. Look in $doc_path/orig and find the chart document's directory, e.g. \"Object 3\". Then copy the meta.xml, styles.xml and content.xml from there to $doc_path/. After that you can safely remove $doc_path/orig/ and you're done."
 
89
        exit
 
90
fi
 
91
 
 
92
# 6) Clean up
 
93
rm -rf "$doc_path/orig"
 
94
 
 
95
echo ""
 
96
echo "========= Successfully created test case \"$name\"! ========="