OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to get a table by position in a text range.[java]

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
mikepb78
General User
General User


Joined: 22 Jun 2005
Posts: 37

PostPosted: Sun Nov 19, 2006 11:46 pm    Post subject: How to get a table by position in a text range.[java] Reply with quote

Here is a simple code snippet on how to get a table by position in a specific text range.

Code:

   /**
    * Get a table by position within a specific range.
    *
    * @param pobjRange The text range to look within.
    * @param pintTable The table position. 1, will return the first table in this range.
    * @return Returns the text table.
    */
   public XTextTable getTable(XTextRange pobjRange, int pintTable) {
      try {
         XTextTable getTable = null;

         //----
         // Look within the supplied text range
         //----
         int intCrrnt = 1;
         XText xText = pobjRange.getText();
         XEnumerationAccess xParaAccess = QI.XEnumerationAccess(xText);
         XEnumeration xParaEnum = xParaAccess.createEnumeration();
         while (xParaEnum.hasMoreElements()) {
            Object objElement = xParaEnum.nextElement();
            XServiceInfo xInfo = QI.XServiceInfo(objElement);
            if (xInfo.supportsService("com.sun.star.text.TextTable")) {
               if (intCrrnt == pintTable) {
                  getTable = QI.XTextTable(objElement);
                  break;
               }
               intCrrnt++;
            }
         }
         
         return getTable;
      } catch (Exception e) {
         getZx().trace.addError("Failed to get table number " + pintTable, e);
         throw new RuntimeException(e);
      }
   }
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group