void SampleItem::setLoremIpsum(int para) { LoremParser *m = new LoremParser("loremipsum.xml"); text = m->createLorem(para); // really needed ?? // text = QString::fromUtf8(text); delete m; }
void LoremManager::insertLoremIpsum(QString name, int paraCount, bool random) { //CB: Avox please make insertText for text frame to nuke all this // is it really applied? // bool done = false; for (int i = 0; i < m_Doc->m_Selection->count(); ++i) { PageItem* currItem=m_Doc->m_Selection->itemAt(i); if (currItem == NULL) continue; if (!currItem->asTextFrame()) continue; if (currItem->itemText.length() != 0) { m_Doc->itemSelection_ClearItem(); /* ClearItem() doesn't return true or false so the following test has to be done */ if (currItem->itemText.length() != 0) continue; } LoremParser *lp = new LoremParser(name); if (lp == NULL) { qDebug("LoremManager::okButton_clicked() *lp == NULL"); return; } #if 0 // Set up the gtWriter instance with the selected paragraph style gtWriter* writer = new gtWriter(false, currItem); if (writer != NULL) { writer->setUpdateParagraphStyles(false); writer->setOverridePStyleFont(false); gtFrameStyle* fstyle = writer->getDefaultStyle(); gtParagraphStyle* pstyle = new gtParagraphStyle(*fstyle); pstyle->setName(currItem->currentStyle().name()); writer->setParagraphStyle(pstyle); done = true; writer->append(lp->createLorem(paraCount)); } delete writer; #endif // K.I.S.S.: currItem->itemText.insertChars(0, lp->createLorem(paraCount, random)); delete lp; //if (ScMW->view->SelItem.at(i)->Doc->docHyphenator->AutoCheck) // ScMW->view->SelItem.at(i)->Doc->docHyphenator->slotHyphenate(ScMW->view->SelItem.at(i)); if (m_Doc->docHyphenator->AutoCheck) m_Doc->docHyphenator->slotHyphenate(currItem); currItem->invalidateLayout(); } // if (done) // { m_Doc->regionsChanged()->update(QRectF()); m_Doc->changed(); // } }