1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 package org.apache.openoffice.ooxml.framework.part;
23 
24 import java.io.File;
25 import java.io.InputStream;
26 import java.lang.ref.SoftReference;
27 import java.util.HashMap;
28 import java.util.HashSet;
29 import java.util.Map;
30 import java.util.Set;
31 import java.util.Vector;
32 
33 public class Package
34     implements IReferenceProvider
35 {
Create(final File aOOXMLFile)36     public static Package Create (final File aOOXMLFile)
37     {
38         return new Package(
39             aOOXMLFile.getAbsolutePath(),
40             new PartManager(aOOXMLFile));
41     }
42 
43 
44 
45 
Package( final String sFullFilename, final PartManager aPartManager)46     protected Package (
47         final String sFullFilename,
48         final PartManager aPartManager)
49     {
50         msFullFilename = sFullFilename;
51         maPartManager = aPartManager;
52         maRelatedParts = new RelatedParts(
53             new PartName(""),
54             aPartManager);
55 
56         final PartName aDocumentPartName = maRelatedParts.GetSingleTargetForType(RelationshipType.OfficeDocument);
57         maOfficeDocumentPart = new Part(
58             maPartManager.getContentTypes().getTypeForPartName(aDocumentPartName),
59             maPartManager,
60             aDocumentPartName);
61     }
62 
63 
64 
65 
getOfficeDocumentPart()66     public Part getOfficeDocumentPart ()
67     {
68         return maOfficeDocumentPart;
69     }
70 
71 
72 
73 
getDigitalSignaturesParts()74     public Iterable<Part> getDigitalSignaturesParts ()
75     {
76         // TODO
77         return new Vector<>();
78     }
79 
80 
81 
82 
getRelatedParts()83     public RelatedParts getRelatedParts ()
84     {
85         return maRelatedParts;
86     }
87 
88 
89 
90 
hasAppDefFilePropertiesPart()91     public boolean hasAppDefFilePropertiesPart ()
92     {
93         // TODO
94         return false;
95     }
96 
97 
98 
99 
getAppDefFilePropertiesPart()100     public Part getAppDefFilePropertiesPart ()
101     {
102         // TODO
103         return null;
104     }
105 
106 
107 
108 
hasCoreFilePropertiesPart()109     public boolean hasCoreFilePropertiesPart ()
110     {
111         // TODO
112         return false;
113     }
114 
115 
116 
117 
getCoreFilePropertiesPart()118     public Part getCoreFilePropertiesPart ()
119     {
120         // TODO
121         return null;
122     }
123 
124 
125 
126 
hasCustomFilePropertiesPart()127     public boolean hasCustomFilePropertiesPart ()
128     {
129         // TODO
130         return false;
131     }
132 
133 
134 
135 
getCustomFilePropertiesPart()136     public Part getCustomFilePropertiesPart ()
137     {
138         // TODO
139         return null;
140     }
141 
142 
143 
144 
getFileName()145     public String getFileName()
146     {
147         return msFullFilename;
148     }
149 
150 
151 
152 
153     /** Return a list of stream names.
154      *  Note that that list is not necessarily identical to the list of part
155      *  names.  It can contain entries that are not parts.
156      */
listStreamNames()157     public String[] listStreamNames ()
158     {
159         return maPartManager.listStreamNames();
160     }
161 
162 
163 
164 
165     /** Return an InputStream object for the specified stream.
166      */
getStream(final String sStreamName)167     public InputStream getStream (final String sStreamName)
168     {
169         return maPartManager.getStreamForStreamName(sStreamName);
170     }
171 
172 
173 
174 
175     private final String msFullFilename;
176     protected final PartManager maPartManager;
177     private final RelatedParts maRelatedParts;
178     private final Part maOfficeDocumentPart;
179 }
180