On 01/28/2011 12:09 PM, Zbigniew Szot wrote:
Hi again

If i  apply my  " use case" (TextSection nested in textTable) to Your
snippet.  The TextTable property will not be set (will be null) and
the textsection property will be set to "nested" text section.

So its dead loop exacly as in my example.
I'm working bit too long, and started to have problem with
communicating in the clear way.
Thanks for taking interest  Piter.
I hope I've managed to explain where is the catch ;-)

Zbyszek
On a whim, I spent another couple hours looking at this and I must agree that a solution, if it exists, is tricky at best. Part of the problem is that if you have one object nested in another, then you will likely see both objects.

I inserted a section in a section in a table in a section.

I can easily walk the parent sections, but, then this totally misses the table. On the other hand, if I check for the table first, then I miss the section.

If I walk a sections parents, then I must jump through hoops to find the table (but I can do it). For example, section in a section in a table. I can find the table, but, I must do something a wee bit odd (like create a text cursor).

I might be able to find a solution by inspecting the text object in each section, but, that would take way more time than I am willing to invest (since it is not really my problem). This is part of my test code.



Sub TraceParent
MsgBox TraceParentFromRange(ThisComponent.CurrentCOntroller.ViewCursor, False)
End Sub

Function TraceParentFromRange(oRangeArg, ignoreTextSection As Boolean) As String
  If IsNull(oRangeArg) OR IsEmpty(oRangeArg) Then
    TraceParentFromRange = ""
    Exit Function
  End If

  Dim oRange
  oRange = oRangeArg

  Dim oAnchor
  Dim s$
  Dim sParent$
  Dim oSection
  Dim localIgnoreTextSection As Boolean
  s = ""
  localIgnoreTextSection = False
  If NOT IsEmpty(oRange.TextSection) AND NOT ignoreTextSection Then
    localIgnoreTextSection = True
    oSection = oRange.TextSection
    Do While NOT IsEmpty(oSection) AND NOT IsNull(oSection)
      If Len(s) = 0 Then
        s = "TextSection: '" & oSection.getName() & "'"
      Else
s = s & " Anchored in" & CHR$(10) & "TextSection: '" & oSection.getName() & "'"
      End If
      oAnchor = oSection.getAnchor()
      oSection = oSection.getParentSection()
    Loop
    'Inspect oAnchor.getText().createTextCursorByRange(oAnchor)
If oAnchor.getText().SupportsService("com.sun.star.text.CellProperties") Then
      oAnchor = oAnchor.getText().createTextCursor()
    End If
  End If
  If NOT IsEmpty(oRange.Cell) Then
    If Len(s) > 0 Then
      s = s & CHR$(10)
    End If
s = s & "Cell " & oRange.Cell.CellName & " in table " & oRange.TextTable.getName()
    oAnchor =  oRange.TextTable.getAnchor()
  End If
  If s = "" Then
    TraceParentFromRange = "Root"
    Exit Function
  End If
  sParent$ = TraceParentFromRange(oAnchor, localIgnoreTextSection)
  If Len(sParent) = 0 Then
    TraceParentFromRange = s
  Else
    TraceParentFromRange = s & CHR$(10) & "Anchored in: " & sParent
  End If
End Function

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to