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 "SimplePDF_decls.h"
22 #include "Shapes_Lang_decls.h"
23 #include "Shapes_Kernel_decls.h"
25 #include "shapestypes.h"
45 Ast::SourceLocation loc_
;
46 RequestLocation( bool literal
, const Ast::SourceLocation
& loc
)
47 : literal_( literal
), loc_( loc
)
51 std::set
< std::string
> allRequests
;
52 std::map
< std::string
, RequestLocation
> currentRequests
;
55 typedef std::map
< std::string
, RefCountPtr
< const Lang::XObject
> > MapType
;
57 MapType availableLabels
;
61 std::string inDir_
; /* Absolute path. Change to this directory before running pdfLaTeX! */
62 std::string tmpDir_
; /* Absolute path. Specify this as -output-directory when running pdfLaTeX! */
63 std::string texJobName_
; /* This is the jobname without the directory part. */
66 std::string
stringWithJobNumber( const std::string
& str
, bool withDirectory
= true ) const;
68 std::string documentclass
;
69 std::list
< std::string
> documentoptions
;
72 std::ostringstream preamble
;
73 std::ostringstream documentTop
;
76 std::string setupCode
;
77 std::string setupCodeHash
;
83 void setup( const std::string
& inDir
, const std::string
& tmpDir
, const std::string
& texJobName
);
85 void announce( const std::string
& str
, const Ast::SourceLocation
& loc
);
86 RefCountPtr
< const Lang::Value
> request( const std::string
& str
, const Ast::SourceLocation
& loc
, Kernel::PassedDyn dyn
);
88 void iterativeStartup( RefCountPtr
< std::istream
> labelsFile
);
89 void iterativeFinish( const std::string
& labelDBFilename
);
91 void setDocumentClass( const Ast::SourceLocation
& loc
, const char * str
);
92 void addDocumentOption( const Ast::SourceLocation
& loc
, const char * str
);
93 void setlmodernT1( const Ast::SourceLocation
& loc
, bool val
);
94 void setutf8( const Ast::SourceLocation
& loc
, bool val
);
95 void addPreambleLine( const Ast::SourceLocation
& loc
, const char * line
);
96 void addDocumentTopLine( const Ast::SourceLocation
& loc
, const char * line
);
99 void assertNotSetupFinalized( const Ast::SourceLocation
& loc
) const;
100 void processRequests( );
101 void loadLabels( RefCountPtr
< std::istream
> labelsFile
);
102 static std::string
safeSourceHash( const std::string
& str
);
103 void compileSetupCode( );
104 static bool isAllBlank( const char * str
);
105 void assertBalanced( const std::string
& str
, const RequestLocation
& loc
) const;
106 void parseTeXErrors( std::istream
& interaction
);