Revision 2149
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.app/org.gvsig.ods.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<dependencySets> |
|
26 |
|
|
27 |
<dependencySet> |
|
28 |
<useProjectArtifact>false</useProjectArtifact> |
|
29 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
30 |
<outputDirectory>lib</outputDirectory> |
|
31 |
<includes> |
|
32 |
<include>org.jopendocument:jOpenDocument</include> |
|
33 |
<include>com.github.miachm.sods:SODS</include> |
|
34 |
<include>org.gvsig:org.gvsig.ods.lib.api</include> |
|
35 |
<include>org.gvsig:org.gvsig.ods.lib.impl</include> |
|
36 |
<include>org.gvsig:org.gvsig.ods.provider</include> |
|
37 |
<include>org.gvsig:org.gvsig.ods.swing.api</include> |
|
38 |
<include>org.gvsig:org.gvsig.ods.swing.impl</include> |
|
39 |
</includes> |
|
40 |
</dependencySet> |
|
41 |
|
|
42 |
</dependencySets> |
|
43 |
|
|
44 |
</assembly> |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.app/org.gvsig.ods.app.mainplugin/src/main/java/org/gvsig/ods/ODSExtension.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.ods; |
|
25 |
|
|
26 |
import org.gvsig.andami.plugins.Extension; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @author jjdelcerro |
|
31 |
*/ |
|
32 |
public class ODSExtension extends Extension { |
|
33 |
|
|
34 |
@Override |
|
35 |
public void initialize() { |
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public void postInitialize() { |
|
41 |
|
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public void execute(String action) { |
|
46 |
|
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public boolean isEnabled() { |
|
51 |
|
|
52 |
return true; |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public boolean isVisible() { |
|
57 |
return true; |
|
58 |
} |
|
59 |
|
|
60 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.app/org.gvsig.ods.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<libraries library-dir="lib/"/> |
|
4 |
<depends plugin-name="org.gvsig.app.mainplugin"/> |
|
5 |
<depends plugin-name="org.gvsig.pdf.app.mainplugin"/> |
|
6 |
<resourceBundle name="text"/> |
|
7 |
<extensions> |
|
8 |
<extension class-name="org.gvsig.andami.LibraryExtension" active="false"/> |
|
9 |
</extensions> |
|
10 |
</plugin-config> |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.app/org.gvsig.ods.app.mainplugin/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.ods.app.mainplugin</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
<description>ODS file format support</description> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.ods.app</artifactId> |
|
11 |
<version>1.0.173</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencies> |
|
15 |
<dependency> |
|
16 |
<groupId>org.gvsig</groupId> |
|
17 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
18 |
<scope>compile</scope> |
|
19 |
</dependency> |
|
20 |
<dependency> |
|
21 |
<groupId>org.gvsig</groupId> |
|
22 |
<artifactId>org.gvsig.andami</artifactId> |
|
23 |
<scope>compile</scope> |
|
24 |
</dependency> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.ods.provider</artifactId> |
|
28 |
<scope>compile</scope> |
|
29 |
</dependency> |
|
30 |
<dependency> |
|
31 |
<groupId>org.gvsig</groupId> |
|
32 |
<artifactId>org.gvsig.ods.swing.api</artifactId> |
|
33 |
<scope>runtime</scope> |
|
34 |
</dependency> |
|
35 |
<dependency> |
|
36 |
<groupId>org.gvsig</groupId> |
|
37 |
<artifactId>org.gvsig.ods.swing.impl</artifactId> |
|
38 |
<scope>runtime</scope> |
|
39 |
</dependency> |
|
40 |
<dependency> |
|
41 |
<groupId>org.gvsig</groupId> |
|
42 |
<artifactId>org.gvsig.ods.lib.impl</artifactId> |
|
43 |
<scope>runtime</scope> |
|
44 |
</dependency> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.ods.lib.api</artifactId> |
|
48 |
<scope>runtime</scope> |
|
49 |
</dependency> |
|
50 |
<dependency> |
|
51 |
<groupId>org.jopendocument</groupId> |
|
52 |
<artifactId>jOpenDocument</artifactId> |
|
53 |
<scope>runtime</scope> |
|
54 |
</dependency> |
|
55 |
<dependency> |
|
56 |
<groupId>com.github.miachm.sods</groupId> |
|
57 |
<artifactId>SODS</artifactId> |
|
58 |
<scope>runtime</scope> |
|
59 |
</dependency> |
|
60 |
</dependencies> |
|
61 |
|
|
62 |
<properties> |
|
63 |
<!-- Package info property values --> |
|
64 |
<!-- Default values in org.gvsig.desktop --> |
|
65 |
<gvsig.package.info.name>Formats: ODS file format support</gvsig.package.info.name> |
|
66 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
67 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
68 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.1.0-A</gvsig.package.info.dependencies> |
|
69 |
<gvsig.package.info.categories>Formats,Vector</gvsig.package.info.categories> |
|
70 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-jexcel/pool/</gvsig.package.info.poolURL> |
|
71 |
</properties> |
|
72 |
|
|
73 |
</project> |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.app/org.gvsig.ods.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Tue Jun 11 10:25:21 CEST 2024 |
|
2 |
buildNumber=180 |
|
0 | 3 |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.ods.app</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.ods</artifactId> |
|
10 |
<version>1.0.173</version> |
|
11 |
</parent> |
|
12 |
|
|
13 |
<modules> |
|
14 |
<module>${project.artifactId}.mainplugin</module> |
|
15 |
</modules> |
|
16 |
|
|
17 |
|
|
18 |
</project> |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.ods</artifactId> |
|
7 |
<packaging>pom</packaging> |
|
8 |
<name>${project.artifactId}</name> |
|
9 |
<version>1.0.173</version> |
|
10 |
<description>ODS support fort DAL and gvSIG</description> |
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.desktop</artifactId> |
|
14 |
<version>2.0.448</version> |
|
15 |
</parent> |
|
16 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-jexcel/org.gvsig.ods</url> |
|
17 |
|
|
18 |
<scm> |
|
19 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-jexcel/org.gvsig.ods/tags/org.gvsig.ods-1.0.173</connection> |
|
20 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-jexcel/org.gvsig.ods/tags/org.gvsig.ods-1.0.173</developerConnection> |
|
21 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-jexcel/repository/show/org.gvsig.ods/tags/org.gvsig.ods-1.0.173</url> |
|
22 |
</scm> |
|
23 |
<repositories> |
|
24 |
<repository> |
|
25 |
<id>gvsig-public-http-repository</id> |
|
26 |
<name>gvSIG maven public HTTP repository</name> |
|
27 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
28 |
<releases> |
|
29 |
<enabled>true</enabled> |
|
30 |
<updatePolicy>daily</updatePolicy> |
|
31 |
<checksumPolicy>warn</checksumPolicy> |
|
32 |
</releases> |
|
33 |
<snapshots> |
|
34 |
<enabled>true</enabled> |
|
35 |
<updatePolicy>daily</updatePolicy> |
|
36 |
<checksumPolicy>warn</checksumPolicy> |
|
37 |
</snapshots> |
|
38 |
</repository> |
|
39 |
</repositories> |
|
40 |
|
|
41 |
<build> |
|
42 |
<plugins> |
|
43 |
<plugin> |
|
44 |
<groupId>org.apache.maven.plugins</groupId> |
|
45 |
<artifactId>maven-release-plugin</artifactId> |
|
46 |
<configuration> |
|
47 |
<tagBase>https://devel.gvsig.org/svn/gvsig-jexcel/org.gvsig.ods/tags</tagBase> |
|
48 |
</configuration> |
|
49 |
</plugin> |
|
50 |
</plugins> |
|
51 |
</build> |
|
52 |
|
|
53 |
<properties> |
|
54 |
<org.gvsig.pdf.version>1.0.153</org.gvsig.pdf.version> |
|
55 |
</properties> |
|
56 |
|
|
57 |
<dependencyManagement> |
|
58 |
<dependencies> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.ods.lib.api</artifactId> |
|
62 |
<version>1.0.173</version> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.ods.lib.impl</artifactId> |
|
67 |
<version>1.0.173</version> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>org.gvsig</groupId> |
|
71 |
<artifactId>org.gvsig.ods.swing.api</artifactId> |
|
72 |
<version>1.0.173</version> |
|
73 |
</dependency> |
|
74 |
<dependency> |
|
75 |
<groupId>org.gvsig</groupId> |
|
76 |
<artifactId>org.gvsig.ods.swing.impl</artifactId> |
|
77 |
<version>1.0.173</version> |
|
78 |
</dependency> |
|
79 |
<dependency> |
|
80 |
<groupId>org.gvsig</groupId> |
|
81 |
<artifactId>org.gvsig.ods.provider</artifactId> |
|
82 |
<version>1.0.173</version> |
|
83 |
</dependency> |
|
84 |
<dependency> |
|
85 |
<groupId>org.gvsig</groupId> |
|
86 |
<artifactId>org.gvsig.ods.app.mainplugin</artifactId> |
|
87 |
<version>1.0.173</version> |
|
88 |
</dependency> |
|
89 |
<dependency> |
|
90 |
<groupId>com.github.miachm.sods</groupId> |
|
91 |
<artifactId>SODS</artifactId> |
|
92 |
<version>1.0.1</version> |
|
93 |
</dependency> |
|
94 |
<dependency> |
|
95 |
<groupId>org.gvsig</groupId> |
|
96 |
<artifactId>org.gvsig.pdf</artifactId> |
|
97 |
<version>${org.gvsig.pdf.version}</version> |
|
98 |
<type>pom</type> |
|
99 |
<scope>import</scope> |
|
100 |
</dependency> |
|
101 |
</dependencies> |
|
102 |
</dependencyManagement> |
|
103 |
|
|
104 |
|
|
105 |
<modules> |
|
106 |
<module>${project.artifactId}.app</module> |
|
107 |
<module>${project.artifactId}.provider</module> |
|
108 |
<module>${project.artifactId}.swing</module> |
|
109 |
<module>${project.artifactId}.lib</module> |
|
110 |
</modules> |
|
111 |
|
|
112 |
|
|
113 |
</project> |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.ods</artifactId> |
|
6 |
<version>1.0.173</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.ods.lib</artifactId> |
|
9 |
<packaging>pom</packaging> |
|
10 |
<name>${project.artifactId}</name> |
|
11 |
<modules> |
|
12 |
<module>org.gvsig.ods.lib.api</module> |
|
13 |
<module>org.gvsig.ods.lib.impl</module> |
|
14 |
</modules> |
|
15 |
</project> |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.ods.lib</artifactId> |
|
6 |
<version>1.0.173</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.ods.lib.impl</artifactId> |
|
9 |
<name>${project.artifactId}</name> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.ods.lib.api</artifactId> |
|
14 |
<scope>compile</scope> |
|
15 |
</dependency> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
19 |
<scope>compile</scope> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
24 |
<scope>compile</scope> |
|
25 |
</dependency> |
|
26 |
<dependency> |
|
27 |
<groupId>commons-codec</groupId> |
|
28 |
<artifactId>commons-codec</artifactId> |
|
29 |
<scope>compile</scope> |
|
30 |
</dependency> |
|
31 |
<dependency> |
|
32 |
<groupId>org.gvsig</groupId> |
|
33 |
<artifactId>org.gvsig.pdf.lib.api</artifactId> |
|
34 |
<scope>compile</scope> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.jopendocument</groupId> |
|
38 |
<artifactId>jOpenDocument</artifactId> |
|
39 |
<scope>compile</scope> |
|
40 |
</dependency> |
|
41 |
<dependency> |
|
42 |
<groupId>com.github.miachm.sods</groupId> |
|
43 |
<artifactId>SODS</artifactId> |
|
44 |
<scope>compile</scope> |
|
45 |
</dependency> |
|
46 |
</dependencies> |
|
47 |
</project> |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/src/main/java/org/gvsig/ods/lib/impl/ODSImplLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.ods.lib.impl; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.DALLibrary; |
|
27 |
import org.gvsig.ods.lib.api.ODSLibrary; |
|
28 |
import org.gvsig.ods.lib.api.ODSLocator; |
|
29 |
import org.gvsig.tools.ToolsLibrary; |
|
30 |
import org.gvsig.tools.library.AbstractLibrary; |
|
31 |
import org.gvsig.tools.library.LibraryException; |
|
32 |
|
|
33 |
public class ODSImplLibrary extends AbstractLibrary { |
|
34 |
|
|
35 |
@Override |
|
36 |
public void doRegistration() { |
|
37 |
super.doRegistration(); |
|
38 |
registerAsImplementationOf(ODSLibrary.class); |
|
39 |
this.require(ToolsLibrary.class); |
|
40 |
this.require(DALLibrary.class); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void doInitialize() throws LibraryException { |
|
45 |
ODSLocator.registerDefaultODSManager(DefaultODSManager.class); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doPostInitialize() throws LibraryException { |
|
50 |
ODSProfile.selfRegister(); |
|
51 |
} |
|
52 |
|
|
53 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/src/main/java/org/gvsig/ods/lib/impl/Spread.java | ||
---|---|---|
1 |
package org.gvsig.ods.lib.impl; |
|
2 |
|
|
3 |
import java.io.Closeable; |
|
4 |
import java.io.File; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Locale; |
|
7 |
import org.gvsig.ods.lib.api.ODSDocument.Sheet; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author jjdelcerro |
|
12 |
*/ |
|
13 |
public interface Spread extends Closeable { |
|
14 |
|
|
15 |
public void open(File ODSFile, Locale locale); |
|
16 |
|
|
17 |
public File getFile(); |
|
18 |
|
|
19 |
public Sheet getSheet(int sheetIndex); |
|
20 |
|
|
21 |
public List<String> getSheetNames(); |
|
22 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/src/main/java/org/gvsig/ods/lib/impl/DefaultODSManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.ods.lib.impl; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
import org.gvsig.ods.lib.api.ODSDocument; |
|
28 |
import org.gvsig.ods.lib.api.ODSManager; |
|
29 |
|
|
30 |
public class DefaultODSManager implements ODSManager { |
|
31 |
|
|
32 |
@Override |
|
33 |
public ODSDocument createODSDocument(byte[] document) { |
|
34 |
DefaultODSDocument doc = new DefaultODSDocument(); |
|
35 |
doc.setSource(document); |
|
36 |
return doc; |
|
37 |
} |
|
38 |
|
|
39 |
// public ODSDocument createODSDocument(String document) { |
|
40 |
// DefaultODSDocument doc = new DefaultODSDocument(); |
|
41 |
// doc.setDocument(document); |
|
42 |
// return doc; |
|
43 |
// } |
|
44 |
|
|
45 |
@Override |
|
46 |
public ODSDocument createODSDocument(File document) { |
|
47 |
DefaultODSDocument doc = new DefaultODSDocument(); |
|
48 |
doc.setSource(document); |
|
49 |
return doc; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public ODSDocument createODSDocument() { |
|
54 |
DefaultODSDocument doc = new DefaultODSDocument(); |
|
55 |
return doc; |
|
56 |
} |
|
57 |
|
|
58 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/src/main/java/org/gvsig/ods/lib/impl/ODSProfile.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.ods.lib.impl; |
|
7 |
|
|
8 |
import java.io.File; |
|
9 |
import org.gvsig.fmap.dal.DALLocator; |
|
10 |
import org.gvsig.fmap.dal.DataManager; |
|
11 |
import org.gvsig.fmap.dal.feature.AbstractDataProfile; |
|
12 |
import org.gvsig.ods.lib.api.ODSDocument; |
|
13 |
import org.gvsig.ods.lib.api.ODSLocator; |
|
14 |
import org.gvsig.ods.lib.api.ODSManager; |
|
15 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
16 |
import org.gvsig.tools.dataTypes.DataType; |
|
17 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
18 |
import org.gvsig.tools.dynobject.Tags; |
|
19 |
|
|
20 |
public class ODSProfile extends AbstractDataProfile { |
|
21 |
|
|
22 |
public ODSProfile() { |
|
23 |
super("ODS", File.class); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public Object createData(Object ods, Tags tags) { |
|
28 |
ODSManager manager = ODSLocator.getODSManager(); |
|
29 |
ODSDocument odsdoc = manager.createODSDocument(); |
|
30 |
odsdoc.setSource(ods); |
|
31 |
return odsdoc; |
|
32 |
} |
|
33 |
|
|
34 |
@Override |
|
35 |
public Object coerce(DataType dataType, Object data, Tags tags) throws CoercionException { |
|
36 |
ODSDocument document; |
|
37 |
try { |
|
38 |
switch (dataType.getType()) { |
|
39 |
case DataTypes.BYTEARRAY: |
|
40 |
document = ODSLocator.getODSManager().createODSDocument(); |
|
41 |
document.setSource(data); |
|
42 |
return document.toByteArray(); |
|
43 |
case DataTypes.FILE: |
|
44 |
if (data instanceof File) { |
|
45 |
return data; |
|
46 |
} |
|
47 |
case DataTypes.STRING: |
|
48 |
document = ODSLocator.getODSManager().createODSDocument(); |
|
49 |
document.setSource(data); |
|
50 |
return document.toHexString(); |
|
51 |
default: |
|
52 |
break; |
|
53 |
} |
|
54 |
} catch (Exception ex) { |
|
55 |
throw new CoercionException("Can't convert ODS to " + dataType.getName(), ex); |
|
56 |
} |
|
57 |
throw new CoercionException("Can't convert ODS to " + dataType.getName()); |
|
58 |
} |
|
59 |
|
|
60 |
public static void selfRegister() { |
|
61 |
DataManager dataManager = DALLocator.getDataManager(); |
|
62 |
dataManager.registerDataProfile(new ODSProfile()); |
|
63 |
} |
|
64 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/src/main/java/org/gvsig/ods/lib/impl/SpreadSODS.java | ||
---|---|---|
1 |
package org.gvsig.ods.lib.impl; |
|
2 |
|
|
3 |
import com.github.miachm.SODS.spreadsheet.SpreadSheet; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileInputStream; |
|
6 |
import java.io.IOException; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.Collections; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Locale; |
|
11 |
import java.util.Objects; |
|
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 |
import com.github.miachm.SODS.spreadsheet.Range; |
|
14 |
import java.awt.Rectangle; |
|
15 |
import java.io.FileNotFoundException; |
|
16 |
import java.io.InputStream; |
|
17 |
import org.apache.commons.io.IOUtils; |
|
18 |
import org.gvsig.ods.lib.api.ODSDocument.Sheet; |
|
19 |
import org.slf4j.Logger; |
|
20 |
import org.slf4j.LoggerFactory; |
|
21 |
|
|
22 |
/** |
|
23 |
* |
|
24 |
* @author jjdelcerro |
|
25 |
*/ |
|
26 |
public class SpreadSODS implements Spread { |
|
27 |
|
|
28 |
private static final Logger LOGGER = LoggerFactory.getLogger(SpreadSODS.class); |
|
29 |
|
|
30 |
@Override |
|
31 |
public File getFile() { |
|
32 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
33 |
} |
|
34 |
|
|
35 |
private static class SODSSheet implements Sheet { |
|
36 |
|
|
37 |
private int sheetIndex; |
|
38 |
private com.github.miachm.SODS.spreadsheet.Sheet ODSSheet; |
|
39 |
private Range usedRange = null; |
|
40 |
|
|
41 |
public SODSSheet(InputStream odsis, int sheetIndex, Locale locale) throws IOException { |
|
42 |
try { |
|
43 |
SpreadSheet spread = new SpreadSheet(odsis, locale); |
|
44 |
this.ODSSheet = spread.getSheet(sheetIndex); |
|
45 |
} finally { |
|
46 |
odsis.reset(); |
|
47 |
} |
|
48 |
this.sheetIndex = sheetIndex; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public int getColumnCount() { |
|
53 |
// return this.ODSSheet.getMaxColumns(); |
|
54 |
return this.getUsedData().getNumColumns(); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public Rectangle getUsedRange() { |
|
59 |
Range x = this.getUsedData(); |
|
60 |
return new Rectangle(x.getColumn(), x.getRow(), x.getNumColumns(), x.getNumRows()); |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public List<String> getColumnNames(boolean isFirstLineHedaer) { |
|
65 |
int columns = this.getColumnCount(); |
|
66 |
List<String> columnNames = new ArrayList<>(columns); |
|
67 |
|
|
68 |
String abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
|
69 |
if (columns > abc.length()) { |
|
70 |
for (int i = 0; i < columns; i++) { |
|
71 |
columnNames.add("C" + i); |
|
72 |
} |
|
73 |
} else { |
|
74 |
for (int i = 0; i < columns; i++) { |
|
75 |
columnNames.add(abc.substring(i, i + 1)); |
|
76 |
} |
|
77 |
} |
|
78 |
if (isFirstLineHedaer) { |
|
79 |
for (int col = 0; col < columns; col++) { |
|
80 |
Object value = this.getValueAt(col, 0); |
|
81 |
String s = Objects.toString(value); |
|
82 |
if (!StringUtils.isBlank(s)) { |
|
83 |
columnNames.set(col, s); |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
return columnNames; |
|
88 |
} |
|
89 |
|
|
90 |
private Range getUsedData() { |
|
91 |
if (this.usedRange == null) { |
|
92 |
Range data = this.ODSSheet.getDataRange(); |
|
93 |
int minCol = -1, minRow = -1, maxCol = -1, maxRow = -1; |
|
94 |
final int colCount = data.getNumColumns(); |
|
95 |
final int rowCount = data.getNumRows(); |
|
96 |
for (int row = 0; row < rowCount; row++) { |
|
97 |
for (int col = 0; col < colCount; col++) { |
|
98 |
Object value = data.getCell(row, col).getValue(); |
|
99 |
if (value != null) { |
|
100 |
if (minCol < 0 || col < minCol) { |
|
101 |
minCol = col; |
|
102 |
} |
|
103 |
if (minRow < 0 || row < minRow) { |
|
104 |
minRow = row; |
|
105 |
} |
|
106 |
|
|
107 |
if (maxCol < 0 || col > maxCol) { |
|
108 |
maxCol = col; |
|
109 |
} |
|
110 |
if (maxRow < 0 || row > maxRow) { |
|
111 |
maxRow = row; |
|
112 |
} |
|
113 |
} |
|
114 |
} |
|
115 |
} |
|
116 |
this.usedRange = this.ODSSheet.getRange(minRow, minCol, maxRow - minRow+1, maxCol - minCol+1); |
|
117 |
} |
|
118 |
return this.usedRange; |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
122 |
public String getName() { |
|
123 |
return this.ODSSheet.getName(); |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public int getRowCount() { |
|
128 |
// return this.ODSSheet.getMaxRows(); |
|
129 |
return this.getUsedData().getNumRows(); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public int getSheetIndex() { |
|
134 |
return this.sheetIndex; |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public Object getValueAt(int col, int row) { |
|
139 |
// return this.ODSSheet.getRange(col, row).getValue(); |
|
140 |
Range data = this.getUsedData(); |
|
141 |
Object value = data.getCell(row, col).getValue(); |
|
142 |
if( row<5 && col<10 ) { |
|
143 |
LOGGER.info("getValueAt: row "+row+", col "+col+", value "+value); |
|
144 |
} |
|
145 |
|
|
146 |
return value; |
|
147 |
} |
|
148 |
|
|
149 |
@Override |
|
150 |
public void close() { |
|
151 |
this.ODSSheet = null; |
|
152 |
this.sheetIndex = -1; |
|
153 |
this.usedRange = null; |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
157 |
private InputStream source; |
|
158 |
private Locale locale; |
|
159 |
|
|
160 |
public SpreadSODS() { |
|
161 |
|
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public void open(File source, Locale locale) { |
|
166 |
FileInputStream is; |
|
167 |
try { |
|
168 |
is = new FileInputStream(source); |
|
169 |
this.open(is, locale); |
|
170 |
} catch (FileNotFoundException ex) { |
|
171 |
throw new RuntimeException("Can' open ODS file '"+Objects.toString(source)+"'.", ex); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
public void open(InputStream source, Locale locale) { |
|
176 |
this.source = source; |
|
177 |
this.locale = locale; |
|
178 |
this.source.mark(Integer.MAX_VALUE); |
|
179 |
} |
|
180 |
|
|
181 |
@Override |
|
182 |
public void close() throws IOException { |
|
183 |
IOUtils.closeQuietly(this.source); |
|
184 |
this.source = null; |
|
185 |
this.locale = null; |
|
186 |
} |
|
187 |
|
|
188 |
@Override |
|
189 |
public Sheet getSheet(int sheetIndex) { |
|
190 |
try { |
|
191 |
if (source == null || sheetIndex < 0) { |
|
192 |
return null; |
|
193 |
} |
|
194 |
return new SODSSheet(source, sheetIndex, locale); |
|
195 |
} catch (IOException ex) { |
|
196 |
return null; |
|
197 |
} |
|
198 |
} |
|
199 |
|
|
200 |
@Override |
|
201 |
public List<String> getSheetNames() { |
|
202 |
try { |
|
203 |
SpreadSheet spread = new SpreadSheet(source); |
|
204 |
List<String> r = new ArrayList<>(); |
|
205 |
for (int n = 0; n < spread.getNumSheets(); n++) { |
|
206 |
r.add(spread.getSheet(n).getName()); |
|
207 |
} |
|
208 |
return r; |
|
209 |
} catch (IOException ex) { |
|
210 |
return Collections.emptyList(); |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/src/main/java/org/gvsig/ods/lib/impl/DefaultODSDocument.java | ||
---|---|---|
1 |
package org.gvsig.ods.lib.impl; |
|
2 |
|
|
3 |
import java.awt.Graphics2D; |
|
4 |
import java.io.ByteArrayInputStream; |
|
5 |
import java.io.File; |
|
6 |
import java.io.FileInputStream; |
|
7 |
import java.io.FileNotFoundException; |
|
8 |
import java.io.IOException; |
|
9 |
import java.io.InputStream; |
|
10 |
import java.net.URL; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Locale; |
|
13 |
import org.gvsig.pdf.lib.api.PDFDocument; |
|
14 |
import org.slf4j.LoggerFactory; |
|
15 |
import org.apache.commons.codec.binary.Hex; |
|
16 |
import org.apache.commons.codec.DecoderException; |
|
17 |
import org.apache.commons.codec.binary.Base64; |
|
18 |
import org.apache.commons.io.IOUtils; |
|
19 |
import org.gvsig.ods.lib.api.ODSDocument; |
|
20 |
import org.gvsig.pdf.lib.api.PDFLocator; |
|
21 |
import org.gvsig.pdf.lib.api.PDFManager; |
|
22 |
import org.gvsig.pdf.lib.api.PDFWriter; |
|
23 |
import org.jopendocument.model.OpenDocument; |
|
24 |
import org.jopendocument.renderer.ODTRenderer; |
|
25 |
import org.slf4j.Logger; |
|
26 |
|
|
27 |
/** |
|
28 |
* |
|
29 |
* @author osc |
|
30 |
*/ |
|
31 |
public class DefaultODSDocument implements ODSDocument { |
|
32 |
|
|
33 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultODSDocument.class); |
|
34 |
|
|
35 |
private Object source; |
|
36 |
private Locale locale; |
|
37 |
private Spread spread; |
|
38 |
|
|
39 |
public DefaultODSDocument() { |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public void setSource(File source) { |
|
45 |
this.setSource((Object)source); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public void setSource(Object source) { |
|
50 |
this.source = source; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public void setLocale(Locale locale) { |
|
55 |
this.locale = locale; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public void close() { |
|
60 |
this.source = null; |
|
61 |
this.locale = null; |
|
62 |
IOUtils.closeQuietly(this.spread); |
|
63 |
this.spread = null; |
|
64 |
} |
|
65 |
|
|
66 |
public File getFile() { |
|
67 |
if( this.source instanceof File) { |
|
68 |
return (File) this.source; |
|
69 |
} |
|
70 |
return null; |
|
71 |
} |
|
72 |
|
|
73 |
private Spread getSpread() { |
|
74 |
if( this.spread==null ) { |
|
75 |
if( this.getFile()!=null ) { |
|
76 |
try { |
|
77 |
this.spread = new SpreadJOpenDocument(); |
|
78 |
this.spread.open(this.getFile(), this.locale); |
|
79 |
} catch (Exception ex) { |
|
80 |
IOUtils.closeQuietly(this.spread); |
|
81 |
this.spread = null; |
|
82 |
throw new RuntimeException("Can't load spread.", ex); |
|
83 |
} |
|
84 |
} else { |
|
85 |
SpreadSODS theSpread = new SpreadSODS(); |
|
86 |
InputStream is = null; |
|
87 |
try { |
|
88 |
is = this.getInputStream(); |
|
89 |
theSpread.open(is, this.locale); |
|
90 |
} catch (Exception ex) { |
|
91 |
IOUtils.closeQuietly(is); |
|
92 |
IOUtils.closeQuietly(theSpread); |
|
93 |
throw new RuntimeException("Can't load spread.", ex); |
|
94 |
} |
|
95 |
this.spread = theSpread; |
|
96 |
} |
|
97 |
} |
|
98 |
return this.spread; |
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public InputStream getInputStream() throws IOException { |
|
103 |
InputStream is = null; |
|
104 |
if (source == null) { |
|
105 |
return null; |
|
106 |
} else if (source instanceof File) { |
|
107 |
File fileSource = (File) source; |
|
108 |
try { |
|
109 |
is = new FileInputStream(fileSource); |
|
110 |
} catch (IOException ex) { |
|
111 |
LOGGER.warn("Not been able to convert file to input stream", ex); |
|
112 |
throw new IOException(ex); |
|
113 |
} |
|
114 |
} else if (source instanceof URL) { |
|
115 |
URL urlSource = (URL) source; |
|
116 |
try { |
|
117 |
is = urlSource.openStream(); |
|
118 |
} catch (IOException ex) { |
|
119 |
LOGGER.warn("Not been able to open URL stream", ex); |
|
120 |
throw new IOException(ex); |
|
121 |
} |
|
122 |
} else if (source instanceof String) { |
|
123 |
String strSource = (String) source; |
|
124 |
File f = new File(strSource); |
|
125 |
if (f.exists()) { |
|
126 |
try { |
|
127 |
is = new FileInputStream(f); |
|
128 |
} catch (FileNotFoundException ex) { |
|
129 |
LOGGER.warn("Not been able to load existing file", ex); |
|
130 |
throw new IOException(ex); |
|
131 |
} |
|
132 |
} else { |
|
133 |
try { |
|
134 |
URL url = new URL(strSource); |
|
135 |
is = url.openStream(); |
|
136 |
is.available(); // Force exception if is null |
|
137 |
} catch (Exception ex) { |
|
138 |
try { |
|
139 |
byte[] data = Hex.decodeHex(strSource.toCharArray()); |
|
140 |
is = new ByteArrayInputStream(data); |
|
141 |
} catch (DecoderException ex2) { |
|
142 |
try { |
|
143 |
byte[] data = Base64.decodeBase64(strSource); |
|
144 |
is = new ByteArrayInputStream(data); |
|
145 |
} catch (Exception ex3) { |
|
146 |
throw new IOException(ex3); |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
} |
|
151 |
} else if (source instanceof byte[]) { |
|
152 |
byte[] byteSource = (byte[]) source; |
|
153 |
is = new ByteArrayInputStream(byteSource); |
|
154 |
} |
|
155 |
|
|
156 |
return is; |
|
157 |
} |
|
158 |
|
|
159 |
@Override |
|
160 |
public byte[] toByteArray() { |
|
161 |
if (this.source != null) { |
|
162 |
InputStream is= null; |
|
163 |
try { |
|
164 |
is = this.getInputStream(); |
|
165 |
byte[] bytes = new byte[is.available()]; |
|
166 |
is.read(bytes); |
|
167 |
return bytes; |
|
168 |
} catch (IOException ex) { |
|
169 |
LOGGER.warn("Not been able to convert to byte array", ex); |
|
170 |
} finally { |
|
171 |
IOUtils.closeQuietly(is); |
|
172 |
} |
|
173 |
} |
|
174 |
return null; |
|
175 |
|
|
176 |
} |
|
177 |
|
|
178 |
private String bytearray_hex(byte[] data) { |
|
179 |
StringBuilder builder = new StringBuilder(); |
|
180 |
for (byte abyte : data) { |
|
181 |
int v = abyte & 0xff; |
|
182 |
builder.append(String.format("%02x", v)); |
|
183 |
} |
|
184 |
return builder.toString(); |
|
185 |
} |
|
186 |
|
|
187 |
@Override |
|
188 |
public String toHexString() { |
|
189 |
byte[] data = this.toByteArray(); |
|
190 |
return bytearray_hex(data); |
|
191 |
} |
|
192 |
|
|
193 |
@Override |
|
194 |
public PDFDocument createPDF(int pageSize) { |
|
195 |
PDFManager pdfManager = PDFLocator.getPDFManager(); |
|
196 |
|
|
197 |
OpenDocument doc = new OpenDocument(); |
|
198 |
doc.loadFrom(this.getFile()); |
|
199 |
|
|
200 |
PDFWriter writer = pdfManager.createPDFWriter(); |
|
201 |
writer.open(pageSize); |
|
202 |
Graphics2D g = writer.getGraphics2D(); |
|
203 |
|
|
204 |
// Configure the renderer |
|
205 |
ODTRenderer renderer = new ODTRenderer(doc); |
|
206 |
renderer.setIgnoreMargins(true); |
|
207 |
renderer.setPaintMaxResolution(true); |
|
208 |
// Scale the renderer to fit width |
|
209 |
renderer.setResizeFactor(renderer.getPrintWidth() / writer.getWidth()); |
|
210 |
// Render |
|
211 |
renderer.paintComponent(g); |
|
212 |
|
|
213 |
writer.close(); |
|
214 |
|
|
215 |
return writer.toDocument(); |
|
216 |
} |
|
217 |
|
|
218 |
@Override |
|
219 |
public Sheet getSheet(int sheetIndex) { |
|
220 |
if( this.getSpread() == null || sheetIndex<0 ) { |
|
221 |
return null; |
|
222 |
} |
|
223 |
return this.getSpread().getSheet(sheetIndex); |
|
224 |
} |
|
225 |
|
|
226 |
@Override |
|
227 |
public List<String> getSheetNames() { |
|
228 |
if( this.getSpread() == null ) { |
|
229 |
return null; |
|
230 |
} |
|
231 |
return this.getSpread().getSheetNames(); |
|
232 |
} |
|
233 |
|
|
234 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/src/main/java/org/gvsig/ods/lib/impl/SpreadJOpenDocument.java | ||
---|---|---|
1 |
package org.gvsig.ods.lib.impl; |
|
2 |
|
|
3 |
import java.awt.Rectangle; |
|
4 |
import java.io.File; |
|
5 |
import java.io.IOException; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.Collections; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Locale; |
|
10 |
import java.util.Objects; |
|
11 |
import org.apache.commons.lang3.StringUtils; |
|
12 |
import org.gvsig.ods.lib.api.ODSDocument.Sheet; |
|
13 |
import org.jopendocument.dom.ODPackage; |
|
14 |
import org.jopendocument.dom.spreadsheet.SpreadSheet; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
/** |
|
19 |
* |
|
20 |
* @author jjdelcerro |
|
21 |
*/ |
|
22 |
public class SpreadJOpenDocument implements Spread { |
|
23 |
|
|
24 |
private static final Logger LOGGER = LoggerFactory.getLogger(SpreadJOpenDocument.class); |
|
25 |
|
|
26 |
private class JOpenDocumentSheet implements Sheet { |
|
27 |
|
|
28 |
private int sheetIndex; |
|
29 |
private org.jopendocument.dom.spreadsheet.Sheet ODSSheet; |
|
30 |
private Rectangle usedRange = null; |
|
31 |
|
|
32 |
public JOpenDocumentSheet(File ODSFile, int sheetIndex) throws IOException { |
|
33 |
SpreadSheet workbook = ODPackage.createFromFile(ODSFile).getSpreadSheet(); |
|
34 |
this.ODSSheet = workbook.getSheet(sheetIndex); |
|
35 |
this.sheetIndex = sheetIndex; |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public Rectangle getUsedRange() { |
|
40 |
if( this.usedRange == null ) { |
|
41 |
Spread spread = new SpreadSODS(); |
|
42 |
spread.open(ODSFile, locale); |
|
43 |
Sheet sheet = spread.getSheet(this.sheetIndex); |
|
44 |
this.usedRange = sheet.getUsedRange(); |
|
45 |
} |
|
46 |
return this.usedRange; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public int getColumnCount() { |
|
51 |
// return this.ODSSheet.getColumnCount(); |
|
52 |
if( this.usedRange==null ) { |
|
53 |
this.usedRange = this.getUsedRange(); |
|
54 |
} |
|
55 |
return this.usedRange.width; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public List<String> getColumnNames(boolean isFirstLineHedaer) { |
|
60 |
int columns = this.getColumnCount(); |
|
61 |
List<String> columnNames = new ArrayList<>(columns); |
|
62 |
|
|
63 |
String abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
|
64 |
if (columns > abc.length()) { |
|
65 |
for (int i = 0; i < columns; i++) { |
|
66 |
columnNames.add( "C" + i); |
|
67 |
} |
|
68 |
} else { |
|
69 |
for (int i = 0; i < columns; i++) { |
|
70 |
columnNames.add(abc.substring(i, i + 1)); |
|
71 |
} |
|
72 |
} |
|
73 |
if (isFirstLineHedaer) { |
|
74 |
for (int col = 0; col < columns; col++) { |
|
75 |
Object value = this.getValueAt(col, 0); |
|
76 |
String s = Objects.toString(value); |
|
77 |
if (!StringUtils.isBlank(s)) { |
|
78 |
columnNames.set(col, s); |
|
79 |
} |
|
80 |
} |
|
81 |
} |
|
82 |
return columnNames; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public String getName() { |
|
87 |
return this.ODSSheet.getName(); |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public int getRowCount() { |
|
92 |
// return this.ODSSheet.getRowCount(); |
|
93 |
if( this.usedRange==null ) { |
|
94 |
this.usedRange = this.getUsedRange(); |
|
95 |
} |
|
96 |
return this.usedRange.height; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public int getSheetIndex() { |
|
101 |
return this.sheetIndex; |
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public Object getValueAt(int col, int row) { |
|
106 |
return this.ODSSheet.getValueAt(col, row); |
|
107 |
} |
|
108 |
|
|
109 |
@Override |
|
110 |
public void close() { |
|
111 |
this.ODSSheet = null; |
|
112 |
this.sheetIndex = -1; |
|
113 |
this.usedRange = null; |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
private File ODSFile; |
|
118 |
private Locale locale; |
|
119 |
|
|
120 |
public SpreadJOpenDocument() { |
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public void open(File ODSFile, Locale locale) { |
|
126 |
this.ODSFile = ODSFile; |
|
127 |
this.locale = locale; |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public File getFile() { |
|
132 |
return this.ODSFile; |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public Sheet getSheet(int sheetIndex) { |
|
137 |
try { |
|
138 |
if( ODSFile == null || sheetIndex<0 ) { |
|
139 |
return null; |
|
140 |
} |
|
141 |
return new JOpenDocumentSheet(ODSFile, sheetIndex); |
|
142 |
} catch (IOException ex) { |
|
143 |
return null; |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
public List<String> getSheetNames() { |
|
149 |
try { |
|
150 |
SpreadSheet workbook = ODPackage.createFromFile(ODSFile).getSpreadSheet(); |
|
151 |
List<String> r = new ArrayList<>(); |
|
152 |
for( int n=0; n<workbook.getSheetCount(); n++ ) { |
|
153 |
r.add(workbook.getSheet(n).getName()); |
|
154 |
} |
|
155 |
return r; |
|
156 |
} catch (IOException ex) { |
|
157 |
return Collections.emptyList(); |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public void close() { |
|
163 |
this.ODSFile = null; |
|
164 |
this.locale = null; |
|
165 |
} |
|
166 |
|
|
167 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.ods.lib.impl.ODSImplLibrary |
|
0 | 2 |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.api/src/main/java/org/gvsig/ods/lib/api/ODSLocator.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.ods.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.locator.AbstractLocator; |
|
27 |
import org.gvsig.tools.locator.Locator; |
|
28 |
import org.gvsig.tools.locator.LocatorException; |
|
29 |
|
|
30 |
@SuppressWarnings("rawtypes") |
|
31 |
public class ODSLocator extends AbstractLocator { |
|
32 |
|
|
33 |
private static final String LOCATOR_NAME = "ODSLocator"; |
|
34 |
|
|
35 |
public static final String ODS_MANAGER_NAME = |
|
36 |
"ODSManager"; |
|
37 |
|
|
38 |
private static final String ODS_MANAGER_DESCRIPTION = |
|
39 |
"ODS Manager of gvSIG"; |
|
40 |
|
|
41 |
private static final ODSLocator INSTANCE = new ODSLocator(); |
|
42 |
|
|
43 |
private ODSLocator() { |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Return the singleton instance. |
|
49 |
* |
|
50 |
* @return the singleton instance |
|
51 |
*/ |
|
52 |
public static ODSLocator getInstance() { |
|
53 |
return INSTANCE; |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public String getLocatorName() { |
|
58 |
return LOCATOR_NAME; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Return a reference to ODSManager. |
|
63 |
* |
|
64 |
* @return a reference to ODSManager |
|
65 |
* @throws LocatorException |
|
66 |
* if there is no access to the class or the class cannot be |
|
67 |
* instantiated |
|
68 |
* @see Locator#get(String) |
|
69 |
*/ |
|
70 |
public static ODSManager getODSManager() |
|
71 |
throws LocatorException { |
|
72 |
return (ODSManager) getInstance().get(ODS_MANAGER_NAME); |
|
73 |
} |
|
74 |
|
|
75 |
public static ODSManager getManager() |
|
76 |
throws LocatorException { |
|
77 |
return getODSManager(); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* Registers the Class implementing the ODSManager interface. |
|
82 |
* |
|
83 |
* @param clazz |
|
84 |
* implementing the ODSManager interface |
|
85 |
*/ |
|
86 |
public static void registerODSManager(Class clazz) { |
|
87 |
getInstance().register(ODS_MANAGER_NAME, |
|
88 |
ODS_MANAGER_DESCRIPTION, clazz); |
|
89 |
} |
|
90 |
|
|
91 |
public static void registerDefaultODSManager(Class clazz) { |
|
92 |
getInstance().registerDefault(ODS_MANAGER_NAME, |
|
93 |
ODS_MANAGER_DESCRIPTION, clazz); |
|
94 |
} |
|
95 |
|
|
96 |
|
|
97 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.api/src/main/java/org/gvsig/ods/lib/api/ODSLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.ods.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.ToolsLibrary; |
|
27 |
import org.gvsig.tools.library.AbstractLibrary; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
* @author jjdelcerro |
|
34 |
*/ |
|
35 |
public class ODSLibrary extends AbstractLibrary { |
|
36 |
|
|
37 |
@Override |
|
38 |
public void doRegistration() { |
|
39 |
super.doRegistration(); |
|
40 |
registerAsAPI(ODSLibrary.class); |
|
41 |
this.require(ToolsLibrary.class); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void doInitialize() throws LibraryException { |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doPostInitialize() throws LibraryException { |
|
50 |
if(! ODSLocator.getInstance().exists(ODSLocator.ODS_MANAGER_NAME)) { |
|
51 |
throw new ReferenceNotRegisteredException( |
|
52 |
ODSLocator.ODS_MANAGER_NAME, |
|
53 |
ODSLocator.getInstance()); |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
} |
org.gvsig.ods/tags/org.gvsig.ods-1.0.173/org.gvsig.ods.lib/org.gvsig.ods.lib.api/src/main/java/org/gvsig/ods/lib/api/ODSManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.ods.lib.api; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @author jjdelcerro |
|
31 |
*/ |
|
32 |
public interface ODSManager { |
|
33 |
|
|
34 |
public ODSDocument createODSDocument(byte[] document); |
|
35 |
// public ODSDocument createODSDocument(String document); |
|
36 |
public ODSDocument createODSDocument(File document); |
|
37 |
public ODSDocument createODSDocument(); |
Also available in: Unified diff