gfx/skia/trunk/include/pdf/SkPDFDocument.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2010 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkPDFDocument_DEFINED
michael@0 11 #define SkPDFDocument_DEFINED
michael@0 12
michael@0 13 #include "SkAdvancedTypefaceMetrics.h"
michael@0 14 #include "SkRefCnt.h"
michael@0 15 #include "SkTDArray.h"
michael@0 16 #include "SkTemplates.h"
michael@0 17
michael@0 18 class SkPDFCatalog;
michael@0 19 class SkPDFDevice;
michael@0 20 class SkPDFDict;
michael@0 21 class SkPDFPage;
michael@0 22 class SkPDFObject;
michael@0 23 class SkWStream;
michael@0 24 template <typename T> class SkTSet;
michael@0 25
michael@0 26 /** \class SkPDFDocument
michael@0 27
michael@0 28 A SkPDFDocument assembles pages together and generates the final PDF file.
michael@0 29 */
michael@0 30 class SkPDFDocument {
michael@0 31 public:
michael@0 32 enum Flags {
michael@0 33 kNoCompression_Flags = 0x01, //!< DEPRECATED.
michael@0 34 kFavorSpeedOverSize_Flags = 0x01, //!< Don't compress the stream, but
michael@0 35 // if it is already compressed return
michael@0 36 // the compressed stream.
michael@0 37 kNoLinks_Flags = 0x02, //!< do not honor link annotations.
michael@0 38
michael@0 39 kDraftMode_Flags = 0x01,
michael@0 40 };
michael@0 41 /** Create a PDF document.
michael@0 42 */
michael@0 43 explicit SK_API SkPDFDocument(Flags flags = (Flags)0);
michael@0 44 SK_API ~SkPDFDocument();
michael@0 45
michael@0 46 /** Output the PDF to the passed stream. It is an error to call this (it
michael@0 47 * will return false and not modify stream) if no pages have been added
michael@0 48 * or there are pages missing (i.e. page 1 and 3 have been added, but not
michael@0 49 * page 2).
michael@0 50 *
michael@0 51 * @param stream The writable output stream to send the PDF to.
michael@0 52 */
michael@0 53 SK_API bool emitPDF(SkWStream* stream);
michael@0 54
michael@0 55 /** Sets the specific page to the passed PDF device. If the specified
michael@0 56 * page is already set, this overrides it. Returns true if successful.
michael@0 57 * Will fail if the document has already been emitted.
michael@0 58 *
michael@0 59 * @param pageNumber The position to add the passed device (1 based).
michael@0 60 * @param pdfDevice The page to add to this document.
michael@0 61 */
michael@0 62 SK_API bool setPage(int pageNumber, SkPDFDevice* pdfDevice);
michael@0 63
michael@0 64 /** Append the passed pdf device to the document as a new page. Returns
michael@0 65 * true if successful. Will fail if the document has already been emitted.
michael@0 66 *
michael@0 67 * @param pdfDevice The page to add to this document.
michael@0 68 */
michael@0 69 SK_API bool appendPage(SkPDFDevice* pdfDevice);
michael@0 70
michael@0 71 /** Get the count of unique font types used in the document.
michael@0 72 */
michael@0 73 SK_API void getCountOfFontTypes(
michael@0 74 int counts[SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1]) const;
michael@0 75
michael@0 76 private:
michael@0 77 SkAutoTDelete<SkPDFCatalog> fCatalog;
michael@0 78 int64_t fXRefFileOffset;
michael@0 79
michael@0 80 SkTDArray<SkPDFPage*> fPages;
michael@0 81 SkTDArray<SkPDFDict*> fPageTree;
michael@0 82 SkPDFDict* fDocCatalog;
michael@0 83 SkTSet<SkPDFObject*>* fFirstPageResources;
michael@0 84 SkTSet<SkPDFObject*>* fOtherPageResources;
michael@0 85 SkTDArray<SkPDFObject*> fSubstitutes;
michael@0 86
michael@0 87 SkPDFDict* fTrailerDict;
michael@0 88
michael@0 89 /** Output the PDF header to the passed stream.
michael@0 90 * @param stream The writable output stream to send the header to.
michael@0 91 */
michael@0 92 void emitHeader(SkWStream* stream);
michael@0 93
michael@0 94 /** Get the size of the header.
michael@0 95 */
michael@0 96 size_t headerSize();
michael@0 97
michael@0 98 /** Output the PDF footer to the passed stream.
michael@0 99 * @param stream The writable output stream to send the footer to.
michael@0 100 * @param objCount The number of objects in the PDF.
michael@0 101 */
michael@0 102 void emitFooter(SkWStream* stream, int64_t objCount);
michael@0 103 };
michael@0 104
michael@0 105 #endif

mercurial