void Autocorrect::finishedWord(QTextDocument *document, int cursorPosition) { if (!m_enabled->isChecked()) return; m_cursor = QTextCursor(document); selectWord(m_cursor, cursorPosition); m_word = m_cursor.selectedText(); if (m_word.isEmpty()) return; emit startMacro(i18n("Autocorrection")); bool done = autoFormatURLs(); if (!done) done = singleSpaces(); if (!done) done = autoBoldUnderline(); if (!done) done = autoFractions(); if (!done) advancedAutocorrect(); if (!done) uppercaseFirstCharOfSentence(); if (!done) fixTwoUppercaseChars(); if (!done) autoNumbering(); if (!done) superscriptAppendix(); if (!done) capitalizeWeekDays(); if (!done) autoFormatBulletList(); if (!done) replaceTypographicQuotes(); if (m_cursor.selectedText() != m_word) m_cursor.insertText(m_word); emit stopMacro(); }
void KoInlineNote::saveOdf(KoShapeSavingContext & context) { KoXmlWriter *writer = &context.xmlWriter(); QTextDocument *document = new QTextDocument(); KoTextDocument textDocument(document); Q_ASSERT(!d->styleManager.isNull()); textDocument.setStyleManager(d->styleManager.data()); QTextCursor cursor(document); cursor.insertFragment(d->text); if (d->type == Footnote || d->type == Endnote) { writer->startElement("text:note", false); if (d->type == Footnote) writer->addAttribute("text:note-class", "footnote"); else writer->addAttribute("text:note-class", "endnote"); writer->addAttribute("text:id", d->id); writer->startElement("text:note-citation", false); if (!autoNumbering()) writer->addAttribute("text:label", d->label); writer->addTextNode(d->label); writer->endElement(); writer->startElement("text:note-body", false); KoTextWriter textWriter(context); textWriter.write(document, 0); writer->endElement(); writer->endElement(); } else if (d->type == Annotation) { writer->startElement("office:annotation"); if (!d->author.isEmpty()) { writer->startElement("dc:creator"); writer->addTextNode(d->author); writer->endElement(); } if (d->date.isValid()) { writer->startElement("dc:date"); writer->addTextSpan(d->date.toString(Qt::ISODate)); writer->endElement(); } KoTextWriter textWriter(context); textWriter.write(document, 0); writer->endElement(); } delete document; }
void KoInlineNote::saveOdf(KoShapeSavingContext & context) { KoXmlWriter *writer = &context.xmlWriter(); writer->startElement("text:note", false); if (d->type == Footnote) writer->addAttribute("text:note-class", "footnote"); else writer->addAttribute("text:note-class", "endnote"); writer->addAttribute("text:id", d->id); writer->startElement("text:note-citation", false); if (!autoNumbering()) writer->addAttribute("text:label", d->label); writer->addTextNode(d->label); writer->endElement(); writer->startElement("text:note-body", false); writer->startElement("text:p"); writer->addTextNode(d->text); writer->endElement(); writer->endElement(); writer->endElement(); }