本文整理汇总了C++中KoParagraphStyle::name方法的典型用法代码示例。如果您正苦于以下问题:C++ KoParagraphStyle::name方法的具体用法?C++ KoParagraphStyle::name怎么用?C++ KoParagraphStyle::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoParagraphStyle
的用法示例。
在下文中一共展示了KoParagraphStyle::name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveParagraphStyle
QString KoTextWriter::saveParagraphStyle(const QTextBlockFormat &blockFormat, const QTextCharFormat &charFormat, KoStyleManager * styleManager, KoShapeSavingContext &context)
{
KoParagraphStyle *defaultParagraphStyle = styleManager->defaultParagraphStyle();
KoParagraphStyle *originalParagraphStyle = styleManager->paragraphStyle(blockFormat.intProperty(KoParagraphStyle::StyleId));
if (!originalParagraphStyle)
originalParagraphStyle = defaultParagraphStyle;
QString generatedName;
QString displayName = originalParagraphStyle->name();
QString internalName = QString(QUrl::toPercentEncoding(displayName, "", " ")).replace('%', '_');
// we'll convert the blockFormat to a KoParagraphStyle to check for local changes.
KoParagraphStyle paragStyle(blockFormat, charFormat);
if (paragStyle == (*originalParagraphStyle)) { // This is the real, unmodified character style.
// TODO zachmann: this could use the name of the saved style without saving it again
// therefore we would need to store that information in the saving context
if (originalParagraphStyle != defaultParagraphStyle) {
KoGenStyle style(KoGenStyle::ParagraphStyle, "paragraph");
originalParagraphStyle->saveOdf(style, context);
generatedName = context.mainStyles().insert(style, internalName, KoGenStyles::DontAddNumberToName);
}
} else { // There are manual changes... We'll have to store them then
KoGenStyle style(KoGenStyle::ParagraphAutoStyle, "paragraph", internalName);
if (context.isSet(KoShapeSavingContext::AutoStyleInStyleXml))
style.setAutoStyleInStylesDotXml(true);
if (originalParagraphStyle) {
paragStyle.removeDuplicates(*originalParagraphStyle);
paragStyle.setParentStyle(originalParagraphStyle);
}
paragStyle.saveOdf(style, context);
generatedName = context.mainStyles().insert(style, "P");
}
return generatedName;
}
示例2: thumbnail
QImage KoStyleThumbnailer::thumbnail(KoParagraphStyle *style, QSize size, bool recreateThumbnail, KoStyleThumbnailerFlags flags)
{
if ((flags & UseStyleNameText) && (!style || style->name().isNull())) {
return QImage();
} else if ((! (flags & UseStyleNameText)) && d->thumbnailText.isEmpty()) {
return QImage();
}
if (!size.isValid() || size.isNull()) {
size = d->defaultSize;
}
QString imageKey = "p_" + QString::number(reinterpret_cast<unsigned long>(style)) + "_" + QString::number(size.width()) + "_" + QString::number(size.height());
if (!recreateThumbnail && d->thumbnailCache.object(imageKey)) {
return QImage(*(d->thumbnailCache.object(imageKey)));
}
QImage *im = new QImage(size.width(), size.height(), QImage::Format_ARGB32_Premultiplied);
im->fill(QColor(Qt::transparent).rgba());
KoParagraphStyle *clone = style->clone();
//TODO: make the following real options
//we ignore these properties when the thumbnail would not be sufficient to preview properly the whole paragraph with margins.
clone->setMargin(QTextLength(QTextLength::FixedLength, 0));
clone->setPadding(0);
//
QTextCursor cursor(d->thumbnailHelperDocument);
cursor.select(QTextCursor::Document);
cursor.setBlockFormat(QTextBlockFormat());
cursor.setBlockCharFormat(QTextCharFormat());
cursor.setCharFormat(QTextCharFormat());
QTextBlock block = cursor.block();
clone->applyStyle(block, true);
QTextCharFormat format;
// Default to black as text color, to match what KoTextLayoutArea::paint(...)
// does, setting solid black if no brush is set. Otherwise the UI text color
// would be used, which might be too bright with dark UI color schemes
format.setForeground(QColor(Qt::black));
clone->KoCharacterStyle::applyStyle(format);
if (flags & UseStyleNameText) {
cursor.insertText(clone->name(), format);
} else {
cursor.insertText(d->thumbnailText, format);
}
layoutThumbnail(size, im, flags);
d->thumbnailCache.insert(imageKey, im);
delete clone;
return QImage(*im);
}