Example #1
0
        private void DropDocument(POIFSReaderListener listener,
                                  DocumentDescriptor descriptor)
        {
            List <object> listeners = (List <object>)chosenDocumentDescriptors[descriptor];

            listeners.Remove(listener);
            if (listeners.Count == 0)
            {
                chosenDocumentDescriptors.Remove(descriptor);
            }
        }
Example #2
0
        private void DropDocument(POIFSReaderListener listener,
                                  DocumentDescriptor descriptor)
        {
            ArrayList listeners = (ArrayList)chosenDocumentDescriptors[descriptor];

            listeners.Remove(listener);
            if (listeners.Count == 0)
            {
                chosenDocumentDescriptors.Remove(descriptor);
            }
        }
Example #3
0
        /**
         * Register for all documents
         *
         * @param listener the listener who wants to Get all documents
         */

        public void RegisterListener(POIFSReaderListener listener)
        {
            if (!omnivorousListeners.Contains(listener))
            {
                // wasn't alReady listening for everything, so drop
                // anything listener might have been listening for and
                // then Add the listener to the Set of omnivorous
                // listeners
                RemoveSelectiveListener(listener);
                omnivorousListeners.Add(listener);
            }
        }
Example #4
0
        /**
         * Register a POIFSReaderListener for all documents
         *
         * @param listener the listener to be registered
         *
         * @exception NullPointerException if listener is null
         * @exception InvalidOperationException if read() has already been
         *                                  called
         */

        public void RegisterListener(POIFSReaderListener listener)
        {
            if (listener == null)
            {
                throw new NullReferenceException();
            }
            if (registryClosed)
            {
                throw new InvalidOperationException();
            }
            registry.RegisterListener(listener);
        }
Example #5
0
        private void RemoveSelectiveListener(POIFSReaderListener listener)
        {
            ArrayList selectedDescriptors = (ArrayList)selectiveListeners[listener];

            if (selectedDescriptors != null)
            {
                selectiveListeners.Remove(listener);
                IEnumerator iter = selectedDescriptors.GetEnumerator();

                while (iter.MoveNext())
                {
                    DropDocument(listener, (DocumentDescriptor)iter.Current);
                }
            }
        }
Example #6
0
        /**
         * Register a POIFSReaderListener for a document in the specified
         * directory
         *
         * @param listener the listener to be registered
         * @param path the document path; if null, the root directory is
         *             assumed
         * @param name the document name
         *
         * @exception NullPointerException if listener is null or name is
         *                                 null or empty
         * @exception InvalidOperationException if read() has already been
         *                                  called
         */

        public void RegisterListener(POIFSReaderListener listener,
                                     POIFSDocumentPath path,
                                     String name)
        {
            if ((listener == null) || (name == null) || (name.Length == 0))
            {
                throw new NullReferenceException();
            }
            if (registryClosed)
            {
                throw new InvalidOperationException();
            }
            registry.RegisterListener(listener,
                                      (path == null) ? new POIFSDocumentPath()
                                                     : path, name);
        }
Example #7
0
    /**
     * Register a POIFSReaderListener for a particular document
     *
     * @param listener the listener
     * @param path the path of the document of interest
     * @param documentName the name of the document of interest
     */

    public void RegisterListener(POIFSReaderListener listener,
                          POIFSDocumentPath path,
                          String documentName)
    {
        if (!omnivorousListeners.Contains(listener))
        {

            // not an omnivorous listener (if it was, this method is a
            // no-op)
            ArrayList descriptors = (ArrayList)selectiveListeners[listener];

            if (descriptors == null)
            {

                // this listener has not Registered before
                descriptors = new ArrayList();
                selectiveListeners[listener]=descriptors;
            }
            DocumentDescriptor descriptor = new DocumentDescriptor(path,
                                                documentName);

            if (descriptors.Add(descriptor)>=0)
            {

                // this listener wasn't alReady listening for this
                // document -- Add the listener to the Set of
                // listeners for this document
                ArrayList listeners =
                    (ArrayList)chosenDocumentDescriptors[descriptor];

                if (listeners == null)
                {

                    // nobody was listening for this document before
                    listeners = new ArrayList();
                    chosenDocumentDescriptors[descriptor]=listeners;
                }
                listeners.Add(listener);
            }
        }
    }
