Esempio n. 1
0
        /**
         * Constructor. <b>Operation not supported.</b>
         *
         * @param in
         *            Zip input stream to load.
         * @param access
         */
        public ZipPackage(Stream in1, PackageAccess access)
            : base(access)
        {
            isStream = true;
            ZipInputStream zis = ZipHelper.OpenZipStream(in1);

            // TODO: ZipSecureFile
            //ThresholdInputStream zis = ZipHelper.OpenZipStream(in1);
            this.zipArchive = new ZipInputStreamZipEntrySource(zis);
        }
Esempio n. 2
0
        /**
         * Constructor. Opens a Zip based Open XML document.
         *
         * @param path
         *            The path of the file to open or create.
         * @param access
         *            The package access mode.
         * @throws InvalidFormatException
         *             If the content type part parsing encounters an error.
         */
        public ZipPackage(String path, PackageAccess access)
            : base(access)
        {


            ZipFile zipFile = ZipHelper.OpenZipFile(path);
            if (zipFile == null)
                throw new InvalidOperationException(
                        "Can't open the specified file: '" + path + "'");
            this.zipArchive = new ZipFileZipEntrySource(zipFile);
        }
Esempio n. 3
0
        /**
         * Constructor. Opens a Zip based Open XML document.
         *
         * @param path
         *            The path of the file to open or create.
         * @param access
         *            The package access mode.
         * @throws InvalidFormatException
         *             If the content type part parsing encounters an error.
         */
        public ZipPackage(String path, PackageAccess access)
            : base(access)
        {
            ZipFile zipFile = ZipHelper.OpenZipFile(path);

            if (zipFile == null)
            {
                throw new InvalidOperationException(
                          "Can't open the specified file: '" + path + "'");
            }
            this.zipArchive = new ZipFileZipEntrySource(zipFile);
        }
Esempio n. 4
0
        public override void eSet(int featureID, object newValue)
        {
            switch (featureID)
            {
            case Java_PackageImpl.PACKAGEACCESS_PACKAGE:
                package = (Package)newValue;
                return;

            case Java_PackageImpl.PACKAGEACCESS_QUALIFIER:
                qualifier = (PackageAccess)newValue;
                return;
            }
            base.eSet(featureID, newValue);
        }
Esempio n. 5
0
        /**
         * @deprecated use {@link OPCPackage#open(String,PackageAccess)} 
         */
        public static Package Open(String path, PackageAccess access)
        {
            if (path == null || "".Equals(path.Trim())
                    || new DirectoryInfo(path).Exists)
                throw new ArgumentException("path");

            Package pack = new ZipPackage(path, access);
            if (pack.partList == null && access != PackageAccess.WRITE)
            {
                pack.GetParts();
            }
            pack.originalPackagePath = Path.GetFullPath(path);
            return pack;
        }
Esempio n. 6
0
        /**
         * @deprecated use {@link OPCPackage#open(String,PackageAccess)}
         */
        public static Package Open(String path, PackageAccess access)
        {
            if (path == null || "".Equals(path.Trim()) ||
                new DirectoryInfo(path).Exists)
            {
                throw new ArgumentException("path");
            }

            Package pack = new ZipPackage(path, access);

            if (pack.partList == null && access != PackageAccess.WRITE)
            {
                pack.GetParts();
            }
            pack.originalPackagePath = Path.GetFullPath(path);
            return(pack);
        }
Esempio n. 7
0
        /**
         * Constructor. Opens a Zip based Open XML document.
         *
         * @param file
         *            The file to open or create.
         * @param access
         *            The package access mode.
         * @throws InvalidFormatException
         *             If the content type part parsing encounters an error.
         */
        public ZipPackage(FileInfo file, PackageAccess access)
            : base(access)
        {
            ZipFile zipFile = null;

            try
            {
                zipFile = ZipHelper.OpenZipFile(file);
            }
            catch (IOException e)
            {
                throw new InvalidOperationException(
                          "Can't open the specified file: '" + file + "'", e);
            }

            this.zipArchive = new ZipFileZipEntrySource(zipFile);
        }
