private void DropDocument(POIFSReaderListener listener, DocumentDescriptor descriptor) { List <object> listeners = (List <object>)chosenDocumentDescriptors[descriptor]; listeners.Remove(listener); if (listeners.Count == 0) { chosenDocumentDescriptors.Remove(descriptor); } }
private void DropDocument(POIFSReaderListener listener, DocumentDescriptor descriptor) { ArrayList listeners = (ArrayList)chosenDocumentDescriptors[descriptor]; listeners.Remove(listener); if (listeners.Count == 0) { chosenDocumentDescriptors.Remove(descriptor); } }
/** * 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); } }
/** * 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); }
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); } } }
/** * 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); }
/** * 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); } } }
/** * 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); } } }
/// <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); }
/** * 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); }
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); } } }
/** * 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); }
/** * 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); }
/** * 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); }