summaryrefslogtreecommitdiffstats
path: root/printing/page_range.cc
blob: 7a8cb84c84c70e58fdd8a23bef7fd31bad96adeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "printing/page_range.h"

#include <set>
#include <vector>

namespace printing {

/* static */
std::vector<int> PageRange::GetPages(const PageRanges& ranges) {
  std::set<int> pages;
  for (unsigned i = 0; i < ranges.size(); ++i) {
    const PageRange& range = ranges[i];
    // Ranges are inclusive.
    for (int i = range.from; i <= range.to; ++i) {
      pages.insert(i);
    }
  }
  return std::vector<int>(pages.begin(), pages.end());
}

}  // namespace printing