/* drvMIF.c : This file is part of pstoedit Backend for Framemaker(TM) MIF format Copyright (C) 1993,1994,1995,1996 Wolfgang Glunz, Wolfgang.Glunz@zfe.siemens.de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "drvmif.h" #include #include #include static const char * colorstring(float r, float g, float b) { static char buffer[15]; sprintf(buffer,"R%.3dG%.3dB%.3d", (int) (r * 255), (int) ( g * 255) , (int) (b * 255)); return buffer; } static ColorTable colorTable(0,0,colorstring); static void writeColorCatEntry(ostream & out, float r, float g, float b) { // all ColorCatEntries are written directly to the output file. // the other stuff is written to the buffer if (!colorTable.isKnownColor(r,g,b)) { // color not known so far int cyan = (int) (100 * (1.0 - r)) ; int magenta = (int) (100 * (1.0 - g)) ; int yellow = (int) (100 * (1.0 - b)) ; //int black = ((cyan + magenta + yellow) == 300 ) ? 100 : 0; // black 0 if not black int black = 0; // remember, getColorString registers the new color out << " " << "" << "" << "" << "" << ">" << endl; } } drvMIF::drvMIF(ostream & theoutStream): drvbase(theoutStream,0,0,0), buffer(tempFile.asOutput()) { outf << "\n"; outf << "\n"; outf << "\n";// end of ColorCatalog ifstream & inbuffer = tempFile.asInput(); copy_file(inbuffer,outf); } void drvMIF::print_coords() { for (unsigned int n = 0; n < numberOfElementsInPath(); n++) { const Point & p = pathElement(n).getPoint(0); buffer <<" " << endl; } } void drvMIF::close_page() { buffer << "> # end of Frame\n"; buffer << "> # end of Page\n"; } static const int Fill = 0; // solid fill static const int noFill = 15; // no fill void drvMIF::open_page() { buffer << "\n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << "\n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; } void drvMIF::show_text(const TextInfo & textinfo) { const char * start_of_text = textinfo.thetext; buffer << " \n"; buffer << " \n"; buffer << " " << endl; buffer << " \n"; buffer << " \n"; buffer << "# currentFontFamilyName: " << textinfo.currentFontFamilyName << endl; buffer << "# currentFontFullName: " << textinfo.currentFontFullName << endl; buffer << "# currentFontName: " << textinfo.currentFontName << endl; buffer << " \n"; buffer << " "<< endl; if ( (strstr(textinfo.currentFontName,"Italic") != NULL) || (strstr(textinfo.currentFontName,"Oblique") != NULL)) { buffer << " \n"; } else { buffer << " \n"; } buffer << " \n" ; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; buffer << " \n"; writeColorCatEntry(outf,textinfo.currentR,textinfo.currentG,textinfo.currentB); buffer << " "; buffer << "\n" << endl; buffer << " > # end of Font\n"; buffer << " ') { buffer << "\\"; } buffer << *start_of_text; start_of_text++; } buffer << "'>\n"; buffer << " > # end of TextLine\n"; } void drvMIF::show_path() { if (isPolygon()) { numberOfElementsInPath()--; // MIF does not need end=start buffer << "\n"; if (currentShowType() == drvbase::stroke) { buffer << " \n"; } else { buffer << " \n"; } buffer << " \n"; buffer << " \n"; writeColorCatEntry(outf,currentR(),currentG(),currentB()) ; buffer << " "; buffer << "\n" << endl; print_coords(); buffer << "> # end of Polygon\n"; numberOfElementsInPath()++; // restore old value for proper cleanup } else { buffer << "\n"; if (currentShowType() == drvbase::stroke) { buffer << " \n"; } else { buffer << " \n"; } buffer << " \n"; buffer << " \n"; writeColorCatEntry(outf,currentR(),currentG(),currentB()) ; buffer << " "; buffer << endl; print_coords(); buffer << "> # end of PolyLine\n"; } } void drvMIF::show_rectangle(const float llx, const float lly, const float urx, const float ury) { buffer << "\n"; } else { buffer << " \n"; } buffer << " \n"; buffer << " \n"; writeColorCatEntry(outf,currentR(),currentG(),currentB()) ; buffer << " "; buffer << "\n" << endl; buffer << " \n> # end of Rectangle\n"; }