Re: Delete table in cursor position
Andrew Douglas Pitonyak <[email protected]> Sun, 10 Jul 2011 22:32:26 -0400
| Newsgroups | gmane.comp.openoffice.devel.general |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------050106010400000100080505
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
You should reply to the list, not to me directly.
I did look at this, and there are problems with any solution that I
tried. For example, first, I tried walking the text table anchor, but I
repeatedly crashed LO when I tried that. I also found that performing a
few sneaky things (such as looking at the anchor's text object and then
creating a cursor at that text object failed when I had a cell that
contained ONLY a text table (because creating a cursor in that cell did
not leave any place for that cursor to be except for in the containing
text table).
Next, I tried another sneaky thing such as simply disposing the text
table and then checking to see if the view cursor was still in a text
table. it looks like that approach may work, but I did not pursue it
past a few very basic tests.
sub MainTable
Dim oTable
Dim oVC
Dim sName$
ovc = ThisComponent.getCurrentController().getViewCursor()
Do While NOT IsNull (ovc.TextTable) AND NOT IsEmpty(ovc.TextTable)
oTable = ovc.TextTable
sName = oTable.Name
oTable.dispose()
'Print "removed " & sName
Loop
End Sub
On 07/10/2011 11:25 AM, Shameera Rathnayaka wrote:
> thanks Andrew,
>
> this is the code in java its worked
>
> // get text view cursor from the text document
> XController xController =
> xTextDocument.getCurrentController();
> XTextViewCursorSupplier xCursorSup =
> (XTextViewCursorSupplier)
> UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
> XTextViewCursor xViewCursor = xCursorSup.getViewCursor();
> XPropertySet xCursorPropertySet = (XPropertySet)
> UnoRuntime.queryInterface(XPropertySet.class, xViewCursor);
> Object tab = xCursorPropertySet.getPropertyValue("TextTable");
> XTextTable table = (XTextTable)
> UnoRuntime.queryInterface(XTextTable.class, tab);
> table.dispose(); // delete the table
> and now i want to duplicate the complex table, complex table mean it
> has several tables inside it, even if the cursor inside the one of
> it's child table, i want to duplicate the full complex table. for this
> i want to select most outer table.
> can anybody help me with this
>
> *Thanks*
>
> On Sun, Jul 10, 2011 at 7:28 PM, Andrew Douglas Pitonyak
> <[email protected] <mailto:[email protected]>> wrote:
>
> 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
> <http://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
>
>
>
>
> --
> 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
--------------050106010400000100080505
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">
You should reply to the list, not to me directly.<br>
<br>
I did look at this, and there are problems with any solution that I
tried. For example, first, I tried walking the text table anchor,
but I repeatedly crashed LO when I tried that. I also found that
performing a few sneaky things (such as looking at the anchor's text
object and then creating a cursor at that text object failed when I
had a cell that contained ONLY a text table (because creating a
cursor in that cell did not leave any place for that cursor to be
except for in the containing text table).<br>
<br>
Next, I tried another sneaky thing such as simply disposing the text
table and then checking to see if the view cursor was still in a
text table. it looks like that approach may work, but I did not
pursue it past a few very basic tests.<br>
<br>
sub MainTable<br>
Dim oTable<br>
Dim oVC<br>
Dim sName$<br>
ovc = ThisComponent.getCurrentController().getViewCursor()<br>
Do While NOT IsNull (ovc.TextTable) AND NOT IsEmpty(ovc.TextTable)<br>
oTable = ovc.TextTable<br>
sName = oTable.Name<br>
oTable.dispose()<br>
'Print "removed " & sName<br>
Loop<br>
End Sub<br>
<br>
<br>
On 07/10/2011 11:25 AM, Shameera Rathnayaka wrote:
<blockquote
cite="mid:CAJvLytqcwYsLvS2Ht9vbmi9_jfR1hXJ4+=eSOJ_QQu-HJrzBZQ@mail.gmail.com"
type="cite">thanks Andrew,
<div><br>
</div>
<div>this is the code in java its worked </div>
<div><br>
</div>
<div>
<div> <font class="Apple-style-span" size="1"> // get
text view cursor from the text document</font></div>
<div><font class="Apple-style-span" size="1">
XController xController =
xTextDocument.getCurrentController();</font></div>
<div><font class="Apple-style-span" size="1">
XTextViewCursorSupplier xCursorSup =
(XTextViewCursorSupplier)
UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
xController);</font></div>
<div><font class="Apple-style-span" size="1">
XTextViewCursor xViewCursor = xCursorSup.getViewCursor();</font></div>
<div><font class="Apple-style-span" size="1">
XPropertySet xCursorPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xViewCursor);</font></div>
<div><font class="Apple-style-span" size="1"> Object
tab = xCursorPropertySet.getPropertyValue("TextTable");</font></div>
<div><font class="Apple-style-span" size="1">
XTextTable table = (XTextTable)
UnoRuntime.queryInterface(XTextTable.class, tab);</font></div>
<div><font class="Apple-style-span" size="1">
table.dispose(); // delete the table </font></div>
<div><font class="Apple-style-span" size="1"> </font></div>
<div>and now i want to duplicate the complex table, complex
table mean it has several tables inside it, even if the cursor
inside the one of it's child table, i want to duplicate the
full complex table. for this i want to select most outer
table. </div>
<div>can anybody help me with this </div>
<div><br>
</div>
<b>Thanks</b></div>
<div><br>
<div class="gmail_quote">On Sun, Jul 10, 2011 at 7:28 PM, Andrew
Douglas Pitonyak <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:[email protected]">[email protected]</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
<div class="im"> On 07/09/2011 01:52 AM, Shameera
Rathnayaka wrote:
<blockquote 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>
</div>
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>
Dim oVC : oVC =
ThisComponent.getCurrentController().getViewCursor()<br>
If Not IsNull(oVC.TextTable) Then<br>
Print "In TextTable " & <a moz-do-not-send="true"
href="http://oVC.TextTable.Name" target="_blank">oVC.TextTable.Name</a><br>
End If
<div>
<div class="h5"><br>
<br>
<blockquote 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 </div>
<div><br>
</div>
<div>
<div>XTextTable table=null;</div>
<div> XText text = xTextDocument.getText();</div>
<div> XTextRange textRange=
text.getStart();</div>
<div><br>
</div>
<div> XEnumerationAccess xParaAccess =
(XEnumerationAccess)
UnoRuntime.queryInterface(XEnumerationAccess.class,
textRange.getText());</div>
<div> XEnumeration xParaEnum =
xParaAccess.createEnumeration();</div>
<div> while (xParaEnum.hasMoreElements()) {</div>
<div> try {</div>
<div> Object objElement =
xParaEnum.nextElement();</div>
<div> XServiceInfo xInfo =
(XServiceInfo)
UnoRuntime.queryInterface(XServiceInfo.class,
objElement);</div>
<div> if
(xInfo.supportsService("com.sun.star.text.TextTable"))
{</div>
<div> table = (XTextTable)
UnoRuntime.queryInterface(</div>
<div>
XTextTable.class,objElement);</div>
<div> table.dispose();</div>
<div> }</div>
<div> } catch
(com.sun.star.container.NoSuchElementException
ex) {</div>
<div>
java.util.logging.Logger.getLogger(TableOparater.class.getName()).log(Level.SEVERE,
null, ex);</div>
<div> } catch (WrappedTargetException
ex) {</div>
<div>
java.util.logging.Logger.getLogger(TableOparater.class.getName()).log(Level.SEVERE,
null, ex);</div>
<div> }</div>
<div> }</div>
<div><br>
</div>
<b>thanks </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. 0719221454</span><br>
</div>
</blockquote>
<br>
</div>
</div>
<pre cols="72">--
Andrew Pitonyak
My Macro Document: <a moz-do-not-send="true" href="http://www.pitonyak.org/AndrewMacro.odt" target="_blank">http://www.pitonyak.org/AndrewMacro.odt</a>
Info: <a moz-do-not-send="true" href="http://www.pitonyak.org/oo.php" target="_blank">http://www.pitonyak.org/oo.php</a>
</pre>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<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.
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>
--------------050106010400000100080505--