Example #8
0
        /**
         * Register a POIFSReaderListener for a particular document
         *
         * @param listener the listener
         * @param path the path of the document of interest
         * @param documentName the name of the document of interest
         */

        public void RegisterListener(POIFSReaderListener listener,
                                     POIFSDocumentPath path,
                                     String documentName)
        {
            if (!omnivorousListeners.Contains(listener))
            {
                // not an omnivorous listener (if it was, this method is a
                // no-op)
                ArrayList descriptors = (ArrayList)selectiveListeners[listener];

                if (descriptors == null)
                {
                    // this listener has not Registered before
                    descriptors = new ArrayList();
                    selectiveListeners[listener] = descriptors;
                }
                DocumentDescriptor descriptor = new DocumentDescriptor(path,
                                                                       documentName);

                if (descriptors.Add(descriptor) >= 0)
                {
                    // this listener wasn't alReady listening for this
                    // document -- Add the listener to the Set of
                    // listeners for this document
                    ArrayList listeners =
                        (ArrayList)chosenDocumentDescriptors[descriptor];

                    if (listeners == null)
                    {
                        // nobody was listening for this document before
                        listeners = new ArrayList();
                        chosenDocumentDescriptors[descriptor] = listeners;
                    }
                    listeners.Add(listener);
                }
            }
        }
Example #9
0
        /// <summary>
        /// Processes the properties.
        /// </summary>
        /// <param name="small_blocks">The small_blocks.</param>
        /// <param name="big_blocks">The big_blocks.</param>
        /// <param name="properties">The properties.</param>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        private List <DocumentDescriptor> ProcessProperties(BlockList small_blocks,
                                                            BlockList big_blocks,
                                                            IEnumerator properties,
                                                            POIFSDocumentPath path)
        {
            List <DocumentDescriptor> documents =
                new List <DocumentDescriptor>();

            while (properties.MoveNext())
            {
                Property property = (Property)properties.Current;
                String   name     = property.Name;

                if (property.IsDirectory)
                {
                    POIFSDocumentPath new_path = new POIFSDocumentPath(path,
                                                                       new String[]
                    {
                        name
                    });

                    ProcessProperties(
                        small_blocks, big_blocks,
                        ((DirectoryProperty)property).Children, new_path);
                }
                else
                {
                    int            startBlock = property.StartBlock;
                    IEnumerator    listeners  = registry.GetListeners(path, name);
                    OPOIFSDocument document   = null;
                    if (listeners.MoveNext())
                    {
                        listeners.Reset();
                        int size = property.Size;


                        if (property.ShouldUseSmallBlocks)
                        {
                            document =
                                new OPOIFSDocument(name, small_blocks
                                                   .FetchBlocks(startBlock, -1), size);
                        }
                        else
                        {
                            document =
                                new OPOIFSDocument(name, big_blocks
                                                   .FetchBlocks(startBlock, -1), size);
                        }
                        //POIFSReaderListener listener =
                        //        (POIFSReaderListener)listeners.Current;
                        //listener.ProcessPOIFSReaderEvent(
                        //        new POIFSReaderEvent(
                        //            new DocumentInputStream(document), path,
                        //            name));
                        while (listeners.MoveNext())
                        {
                            POIFSReaderListener listener =
                                (POIFSReaderListener)listeners.Current;
                            listener.ProcessPOIFSReaderEvent(
                                new POIFSReaderEvent(
                                    new DocumentInputStream(document), path,
                                    name));
                        }
                    }
                    else
                    {
                        // consume the document's data and discard it
                        if (property.ShouldUseSmallBlocks)
                        {
                            small_blocks.FetchBlocks(startBlock, -1);
                        }
                        else
                        {
                            big_blocks.FetchBlocks(startBlock, -1);
                        }
                        //documents.Add(
                        //        new DocumentDescriptor(path, name));
                        //fire event
                        //OnStreamReaded(new POIFSReaderEventArgs(name, path, document));
                    }
                }
            }
            return(documents);
        }
