10.3.28 GetParagraphs
Liest die vorhandenen Absätze aus dem Writerdokument. Mit dem Parameter ignoreEmpty werden leere Absätze ingoriert.


function getParagraphs(odoc as object, optional ignoreEmpty as boolean)

     Dim myEnum as object
    Dim isAbsatz as boolean
    Dim myAbsatz as object
    Dim i as Integer   
    if IsMissing(ignoreEmpty) then
      ignoreEmpty = false
    end if
    msgbox ignoreEmpty

    'Auslesen der Anzahl
    i=0
     myEnum = oDoc.Text.createEnumeration
    While myEnum.hasMoreElements
          myAbsatz = myEnum.nextElement
            isAbsatz=hasunointerfaces(myAbsatz,"com.sun.star.text.XTextRange")
            if isAbsatz then
               if ignoreEmpty then   
                    if myAbsatz.string<>"" then
                       i=i+1
                    end if
                 else
                 i=i+1
               end if     
            end if
     Wend

    Redim allParagraphs(i)  

     'Auslesen der Absätze
     i=0
     myEnum = oDoc.Text.createEnumeration
     While myEnum.hasMoreElements
          myAbsatz = myEnum.nextElement
            isAbsatz=hasunointerfaces(myAbsatz,"com.sun.star.text.XTextRange")
            if isAbsatz then
              if ignoreEmpty then   
                    if myAbsatz.string<>"" then
                      allParagraphs(i)=myAbsatz
                      i=i+1
                    end if
                 else
                 allParagraphs(i)=myAbsatz
                 i=i+1
               end if     
            end if
        Wend
    getParagraphs()=allParagraphs()   
end function