Esempio n. 8
0
        public NotificationChain basicSetQualifier(PackageAccess newobj, NotificationChain msgs)
        {
            var oldobj = _qualifier;

            _qualifier = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.PACKAGEACCESS_QUALIFIER, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Esempio n. 9
0
 /**
  * Constructor.
  * 
  * @param access
  *            Package access.
  */
 public OPCPackage(PackageAccess access)
 {
     if (GetType() != typeof(ZipPackage))
     {
         throw new ArgumentException("PackageBase may not be subclassed");
     }
     Init();
     this.packageAccess = access;
 }
Esempio n. 10
0
        /**
         * Constructor. Opens a Zip based Open XML document.
         *
         * @param file
         *            The file to open or create.
         * @param access
         *            The package access mode.
         */
        public ZipPackage(FileInfo file, PackageAccess access)
            : base(access)
        {
            ZipEntrySource ze;

            try
            {
                ZipFile zipFile = ZipHelper.OpenZipFile(file);
                ze = new ZipFileZipEntrySource(zipFile);
            }
            catch (IOException e)
            {
                // probably not happening with write access - not sure how to handle the default read-write access ...
                if (access == PackageAccess.WRITE)
                {
                    throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e);
                }
                logger.Log(POILogger.ERROR, "Error in zip file " + file + " - falling back to stream processing (i.e. ignoring zip central directory)");
                // some zips can't be opened via ZipFile in JDK6, as the central directory
                // contains either non-latin entries or the compression type can't be handled
                // the workaround is to iterate over the stream and not the directory
                FileStream fis = null;
                //ThresholdInputStream zis = null;
                ZipInputStream zis = null;
                try
                {
                    fis = file.Create();
                    // TODO: ZipSecureFile
                    // zis = ZipHelper.OpenZipStream(fis);
                    zis = ZipHelper.OpenZipStream(fis);
                    ze  = new ZipInputStreamZipEntrySource(zis);
                }
                catch (IOException e2)
                {
                    if (zis != null)
                    {
                        try
                        {
                            zis.Close();
                        }
                        catch (IOException)
                        {
                            throw new InvalidOperationException("Can't open the specified file: '" + file + "'" +
                                                                " and couldn't close the file input stream", e);
                        }
                    }
                    else if (fis != null)
                    {
                        try
                        {
                            fis.Close();
                        }
                        catch (IOException)
                        {
                            throw new InvalidOperationException("Can't open the specified file: '" + file + "'" +
                                                                " and couldn't close the file input stream", e);
                        }
                    }
                    throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e2);
                }
            }
            this.zipArchive = ze;
        }
Esempio n. 11
0
 /**
  * Constructor. <b>Operation not supported.</b>
  *
  * @param in
  *            Zip input stream to load.
  * @param access
  * @throws ArgumentException
  *             If the specified input stream not an instance of
  *             ZipInputStream.
  */
 public ZipPackage(Stream in1, PackageAccess access)
     : base(access)
 {
     this.zipArchive = new ZipInputStreamZipEntrySource(new ZipInputStream(in1));
 }
Esempio n. 12
0
        /**
         * @deprecated use {@link OPCPackage} 
         */
        public Package(PackageAccess access)
            : base(access)
        {

        }
Esempio n. 13
0
 /**
  * Constructor. Opens a Zip based Open XML document.
  *
  * @param path
  *            The path of the file to open or create.
  * @param access
  *            The package access mode.
  */
 public ZipPackage(String path, PackageAccess access)
     : this(new FileInfo(path), access)
 {
 }
Esempio n. 14
0
 public PackageControl(PackageAccess packageAccess)
 {
     this.packageAccess = packageAccess;
 }
Esempio n. 15
0
 /**
  * Constructor. Opens a Zip based Open XML document from
  *  a custom ZipEntrySource, typically an open archive
  *  from another system
  *
  * @param zipEntry
  *            Zip data to load.
  * @param access
  *            The package access mode.
  */
 public ZipPackage(ZipEntrySource zipEntry, PackageAccess access)
     : base(access)
 {
     this.zipArchive = zipEntry;
 }