Example #10
0
        /**
         * Register a POIFSReaderListener for a document in the root
         * directory
         *
         * @param listener the listener to be registered
         * @param name the document name
         *
         * @exception NullPointerException if listener is null or name is
         *                                 null or empty
         * @exception InvalidOperationException if read() has already been
         *                                  called
         */

        public void RegisterListener(POIFSReaderListener listener,
                                     String name)
        {
            RegisterListener(listener, null, name);
        }
Example #11
0
    private void DropDocument(POIFSReaderListener listener,
                              DocumentDescriptor descriptor)
    {
        ArrayList listeners = (ArrayList)chosenDocumentDescriptors[descriptor];

        listeners.Remove(listener);
        if (listeners.Count == 0)
        {
            chosenDocumentDescriptors.Remove(descriptor);
        }
    }
Example #12
0
    private void RemoveSelectiveListener(POIFSReaderListener listener)
    {
        ArrayList selectedDescriptors = (ArrayList)selectiveListeners[listener];

        if (selectedDescriptors != null)
        {
            selectiveListeners.Remove(listener);
            IEnumerator iter = selectedDescriptors.GetEnumerator();

            while (iter.MoveNext())
            {
                DropDocument(listener, ( DocumentDescriptor ) iter.Current);
            }
        }
    }
Example #13
0
    /**
     * Register for all documents
     *
     * @param listener the listener who wants to Get all documents
     */

    public void RegisterListener(POIFSReaderListener listener)
    {
        if (!omnivorousListeners.Contains(listener))
        {

            // wasn't alReady listening for everything, so drop
            // anything listener might have been listening for and
            // then Add the listener to the Set of omnivorous
            // listeners
            RemoveSelectiveListener(listener);
            omnivorousListeners.Add(listener);
        }
    }
Example #14
0
        /**
         * Register a POIFSReaderListener for a document in the specified
         * directory
         *
         * @param listener the listener to be registered
         * @param path the document path; if null, the root directory is
         *             assumed
         * @param name the document name
         *
         * @exception NullPointerException if listener is null or name is
         *                                 null or empty
         * @exception IllegalStateException if read() has already been
         *                                  called
         */

        public void RegisterListener(POIFSReaderListener listener,
                                     POIFSDocumentPath path,
                                     String name)
        {
            if ((listener == null) || (name == null) || (name.Length == 0))
            {
                throw new NullReferenceException();
            }
            if (registryClosed)
            {
                throw new InvalidOperationException();
            }
            registry.RegisterListener(listener,
                                      (path == null) ? new POIFSDocumentPath()
                                                     : path, name);
        }
Example #15
0
        /**
         * Register a POIFSReaderListener for a document in the root
         * directory
         *
         * @param listener the listener to be registered
         * @param name the document name
         *
         * @exception NullPointerException if listener is null or name is
         *                                 null or empty
         * @exception IllegalStateException if read() has already been
         *                                  called
         */

        public void RegisterListener(POIFSReaderListener listener,
                                     String name)
        {
            RegisterListener(listener, null, name);
        }
Example #16
0
        /**
         * Register a POIFSReaderListener for all documents
         *
         * @param listener the listener to be registered
         *
         * @exception NullPointerException if listener is null
         * @exception IllegalStateException if read() has already been
         *                                  called
         */

        public void RegisterListener(POIFSReaderListener listener)
        {
            if (listener == null)
            {
                throw new NullReferenceException();
            }
            if (registryClosed)
            {
                throw new InvalidOperationException();
            }
            registry.RegisterListener(listener);
        }