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.
5 #ifndef PRINTING_PAGE_NUMBER_H_
6 #define PRINTING_PAGE_NUMBER_H_
10 #include "printing/page_range.h"
16 // Represents a page series following the array of page ranges defined in a
18 class PRINTING_EXPORT PageNumber
{
20 // Initializes the page to the first page in the settings's range or 0.
21 PageNumber(const PrintSettings
& settings
, int document_page_count
);
25 void operator=(const PageNumber
& other
);
27 // Initializes the page to the first page in the setting's range or 0. It
28 // initialize to npos if the range is empty and document_page_count is 0.
29 void Init(const PrintSettings
& settings
, int document_page_count
);
31 // Converts to a page numbers.
36 // Calculates the next page in the serie.
39 // Returns an instance that represents the end of a serie.
40 static const PageNumber
npos() {
44 // Equality operator. Only the current page number is verified so that
45 // "page != PageNumber::npos()" works.
46 bool operator==(const PageNumber
& other
) const;
47 bool operator!=(const PageNumber
& other
) const;
50 // The page range to follow.
51 const PageRanges
* ranges_
;
53 // The next page to be printed. -1 when not printing.
56 // The next page to be printed. -1 when not used. Valid only if
57 // document()->settings().range.empty() is false.
58 int page_range_index_
;
60 // Number of expected pages in the document. Used when ranges_ is NULL.
61 int document_page_count_
;
64 // Debug output support.
65 template<class E
, class T
>
66 inline typename
std::basic_ostream
<E
,T
>& operator<<(
67 typename
std::basic_ostream
<E
,T
>& ss
, const PageNumber
& page
) {
68 return ss
<< page
.ToInt();
71 } // namespace printing
73 #endif // PRINTING_PAGE_NUMBER_H_