本文整理汇总了C++中KoParagraphStyle::setStyleId方法的典型用法代码示例。如果您正苦于以下问题:C++ KoParagraphStyle::setStyleId方法的具体用法?C++ KoParagraphStyle::setStyleId怎么用?C++ KoParagraphStyle::setStyleId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoParagraphStyle
的用法示例。
在下文中一共展示了KoParagraphStyle::setStyleId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testApplyParagraphStyle
void TestStyles::testApplyParagraphStyle()
{
KoParagraphStyle style;
style.setStyleId(1001);
QTextBlockFormat format;
QCOMPARE(format.properties().count(), 0);
style.applyStyle(format);
QCOMPARE(format.properties().count(), 2); // the styleId and nextStyleId
QCOMPARE(format.property(KoParagraphStyle::StyleId).toInt(), 1001);
QCOMPARE(format.property(KoParagraphStyle::NextStyle).toInt(), 1001);
style.setName("name");
style.setAlignment(Qt::AlignRight);
style.applyStyle(format);
QCOMPARE(format.properties().count(), 3);
QCOMPARE(format.alignment(), Qt::AlignRight);
}
示例2: initTest
void TestTableLayout::initTest(int rows, int columns,
KoTableStyle *tableStyle,
const QList<KoTableColumnStyle *> &columnStyles,
const QList<KoTableRowStyle *> &rowStyles,
const QMap<QPair<int, int>, KoTableCellStyle *> &cellStyles,
const QMap<QPair<int, int>, QString> &cellTexts)
{
// Mock shape of size 200x1000 pt.
m_shape = new MockTextShape();
Q_ASSERT(m_shape);
m_shape->setSize(QSizeF(200, 1000));
// Document layout.
m_layout = m_shape->layout;
Q_ASSERT(m_layout);
// Document.
m_doc = m_layout->document();
Q_ASSERT(m_doc);
m_doc->setDefaultFont(QFont("Sans Serif", 12, QFont::Normal, false));
// Layout state (layout helper).
m_textLayout = new Layout(m_layout);
Q_ASSERT(m_textLayout);
m_layout->setLayout(m_textLayout);
// Style manager.
m_styleManager = new KoStyleManager();
Q_ASSERT(m_styleManager);
KoTextDocument(m_doc).setStyleManager(m_styleManager);
// Table style.
m_defaultTableStyle = new KoTableStyle();
Q_ASSERT(m_defaultTableStyle);
m_defaultTableStyle->setMargin(0.0);
m_defaultTableStyle->setWidth(QTextLength(QTextLength::FixedLength, 200));
QTextTableFormat tableFormat;
if (tableStyle) {
tableStyle->applyStyle(tableFormat);
} else {
m_defaultTableStyle->applyStyle(tableFormat);
}
// Table.
QTextCursor cursor(m_doc);
m_table = cursor.insertTable(rows, columns, tableFormat);
Q_ASSERT(m_table);
// Column and row style manager.
m_tableColumnAndRowStyleManager = KoTableColumnAndRowStyleManager::getManager(m_table);
// Column styles.
m_defaultColumnStyle.setRelativeColumnWidth(50.0);
for (int col = 0; col < columns; ++col) {
if (columnStyles.value(col)) {
m_tableColumnAndRowStyleManager.setColumnStyle(col, *(columnStyles.at(col)));
} else {
m_tableColumnAndRowStyleManager.setColumnStyle(col, m_defaultColumnStyle);
}
}
// Row styles.
for (int row = 0; row < rows; ++row) {
if (rowStyles.value(row)) {
m_tableColumnAndRowStyleManager.setRowStyle(row, *(rowStyles.at(row)));
} else {
m_tableColumnAndRowStyleManager.setRowStyle(row, m_defaultRowStyle);
}
}
// Cell styles and texts.
m_defaultCellStyle = new KoTableCellStyle();
Q_ASSERT(m_defaultCellStyle);
for (int row = 0; row < m_table->rows(); ++row) {
for (int col = 0; col < m_table->columns(); ++col) {
// Style.
QTextTableCell cell = m_table->cellAt(row, col);
QTextTableCellFormat cellFormat = cell.format().toTableCellFormat();
if (cellStyles.contains(qMakePair(row, col))) {
cellStyles.value(qMakePair(row, col))->applyStyle(cellFormat);
cell.setFormat(cellFormat.toCharFormat());
} else {
m_defaultCellStyle->applyStyle(cellFormat);
}
cell.setFormat(cellFormat.toCharFormat());
// Text.
if (cellTexts.contains(qMakePair(row, col))) {
cell.firstCursorPosition().insertText(cellTexts.value(qMakePair(row, col)));
}
}
}
KoParagraphStyle style;
style.setStyleId(101); // needed to do manually since we don't use the stylemanager
QTextBlock b2 = m_doc->begin();
while (b2.isValid()) {
style.applyStyle(b2);
b2 = b2.next();
}
}
示例3: setupTest
void TestTableLayout::setupTest(const QString &mergedText, const QString &topRightText, const QString &midRightText, const QString &bottomLeftText, const QString &bottomMidText, const QString &bottomRightText, KoTableStyle* tableStyle)
{
QTextCursor cursor = setupTest();
KoParagraphStyle style;
style.setStyleId(101); // needed to do manually since we don't use the stylemanager
style.applyStyle(m_block);
QTextTableFormat tableFormat;
if (tableStyle)
tableStyle->applyStyle(tableFormat);
m_table = cursor.insertTable(3,3,tableFormat);
m_table->mergeCells(0,0,2,2);
if (mergedText.length() > 0) {
m_table->cellAt(0,0).firstCursorPosition().insertText(mergedText);
QTextBlock b2 = m_table->cellAt(0,0).firstCursorPosition().block();
while (b2.isValid()) {
style.applyStyle(b2);
b2 = b2.next();
}
}
if (topRightText.length() > 0) {
m_table->cellAt(0,2).firstCursorPosition().insertText(topRightText);
QTextBlock b2 = m_table->cellAt(0,2).firstCursorPosition().block();
while (b2.isValid()) {
style.applyStyle(b2);
b2 = b2.next();
}
}
if (midRightText.length() > 0) {
m_table->cellAt(1,2).firstCursorPosition().insertText(midRightText);
QTextBlock b2 = m_table->cellAt(1,2).firstCursorPosition().block();
while (b2.isValid()) {
style.applyStyle(b2);
b2 = b2.next();
}
}
if (bottomLeftText.length() > 0) {
m_table->cellAt(2,0).firstCursorPosition().insertText(bottomLeftText);
QTextBlock b2 = m_table->cellAt(2,0).firstCursorPosition().block();
while (b2.isValid()) {
style.applyStyle(b2);
b2 = b2.next();
}
}
if (bottomMidText.length() > 0) {
m_table->cellAt(2,1).firstCursorPosition().insertText(bottomMidText);
QTextBlock b2 = m_table->cellAt(2,1).firstCursorPosition().block();
while (b2.isValid()) {
style.applyStyle(b2);
b2 = b2.next();
}
}
if (bottomRightText.length() > 0) {
m_table->cellAt(2,2).firstCursorPosition().insertText(bottomRightText);
QTextBlock b2 = m_table->cellAt(2,2).firstCursorPosition().block();
while (b2.isValid()) {
style.applyStyle(b2);
b2 = b2.next();
}
}
}