ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #07575
[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/spreadsheet-part-selector into lp:ubuntu-docviewer-app
Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/spreadsheet-part-selector into lp:ubuntu-docviewer-app with lp:~verzegnassi-stefano/ubuntu-docviewer-app/lok-qml-currentpart-moved as a prerequisite.
Commit message:
LibreOffice viewer:
* Added a sheet selector
* Show an empty state when the current sheet has no content
* Fixed "currentPart" usage, partially broken after a recent commit in trunk
Requested reviews:
Jenkins Bot (ubuntu-core-apps-jenkins-bot): continuous-integration
Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)
For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/spreadsheet-part-selector/+merge/282845
LibreOffice viewer:
* Added a sheet selector
* Show an empty state when the current sheet has no content
* Fixed "currentPart" usage, partially broken after a recent commit in trunk
--
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/spreadsheet-part-selector into lp:ubuntu-docviewer-app.
=== modified file 'po/com.ubuntu.docviewer.pot'
--- po/com.ubuntu.docviewer.pot 2016-01-18 00:02:05 +0000
+++ po/com.ubuntu.docviewer.pot 2016-01-25 13:15:25 +0000
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-01-18 00:54+0100\n"
+"POT-Creation-Date: 2016-01-25 14:11+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -215,7 +215,7 @@
msgstr ""
#: ../src/app/qml/documentPage/DocumentPage.qml:23
-#: /tmp/build-lok-new-zoom-modes+spreadsheet-zoom-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid_8e2ec5-Default/po/com.ubuntu.docviewer.desktop.in.in.h:3
+#: /tmp/spreadsheet-part-selector-build/po/com.ubuntu.docviewer.desktop.in.in.h:3
msgid "Documents"
msgstr ""
@@ -366,20 +366,24 @@
msgid "GO!"
msgstr ""
-#: ../src/app/qml/loView/LOViewPage.qml:129
+#: ../src/app/qml/loView/LOViewPage.qml:137
msgid "LibreOffice binaries not found."
msgstr ""
-#: ../src/app/qml/loView/LOViewPage.qml:132
+#: ../src/app/qml/loView/LOViewPage.qml:140
msgid "Error while loading LibreOffice."
msgstr ""
-#: ../src/app/qml/loView/LOViewPage.qml:135
+#: ../src/app/qml/loView/LOViewPage.qml:143
msgid ""
"Document not loaded.\n"
"The requested document may be corrupt or protected by a password."
msgstr ""
+#: ../src/app/qml/loView/LOViewPage.qml:164
+msgid "This sheet has no content."
+msgstr ""
+
#. TRANSLATORS: 'LibreOfficeKit' is the name of the library used by
#. Document Viewer for rendering LibreOffice/MS-Office documents.
#. Ref. https://docs.libreoffice.org/libreofficekit.html
@@ -387,6 +391,13 @@
msgid "Powered by LibreOfficeKit"
msgstr ""
+#. TRANSLATORS: Please don't add any space between "Sheet" and "%1".
+#. This is the default name for a sheet in LibreOffice.
+#: ../src/app/qml/loView/SpreadsheetSelector.qml:64
+#, qt-format
+msgid "Sheet%1"
+msgstr ""
+
#: ../src/app/qml/loView/ZoomSelector.qml:122
msgid "Fit width"
msgstr ""
@@ -452,10 +463,10 @@
msgid "copy %1"
msgstr ""
-#: /tmp/build-lok-new-zoom-modes+spreadsheet-zoom-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid_8e2ec5-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
+#: /tmp/spreadsheet-part-selector-build/po/com.ubuntu.docviewer.desktop.in.in.h:1
msgid "Document Viewer"
msgstr ""
-#: /tmp/build-lok-new-zoom-modes+spreadsheet-zoom-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_15_04_vivid_8e2ec5-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
+#: /tmp/spreadsheet-part-selector-build/po/com.ubuntu.docviewer.desktop.in.in.h:2
msgid "documents;viewer;pdf;reader;"
msgstr ""
=== modified file 'src/app/qml/loView/LOViewPage.qml'
--- src/app/qml/loView/LOViewPage.qml 2015-12-27 07:30:41 +0000
+++ src/app/qml/loView/LOViewPage.qml 2016-01-25 13:15:25 +0000
@@ -30,6 +30,7 @@
property bool isPresentation: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.PresentationDocument)
property bool isTextDocument: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.TextDocument)
+ property bool isSpreadsheet: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.SpreadsheetDocument)
title: DocumentViewer.getFileBaseNameFromPath(file.path);
flickable: isTextDocument ? loPage.contentItem.loView : null
@@ -76,9 +77,16 @@
left: leftSidebar.right
right: parent.right
top: parent.top
- bottom: parent.bottom
+ bottom: sSelector.top
}
}
+
+ SpreadsheetSelector {
+ id: sSelector
+ anchors.bottom: parent.bottom
+ visible: loPage.isSpreadsheet
+ view: loView
+ }
}
}
]
@@ -148,29 +156,47 @@
Scrollbar { flickableItem: loView; parent: loView.parent }
Scrollbar { flickableItem: loView; parent: loView.parent; align: Qt.AlignBottom }
+
+ Label {
+ anchors.centerIn: parent
+ parent: loPage
+ textSize: Label.Large
+ text: i18n.tr("This sheet has no content.")
+ visible: loPage.isSpreadsheet && loView.contentWidth <= 0 && loView.contentHeight <= 0
+ }
}
}
- PartsView {
+ Item {
id: bottomBar
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
- height: visible ? units.gu(12) : 0
- visible: loPage.isPresentation
-
- model: loView.partsModel
- orientation: ListView.Horizontal
-
- HorizontalDivider {
- anchors {
- left: parent.left
- right: parent.right
- top: parent.top
+ height: childrenRect.height
+
+ PartsView {
+ anchors { left: parent.left; right: parent.right }
+ height: visible ? units.gu(12) : 0
+ visible: loPage.isPresentation
+
+ model: loView.partsModel
+ orientation: ListView.Horizontal
+
+ HorizontalDivider {
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ }
}
}
+
+ SpreadsheetSelector {
+ visible: loPage.isSpreadsheet
+ view: loView
+ }
}
}
}
=== added file 'src/app/qml/loView/SpreadsheetSelector.qml'
--- src/app/qml/loView/SpreadsheetSelector.qml 1970-01-01 00:00:00 +0000
+++ src/app/qml/loView/SpreadsheetSelector.qml 2016-01-25 13:15:25 +0000
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2016 Stefano Verzegnassi
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.4
+import Ubuntu.Components 1.3
+import DocumentViewer.LibreOffice 1.0
+
+import "../common"
+
+Item {
+ id: spreadsheetSelector
+ anchors { left: parent.left; right: parent.right }
+ height: visible ? units.gu(6) : 0
+
+ property Viewer view
+
+ Rectangle {
+ anchors.fill: parent
+ color: theme.palette.normal.background
+ }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ boundsBehavior: Flickable.StopAtBounds
+ orientation: ListView.Horizontal
+
+ model: spreadsheetSelector.view.partsModel
+
+ delegate: AbstractButton {
+ id: del
+ property bool selected: spreadsheetSelector.view.currentPart == model.index
+
+ width: nameLabel.paintedWidth + units.gu(4)
+ height: parent.height
+
+ onClicked: spreadsheetSelector.view.currentPart = model.index
+
+ Rectangle {
+ anchors.fill: parent
+ visible: del.selected
+ color: theme.palette.selected.background
+ }
+
+ Label {
+ id: nameLabel
+ anchors.centerIn: parent
+
+ // TRANSLATORS: Please don't add any space between "Sheet" and "%1".
+ // This is the default name for a sheet in LibreOffice.
+ text: model.name || i18n.tr("Sheet%1").arg(model.index + 1)
+ color: del.selected ? UbuntuColors.orange : theme.palette.normal.baseText
+ }
+
+ Rectangle {
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+ height: units.dp(2)
+ color: UbuntuColors.orange
+ visible: del.selected
+ }
+ }
+ }
+
+ HorizontalDivider {
+ anchors { left: parent.left; right: parent.right }
+ }
+}
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2015-12-14 00:40:55 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2016-01-25 13:15:25 +0000
@@ -127,25 +127,16 @@
return m_docType;
}
-int LODocument::documentPart() const
-{
- return m_lokDocument->getPart();
-}
-
-void LODocument::setDocumentPart(int p)
-{
- if (documentPart() != p)
- m_lokDocument->setPart(p);
-}
-
// Return the size of the document, in TWIPs
-QSize LODocument::documentSize() const
+QSize LODocument::documentSize(int part) const
{
if (!m_lokDocument)
return QSize(0, 0);
long pWidth(0);
long pHeight(0);
+
+ m_lokDocument->setPart(part);
m_lokDocument->getDocumentSize(&pWidth, &pHeight);
return QSize(pWidth, pHeight);
@@ -184,15 +175,16 @@
if (!m_lokDocument)
return QImage();
- m_lokDocument->setPart(part);
-
#ifdef DEBUG_TILE_BENCHMARK
QElapsedTimer renderTimer;
renderTimer.start();
#endif
- qreal tWidth = this->documentSize().width();
- qreal tHeight = this->documentSize().height();
+ long tWidth(0);
+ long tHeight(0);
+
+ m_lokDocument->setPart(part);
+ m_lokDocument->getDocumentSize(&tWidth, &tHeight);
QSize resultSize;
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.h'
--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2015-12-14 00:40:55 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2016-01-25 13:15:25 +0000
@@ -35,7 +35,6 @@
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
// Declare partsCount as constant at the moment, since LOK-plugin is just a viewer for now.
Q_PROPERTY(int partsCount READ partsCount CONSTANT)
- Q_PROPERTY(int documentPart READ documentPart WRITE setDocumentPart NOTIFY documentPartChanged)
Q_PROPERTY(DocumentType documentType READ documentType NOTIFY documentTypeChanged)
Q_PROPERTY(LibreOfficeError::Error error READ error NOTIFY errorChanged)
Q_ENUMS(DocumentType)
@@ -57,10 +56,7 @@
DocumentType documentType() const;
- int documentPart() const;
- void setDocumentPart(int p);
-
- QSize documentSize() const;
+ QSize documentSize(int part) const;
QImage paintTile(int part, const QSize& canvasSize, const QRect& tileSize, const qreal& zoom = 1.0);
QImage paintThumbnail(int part, qreal size);
@@ -74,7 +70,6 @@
Q_SIGNALS:
void pathChanged();
void documentTypeChanged();
- void documentPartChanged();
void errorChanged();
private:
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2016-01-17 22:57:05 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2016-01-25 13:15:25 +0000
@@ -56,6 +56,7 @@
connect(this, SIGNAL(zoomFactorChanged()), this, SLOT(updateViewSize()));
connect(this, SIGNAL(parentFlickableChanged()), this, SLOT(updateVisibleRect()));
connect(this, SIGNAL(cacheBufferChanged()), this, SLOT(updateVisibleRect()));
+ connect(this, SIGNAL(currentPartChanged()), this, SLOT(invalidateAllTiles()));
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateVisibleRect()));
connect(RenderEngine::instance(), &RenderEngine::taskRenderFinished,
@@ -122,9 +123,6 @@
engine->addImageProvider("lok", m_imageProvider);
// --------------------------------------------------
- setCurrentPart(0);
- connect(this, SIGNAL(currentPartChanged()), this, SLOT(invalidateAllTiles()));
-
Q_EMIT documentChanged();
// Set the proper zoom mode, according to the type of the loaded document.
@@ -236,7 +234,7 @@
setZoomMode(LOView::FitToWidth);
zoomValueToFitWidth = getZoomToFitWidth(m_parentFlickable->width(),
- m_document->documentSize().width());
+ m_document->documentSize(m_currentPart).width());
if (m_zoomFactor != zoomValueToFitWidth) {
setZoomFactor(zoomValueToFitWidth);
@@ -257,7 +255,7 @@
setZoomMode(LOView::FitToHeight);
zoomValueToFitHeight = getZoomToFitHeight(m_parentFlickable->height(),
- m_document->documentSize().height());
+ m_document->documentSize(m_currentPart).height());
if (m_zoomFactor != zoomValueToFitHeight) {
setZoomFactor(zoomValueToFitHeight);
@@ -278,10 +276,10 @@
setZoomMode(LOView::Automatic);
zoomValueToFitWidth = getZoomToFitWidth(m_parentFlickable->width(),
- m_document->documentSize().width());
+ m_document->documentSize(m_currentPart).width());
zoomValueToFitHeight = getZoomToFitHeight(m_parentFlickable->height(),
- m_document->documentSize().height());
+ m_document->documentSize(m_currentPart).height());
if (m_zoomFactor != qMin(zoomValueToFitHeight, zoomValueToFitWidth)) {
setZoomFactor(qMin(zoomValueToFitHeight, zoomValueToFitWidth));
@@ -298,7 +296,7 @@
if (!m_document)
return;
- QSize docSize = m_document->documentSize();
+ QSize docSize = m_document->documentSize(m_currentPart);
this->setWidth(Twips::convertTwipsToPixels(docSize.width(), m_zoomFactor));
this->setHeight(Twips::convertTwipsToPixels(docSize.height(), m_zoomFactor));