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, 2010 Henrik Tidefelt
19 #include "pdfversion.h"
20 #include "shapesexceptions.h"
25 using namespace SimplePDF
;
27 SimplePDF::PDF_Version::PDF_Version( )
28 : version_( SimplePDF::PDF_Version::PDF_1_4
),
29 maxRequestVersion_( SimplePDF::PDF_Version::PDF_1_1
),
30 versionAction_( SimplePDF::PDF_Version::WARN
)
34 SimplePDF::PDF_Version::setVersion( Version version
)
40 SimplePDF::PDF_Version::setAction( Action action
)
42 versionAction_
= action
;
46 SimplePDF::PDF_Version::greaterOrEqual( Version required
, bool justCurious
)
50 maxRequestVersion_
= std::max( maxRequestVersion_
, required
);
52 return version_
>= required
;
56 SimplePDF::PDF_Version::greaterOrEqualOrX( Version required
, bool justCurious
)
60 maxRequestVersion_
= std::max( maxRequestVersion_
, required
);
62 return version_
>= required
|| version_
== PDF_X
;
66 SimplePDF::PDF_Version::maxRequestVersionString( ) const
68 if( version_
== PDF_X
)
70 return toString( PDF_X
);
72 return toString( maxRequestVersion_
);
76 SimplePDF::PDF_Version::message( Version required
, const char * message
) const
78 using namespace Shapes
;
80 switch( versionAction_
)
83 throw Exceptions::PDFVersionError( version_
, required
, message
);
86 WARN_OR_THROW( Exceptions::PDFVersionError( version_
, required
, message
, true ) );
92 throw Exceptions::InternalError( "PDF_out versionAction_ out of range." );
97 SimplePDF::PDF_Version::toString( SimplePDF::PDF_Version::Version version
)
116 throw Shapes::Exceptions::InternalError( "PDF version out of range." );