blob: 3c050efb1c7787beffa989b96766ae320601d55c [file] [log] [blame]
[email protected]e2319752011-09-23 23:19:091// Copyright (c) 2011 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]8ff1d422009-07-07 21:31:395#include "printing/page_range.h"
initial.commit09911bf2008-07-26 23:55:296
avi126e93c2015-12-21 21:48:167#include <stddef.h>
8
[email protected]7286e3fc2011-07-19 22:13:249#include <set>
[email protected]f9114342013-10-02 20:11:5010
11namespace {
12const std::size_t kMaxNumberOfPages = 100000;
13}
initial.commit09911bf2008-07-26 23:55:2914
15namespace printing {
16
[email protected]82270452009-06-19 15:58:0117/* static */
initial.commit09911bf2008-07-26 23:55:2918std::vector<int> PageRange::GetPages(const PageRanges& ranges) {
[email protected]f9114342013-10-02 20:11:5019 // TODO(vitalybuka): crbug.com/95548 Remove this method as part fix.
initial.commit09911bf2008-07-26 23:55:2920 std::set<int> pages;
21 for (unsigned i = 0; i < ranges.size(); ++i) {
22 const PageRange& range = ranges[i];
23 // Ranges are inclusive.
24 for (int i = range.from; i <= range.to; ++i) {
25 pages.insert(i);
[email protected]f9114342013-10-02 20:11:5026 if (pages.size() >= kMaxNumberOfPages)
27 return std::vector<int>(pages.begin(), pages.end());
initial.commit09911bf2008-07-26 23:55:2928 }
29 }
[email protected]7286e3fc2011-07-19 22:13:2430 return std::vector<int>(pages.begin(), pages.end());
initial.commit09911bf2008-07-26 23:55:2931}
32
33} // namespace printing