Merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/spreadsheet-part-selector into lp:ubuntu-docviewer-app

Proposed by Stefano Verzegnassi
Status: Merged
Approved by: Stefano Verzegnassi
Approved revision: 245
Merged at revision: 287
Proposed branch: lp:~verzegnassi-stefano/ubuntu-docviewer-app/spreadsheet-part-selector
Merge into: lp:ubuntu-docviewer-app
Prerequisite: lp:~verzegnassi-stefano/ubuntu-docviewer-app/lok-qml-currentpart-moved
Diff against target: 415 lines (+162/-50)
7 files modified
po/com.ubuntu.docviewer.pot (+18/-7)
src/app/qml/loView/LOViewPage.qml (+39/-13)
src/app/qml/loView/SpreadsheetSelector.qml (+84/-0)
src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp (+8/-16)
src/plugin/libreofficetoolkit-qml-plugin/lodocument.h (+1/-6)
src/plugin/libreofficetoolkit-qml-plugin/loview.cpp (+2/-4)
src/plugin/libreofficetoolkit-qml-plugin/lozoom.cpp (+10/-4)
To merge this branch: bzr merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/spreadsheet-part-selector
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Needs Fixing
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Review via email: mp+282845@code.launchpad.net

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

Description of the change

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

To post a comment you must log in.
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

This is excellent. Works really well.

review: Approve
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://core-apps-jenkins.ubuntu.com/job/docviewer-app-autolanding/65/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1479/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

