Add suport of print area and page setup #31
Open
drow-it wants to merge 9 commits into
Open
Conversation
To set print area of sheet use bool setPrintArea(const CellRange &range, const QString &sheetName=QString()); To set page scaling to percent use bool setPageSetup(double percent, QPageSize::PageSizeId size, QPageLayout::Orientation orientation); To set page scaling to number of pages use bool setPageSetup(int fitToWidth, int fitToHeight, QPageSize::PageSizeId size, QPageLayout::Orientation orientation);
- support of manual row breaks and column breaks - better multiline text format
Page breaks and multiline text
- 0 is valid value for fitToWidth and fitToHeight, which means "Auto"
Fix PageSetup
VSRonin
requested changes
Mar 19, 2019
| sheet); | ||
| } | ||
|
|
||
| bool Document::setPageSetup(double percent, |
| writer.writeStartElement(QStringLiteral("si")); | ||
| if (string.isRichString()) { | ||
| //Rich text string | ||
| Format lastNotEmptyFragmentFormat; |
Owner
There was a problem hiding this comment.
This change is unrelated to the pull request. Not a big deal but next time please try to keep them separated
| /*! | ||
| * Add manual page break above the specified row \a row (1-indexed) | ||
| */ | ||
| void Worksheet::addRowBreak(int row) |
Owner
There was a problem hiding this comment.
Rename to clearer method name. I'd suggest addPageBreakRow and addPageBreakColumn.
| { | ||
| writer.writeStartElement(QStringLiteral("pageSetup")); | ||
| writer.writeAttribute(QStringLiteral("paperSize"), QString::number(d->pageSetup.xlsxPageSize())); | ||
| if (d->pageSetup.isScale()) writer.writeAttribute(QStringLiteral("scale"), QString::number(d->pageSetup.scale)); |
Owner
There was a problem hiding this comment.
Style: put statements in the if and else blocks to a new line
| writer.writeStartElement(QStringLiteral("rowBreaks")); | ||
| writer.writeAttribute(QStringLiteral("count"), QString::number(d->rowBreaks.count())); | ||
| writer.writeAttribute(QStringLiteral("manualBreakCount"), QString::number(d->rowBreaks.count())); | ||
| QList<int> sortedBreaks = d->rowBreaks.toList(); |
|
|
||
| while (!reader.atEnd() && !(reader.name() == QLatin1String("hyperlinks") | ||
| && reader.tokenType() == QXmlStreamReader::EndElement)) { | ||
| && reader.tokenType() == QXmlStreamReader::EndElement)) { |
| Q_ASSERT(reader.name() == QLatin1String("sheetPr")); | ||
|
|
||
| while (!reader.atEnd() && !(reader.name() == QLatin1String("sheetPr") | ||
| && reader.tokenType() == QXmlStreamReader::EndElement)) { |
|
|
||
| WorksheetPrivate::PageSetup::PageSetup(): | ||
| scale(0), | ||
| fitToWidth(-1), |
| QPageSize::PageSizeId _pageSize, | ||
| QPageLayout::Orientation _orientation) : | ||
| scale(_scale), | ||
| fitToWidth(-1), |
|
|
||
| QPageLayout::Orientation WorksheetPrivate::PageSetup::fromOrientationString(const QString& str) | ||
| { | ||
| if (!str.compare(QStringLiteral("landscape"), Qt::CaseInsensitive)) return QPageLayout::Landscape; |
Owner
There was a problem hiding this comment.
statements after if to new line. remove the else as required by Qt style guide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To set print area of sheet use
bool setPrintArea(const CellRange &range, const QString &sheetName=QString());
To set page scaling to percent use
bool setPageSetup(double percent,
QPageSize::PageSizeId size,
QPageLayout::Orientation orientation);
To set page scaling to number of pages use
bool setPageSetup(int fitToWidth,
int fitToHeight,
QPageSize::PageSizeId size,
QPageLayout::Orientation orientation);
Autoformatting in Qt Creator insert some extra spaces in old code, that's why so many lines has changes