Re: Delete table in cursor position

Andrew Douglas Pitonyak <[email protected]> Sun, 10 Jul 2011 09:58:41 -0400
Newsgroups gmane.comp.openoffice.devel.general
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------060301090907080200060102
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

On 07/09/2011 01:52 AM, Shameera Rathnayaka wrote:
> hi dev,
>
> This is my problem i could delete all table in doc , but how can i 
> delete table in cursor position which i dont know the name and index 
> of that table.

I believe that the view cursor has a text table property that you can 
check to see if the cursor is in a text table. This is how I do it in Basic

   Dim oVC : oVC = ThisComponent.getCurrentController().getViewCursor()
   If Not IsNull(oVC.TextTable) Then
     Print "In TextTable " & oVC.TextTable.Name
   End If

>
> here my code to delete all table in textRange but it delete all table 
> in my doc, if you know please give me a help or point out some helpful 
> links
>
> XTextTable table=null;
>         XText text = xTextDocument.getText();
>         XTextRange textRange= text.getStart();
>
>         XEnumerationAccess xParaAccess = (XEnumerationAccess) 
> UnoRuntime.queryInterface(XEnumerationAccess.class, textRange.getText());
>         XEnumeration xParaEnum = xParaAccess.createEnumeration();
>         while (xParaEnum.hasMoreElements()) {
>             try {
>                 Object objElement = xParaEnum.nextElement();
>                 XServiceInfo xInfo = (XServiceInfo) 
> UnoRuntime.queryInterface(XServiceInfo.class, objElement);
>                 if 
> (xInfo.supportsService("com.sun.star.text.TextTable")) {
>                     table = (XTextTable) UnoRuntime.queryInterface(
>                        XTextTable.class,objElement);
>                     table.dispose();
>                 }
>             } catch (com.sun.star.container.NoSuchElementException ex) {
>                 
> java.util.logging.Logger.getLogger(TableOparater.class.getName()).log(Level.SEVERE, 
> null, ex);
>             } catch (WrappedTargetException ex) {
>                 
> java.util.logging.Logger.getLogger(TableOparater.class.getName()).log(Level.SEVERE, 
> null, ex);
>             }
>     }
>
> *thanks *
> -- 
> Shameera Rathnayaka
> Undergraduate
> Department of Computer Science and Engineering
> University of Moratuwa.
> Sri Lanka.
> T.P.  0719221454

-- 
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php

-- 
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help

--------------060301090907080200060102
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 07/09/2011 01:52 AM, Shameera Rathnayaka wrote:
    <blockquote
cite="mid:CAJvLytr7+U=4iWpr=6MPfkGSkiVM+qp+iLVm4Bs8UzqHSTMqQw@mail.gmail.com"
      type="cite">hi dev,
      <div><br>
      </div>
      <div>This is my problem i could delete all table in doc , but how
        can i delete table in cursor position which i dont know the name
        and index of that table.</div>
    </blockquote>
    <br>
    I believe that the view cursor has a text table property that you
    can check to see if the cursor is in a text table. This is how I do
    it in Basic<br>
    <br>
    &nbsp; Dim oVC : oVC =
    ThisComponent.getCurrentController().getViewCursor()<br>
    &nbsp; If Not IsNull(oVC.TextTable) Then<br>
    &nbsp;&nbsp;&nbsp; Print "In TextTable " &amp; oVC.TextTable.Name<br>
    &nbsp; End If<br>
    <br>
    <blockquote
cite="mid:CAJvLytr7+U=4iWpr=6MPfkGSkiVM+qp+iLVm4Bs8UzqHSTMqQw@mail.gmail.com"
      type="cite">
      <div><br>
      </div>
      <div>here my code to delete all table in textRange but it delete
        all table in my doc, if you know please give me a help or point
        out some helpful links&nbsp;</div>
      <div><br>
      </div>
      <div>
        <div>XTextTable table=null;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; XText text = xTextDocument.getText();</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; XTextRange textRange= text.getStart();</div>
        <div><br>
        </div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; XEnumerationAccess xParaAccess =
          (XEnumerationAccess)
          UnoRuntime.queryInterface(XEnumerationAccess.class,
          textRange.getText());</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; XEnumeration xParaEnum =
          xParaAccess.createEnumeration();</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; while (xParaEnum.hasMoreElements()) {</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Object objElement =
          xParaEnum.nextElement();</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XServiceInfo xInfo = (XServiceInfo)
          UnoRuntime.queryInterface(XServiceInfo.class, objElement);</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if
          (xInfo.supportsService("com.sun.star.text.TextTable")) {</div>
        <div>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table = (XTextTable)
          UnoRuntime.queryInterface(</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XTextTable.class,objElement);</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.dispose();</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch
          (com.sun.star.container.NoSuchElementException ex) {</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          java.util.logging.Logger.getLogger(TableOparater.class.getName()).log(Level.SEVERE,
          null, ex);</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (WrappedTargetException ex) {</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          java.util.logging.Logger.getLogger(TableOparater.class.getName()).log(Level.SEVERE,
          null, ex);</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
        <div>&nbsp; &nbsp; }</div>
        <div><br>
        </div>
        <b>thanks&nbsp;</b><br>
        -- <br>
        <span style="font-family: comic sans ms,sans-serif;">Shameera
          Rathnayaka</span><br style="font-family: comic sans
          ms,sans-serif;">
        <span style="font-family: comic sans ms,sans-serif;">Undergraduate</span><br
          style="font-family: comic sans ms,sans-serif;">
        <span style="font-family: comic sans ms,sans-serif;">Department
          of Computer Science and Engineering</span><br
          style="font-family: comic sans ms,sans-serif;">
        <span style="font-family: comic sans ms,sans-serif;">University
          of Moratuwa.</span><br style="font-family: comic sans
          ms,sans-serif;">
        <span style="font-family: comic sans ms,sans-serif;">Sri Lanka.</span><br
          style="font-family: comic sans ms,sans-serif;">
        <span style="font-family: comic sans ms,sans-serif;">T.P.&nbsp;
          0719221454</span><br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Andrew Pitonyak
My Macro Document: <a class="moz-txt-link-freetext" href="http://www.pitonyak.org/AndrewMacro.odt">http://www.pitonyak.org/AndrewMacro.odt</a>
Info:  <a class="moz-txt-link-freetext" href="http://www.pitonyak.org/oo.php">http://www.pitonyak.org/oo.php</a>
</pre>
  </body>
</html>

--------------060301090907080200060102--