pdf_obj.cpp

来自「ncbi源码」· C++ 代码 · 共 341 行

CPP
341
字号
/* * =========================================================================== * PRODUCTION $Log: pdf_obj.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 21:03:43  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * PRODUCTION * =========================================================================== *//*  $Id: pdf_obj.cpp,v 1000.1 2004/06/01 21:03:43 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: *   CPdfObj - Stream for output of Adobe PDF objects */#include <ncbi_pch.hpp>#include "pdf_obj.hpp"#include "pdf_object.hpp"#include "pdf_object_writer.hpp"#include <math.h>BEGIN_NCBI_SCOPECPdfObj::CPdfObj(const string& str) : m_Str(str){}CPdfObj::CPdfObj(){}CPdfObj::~CPdfObj(){}void CPdfObj::PrintTo(CNcbiOstream& stream) const{    stream << m_Str;}CPdfNumber::CPdfNumber(unsigned int i)    : m_Num(i),      m_Prec(0){}CPdfNumber::CPdfNumber(int i)    : m_Num(i),      m_Prec(0){}CPdfNumber::CPdfNumber(double d)    : m_Num(d),      m_Prec(6){}CPdfNumber::~CPdfNumber(){}void CPdfNumber::PrintTo(CNcbiOstream& stream) const{    stream << setiosflags(ios::fixed) << setprecision(m_Prec) << m_Num;}CPdfRotate::CPdfRotate(double angle) : m_Rot(angle){}CPdfRotate::~CPdfRotate(){}void CPdfRotate::PrintTo(CNcbiOstream& stream) const{    const double rad = m_Rot * 3.1415926535 / 180;    const double c = cos(rad);    const double s = sin(rad);    stream << setiosflags(ios::fixed) << c << ' ' << s << ' ' << -s << ' ' << c << " 0 0 cm";}CPdfTranslate::CPdfTranslate(double xoff, double yoff)    : m_XOff(xoff),      m_YOff(yoff),      m_Prec(6){}CPdfTranslate::CPdfTranslate(unsigned int xoff, unsigned int yoff)    : m_XOff(xoff),      m_YOff(yoff),      m_Prec(0){}CPdfTranslate::CPdfTranslate(int xoff, int yoff)    : m_XOff(xoff),      m_YOff(yoff),      m_Prec(0){}CPdfTranslate::~CPdfTranslate(){}void CPdfTranslate::PrintTo(CNcbiOstream& stream) const{    stream << "1 0 0 1 " << setiosflags(ios::fixed) << setprecision(m_Prec)           << m_XOff << ' ' << m_YOff << " cm";}CPdfString::CPdfString(const string& str) : CPdfObj(str){}CPdfString::~CPdfString(){}void CPdfString::PrintTo(CNcbiOstream& stream) const{    stream << '(' << m_Str << ')';}CPdfName::CPdfName(const string& str) : CPdfObj(str){}CPdfName::~CPdfName(){}void CPdfName::PrintTo(CNcbiOstream& stream) const{    stream << '/' << m_Str;}CPdfIndirectObj::CPdfIndirectObj(const CRef<CPdfObject>& obj) : m_Obj(obj){}CPdfIndirectObj::~CPdfIndirectObj(){}void CPdfIndirectObj::PrintTo(CNcbiOstream& stream) const{    stream << m_Obj->GetObjNum() << ' ' << m_Obj->GetGeneration() << " R";}CPdfArray::TArray& CPdfArray::GetArray(void){    return m_Array;}void CPdfArray::PrintTo(CNcbiOstream& stream) const{    if (m_Array.size() == 0) {        return;    }    stream << '[';    bool first = true;    ITERATE(vector<TPdfObjRef>, it, m_Array) {        if (first) {            first = false;        } else {            stream << ' ';        }        stream << **it;    }    stream << ']';}void CPdfArray::Add(const CRef<CPdfArray>& array){    m_Array.insert(m_Array.end(),                   array->m_Array.begin(), array->m_Array.end());/*    ITERATE(vector<TPdfObjRef>, it, array->m_Array) {        m_Array.push_back(*it);    }*/}CPdfDictionary::TPdfObjRef& CPdfDictionary::operator[](const string& key){    return m_Dict[key];}void CPdfDictionary::PrintTo(CNcbiOstream& stream) const{    if (m_Dict.size() == 0) {        return;    }    stream << "<<";    ITERATE(TDict, it, m_Dict) {        const CPdfObj* val = it->second.GetPointer();        bool insert_space = false;        if (dynamic_cast < const CPdfIndirectObj*>(val)  ||              dynamic_cast < const CPdfNumber*>(val)) {            insert_space = true;        }        stream << '/' << it->first;        if (insert_space) {            stream << ' ';        }        stream << *val;    }    stream << ">>";}void CPdfDictionary::Add(const CRef<CPdfDictionary>& dict){    //     // std::map::insert(beg, end) doesn't seem to work on MSVC++ 6.0.    // Iterate "manually" and copy each element instead.    //    //m_Dict.insert(dict->m_Dict.begin(), dict->m_Dict.end());    ITERATE(TDict, it, dict->m_Dict) {        m_Dict.insert(*it);    }}END_NCBI_SCOPE/* * =========================================================================== * $Log: pdf_obj.cpp,v $ * Revision 1000.1  2004/06/01 21:03:43  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * * Revision 1.9  2004/05/21 22:27:50  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.8  2003/08/11 19:27:35  dicuccio * Favor member insert to std::copy() * * Revision 1.7  2003/06/25 18:02:51  meric * Source rearrangement: move "private" headers into the src/ tree * * Revision 1.6  2003/06/24 15:43:26  meric * Added CPdfRotate and CPdfTranslate * Added CPdfArray::Add(...) * Added CPdfNumber ctors for [unsigned] int, set precision on output * * Revision 1.5  2003/06/18 17:25:39  meric * Final phase of print reorg: remove dependence on gui/opengl and OpenGL * * Revision 1.4  2003/06/18 16:40:33  meric * First phase of print reorg: remove dependence on gui/opengl and OpenGL * except for class COpenGLPrintBuffer * * Revision 1.3  2003/06/17 19:33:38  meric * Print Dictionary more concisely, on one line * * Revision 1.2  2003/06/16 12:44:52  dicuccio * Clean-up after initial commit * * Revision 1.1  2003 / 06 / 13 18:13:56  meric * Initial version * * * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?