Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6a579e2 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by android-build-merger
Browse files

Merge "Do not rely on documentInfo.pageCount when selecting which pages to scrap" into nyc-dev

am: c84bbd57

* commit 'c84bbd57':
  Do not rely on documentInfo.pageCount when selecting which pages to scrap

Change-Id: Ic7f7f2039b30983944c495ccfc28d9172efd0297
parents 43cdd427 c84bbd57
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -244,9 +244,20 @@ public final class PdfManipulationService extends Service {

                ranges = PageRangeUtils.normalize(ranges);

                int lastPageIdx = mEditor.getPageCount() - 1;

                final int rangeCount = ranges.length;
                for (int i = rangeCount - 1; i >= 0; i--) {
                    PageRange range = ranges[i];

                    // Ignore removal of pages that are outside the document
                    if (range.getEnd() > lastPageIdx) {
                        if (range.getStart() > lastPageIdx) {
                            continue;
                        }
                        range = new PageRange(range.getStart(), lastPageIdx);
                    }

                    for (int j = range.getEnd(); j >= range.getStart(); j--) {
                        mEditor.removePage(j);
                    }
+3 −8
Original line number Diff line number Diff line
@@ -3103,12 +3103,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
            List<PageRange> rangesToShred = new ArrayList<>();
            PageRange previousRange = null;

            final int pageCount = printJob.getDocumentInfo().getPageCount();

            PageRange[] printedPages = printJob.getPages();
            final int rangeCount = printedPages.length;
            for (int i = 0; i < rangeCount; i++) {
                PageRange range = PageRangeUtils.asAbsoluteRange(printedPages[i], pageCount);
                PageRange range = printedPages[i];

                if (previousRange == null) {
                    final int startPageIdx = 0;
@@ -3127,11 +3125,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
                }

                if (i == rangeCount - 1) {
                    final int startPageIdx = range.getEnd() + 1;
                    final int endPageIdx = printJob.getDocumentInfo().getPageCount() - 1;
                    if (startPageIdx <= endPageIdx) {
                        PageRange removedRange = new PageRange(startPageIdx, endPageIdx);
                        rangesToShred.add(removedRange);
                    if (range.getEnd() != Integer.MAX_VALUE) {
                        rangesToShred.add(new PageRange(range.getEnd() + 1, Integer.MAX_VALUE));
                    }
                }