1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2014 Henrik Tidefelt
21 #include "pdfstructure.h"
23 #include "SimplePDF_decls.h"
24 #include "Shapes_Lang_decls.h"
25 #include "concretecolors.h"
34 class PDF_Resources
: public PDF_Object
37 enum ProcSet
{ PROC_SET_PDF
, PROC_SET_TEXT
, PROC_SET_IMAGE_GRAY
, PROC_SET_IMAGE_COLOR
, PROC_SET_IMAGE_INDEXED
};
41 RefCountPtr
< PDF_Dictionary
> xobject
;
42 RefCountPtr
< PDF_Dictionary
> graphicsStates
;
43 RefCountPtr
< PDF_Dictionary
> colorSpaces
;
44 RefCountPtr
< PDF_Dictionary
> fonts
;
45 RefCountPtr
< PDF_Dictionary
> shadings
;
46 std::set
< ProcSet
> procSets
;
47 RefCountPtr
< PDF_Vector
> procSetsVector
;
49 typedef std::map
< PDF_Object
*, PDF_Name
> ReverseMap
;
50 ReverseMap reverse_xobject
;
51 ReverseMap reverse_graphicsStates
;
52 ReverseMap reverse_colorSpaces
;
53 ReverseMap reverse_fonts
;
54 ReverseMap reverse_shadings
;
58 virtual ~PDF_Resources( );
59 const PDF_Name
& nameofXObject( const RefCountPtr
< PDF_Object
> & obj
);
60 const PDF_Name
& nameofGraphicsState( const RefCountPtr
< PDF_Object
> & obj
);
61 const PDF_Name
& nameofColorSpace( const RefCountPtr
< PDF_Object
> & obj
);
62 const PDF_Name
& nameofFont( const RefCountPtr
< PDF_Object
> & obj
);
63 const PDF_Name
& nameofShading( const RefCountPtr
< PDF_Object
> & obj
);
64 void requireProcedureSet( ProcSet procSet
);
66 virtual void writeTo( std::ostream
& os
, SimplePDF::PDF_xref
* xref
, const RefCountPtr
< const PDF_Object
> & self
) const;
69 static const PDF_Name
& nameof( const RefCountPtr
< PDF_Object
> & obj
, ReverseMap
* reverseMap
, RefCountPtr
< PDF_Dictionary
> * dic
, const char * prefix
, size_t * counter
);
75 RefCountPtr
< PDF_Dictionary
> info_
;
76 std::list
< std::string
> extensionAuthorStrings
;
77 RefCountPtr
< PDF_Indirect_out
> i_info_
;
80 void addExtensionAuthorString( const std::string
& str
);
81 bool addInfo( const char * key
, const RefCountPtr
< PDF_Object
> & datum
);
82 RefCountPtr
< PDF_Indirect_out
> getIndirect( size_t * indirectObjectCounter
);
88 RefCountPtr
< SimplePDF::PDF_Indirect_out
> i_root_
;
89 RefCountPtr
< SimplePDF::PDF_Indirect_out
> i_info_
;
90 RefCountPtr
< const char > firstPageLabel_
;
93 PDF_out( const RefCountPtr
< SimplePDF::PDF_Indirect_out
> & i_root
, const RefCountPtr
< SimplePDF::PDF_Indirect_out
> & i_info
, const RefCountPtr
< const char > & firstPageLabel
);
95 void writeFile( std::ostream
& os
, SimplePDF::PDF_Version
& pdfVersion
) const;
96 RefCountPtr
< const char > getFirstPageLabel( ) const;
99 RefCountPtr
< PDF_HexString
> fileIdentifier( std::streampos osp
) const;
103 extern RefCountPtr
<PDF_Object
> theTrue
;
104 extern RefCountPtr
<PDF_Object
> theFalse
;
105 RefCountPtr
<PDF_Object
> newName( const char * str
);
106 RefCountPtr
<PDF_Object
> newString( const char * str
);
107 RefCountPtr
<PDF_Object
> newInt( PDF_Int::ValueType val
);
108 RefCountPtr
<PDF_Object
> newBoolean( PDF_Boolean::ValueType val
);
109 RefCountPtr
<PDF_Object
> newFloat( PDF_Float::ValueType val
);
114 RefCountPtr
< PDF_Object
> destination_
;
115 RefCountPtr
< const char > title_
;
116 std::list
< RefCountPtr
< OutlineItem
> > kids_
;
121 Shapes::Concrete::RGB color_
;
123 OutlineItem( const RefCountPtr
< PDF_Object
> & destination
, const RefCountPtr
< const char > & title
, bool isOpen
, bool fontBold
, bool fontItalic
, const Shapes::Concrete::RGB
& color
);
125 void addKid( const RefCountPtr
< OutlineItem
> & kid
);
127 bool hasKids( ) const;
128 RefCountPtr
< SimplePDF::PDF_Indirect_out
> getTopIndirectDictionary( SimplePDF::PDF_Version
& pdfVersion
) const;
129 size_t fillInDictionary( RefCountPtr
< SimplePDF::PDF_Dictionary
> dstDic
, const RefCountPtr
< SimplePDF::PDF_Indirect_out
> & i_dstDic
, SimplePDF::PDF_Version
& pdfVersion
) const;