title: OpenOffice with .NET: how to iterate throught all paragraphs and read text
body: <p>How to iterate through all paragraphs in OpenOffice Writer document and output text.
  I have Java examples, but don't know how to convert code to C#.
  Java example could be found here: <a href="http://wiki.services.openoffice.org/wiki/API/Samples/Java/Writer/TextDocumentStructure" rel="nofollow noreferrer">http://wiki.services.openoffice.org/wiki/API/Samples/Java/Writer/TextDocumentStructure</a></p>
  
  <p>My C# code:</p>
  
  <pre><code>InitOpenOfficeEnvironment();
  XMultiServiceFactory multiServiceFactory = connect();
  XComponentLoader componentLoader =           
      XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop"); 
  
  //set the property
  PropertyValue[] propertyValue = new PropertyValue[1];
  PropertyValue aProperty = new PropertyValue();
  aProperty.Name = "Hidden";
  aProperty.Value = new uno.Any(false);
  propertyValue[0] = aProperty;
  
  XComponent xComponent =
          componentLoader.loadComponentFromURL(
              @"file:///C:/code/test3.doc", 
              "_blank", 0, propertyValue);
  
  XEnumerationAccess xEnumerationAccess = (XEnumerationAccess)xComponent;
  XEnumeration xParagraphEnumeration = xEnumerationAccess.createEnumeration();
  
  while ( xParagraphEnumeration.hasMoreElements() ) 
  {
      // ???
      // The problem is here nextElement() returns uno.Any but
      // I some how should get XTextContent????
      uno.Any textElement = xParagraphEnumeration.nextElement();
  
      // create another enumeration to get all text portions of 
      //the paragraph
      XEnumeration xParaEnumerationAccess = textElement.createEnumeration();
  
      //step 3  Through the Text portions Enumeration, 
      //get interface to each individual text portion
  }
  
  xComponent.dispose();
  xComponent = null;
  </code></pre>