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 libraries 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: StyleSheetMgr.C /main/8 1996/10/07 09:02:45 rcs $
26 * Copyright (c) 1992 HAL Computer Systems International, Ltd.
27 * All 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.
53 // NOTE: this is just for the Xassert
56 #define C_StyleSheetMgr
62 #include "oliasdb/locator_hd.h"
63 #include "oliasdb/stylesheet_hd.h"
64 #include "StyleSheet/StyleSheet.h"
65 #include "StyleSheet/StyleSheetExceptions.h"
67 LONG_LIVED_CC(StyleSheetMgr,style_sheet_mgr);
69 // set to true when we are updating only for purposes of changed style sheet
70 bool g_style_sheet_update = FALSE ;
73 // Silly hack. There should be a routine that wraps styleparse and
74 // takes an istream * as an arg.
76 extern istream *g_stylein;
79 // Another silly hack.
82 extern int styleparse();
83 extern void stylerestart(FILE *);
86 StyleSheetMgr::StyleSheetMgr(): fLastSS(0), fCurrent(0), fStyleSheetRead(0) {
89 StyleSheetMgr::~StyleSheetMgr()
97 StyleSheetMgr::font_preference_modified()
100 // 12/27/95 - this is no longer needed because we are not doing live
101 // updates to the nodes when font scale changes. Instead, the font
102 // scale is only updated when a new node is displayed. This is
103 // managed by having NodeMgr create a CanvasRenderer and passing in
104 // the current font scale value
107 g_style_sheet_update = TRUE;
108 // load new style sheet
109 node_mgr().re_display_all();
110 g_style_sheet_update = FALSE;
114 Xassert(0 == "StyleSheetMgr::font_preference_modified()");
115 g_style_sheet_update = FALSE ;
123 // SWM: Note: This is my plagarism of the code that exists
124 // in Doc/Node_mmdb.C. I'm trying to not have any mmdb
125 // dependencies here. However, the style sheet parsing routines
126 // exist today in the mmdb, so they'll have to be moved soon.
129 StyleSheetMgr::initOnlineStyleSheet (UAS_Pointer<UAS_Common> &doc) {
130 UAS_List<UAS_StyleSheet> ssList = doc->style_sheet_list ();
131 UAS_Pointer<UAS_StyleSheet> onlineSS;
132 for (unsigned int i = 0; i < ssList.length(); i ++) {
133 if (ssList[i]->style_sheet_type() == SS_ONLINE) {
134 onlineSS = ssList[i];
139 // SWM -- THROW EXCEPTION HERE OR USE A DEFAULT SS.
141 if ((fLastSS == onlineSS) &&
142 (fLastSS->style_sheet_type() == onlineSS->style_sheet_type())) {
148 fCurrent = new StyleSheet;
149 UAS_String sstextStr = fLastSS->data();
150 istringstream input ((char *) sstextStr);
152 #ifdef DUMP_STYLESHEETS
154 ofstream output("stylesheet.dmp");
155 output << (char *) sstextStr;
166 mcatch_noarg (StyleSheetSyntaxError&) {
169 { // Don't remove these curlies. For destructors before rethrow
170 fCurrent = new StyleSheet;
172 "* { wrap: \"word\", break: \"line\", margin: { left: 20, right: 20} }";
173 istringstream definput(def);
174 input.unsetf (ios::skipws);
175 g_stylein = &definput;
184 // rcs: Note: This is my plagarism of the above code for print.
187 StyleSheetMgr::initPrintStyleSheet (UAS_Pointer<UAS_Common> &doc) {
188 UAS_List<UAS_StyleSheet> ssList = doc->style_sheet_list ();
189 UAS_Pointer<UAS_StyleSheet> printSS;
190 for (unsigned int i = 0; i < ssList.length(); i ++) {
191 if (ssList[i]->style_sheet_type() == SS_HARDCOPY) {
197 // SWM -- THROW EXCEPTION HERE OR USE A DEFAULT SS.
199 if ((fLastSS == printSS) &&
200 (fLastSS->style_sheet_type() == printSS->style_sheet_type())) {
206 fCurrent = new StyleSheet;
207 UAS_String sstextStr = fLastSS->data();
208 istringstream input ((char *) sstextStr);
210 #ifdef DUMP_STYLESHEETS
212 ofstream output("stylesheet.dmp");
213 output << (char *) sstextStr;
224 mcatch_noarg (StyleSheetSyntaxError&) {
227 { // Don't remove these curlies. For destructors before rethrow
228 fCurrent = new StyleSheet;
230 "* { wrap: \"word\", break: \"line\", margin: { left: 20, right: 20} }";
231 istringstream definput(def);
232 input.unsetf (ios::skipws);
233 g_stylein = &definput;