Home | History | Annotate | Download | only in printing
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "printing/page_range.h"
      6 
      7 #include <set>
      8 
      9 namespace {
     10 const std::size_t kMaxNumberOfPages = 100000;
     11 }
     12 
     13 namespace printing {
     14 
     15 /* static */
     16 std::vector<int> PageRange::GetPages(const PageRanges& ranges) {
     17   // TODO(vitalybuka): crbug.com/95548 Remove this method as part fix.
     18   std::set<int> pages;
     19   for (unsigned i = 0; i < ranges.size(); ++i) {
     20     const PageRange& range = ranges[i];
     21     // Ranges are inclusive.
     22     for (int i = range.from; i <= range.to; ++i) {
     23       pages.insert(i);
     24       if (pages.size() >= kMaxNumberOfPages)
     25         return std::vector<int>(pages.begin(), pages.end());
     26     }
     27   }
     28   return std::vector<int>(pages.begin(), pages.end());
     29 }
     30 
     31 }  // namespace printing
     32