Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suport of print area and page setup #31

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

drow-it
Copy link

@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"
sheet);
}

bool Document::setPageSetup(double percent,
Copy link
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

@@ -228,13 +228,23 @@ void SharedStrings::saveToXmlFile(QIODevice *device) const
writer.writeStartElement(QStringLiteral("si"));
if (string.isRichString()) {
//Rich text string
Format lastNotEmptyFragmentFormat;
Copy link
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
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
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
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?

@@ -2181,7 +2267,7 @@ void WorksheetPrivate::loadXmlHyperlinks(QXmlStreamReader &reader)
Q_ASSERT(reader.name() == QLatin1String("hyperlinks"));

while (!reader.atEnd() && !(reader.name() == QLatin1String("hyperlinks")
&& reader.tokenType() == QXmlStreamReader::EndElement)) {
&& reader.tokenType() == QXmlStreamReader::EndElement)) {
Copy link
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
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

@@ -2341,4 +2457,101 @@ SharedStrings *WorksheetPrivate::sharedStrings() const
return workbook->sharedStrings();
}

WorksheetPrivate::PageSetup::PageSetup():
scale(0),
fitToWidth(-1),
Copy link
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
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
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