Commit 5662eec8 authored by C. Boemann's avatar C. Boemann
Browse files

Make printing not show textselections or formatting characters

BUG:288341
parent 9c4c3bef
......@@ -27,6 +27,7 @@ KoShapePaintingContext::KoShapePaintingContext()
, showTextShapeOutlines(false)
, showTableBorders(true)
, showSpellChecking(false)
, showSelections(true)
{
}
......@@ -37,6 +38,7 @@ KoShapePaintingContext::KoShapePaintingContext(KoCanvasBase *canvas, bool forPri
showFormattingCharacters = rm->boolResource(KoCanvasResourceManager::ShowFormattingCharacters);
if (forPrint) {
showTextShapeOutlines = false;
showFormattingCharacters = false;
} else {
showTextShapeOutlines = rm->boolResource(KoCanvasResourceManager::ShowTextShapeOutlines);
}
......@@ -46,6 +48,7 @@ KoShapePaintingContext::KoShapePaintingContext(KoCanvasBase *canvas, bool forPri
showTableBorders = true;
}
showSpellChecking = !forPrint;
showSelections = !forPrint;
}
KoShapePaintingContext::~KoShapePaintingContext()
......
......@@ -43,6 +43,7 @@ public:
bool showTextShapeOutlines;
bool showTableBorders;
bool showSpellChecking;
bool showSelections;
};
#endif /* KOSHAPEPAINTINGCONTEXT_H */
......@@ -70,6 +70,7 @@ public:
, imageCollection(0)
, showFormattingCharacters(false)
, showSpellChecking(false)
, showSelections(true)
, background(Qt::white)
{
}
......@@ -83,6 +84,7 @@ public:
bool showFormattingCharacters;
bool showTableBorders;
bool showSpellChecking;
bool showSelections;
QColor background;
};
......
......@@ -217,32 +217,33 @@ void KoTextLayoutArea::paint(QPainter *painter, const KoTextDocumentLayout::Pain
painter->restore();
QVector<QTextLayout::FormatRange> selections;
foreach(const QAbstractTextDocumentLayout::Selection & selection, context.textContext.selections) {
QTextCursor cursor = selection.cursor;
int begin = cursor.position();
int end = cursor.anchor();
if (begin > end)
qSwap(begin, end);
if (end < block.position() || begin > block.position() + block.length())
continue; // selection does not intersect this block.
if (selection.cursor.hasComplexSelection()) {
continue; // selections of several table cells are covered by the within drawBorders above.
}
if (m_documentLayout->changeTracker()
&& !m_documentLayout->changeTracker()->displayChanges()
&& m_documentLayout->changeTracker()->containsInlineChanges(selection.format)
&& m_documentLayout->changeTracker()->elementById(selection.format.property(KoCharacterStyle::ChangeTrackerId).toInt())->isEnabled()
&& m_documentLayout->changeTracker()->elementById(selection.format.property(KoCharacterStyle::ChangeTrackerId).toInt())->getChangeType() == KoGenChange::DeleteChange) {
continue; // Deletions should not be shown.
if (context.showSelections) {
foreach(const QAbstractTextDocumentLayout::Selection & selection, context.textContext.selections) {
QTextCursor cursor = selection.cursor;
int begin = cursor.position();
int end = cursor.anchor();
if (begin > end)
qSwap(begin, end);
if (end < block.position() || begin > block.position() + block.length())
continue; // selection does not intersect this block.
if (selection.cursor.hasComplexSelection()) {
continue; // selections of several table cells are covered by the within drawBorders above.
}
if (m_documentLayout->changeTracker()
&& !m_documentLayout->changeTracker()->displayChanges()
&& m_documentLayout->changeTracker()->containsInlineChanges(selection.format)
&& m_documentLayout->changeTracker()->elementById(selection.format.property(KoCharacterStyle::ChangeTrackerId).toInt())->isEnabled()
&& m_documentLayout->changeTracker()->elementById(selection.format.property(KoCharacterStyle::ChangeTrackerId).toInt())->getChangeType() == KoGenChange::DeleteChange) {
continue; // Deletions should not be shown.
}
QTextLayout::FormatRange fr;
fr.start = begin - block.position();
fr.length = end - begin;
fr.format = selection.format;
selections.append(fr);
}
QTextLayout::FormatRange fr;
fr.start = begin - block.position();
fr.length = end - begin;
fr.format = selection.format;
selections.append(fr);
}
// this is a workaround to fix text getting cut of when format ranges are used. There
// is a bug in Qt that can hit when text lines overlap each other. In case a format range
// is used for formating it can clip the lines above/below as Qt creates a clip rect for
......
......@@ -152,6 +152,7 @@ void TextShape::paintComponent(QPainter &painter, const KoViewConverter &convert
pc.showFormattingCharacters = paintContext.showFormattingCharacters;
pc.showTableBorders = paintContext.showTableBorders;
pc.showSpellChecking = paintContext.showSpellChecking;
pc.showSelections = paintContext.showSelections;
// When clipping the painter we need to make sure not to cutoff cosmetic pens which
// may used to draw e.g. table-borders for user convenience when on screen (but not
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment