Hello!

I want to find a word in a Writers document and add text-sentences there
until a new page is created. 

I use XPageCursor to determinate how many pages there are in the document.

My problem is: After insertion of a text-sentence, it seems that the layout
is not updated immediately (especially if there is a lot of other text after
the inserted text). So my function to get the page-count doesn't work
correctly at this time. 

It however works correctly when adding a Sleep-command after the insertion.

I tried XTextDocument::reformat to enforce the reformatting, but without
success.

Any ideas about it?

Thanks in advance

Martin


Code (to test it I'm just inserting paragraphs), using OO 1.9.125:

void OOExpandToPageEnd(Reference<XInterface> rDoc, CString sTag)
{       // Find sTag
        Reference <XSearchable> rSearchable ( rDoc, UNO_QUERY );        
        Reference <XSearchDescriptor> rSearch =
rSearchable->createSearchDescriptor();
        Reference <XPropertyReplace> rPropSearch (rSearch, UNO_QUERY);
        rPropSearch->setPropertyValue(ToStr("SearchCaseSensitive"),
makeAny((sal_Bool)false));
        rPropSearch->setPropertyValue(ToStr("SearchWords"),
makeAny((sal_Bool)false));
        rSearch->setSearchString(ToStr(sTag));
        Reference <XTextRange> rFound (rSearchable->findFirst(rSearch),
UNO_QUERY);
        if (!rFound.is())
        {       return ;        
        }
        
        // Get originally page-count
        int nCount = OOGetPageCount(rDoc);
        Reference <XSimpleText> rText (rFound->getText(), UNO_QUERY);
        Reference <XTextDocument> rTxtDoc ( rDoc, UNO_QUERY );          
        int nCountCurrent = OOGetPageCount(rDoc);
        while (nCountCurrent == nCount)
        {       rText->insertControlCharacter(rFound->getStart(),
ControlCharacter::PARAGRAPH_BREAK, false);
                rTxtDoc->reformat(); // -> Doesn't make OOGetPageCount to
work
                // Sleep(500); // -> Makes OOGetPageCount to work
                nCountCurrent = OOGetPageCount(rDoc);   
        }
}

int OOGetPageCount(Reference<XInterface> rInterface)
{       Reference<XModel> rModel (rInterface, UNO_QUERY);
        Reference<XTextViewCursorSupplier> rCurSup
(rModel->getCurrentController(), UNO_QUERY);
        Reference<XPageCursor> rCursor (rCurSup->getViewCursor(),
UNO_QUERY);
        rCursor->jumpToLastPage();
        return rCursor->getPage();
}




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to