本文整理汇总了C++中KWDocument::openUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ KWDocument::openUrl方法的具体用法?C++ KWDocument::openUrl怎么用?C++ KWDocument::openUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KWDocument
的用法示例。
在下文中一共展示了KWDocument::openUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRoundtrip
void TestKoBookmark::testRoundtrip()
{
const QString lorem(
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor"
"incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud"
"exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n"
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla"
"pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia"
"deserunt mollit anim id est laborum.\n"
);
{
// Get the words part and create a document
KWDocument *doc = new KWDocument(new KWPart(0));
Q_ASSERT(doc);
doc->setAutoSave(0);
doc->initEmpty();
// get the main text frame
KWTextFrameSet *mainFrameSet = doc->mainFrameSet();
Q_ASSERT(mainFrameSet);
QTextDocument *textDocument = mainFrameSet->document();
Q_ASSERT(textDocument);
// Insert some text a bookmark pair
KoTextDocument koTextDocument(textDocument);
KoTextEditor *editor = koTextDocument.textEditor();
editor->insertText(lorem);
KoTextRangeManager *rangeManager = koTextDocument.textRangeManager();
QTextCursor cursor(editor->document());
KoBookmark *mark = new KoBookmark(cursor);
mark->setName("TESTMARK");
rangeManager->insert(mark);
editor->insertTable(5,10);
const QTextTable *table = editor->currentTable();
Q_ASSERT(table);
editor->setPosition(table->lastPosition());
mark->setRangeEnd(editor->position());
editor->insertText(lorem);
// Save the document
KUrl url(QString(FILES_OUTPUT_DIR) + "/bookmark_roundtrip.odt");
doc->documentPart()->saveAs(url);
// check the number of bookmarks
QCOMPARE(rangeManager->bookmarkManager()->bookmarkNameList().length(), 1);
QCOMPARE(rangeManager->textRanges().length(), 1);
delete doc;
}
{
// Load the document
KWDocument *doc = new KWDocument(new KWPart(0));
Q_ASSERT(doc);
doc->setAutoSave(0);
KUrl url(QString(FILES_OUTPUT_DIR) + "/bookmark_roundtrip.odt");
// this also creates a view...
bool result = doc->openUrl(url);
Q_ASSERT(result);
// get the main text frame
KWTextFrameSet *mainFrameSet = doc->mainFrameSet();
Q_ASSERT(mainFrameSet);
QTextDocument *textDocument = mainFrameSet->document();
Q_ASSERT(textDocument);
KoTextDocument koTextDocument(textDocument);
// check the number of bookmarks
KoTextRangeManager *rangeManager = koTextDocument.textRangeManager();
QCOMPARE(rangeManager->bookmarkManager()->bookmarkNameList().length(), 1);
QCOMPARE(rangeManager->textRanges().length(), 1);
delete doc;
}
}