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 Henrik Tidefelt
21 #include "pdfstructure.h"
23 #include "SimplePDF_decls.h"
24 #include "Shapes_Lang_decls.h"
25 #include "concretecolors.h"
33 class PDF_Resources
: public PDF_Object
36 enum ProcSet
{ PROC_SET_PDF
, PROC_SET_TEXT
, PROC_SET_IMAGE_GRAY
, PROC_SET_IMAGE_COLOR
, PROC_SET_IMAGE_INDEXED
};
40 RefCountPtr
< PDF_Dictionary
> xobject
;
41 RefCountPtr
< PDF_Dictionary
> graphicsStates
;
42 RefCountPtr
< PDF_Dictionary
> colorSpaces
;
43 RefCountPtr
< PDF_Dictionary
> fonts
;
44 RefCountPtr
< PDF_Dictionary
> shadings
;
45 std::set
< ProcSet
> procSets
;
46 RefCountPtr
< PDF_Vector
> procSetsVector
;
48 typedef std::map
< PDF_Object
*, PDF_Name
> ReverseMap
;
49 ReverseMap reverse_xobject
;
50 ReverseMap reverse_graphicsStates
;
51 ReverseMap reverse_colorSpaces
;
52 ReverseMap reverse_fonts
;
53 ReverseMap reverse_shadings
;
57 virtual ~PDF_Resources( );
58 const PDF_Name
& nameofXObject( const RefCountPtr
< PDF_Object
> & obj
);
59 const PDF_Name
& nameofGraphicsState( const RefCountPtr
< PDF_Object
> & obj
);
60 const PDF_Name
& nameofColorSpace( const RefCountPtr
< PDF_Object
> & obj
);
61 const PDF_Name
& nameofFont( const RefCountPtr
< PDF_Object
> & obj
);
62 const PDF_Name
& nameofShading( const RefCountPtr
< PDF_Object
> & obj
);
63 void requireProcedureSet( ProcSet procSet
);
65 virtual void writeTo( std::ostream
& os
, SimplePDF::PDF_xref
* xref
, const RefCountPtr
< const PDF_Object
> & self
) const;
68 static const PDF_Name
& nameof( const RefCountPtr
< PDF_Object
> & obj
, ReverseMap
* reverseMap
, RefCountPtr
< PDF_Dictionary
> * dic
, const char * prefix
, size_t * counter
);
74 RefCountPtr
< PDF_Dictionary
> info_
;
75 std::list
< std::string
> extensionAuthorStrings
;
76 RefCountPtr
< PDF_Indirect_out
> i_info_
;
79 void addExtensionAuthorString( const std::string
& str
);
80 bool addInfo( const char * key
, const RefCountPtr
< PDF_Object
> & datum
);
81 RefCountPtr
< PDF_Indirect_out
> getIndirect( size_t * indirectObjectCounter
);
87 RefCountPtr
< SimplePDF::PDF_Indirect_out
> i_root_
;
88 RefCountPtr
< SimplePDF::PDF_Indirect_out
> i_info_
;
89 RefCountPtr
< const char > firstPageLabel_
;
92 PDF_out( const RefCountPtr
< SimplePDF::PDF_Indirect_out
> & i_root
, const RefCountPtr
< SimplePDF::PDF_Indirect_out
> & i_info
, const RefCountPtr
< const char > & firstPageLabel
);
94 void writeFile( std::ostream
& os
, SimplePDF::PDF_Version
& pdfVersion
);
95 RefCountPtr
< const char > getFirstPageLabel( ) const;
98 extern RefCountPtr
<PDF_Object
> theTrue
;
99 extern RefCountPtr
<PDF_Object
> theFalse
;
100 RefCountPtr
<PDF_Object
> newName( const char * str
);
101 RefCountPtr
<PDF_Object
> newString( const char * str
);
102 RefCountPtr
<PDF_Object
> newInt( PDF_Int::ValueType val
);
103 RefCountPtr
<PDF_Object
> newBoolean( PDF_Boolean::ValueType val
);
104 RefCountPtr
<PDF_Object
> newFloat( PDF_Float::ValueType val
);
109 RefCountPtr
< PDF_Object
> destination_
;
110 RefCountPtr
< const char > title_
;
111 std::list
< RefCountPtr
< OutlineItem
> > kids_
;
116 Shapes::Concrete::RGB color_
;
118 OutlineItem( const RefCountPtr
< PDF_Object
> & destination
, const RefCountPtr
< const char > & title
, bool isOpen
, bool fontBold
, bool fontItalic
, const Shapes::Concrete::RGB
& color
);
120 void addKid( const RefCountPtr
< OutlineItem
> & kid
);
122 bool hasKids( ) const;
123 RefCountPtr
< SimplePDF::PDF_Indirect_out
> getTopIndirectDictionary( SimplePDF::PDF_Version
& pdfVersion
) const;
124 size_t fillInDictionary( RefCountPtr
< SimplePDF::PDF_Dictionary
> dstDic
, const RefCountPtr
< SimplePDF::PDF_Indirect_out
> & i_dstDic
, SimplePDF::PDF_Version
& pdfVersion
) const;