von F3K Total » Sa, 28.11.2015 00:58
Hi,
Colster hat geschrieben:keine Möglichkeit gefunden
habe geforscht, hier das Ergebnis, funktioniert bei mir:
Code: Alles auswählen
Sub getchkText
dim oRanges(1,0) as Variant
ncounter = 0
oText = thisComponent.text
oTextEnumeration = oText.createEnumeration
While oTextEnumeration.hasmoreelements
oPara = oTextEnumeration.nextelement
oparaEnumeration = oPara.createEnumeration
While oparaEnumeration.hasmoreelements
oPortion = oparaEnumeration.nextelement
oPortionContentEnumeration = oPortion.createContentEnumeration("com.sun.star.drawing.ControlShape")
While oPortionContentEnumeration.hasmoreelements
oShape = oPortionContentEnumeration.nextelement
if oShape.Control.ServiceName = "stardiv.one.form.component.CheckBox" then
redim preserve oRanges(1,nCounter)
oRanges(0,nCounter) = oShape.Control.State
oRanges(1,nCounter) = oPara.Anchor
nCounter = nCounter + 1
endif
wend
wend
wend
oCursor = oText.CreateTextCursor
for i = 0 to uBound(oRanges,2)-1
if oRanges(0,i) = 1 then
oAnchorStart = oRanges(1,i)
oAnchorEnd = oRanges(1,i+1)
oCursor.gotorange(oAnchorEnd,false)
oCursor.gotoPreviousParagraph(false)
oCursor.gotorange(oAnchorStart,true)
if oCursor.CharColor = -1 then
oCursor.CharColor = RGB(0,255,0)
else
oCursor.CharColor = -1
endif
endif
next i
if oRanges(0,uBound(oRanges,2)) = 1 then
oAnchorStart = oRanges(1,uBound(oRanges,2))
oCursor.gotoEnd(false)
oCursor.gotorange(oAnchorStart, true)
if oCursor.CharColor = -1 then
oCursor.CharColor = RGB(0,255,0)
else
oCursor.CharColor = -1
endif
endif
End Sub
Gruß R
Hi,
[quote="Colster"]keine Möglichkeit gefunden[/quote]habe geforscht, hier das Ergebnis, funktioniert bei mir:
[code]Sub getchkText
dim oRanges(1,0) as Variant
ncounter = 0
oText = thisComponent.text
oTextEnumeration = oText.createEnumeration
While oTextEnumeration.hasmoreelements
oPara = oTextEnumeration.nextelement
oparaEnumeration = oPara.createEnumeration
While oparaEnumeration.hasmoreelements
oPortion = oparaEnumeration.nextelement
oPortionContentEnumeration = oPortion.createContentEnumeration("com.sun.star.drawing.ControlShape")
While oPortionContentEnumeration.hasmoreelements
oShape = oPortionContentEnumeration.nextelement
if oShape.Control.ServiceName = "stardiv.one.form.component.CheckBox" then
redim preserve oRanges(1,nCounter)
oRanges(0,nCounter) = oShape.Control.State
oRanges(1,nCounter) = oPara.Anchor
nCounter = nCounter + 1
endif
wend
wend
wend
oCursor = oText.CreateTextCursor
for i = 0 to uBound(oRanges,2)-1
if oRanges(0,i) = 1 then
oAnchorStart = oRanges(1,i)
oAnchorEnd = oRanges(1,i+1)
oCursor.gotorange(oAnchorEnd,false)
oCursor.gotoPreviousParagraph(false)
oCursor.gotorange(oAnchorStart,true)
if oCursor.CharColor = -1 then
oCursor.CharColor = RGB(0,255,0)
else
oCursor.CharColor = -1
endif
endif
next i
if oRanges(0,uBound(oRanges,2)) = 1 then
oAnchorStart = oRanges(1,uBound(oRanges,2))
oCursor.gotoEnd(false)
oCursor.gotorange(oAnchorStart, true)
if oCursor.CharColor = -1 then
oCursor.CharColor = RGB(0,255,0)
else
oCursor.CharColor = -1
endif
endif
End Sub
[/code]
Gruß R