Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java LibreOffice XParagraphCursor在空行时卡住_Java_Libreoffice_Openoffice.org - Fatal编程技术网

Java LibreOffice XParagraphCursor在空行时卡住

Java LibreOffice XParagraphCursor在空行时卡住,java,libreoffice,openoffice.org,Java,Libreoffice,Openoffice.org,我有一个代码在LibreOffice 5之前一直运行良好。但在libreoffice6(32位和64位)中,它停止了工作 public String getNextSentenceOO() { while (moreParagraphsOO) { while (moreSentencesOO) { xSentenceCursor.gotoEndOfSentence(true); textSentence = xSentenc

我有一个代码在LibreOffice 5之前一直运行良好。但在libreoffice6(32位和64位)中,它停止了工作

public String getNextSentenceOO() {
    while (moreParagraphsOO) {
        while (moreSentencesOO) {
            xSentenceCursor.gotoEndOfSentence(true);
            textSentence = xSentenceCursor.getString();
            xTextViewCursor.gotoRange(xSentenceCursor.getStart(), false);
            xTextViewCursor.gotoRange(xSentenceCursor.getEnd(), true);
            if (!textSentence.equals("")) {
                return textSentence;
            }

            moreSentencesOO = xSentenceCursor.gotoNextSentence(false);

            if (xSentenceCursor.isEndOfSentence() && !xSentenceCursor.isStartOfSentence()){
                moreSentencesOO = false;
            }                
        }
        
        moreParagraphsOO = xParagraphCursor.gotoNextParagraph(false);
        moreSentencesOO = xSentenceCursor.gotoStartOfSentence(false);
    }
    return null;
}
当文档中存在空行时,会出现问题。在这种情况下,说明:

moreParagraphsOO = xParagraphCursor.gotoNextParagraph(false);
不会使光标前进到下一段,而是保持在同一位置,因此函数进入无限循环。有什么想法吗


正如我所说,这在LibreOffice 4和5(甚至在LO5的最后一个版本)中工作得非常完美。它在LO6中停止工作。

枚举段落,而不是段落游标。从清单7.52中可以看出:

oParEnum=ThisComponent.getText().createEnumeration()
当oParEnum.hasMoreElements()时执行此操作
oPar=oParEnum.nextElement()
此外,清单7.65中还有一个注释可能与您的问题有关:

REM在这个例子中,我假设后面有文本
删除文本部分。如果没有,那么这就是
REM是一个无限循环。你最好核实一下
REM GOTONEXTPARATION不返回False。
在非空时执行(oCurs.TextSection)
oCurs.GotonExttraphy(假)
环