Skip to content

Add suport of print area and page setup #31

Open
drow-it wants to merge 9 commits into
VSRonin:masterfrom
drow-it:master
Open

Add suport of print area and page setup #31
drow-it wants to merge 9 commits into
VSRonin:masterfrom
drow-it:master

Conversation

@drow-it
Copy link
Copy Markdown

@drow-it drow-it commented Nov 9, 2018

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

drow-it and others added 7 commits November 9, 2018 18:08
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"
Comment thread src/xlsx/xlsxdocument.cpp
sheet);
}

bool Document::setPageSetup(double percent,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document the public methods x2

writer.writeStartElement(QStringLiteral("si"));
if (string.isRichString()) {
//Rich text string
Format lastNotEmptyFragmentFormat;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: why the indent?


while (!reader.atEnd() && !(reader.name() == QLatin1String("hyperlinks")
&& reader.tokenType() == QXmlStreamReader::EndElement)) {
&& reader.tokenType() == QXmlStreamReader::EndElement)) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert spacing change

Q_ASSERT(reader.name() == QLatin1String("sheetPr"));

while (!reader.atEnd() && !(reader.name() == QLatin1String("sheetPr")
&& reader.tokenType() == QXmlStreamReader::EndElement)) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much white space


WorksheetPrivate::PageSetup::PageSetup():
scale(0),
fitToWidth(-1),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra white space

QPageSize::PageSizeId _pageSize,
QPageLayout::Orientation _orientation) :
scale(_scale),
fitToWidth(-1),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra white space


QPageLayout::Orientation WorksheetPrivate::PageSetup::fromOrientationString(const QString& str)
{
if (!str.compare(QStringLiteral("landscape"), Qt::CaseInsensitive)) return QPageLayout::Landscape;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statements after if to new line. remove the else as required by Qt style guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants