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
19 #include "pdfversion.h"
20 #include "shapesexceptions.h"
24 using namespace SimplePDF
;
26 SimplePDF::PDF_Version::PDF_Version( )
27 : version_( SimplePDF::PDF_Version::PDF_1_4
),
28 maxRequestVersion_( SimplePDF::PDF_Version::PDF_1_1
),
29 versionAction_( SimplePDF::PDF_Version::WARN
)
33 SimplePDF::PDF_Version::setVersion( Version version
)
39 SimplePDF::PDF_Version::setAction( Action action
)
41 versionAction_
= action
;
45 SimplePDF::PDF_Version::greaterOrEqual( Version required
, bool justCurious
)
49 maxRequestVersion_
= std::max( maxRequestVersion_
, required
);
51 return version_
>= required
;
55 SimplePDF::PDF_Version::greaterOrEqualOrX( Version required
, bool justCurious
)
59 maxRequestVersion_
= std::max( maxRequestVersion_
, required
);
61 return version_
>= required
|| version_
== PDF_X
;
65 SimplePDF::PDF_Version::maxRequestVersionString( ) const
67 if( version_
== PDF_X
)
69 return toString( PDF_X
);
71 return toString( maxRequestVersion_
);
75 SimplePDF::PDF_Version::message( Version required
, const char * message
) const
77 using namespace Shapes
;
79 switch( versionAction_
)
82 throw Exceptions::PDFVersionError( version_
, required
, message
);
85 std::cerr
<< toString( version_
) << " warning: " << message
<< std::endl
;
91 throw Exceptions::InternalError( "PDF_out versionAction_ out of range." );
96 SimplePDF::PDF_Version::toString( SimplePDF::PDF_Version::Version version
)
115 throw Shapes::Exceptions::InternalError( "PDF version out of range." );