2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: PrintMgr.C /main/15 1996/12/06 14:41:31 rcs $
26 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
27 * All $(MISC_LIB)rights reserved. Unpublished -- rights reserved under
28 * the Copyright Laws of the United States. USE OF A COPYRIGHT
29 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
32 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
34 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
38 * RESTRICTED RIGHTS LEGEND
39 * Use, duplication, or disclosure by the Government is subject
40 * to the restrictions as set forth in subparagraph (c)(l)(ii)
41 * of the Rights in Technical Data and Computer Software clause
42 * at DFARS 252.227-7013.
44 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
56 #define C_NodeViewInfo
59 #define C_PrintPanelAgent
60 #define C_NodePrintAgent
66 #define C_NodeWindowMgr
67 #define C_StyleSheetMgr
74 #include "Managers/CatMgr.hh"
75 #include "Registration.hh"
77 #include "DocParser.h"
79 #include "StyleSheet.h"
80 #include "StyleSheetExceptions.h"
81 #include "../OnlineRender/CanvasRenderer.hh"
84 # define RCS_DEBUG(statement) cerr << statement << endl
86 # define RCS_DEBUG(statement)
89 extern "C" { const char *unique_id(void); }
91 LONG_LIVED_CC(PrintMgr,print_mgr);
93 class PrintNode : public UAS_Receiver<UAS_DocumentRetrievedMsg>
98 UAS_Common::request ((UAS_Receiver<UAS_DocumentRetrievedMsg> *) this);
101 void receive(UAS_DocumentRetrievedMsg &message, void *client_data);
105 PrintNode::receive (UAS_DocumentRetrievedMsg &message, void *client_data)
107 RCS_DEBUG("PrintNode::receive called.");
109 size_t cd = (size_t)client_data;
111 // 1 == print request
113 print_mgr().print(message.fDoc);
116 RCS_DEBUG("PrintNode::receive exiting -- not a print request.");
120 RCS_DEBUG("PrintNode::receive exiting.");
124 static PrintNode node_printer;
126 // /////////////////////////////////////////////////////////////////
128 // /////////////////////////////////////////////////////////////////
131 : f_print_panel(NULL), f_npa(NULL), f_font_scale(0)
133 RCS_DEBUG("PrintMgr::PrintMgr called.");
134 set_font_scale(pref_mgr().get_int(PrefMgr::FontScale));
135 RCS_DEBUG("PrintMgr::PrintMgr exiting.");
138 // /////////////////////////////////////////////////////////////////
139 // print - Just do it.
140 // /////////////////////////////////////////////////////////////////
144 PrintMgr::print(UAS_Pointer<UAS_Common> &node_ptr)
147 f_last_printed = node_ptr;
149 RCS_DEBUG("PrintMgr::print called.");
152 f_npa = new NodePrintAgent();
155 f_npa->display(node_ptr);
157 RCS_DEBUG("PrintMgr::print exiting.");
162 * ------------------------------------------------------------------------
163 * Name: PrintMgr::destroy_agent
167 * Deletes the print agent so that the next print doesn't hang.
171 PrintMgr::destroy_agent()
173 RCS_DEBUG("PrintMgr::destroy_agent called.");
178 RCS_DEBUG("PrintMgr::destroy_agent exiting.");
182 PrintMgr::set_font_scale(int value)
184 int real_value = value * 2 ;
185 if (real_value < - MIN_DOWNSCALE) {
186 real_value = - MIN_DOWNSCALE ;
189 int change_amount = real_value - f_font_scale ;
190 if (change_amount == 0) {
194 // save the new font scale
195 f_font_scale = real_value ;
202 PrintMgr::load(UAS_Pointer<UAS_Common> &node_ptr)
204 static int first = 0;
206 extern int styleparse();
207 extern void stylerestart(FILE *);
208 extern NodeViewInfo *gNodeViewInfo;
212 style_sheet_mgr().initPrintStyleSheet(node_ptr);
214 mcatch_noarg (StyleSheetSyntaxError)
216 message_mgr().error_dialog(
217 (char*)UAS_String(CATGETS(Set_Messages, 39,
218 "There is an error in the Style Sheet for this Section.\nDefault features have been applied.")
223 istringstream input((char *) node_ptr->data());
227 window_system().setPrinting(True);
228 // assign node_ptr to global variable that TmlRenderer can pick up
229 gNodeViewInfo = new NodeViewInfo(node_ptr);
230 CanvasRenderer renderer (pref_mgr().get_int(PrefMgr::FontScale)) ;
231 Resolver resolver(*gPathTab, renderer);
232 DocParser docparser(resolver);
233 docparser.parse(input);
234 window_system().setPrinting(False);
238 ON_DEBUG(cerr << "PrintMgr::load...exception thrown" << endl);
239 delete gNodeViewInfo ;
245 // TmlRenderer set this up for us
246 return gNodeViewInfo ;