https://bugs.freedesktop.org/show_bug.cgi?id=70299

          Priority: medium
            Bug ID: 70299
          Assignee: [email protected]
           Summary: Replacing a string by images only works for the first
                    occurrence
          Severity: normal
    Classification: Unclassified
                OS: Mac OS X (All)
          Reporter: [email protected]
          Hardware: x86-64 (AMD64)
            Status: UNCONFIRMED
           Version: 4.1.2.3 rc
         Component: BASIC
           Product: LibreOffice

Hello.

I try to replace every occurrence of a certain string by an image. It loops,
but writer only replaces the first occurence and I don't see why. Here ist the
code:

I am using LO 4.1
The code:

Sub InsertLogo()
  Dim oGraph
  Dim oDescriptor  'The search descriptor
  Dim oFound       'The found range
  Dim oFoundAll    'The found range
  Dim n%           'General index variable
  Dim oCursor

  oGraph = ThisComponent.createInstance("com.sun.star.text.GraphicObject")
  With oGraph
    .GraphicURL = "file://localhost/anydirectory/logo.png"
    .AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
    .Width = 910
    .Height = 420
    .VertOrient = 4 'CHAR_TOP
  End With

  oDescriptor = ThisComponent.createSearchDescriptor()
  oDescriptor.SearchString = "{logo}"
  oFoundAll = ThisComponent.findAll(oDescriptor)
  For n% = 0 to oFoundAll.getCount()-1
    oFound = oFoundAll.getByIndex(n%)
    oFound.setString("")
    oCursor = oFound.getStart()
    oFound.getText().insertTextContent( oCursor, oGraph, False )
  Next

End Sub

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to