print.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:4k
- /*
- * ===========================================================================
- * PRODUCTION $Log: print.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:03:53 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: print.cpp,v 1000.1 2004/06/01 21:03:53 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software / database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software / database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Peter Meric
- *
- * File Description:
- * Encapsulation of printing functionality
- */
- #include <ncbi_pch.hpp>
- #include <gui/print/print.hpp>
- #include <gui/utils/app_popup.hpp>
- #include <gui/print/print_context.hpp>
- #include <gui/print/print_options.hpp>
- #include <gui/print/pdf.hpp>
- #include <gui/print/postscript.hpp>
- #include <gui/print/vector_output.hpp>
- #include "pdf_object.hpp"
- #include "pdf_object_writer.hpp"
- #include "page_handler.hpp"
- #include "page_buffers.hpp"
- BEGIN_NCBI_SCOPE
- template <typename T>
- void s_PrintContextTmpl(const CPrintOptions& opts,
- const CPrintContext& print_context
- )
- {
- const string& fname = opts.GetFilename();
- if (fname.empty()) {
- return;
- }
- CNcbiOfstream ostr(fname.c_str(), ios::binary);
- CVectorOutput<T> output;
- output.SetOptions(opts);
- output.SetOutputStream(&ostr);
- output.BeginDocument();
- output.PrintPage(&print_context);
- output.EndDocument();
- }
- void PrintContext(const CPrintContext& ctx, const CPrintOptions& opts)
- {
- switch (opts.GetOutputFormat()) {
- case CPrintOptions::ePostscript:
- LOG_POST(Info << "Postscript output deprecated: please use PDF");
- s_PrintContextTmpl<CPostscript>(opts, ctx);
- break;
- case CPrintOptions::ePdf:
- s_PrintContextTmpl<CPdf>(opts, ctx);
- if (opts.GetPrintOutput()) {
- CAppPopup::PopupFile(opts.GetFilename(), filetype::ePdf);
- }
- break;
- case CPrintOptions::eSvg:
- LOG_POST(Info << "SVG output not implemented yet");
- break;
- case CPrintOptions::ePng:
- LOG_POST(Info << "PNG output not implemented yet");
- break;
- default:
- _TRACE("output format not understood: " << opts.GetOutputFormat());
- break;
- }
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: print.cpp,v $
- * Revision 1000.1 2004/06/01 21:03:53 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4
- *
- * Revision 1.4 2004/05/21 22:27:50 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.3 2003/08/15 17:02:16 meric
- * Updates include paths for print-related files from gui/utils to gui/print
- *
- * Revision 1.2 2003/06/25 18:02:51 meric
- * Source rearrangement: move "private" headers into the src/ tree
- *
- * Revision 1.1 2003/06/25 16:25:29 meric
- * Initial version
- *
- *
- * ===========================================================================
- */