Home | History | Annotate | Download | only in common
      1 // Copyright 2014 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 #ifndef COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_PRINTER_DESCRIPTION_H_
      6 #define COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_PRINTER_DESCRIPTION_H_
      7 
      8 #include <string>
      9 
     10 #include "base/logging.h"
     11 #include "components/cloud_devices/common/description_items.h"
     12 
     13 // Defines printer options, CDD and CJT items.
     14 // https://developers.google.com/cloud-print/docs/cdd
     15 
     16 namespace cloud_devices {
     17 
     18 namespace printer {
     19 
     20 typedef std::string ContentType;
     21 
     22 enum DocumentSheetBack { NORMAL, ROTATED, MANUAL_TUMBLE, FLIPPED };
     23 
     24 struct PwgRasterConfig {
     25   PwgRasterConfig();
     26 
     27   DocumentSheetBack document_sheet_back;
     28   bool reverse_order_streaming;
     29   bool rotate_all_pages;
     30 };
     31 
     32 enum ColorType {
     33   STANDARD_COLOR,
     34   STANDARD_MONOCHROME,
     35   CUSTOM_COLOR,
     36   CUSTOM_MONOCHROME,
     37   AUTO_COLOR,
     38 };
     39 
     40 struct Color {
     41   Color();
     42   explicit Color(ColorType type);
     43 
     44   bool IsValid() const;
     45   bool operator==(const Color& other) const;
     46   bool operator!=(const Color& other) const { return !(*this == other); }
     47 
     48   ColorType type;
     49   std::string vendor_id;
     50   std::string custom_display_name;
     51 };
     52 
     53 enum DuplexType {
     54   NO_DUPLEX,
     55   LONG_EDGE,
     56   SHORT_EDGE,
     57 };
     58 
     59 enum OrientationType {
     60   PORTRAIT,
     61   LANDSCAPE,
     62   AUTO_ORIENTATION,
     63 };
     64 
     65 enum MarginsType {
     66   NO_MARGINS,
     67   STANDARD_MARGINS,
     68   CUSTOM_MARGINS,
     69 };
     70 
     71 struct Margins {
     72   Margins();
     73   Margins(MarginsType type,
     74           int32 top_um,
     75           int32 right_um,
     76           int32 bottom_um,
     77           int32 left_um);
     78 
     79   bool operator==(const Margins& other) const;
     80   bool operator!=(const Margins& other) const { return !(*this == other); }
     81 
     82   MarginsType type;
     83   int32 top_um;
     84   int32 right_um;
     85   int32 bottom_um;
     86   int32 left_um;
     87 };
     88 
     89 struct Dpi {
     90   Dpi();
     91   Dpi(int32 horizontal, int32 vertical);
     92 
     93   bool IsValid() const;
     94   bool operator==(const Dpi& other) const;
     95   bool operator!=(const Dpi& other) const { return !(*this == other); }
     96 
     97   int32 horizontal;
     98   int32 vertical;
     99 };
    100 
    101 enum FitToPageType {
    102   NO_FITTING,
    103   FIT_TO_PAGE,
    104   GROW_TO_PAGE,
    105   SHRINK_TO_PAGE,
    106   FILL_PAGE,
    107 };
    108 
    109 enum MediaType {
    110   CUSTOM_MEDIA,
    111 
    112   // North American standard sheet media names.
    113   NA_INDEX_3X5,
    114   NA_PERSONAL,
    115   NA_MONARCH,
    116   NA_NUMBER_9,
    117   NA_INDEX_4X6,
    118   NA_NUMBER_10,
    119   NA_A2,
    120   NA_NUMBER_11,
    121   NA_NUMBER_12,
    122   NA_5X7,
    123   NA_INDEX_5X8,
    124   NA_NUMBER_14,
    125   NA_INVOICE,
    126   NA_INDEX_4X6_EXT,
    127   NA_6X9,
    128   NA_C5,
    129   NA_7X9,
    130   NA_EXECUTIVE,
    131   NA_GOVT_LETTER,
    132   NA_GOVT_LEGAL,
    133   NA_QUARTO,
    134   NA_LETTER,
    135   NA_FANFOLD_EUR,
    136   NA_LETTER_PLUS,
    137   NA_FOOLSCAP,
    138   NA_LEGAL,
    139   NA_SUPER_A,
    140   NA_9X11,
    141   NA_ARCH_A,
    142   NA_LETTER_EXTRA,
    143   NA_LEGAL_EXTRA,
    144   NA_10X11,
    145   NA_10X13,
    146   NA_10X14,
    147   NA_10X15,
    148   NA_11X12,
    149   NA_EDP,
    150   NA_FANFOLD_US,
    151   NA_11X15,
    152   NA_LEDGER,
    153   NA_EUR_EDP,
    154   NA_ARCH_B,
    155   NA_12X19,
    156   NA_B_PLUS,
    157   NA_SUPER_B,
    158   NA_C,
    159   NA_ARCH_C,
    160   NA_D,
    161   NA_ARCH_D,
    162   NA_ASME_F,
    163   NA_WIDE_FORMAT,
    164   NA_E,
    165   NA_ARCH_E,
    166   NA_F,
    167 
    168   // Chinese standard sheet media size names.
    169   ROC_16K,
    170   ROC_8K,
    171   PRC_32K,
    172   PRC_1,
    173   PRC_2,
    174   PRC_4,
    175   PRC_5,
    176   PRC_8,
    177   PRC_6,
    178   PRC_3,
    179   PRC_16K,
    180   PRC_7,
    181   OM_JUURO_KU_KAI,
    182   OM_PA_KAI,
    183   OM_DAI_PA_KAI,
    184   PRC_10,
    185 
    186   // ISO standard sheet media size names.
    187   ISO_A10,
    188   ISO_A9,
    189   ISO_A8,
    190   ISO_A7,
    191   ISO_A6,
    192   ISO_A5,
    193   ISO_A5_EXTRA,
    194   ISO_A4,
    195   ISO_A4_TAB,
    196   ISO_A4_EXTRA,
    197   ISO_A3,
    198   ISO_A4X3,
    199   ISO_A4X4,
    200   ISO_A4X5,
    201   ISO_A4X6,
    202   ISO_A4X7,
    203   ISO_A4X8,
    204   ISO_A4X9,
    205   ISO_A3_EXTRA,
    206   ISO_A2,
    207   ISO_A3X3,
    208   ISO_A3X4,
    209   ISO_A3X5,
    210   ISO_A3X6,
    211   ISO_A3X7,
    212   ISO_A1,
    213   ISO_A2X3,
    214   ISO_A2X4,
    215   ISO_A2X5,
    216   ISO_A0,
    217   ISO_A1X3,
    218   ISO_A1X4,
    219   ISO_2A0,
    220   ISO_A0X3,
    221   ISO_B10,
    222   ISO_B9,
    223   ISO_B8,
    224   ISO_B7,
    225   ISO_B6,
    226   ISO_B6C4,
    227   ISO_B5,
    228   ISO_B5_EXTRA,
    229   ISO_B4,
    230   ISO_B3,
    231   ISO_B2,
    232   ISO_B1,
    233   ISO_B0,
    234   ISO_C10,
    235   ISO_C9,
    236   ISO_C8,
    237   ISO_C7,
    238   ISO_C7C6,
    239   ISO_C6,
    240   ISO_C6C5,
    241   ISO_C5,
    242   ISO_C4,
    243   ISO_C3,
    244   ISO_C2,
    245   ISO_C1,
    246   ISO_C0,
    247   ISO_DL,
    248   ISO_RA2,
    249   ISO_SRA2,
    250   ISO_RA1,
    251   ISO_SRA1,
    252   ISO_RA0,
    253   ISO_SRA0,
    254 
    255   // Japanese standard sheet media size names.
    256   JIS_B10,
    257   JIS_B9,
    258   JIS_B8,
    259   JIS_B7,
    260   JIS_B6,
    261   JIS_B5,
    262   JIS_B4,
    263   JIS_B3,
    264   JIS_B2,
    265   JIS_B1,
    266   JIS_B0,
    267   JIS_EXEC,
    268   JPN_CHOU4,
    269   JPN_HAGAKI,
    270   JPN_YOU4,
    271   JPN_CHOU2,
    272   JPN_CHOU3,
    273   JPN_OUFUKU,
    274   JPN_KAHU,
    275   JPN_KAKU2,
    276 
    277   // Other metric standard sheet media size names.
    278   OM_SMALL_PHOTO,
    279   OM_ITALIAN,
    280   OM_POSTFIX,
    281   OM_LARGE_PHOTO,
    282   OM_FOLIO,
    283   OM_FOLIO_SP,
    284   OM_INVITE,
    285 };
    286 
    287 struct Media {
    288   Media();
    289 
    290   explicit Media(MediaType type);
    291 
    292   Media(MediaType type, int32 width_um, int32 height_um);
    293 
    294   Media(const std::string& custom_display_name,
    295         const std::string& vendor_id,
    296         int32 width_um,
    297         int32 height_um);
    298 
    299   bool MatchBySize();
    300 
    301   bool IsValid() const;
    302   bool operator==(const Media& other) const;
    303   bool operator!=(const Media& other) const { return !(*this == other); }
    304 
    305   MediaType type;
    306   int32 width_um;
    307   int32 height_um;
    308   bool is_continuous_feed;
    309   std::string custom_display_name;
    310   std::string vendor_id;
    311 };
    312 
    313 struct Interval {
    314   Interval();
    315   Interval(int32 start, int32 end);
    316   Interval(int32 start);
    317 
    318   bool operator==(const Interval& other) const;
    319   bool operator!=(const Interval& other) const { return !(*this == other); }
    320 
    321   int32 start;
    322   int32 end;
    323 };
    324 
    325 typedef std::vector<Interval> PageRange;
    326 
    327 class ContentTypeTraits;
    328 class PwgRasterConfigTraits;
    329 class ColorTraits;
    330 class DuplexTraits;
    331 class OrientationTraits;
    332 class MarginsTraits;
    333 class DpiTraits;
    334 class FitToPageTraits;
    335 class MediaTraits;
    336 class CopiesTraits;
    337 class PageRangeTraits;
    338 class CollateTraits;
    339 
    340 typedef ListCapability<ContentType, ContentTypeTraits> ContentTypesCapability;
    341 typedef ValueCapability<PwgRasterConfig, PwgRasterConfigTraits>
    342     PwgRasterConfigCapability;
    343 typedef SelectionCapability<Color, ColorTraits> ColorCapability;
    344 typedef SelectionCapability<DuplexType, DuplexTraits> DuplexCapability;
    345 typedef SelectionCapability<OrientationType, OrientationTraits>
    346     OrientationCapability;
    347 typedef SelectionCapability<Margins, MarginsTraits> MarginsCapability;
    348 typedef SelectionCapability<Dpi, DpiTraits> DpiCapability;
    349 typedef SelectionCapability<FitToPageType, FitToPageTraits> FitToPageCapability;
    350 typedef SelectionCapability<Media, MediaTraits> MediaCapability;
    351 typedef EmptyCapability<class CopiesTraits> CopiesCapability;
    352 typedef EmptyCapability<class PageRangeTraits> PageRangeCapability;
    353 typedef BooleanCapability<class CollateTraits> CollateCapability;
    354 typedef BooleanCapability<class ReverseTraits> ReverseCapability;
    355 
    356 typedef TicketItem<PwgRasterConfig, PwgRasterConfigTraits>
    357     PwgRasterConfigTicketItem;
    358 typedef TicketItem<Color, ColorTraits> ColorTicketItem;
    359 typedef TicketItem<DuplexType, DuplexTraits> DuplexTicketItem;
    360 typedef TicketItem<OrientationType, OrientationTraits> OrientationTicketItem;
    361 typedef TicketItem<Margins, MarginsTraits> MarginsTicketItem;
    362 typedef TicketItem<Dpi, DpiTraits> DpiTicketItem;
    363 typedef TicketItem<FitToPageType, FitToPageTraits> FitToPageTicketItem;
    364 typedef TicketItem<Media, MediaTraits> MediaTicketItem;
    365 typedef TicketItem<int32, CopiesTraits> CopiesTicketItem;
    366 typedef TicketItem<PageRange, PageRangeTraits> PageRangeTicketItem;
    367 typedef TicketItem<bool, CollateTraits> CollateTicketItem;
    368 typedef TicketItem<bool, ReverseTraits> ReverseTicketItem;
    369 
    370 }  // namespace printer
    371 
    372 }  // namespace cloud_devices
    373 
    374 #endif  // COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_PRINTER_DESCRIPTION_H_
    375