Esempio n. 16
0
        /**
         * Open a package.
         * 
         * @param path
         *            The document path.
         * @param access
         *            PackageBase access.
         * @return A PackageBase object, else <b>null</b>.
         * @throws InvalidFormatException
         *             If the specified file doesn't exist, and a parsing error
         *             occur.
         */
        public static OPCPackage Open(String path, PackageAccess access)
        {
            if (path == null || "".Equals(path.Trim()))
                throw new ArgumentException("'path' must be given");

            if (new DirectoryInfo(path).Exists)
                throw new ArgumentException("path must not be a directory");


            OPCPackage pack = new ZipPackage(path, access);
            if (pack.partList == null && access != PackageAccess.WRITE)
            {
                pack.GetParts();
            }
            pack.originalPackagePath = new DirectoryInfo(path).FullName;
            return pack;
        }
Esempio n. 17
0
 /**
  * Constructor. <b>Operation not supported.</b>
  *
  * @param in
  *            Zip input stream to load.
  * @param access
  * @throws ArgumentException
  *             If the specified input stream not an instance of
  *             ZipInputStream.
  */
 public ZipPackage(Stream filestream, PackageAccess access)
     : base(access)
 {
     isStream = true;
     this.zipArchive = new ZipInputStreamZipEntrySource(new ZipInputStream(filestream));
 }
Esempio n. 18
0
 /**
  * Constructor. <b>Operation not supported.</b>
  *
  * @param in
  *            Zip input stream to load.
  * @param access
  * @throws ArgumentException
  *             If the specified input stream not an instance of
  *             ZipInputStream.
  */
 public ZipPackage(Stream in1, PackageAccess access)
     : base(access)
 {
     this.zipArchive = new ZipInputStreamZipEntrySource(new ZipInputStream(in1));
 }
Esempio n. 19
0
        /**
        * Open a package.
        *
        * @param file
        *            The file to open.
        * @param access
        *            PackageBase access.
        * @return A PackageBase object, else <b>null</b>.
        * @throws InvalidFormatException
        *             If the specified file doesn't exist, and a parsing error
        *             occur.
        */
        public static OPCPackage Open(FileInfo file, PackageAccess access)
        {
            if (file == null || new DirectoryInfo(file.FullName).Exists)
                throw new ArgumentException("file");

            OPCPackage pack = new ZipPackage(file, access);
            if (pack.partList == null && access != PackageAccess.WRITE)
            {
                pack.GetParts();
            }
            pack.originalPackagePath = file.FullName;
            return pack;
        }
Esempio n. 20
0
 /**
  * Constructor. <b>Operation not supported.</b>
  *
  * @param in
  *            Zip input stream to load.
  * @param access
  * @throws ArgumentException
  *             If the specified input stream not an instance of
  *             ZipInputStream.
  */
 public ZipPackage(Stream filestream, PackageAccess access)
     : base(access)
 {
     isStream        = true;
     this.zipArchive = new ZipInputStreamZipEntrySource(new ZipInputStream(filestream));
 }
Esempio n. 21
0
        /**
         * Constructor. Opens a Zip based Open XML document.
         *
         * @param file
         *            The file to open or create.
         * @param access
         *            The package access mode.
         * @throws InvalidFormatException
         *             If the content type part parsing encounters an error.
         */
        public ZipPackage(FileInfo file, PackageAccess access)
            : base(access)
        {


            ZipFile zipFile = null;

            try
            {
                zipFile = ZipHelper.OpenZipFile(file);
            }
            catch (IOException e)
            {
                throw new InvalidOperationException(
                      "Can't open the specified file: '" + file + "'", e);
            }

            this.zipArchive = new ZipFileZipEntrySource(zipFile);
        }
Esempio n. 22
0
 /**
  * @deprecated use {@link OPCPackage}
  */
 public Package(PackageAccess access)
     : base(access)
 {
 }