Exemplo n.º 1
0
        /**
         * Reads the additional property sets from the read in compound file
         *
         * @param readCompoundFile the file read in
         * @exception CopyAdditionalPropertySetsException
         * @exception IOException
         */
        private void readAdditionalPropertySets(CSharpJExcel.Jxl.Read.Biff.CompoundFile readCompoundFile)
        {
            if (readCompoundFile == null)
                {
                return;
                }

            additionalPropertySets = new ArrayList();
            standardPropertySets = new Dictionary<string, ReadPropertyStorage>();
            int blocksRequired = 0;

            int numPropertySets = readCompoundFile.getNumberOfPropertySets();

            for (int i = 0; i < numPropertySets; i++)
                {
                PropertyStorage ps = readCompoundFile.getPropertySet(i);

                bool standard = false;

                if (System.String.Compare(ps.name,ROOT_ENTRY_NAME) == 0)
                    {
                    standard = true;
                    ReadPropertyStorage rps = new ReadPropertyStorage(ps, null, i);
                    standardPropertySets.Add(ROOT_ENTRY_NAME, rps);
                    }

                // See if it is a standard property set
                for (int j = 0; j < STANDARD_PROPERTY_SETS.Length && !standard; j++)
                    {
                    if (System.String.Compare(ps.name,STANDARD_PROPERTY_SETS[j]) == 0)
                        {
                        // See if it comes directly off the root entry
                        PropertyStorage ps2 = readCompoundFile.findPropertyStorage(ps.name);
                        Assert.verify(ps2 != null);

                        if (ps2 == ps)
                            {
                            standard = true;
                            ReadPropertyStorage rps = new ReadPropertyStorage(ps, null, i);
                            standardPropertySets.Add(STANDARD_PROPERTY_SETS[j], rps);
                            }
                        }
                    }

                if (!standard)
                    {
                    try
                        {
                        byte[] data = null;
                        if (ps.size > 0)
                            {
                            data = readCompoundFile.getStream(i);
                            }
                        else
                            {
                            data = new byte[0];
                            }
                        ReadPropertyStorage rps = new ReadPropertyStorage(ps, data, i);
                        additionalPropertySets.Add(rps);

                        if (data.Length > SMALL_BLOCK_THRESHOLD)
                            {
                            int blocks = getBigBlocksRequired(data.Length);
                            blocksRequired += blocks;
                            }
                        else
                            {
                            int blocks = getSmallBlocksRequired(data.Length);
                            numSmallBlocks += blocks;
                            }
                        }
                    catch (CSharpJExcel.Jxl.Read.Biff.BiffException e)
                        {
                        //logger.error(e);
                        throw new CopyAdditionalPropertySetsException();
                        }
                    }
                }

            additionalPropertyBlocks = blocksRequired;
        }