It seems that Jenkins has run a build on revision 239, but it didn't update the review. Top-approving...

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) :
review: Approve (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :

FAILED: Autolanding.
Merging failed. More details in the following jenkins job:
https://core-apps-jenkins.ubuntu.com/job/run-ap-tests-autolanding/809/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1511/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://core-apps-jenkins.ubuntu.com/job/docviewer-app-autolanding/137/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1526/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://core-apps-jenkins.ubuntu.com/job/docviewer-app-autolanding/144/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1535/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://core-apps-jenkins.ubuntu.com/job/docviewer-app-autolanding/147/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1562/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Text conflict in po/com.ubuntu.docviewer.pot
1 conflicts encountered.

review: Needs Fixing
245. By Stefano Verzegnassi

Merged trunk + updated .pot

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/com.ubuntu.docviewer.pot'
2--- po/com.ubuntu.docviewer.pot 2016-02-02 11:34:27 +0000
3+++ po/com.ubuntu.docviewer.pot 2016-02-03 00:12:17 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: \n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2016-02-02 12:33+0100\n"
9+"POT-Creation-Date: 2016-02-03 00:58+0100\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13@@ -216,7 +216,7 @@
14 msgstr ""
15
16 #: ../src/app/qml/documentPage/DocumentPage.qml:23
17-#: /tmp/new-empty-state-build/po/com.ubuntu.docviewer.desktop.in.in.h:3
18+#: /tmp/spreadsheet-part-selector-build/po/com.ubuntu.docviewer.desktop.in.in.h:3
19 msgid "Documents"
20 msgstr ""
21
22@@ -367,20 +367,24 @@
23 msgid "GO!"
24 msgstr ""
25
26-#: ../src/app/qml/loView/LOViewPage.qml:129
27+#: ../src/app/qml/loView/LOViewPage.qml:137
28 msgid "LibreOffice binaries not found."
29 msgstr ""
30
31-#: ../src/app/qml/loView/LOViewPage.qml:132
32+#: ../src/app/qml/loView/LOViewPage.qml:140
33 msgid "Error while loading LibreOffice."
34 msgstr ""
35
36-#: ../src/app/qml/loView/LOViewPage.qml:135
37+#: ../src/app/qml/loView/LOViewPage.qml:143
38 msgid ""
39 "Document not loaded.\n"
40 "The requested document may be corrupt or protected by a password."
41 msgstr ""
42
43+#: ../src/app/qml/loView/LOViewPage.qml:164
44+msgid "This sheet has no content."
45+msgstr ""
46+
47 #. TRANSLATORS: 'LibreOfficeKit' is the name of the library used by
48 #. Document Viewer for rendering LibreOffice/MS-Office documents.
49 #. Ref. https://docs.libreoffice.org/libreofficekit.html
50@@ -388,6 +392,13 @@
51 msgid "Powered by LibreOfficeKit"
52 msgstr ""
53
54+#. TRANSLATORS: Please don't add any space between "Sheet" and "%1".
55+#. This is the default name for a sheet in LibreOffice.
56+#: ../src/app/qml/loView/SpreadsheetSelector.qml:64
57+#, qt-format
58+msgid "Sheet%1"
59+msgstr ""
60+
61 #: ../src/app/qml/loView/ZoomSelector.qml:122
62 msgid "Fit width"
63 msgstr ""
64@@ -449,10 +460,10 @@
65 msgid "copy %1"
66 msgstr ""
67
68-#: /tmp/new-empty-state-build/po/com.ubuntu.docviewer.desktop.in.in.h:1
69+#: /tmp/spreadsheet-part-selector-build/po/com.ubuntu.docviewer.desktop.in.in.h:1
70 msgid "Document Viewer"
71 msgstr ""
72
73-#: /tmp/new-empty-state-build/po/com.ubuntu.docviewer.desktop.in.in.h:2
74+#: /tmp/spreadsheet-part-selector-build/po/com.ubuntu.docviewer.desktop.in.in.h:2
75 msgid "documents;viewer;pdf;reader;"
76 msgstr ""
77
78=== modified file 'src/app/qml/loView/LOViewPage.qml'
79--- src/app/qml/loView/LOViewPage.qml 2016-01-20 21:48:21 +0000
80+++ src/app/qml/loView/LOViewPage.qml 2016-02-03 00:12:17 +0000
81@@ -30,6 +30,7 @@
82
83 property bool isPresentation: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.PresentationDocument)
84 property bool isTextDocument: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.TextDocument)
85+ property bool isSpreadsheet: loPage.contentItem && (loPage.contentItem.loDocument.documentType === LibreOffice.Document.SpreadsheetDocument)
86
87 title: DocumentViewer.getFileBaseNameFromPath(file.path);
88 flickable: isTextDocument ? loPage.contentItem.loView : null
89@@ -76,9 +77,16 @@
90 left: leftSidebar.right
91 right: parent.right
92 top: parent.top
93- bottom: parent.bottom
94+ bottom: sSelector.top
95 }
96 }
97+
98+ SpreadsheetSelector {
99+ id: sSelector
100+ anchors.bottom: parent.bottom
101+ visible: loPage.isSpreadsheet
102+ view: loView
103+ }
104 }
105 }
106 ]
107@@ -148,29 +156,47 @@
108
109 Scrollbar { flickableItem: loView; parent: loView.parent }
110 Scrollbar { flickableItem: loView; parent: loView.parent; align: Qt.AlignBottom }
111+
112+ Label {
113+ anchors.centerIn: parent
114+ parent: loPage
115+ textSize: Label.Large
116+ text: i18n.tr("This sheet has no content.")
117+ visible: loPage.isSpreadsheet && loView.contentWidth <= 0 && loView.contentHeight <= 0
118+ }
119 }
120 }
121
122- PartsView {
123+ Item {
124 id: bottomBar
125 anchors {
126 left: parent.left
127 right: parent.right
128 bottom: parent.bottom
129 }
130- height: visible ? units.gu(12) : 0
131- visible: loPage.isPresentation
132-
133- model: loView.partsModel
134- orientation: ListView.Horizontal
135-
136- HorizontalDivider {
137- anchors {
138- left: parent.left
139- right: parent.right
140- top: parent.top
141+ height: childrenRect.height
142+
143+ PartsView {
144+ anchors { left: parent.left; right: parent.right }
145+ height: visible ? units.gu(12) : 0
146+ visible: loPage.isPresentation
147+
148+ model: loView.partsModel
149+ orientation: ListView.Horizontal
150+
151+ HorizontalDivider {
152+ anchors {
153+ left: parent.left
154+ right: parent.right
155+ top: parent.top
156+ }
157 }
158 }
159+
160+ SpreadsheetSelector {
161+ visible: loPage.isSpreadsheet
162+ view: loView
163+ }
164 }
165 }
166 }
167
168=== added file 'src/app/qml/loView/SpreadsheetSelector.qml'
169--- src/app/qml/loView/SpreadsheetSelector.qml 1970-01-01 00:00:00 +0000
170+++ src/app/qml/loView/SpreadsheetSelector.qml 2016-02-03 00:12:17 +0000
171@@ -0,0 +1,84 @@
172+/*
173+ * Copyright (C) 2016 Stefano Verzegnassi
174+ *
175+ * This program is free software; you can redistribute it and/or modify
176+ * it under the terms of the GNU General Public License as published by
177+ * the Free Software Foundation; version 3.
178+ *
179+ * This program is distributed in the hope that it will be useful,
180+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
181+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
182+ * GNU General Public License for more details.
183+ *
184+ * You should have received a copy of the GNU General Public License
185+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
186+ */
187+
188+import QtQuick 2.4
189+import Ubuntu.Components 1.3
190+import DocumentViewer.LibreOffice 1.0
191+
192+import "../common"
193+
194+Item {
195+ id: spreadsheetSelector
196+ anchors { left: parent.left; right: parent.right }
197+ height: visible ? units.gu(6) : 0
198+
199+ property Viewer view
200+
201+ Rectangle {
202+ anchors.fill: parent
203+ color: theme.palette.normal.background
204+ }
205+
206+ ListView {
207+ id: listView
208+ anchors.fill: parent
209+ boundsBehavior: Flickable.StopAtBounds
210+ orientation: ListView.Horizontal
211+
212+ model: spreadsheetSelector.view.partsModel
213+
214+ delegate: AbstractButton {
215+ id: del
216+ property bool selected: spreadsheetSelector.view.currentPart == model.index
217+
218+ width: nameLabel.paintedWidth + units.gu(4)
219+ height: parent.height
220+
221+ onClicked: spreadsheetSelector.view.currentPart = model.index
222+
223+ Rectangle {
224+ anchors.fill: parent
225+ visible: del.selected
226+ color: theme.palette.selected.background
227+ }
228+
229+ Label {
230+ id: nameLabel
231+ anchors.centerIn: parent
232+
233+ // TRANSLATORS: Please don't add any space between "Sheet" and "%1".
234+ // This is the default name for a sheet in LibreOffice.
235+ text: model.name || i18n.tr("Sheet%1").arg(model.index + 1)
236+ color: del.selected ? UbuntuColors.orange : theme.palette.normal.baseText
237+ }
238+
239+ Rectangle {
240+ anchors {
241+ left: parent.left
242+ right: parent.right
243+ bottom: parent.bottom
244+ }
245+ height: units.dp(2)
246+ color: UbuntuColors.orange
247+ visible: del.selected
248+ }
249+ }
250+ }
251+
252+ HorizontalDivider {
253+ anchors { left: parent.left; right: parent.right }
254+ }
255+}
256
257=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp'
258--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2015-12-14 00:40:55 +0000
259+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2016-02-03 00:12:17 +0000
260@@ -127,25 +127,16 @@
261 return m_docType;
262 }
263
264-int LODocument::documentPart() const
265-{
266- return m_lokDocument->getPart();
267-}
268-
269-void LODocument::setDocumentPart(int p)
270-{
271- if (documentPart() != p)
272- m_lokDocument->setPart(p);
273-}
274-
275 // Return the size of the document, in TWIPs
276-QSize LODocument::documentSize() const
277+QSize LODocument::documentSize(int part) const
278 {
279 if (!m_lokDocument)
280 return QSize(0, 0);
281
282 long pWidth(0);
283 long pHeight(0);
284+
285+ m_lokDocument->setPart(part);
286 m_lokDocument->getDocumentSize(&pWidth, &pHeight);
287
288 return QSize(pWidth, pHeight);
289@@ -184,15 +175,16 @@
290 if (!m_lokDocument)
291 return QImage();
292
293- m_lokDocument->setPart(part);
294-
295 #ifdef DEBUG_TILE_BENCHMARK
296 QElapsedTimer renderTimer;
297 renderTimer.start();
298 #endif
299
300- qreal tWidth = this->documentSize().width();
301- qreal tHeight = this->documentSize().height();
302+ long tWidth(0);
303+ long tHeight(0);
304+
305+ m_lokDocument->setPart(part);
306+ m_lokDocument->getDocumentSize(&tWidth, &tHeight);
307
308 QSize resultSize;
309
310
311=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.h'
312--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2015-12-14 00:40:55 +0000
313+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2016-02-03 00:12:17 +0000
314@@ -35,7 +35,6 @@
315 Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
316 // Declare partsCount as constant at the moment, since LOK-plugin is just a viewer for now.
317 Q_PROPERTY(int partsCount READ partsCount CONSTANT)
318- Q_PROPERTY(int documentPart READ documentPart WRITE setDocumentPart NOTIFY documentPartChanged)
319 Q_PROPERTY(DocumentType documentType READ documentType NOTIFY documentTypeChanged)
320 Q_PROPERTY(LibreOfficeError::Error error READ error NOTIFY errorChanged)
321 Q_ENUMS(DocumentType)
322@@ -57,10 +56,7 @@
323
324 DocumentType documentType() const;
325
326- int documentPart() const;
327- void setDocumentPart(int p);
328-
329- QSize documentSize() const;
330+ QSize documentSize(int part) const;
331
332 QImage paintTile(int part, const QSize& canvasSize, const QRect& tileSize, const qreal& zoom = 1.0);
333 QImage paintThumbnail(int part, qreal size);
334@@ -74,7 +70,6 @@
335 Q_SIGNALS:
336 void pathChanged();
337 void documentTypeChanged();
338- void documentPartChanged();
339 void errorChanged();
340
341 private:
342
343=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.cpp'
344--- src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2016-01-26 11:46:42 +0000
345+++ src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2016-02-03 00:12:17 +0000
346@@ -42,6 +42,7 @@
347
348 connect(this, &LOView::documentChanged, this, &LOView::updateViewSize);
349 connect(this, &LOView::parentFlickableChanged, this, &LOView::updateVisibleRect);
350+ connect(this, &LOView::currentPartChanged, this, &LOView::invalidateAllTiles);
351 connect(this, &LOView::cacheBufferChanged, this, &LOView::updateVisibleRect);
352 connect(&m_updateTimer, &QTimer::timeout, this, &LOView::updateVisibleRect);
353
354@@ -114,9 +115,6 @@
355 engine->addImageProvider("lok", m_imageProvider);
356 // --------------------------------------------------
357
358- setCurrentPart(0);
359- connect(this, SIGNAL(currentPartChanged()), this, SLOT(invalidateAllTiles()));
360-
361 Q_EMIT documentChanged();
362
363 // Init zoom settings
364@@ -203,7 +201,7 @@
365 if (!m_document)
366 return;
367
368- QSize docSize = m_document->documentSize();
369+ QSize docSize = m_document->documentSize(m_currentPart);
370 qreal zoomFactor = m_zoomSettings->zoomFactor();
371
372 this->setWidth(Twips::convertTwipsToPixels(docSize.width(), zoomFactor));
373
374=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lozoom.cpp'
375--- src/plugin/libreofficetoolkit-qml-plugin/lozoom.cpp 2016-01-21 14:24:02 +0000
376+++ src/plugin/libreofficetoolkit-qml-plugin/lozoom.cpp 2016-02-03 00:12:17 +0000
377@@ -161,8 +161,10 @@
378 if (changeMode)
379 setZoomMode(LOZoom::FitToWidth);
380
381+ int currentPart = m_view->currentPart();
382+
383 m_valueFitToWidthZoom = getZoomToFitWidth(m_view->parentFlickable()->width(),
384- m_view->document()->documentSize().width());
385+ m_view->document()->documentSize(currentPart).width());
386
387 if (m_zoomFactor != m_valueFitToWidthZoom) {
388 setZoomFactor(m_valueFitToWidthZoom);
389@@ -182,8 +184,10 @@
390 if (changeMode)
391 setZoomMode(LOZoom::FitToHeight);
392
393+ int currentPart = m_view->currentPart();
394+
395 m_valueFitToHeightZoom = getZoomToFitHeight(m_view->parentFlickable()->height(),
396- m_view->document()->documentSize().height());
397+ m_view->document()->documentSize(currentPart).height());
398
399 if (m_zoomFactor != m_valueFitToHeightZoom) {
400 setZoomFactor(m_valueFitToHeightZoom);
401@@ -203,11 +207,13 @@
402 if (changeMode)
403 setZoomMode(LOZoom::Automatic);
404
405+ int currentPart = m_view->currentPart();
406+
407 m_valueFitToWidthZoom = getZoomToFitWidth(m_view->parentFlickable()->width(),
408- m_view->document()->documentSize().width());
409+ m_view->document()->documentSize(currentPart).width());
410
411 m_valueFitToHeightZoom = getZoomToFitHeight(m_view->parentFlickable()->height(),
412- m_view->document()->documentSize().height());
413+ m_view->document()->documentSize(currentPart).height());
414
415 m_valueAutomaticZoom = qMin(m_valueFitToWidthZoom, m_valueFitToHeightZoom);
416

Subscribers

People subscribed via source and target branches