Issue 51971 - Cannot create TextCursors in text frames, which were tables in MS Word
Summary: Cannot create TextCursors in text frames, which were tables in MS Word
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-14 15:52 UTC by ataraxis
Modified: 2013-02-24 21:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
test document with frames and tables in word. all are frames in writer. (33.00 KB, application/msword)
2005-07-14 16:23 UTC, ataraxis
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description ataraxis 2005-07-14 15:52:44 UTC
The following code goes through all text frames and dumps the text on the
command line. When I open a MS Word document which tables in it, OOo converts
those tables into text frames and i get an exception. OOo tables are no problems.

The exception i get:
Exception in thread "main" com.sun.star.uno.RuntimeException: no text available 

The code line where i get the exception:
xTextCursor = xText.createTextCursor();

This is the complete code:

   XTextFramesSupplier xTextFrames = (XTextFramesSupplier)UnoRuntime.queryInterface(
                      XTextFramesSupplier.class, xTextDocument);
   String[] names = xTextFrames.getTextFrames().getElementNames();
   XTextFrame xTextFrame = null;
   XText xText = null;
   XTextCursor xTextCursor = null;
   Object o=null;
   String text="";

   for (int i=0; i<names.length; i++){
      try {
         o= xTextFrames.getTextFrames().getByName(names[i]);
         xTextFrame = (XTextFrame) UnoRuntime.queryInterface(
                 XTextFrame.class, o);
      } catch (NoSuchElementException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (WrappedTargetException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
      xText=xTextFrame.getText();
      xTextCursor = xText.createTextCursor();
      xTextCursor.gotoStart(false);
      xTextCursor.gotoEnd(true);
      text = xTextCursor.getString();
      System.out.println(text);
   }
Comment 1 stephan.wunderlich 2005-07-14 16:12:44 UTC
sw->ataraxis: do you have a sample document where tables are imported as frames
? ... I get tables with all the documents I tried.
Comment 2 ataraxis 2005-07-14 16:23:44 UTC
Created attachment 27927 [details]
test document with frames and tables in word. all are frames in writer.
Comment 3 stephan.wunderlich 2005-07-15 10:21:41 UTC
sw->ataraxis: changing your code like this should solve the problem.

      xText=xTextFrame.getText();
      XEnumerationAccess xEA = (XEnumerationAccess) 
                UnoRuntime.queryInterface(XEnumerationAccess.class, xText);
      XEnumeration xEnum = xEA.createEnumeration();
      
      boolean isTable = false;
      
      try {
            XPropertySet props = (XPropertySet) 
             UnoRuntime.queryInterface(XPropertySet.class, xEnum.nextElement());
     
            isTable = props.getPropertySetInfo().hasPropertyByName("TextTable");
          
      } catch (Exception e) {
          
      }
      if (isTable) {
          xTextCursor = xText.createTextCursor();
          xTextCursor.gotoStart(false);
          xTextCursor.gotoEnd(true);
          text = xTextCursor.getString();
          System.out.println(text);
      }
Comment 4 stephan.wunderlich 2005-07-15 10:23:04 UTC
sw->tl: I wonder why the propery texttable is only available when no table is
inside the frame.