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: 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.
52 // NOTE: this is just for the Xassert
55 #define C_StyleSheetMgr
61 #include "oliasdb/locator_hd.h"
62 #include "oliasdb/stylesheet_hd.h"
63 #include "StyleSheet/StyleSheet.h"
64 #include "StyleSheet/StyleSheetExceptions.h"
66 LONG_LIVED_CC(StyleSheetMgr,style_sheet_mgr);
68 // set to true when we are updating only for purposes of changed style sheet
69 bool g_style_sheet_update = FALSE ;
72 // Silly hack. There should be a routine that wraps styleparse and
73 // takes an istream * as an arg.
75 extern istream *g_stylein;
78 // Another silly hack.
81 extern int styleparse();
82 extern void stylerestart(FILE *);
85 StyleSheetMgr::StyleSheetMgr(): fLastSS(0), fCurrent(0), fStyleSheetRead(0) {
88 StyleSheetMgr::~StyleSheetMgr()
96 StyleSheetMgr::font_preference_modified()
99 // 12/27/95 - this is no longer needed because we are not doing live
100 // updates to the nodes when font scale changes. Instead, the font
101 // scale is only updated when a new node is displayed. This is
102 // managed by having NodeMgr create a CanvasRenderer and passing in
103 // the current font scale value
106 g_style_sheet_update = TRUE;
107 // load new style sheet
108 node_mgr().re_display_all();
109 g_style_sheet_update = FALSE;
113 Xassert(0 == "StyleSheetMgr::font_preference_modified()");
114 g_style_sheet_update = FALSE ;
122 // SWM: Note: This is my plagarism of the code that exists
123 // in Doc/Node_mmdb.C. I'm trying to not have any mmdb
124 // dependencies here. However, the style sheet parsing routines
125 // exist today in the mmdb, so they'll have to be moved soon.
128 StyleSheetMgr::initOnlineStyleSheet (UAS_Pointer<UAS_Common> &doc) {
129 UAS_List<UAS_StyleSheet> ssList = doc->style_sheet_list ();
130 UAS_Pointer<UAS_StyleSheet> onlineSS;
131 for (int i = 0; i < ssList.length(); i ++) {
132 if (ssList[i]->style_sheet_type() == SS_ONLINE) {
133 onlineSS = ssList[i];
138 // SWM -- THROW EXCEPTION HERE OR USE A DEFAULT SS.
140 if ((fLastSS == onlineSS) &&
141 (fLastSS->style_sheet_type() == onlineSS->style_sheet_type())) {
147 fCurrent = new StyleSheet;
148 UAS_String sstextStr = fLastSS->data();
149 istrstream input ((char *) sstextStr);
151 #ifdef DUMP_STYLESHEETS
153 ofstream output("stylesheet.dmp");
154 output << (char *) sstextStr;
165 catch_noarg (StyleSheetSyntaxError) {
168 { // Don't remove these curlies. For destructors before rethrow
169 fCurrent = new StyleSheet;
171 "* { wrap: \"word\", break: \"line\", margin: { left: 20, right: 20} }";
172 istrstream definput(def);
173 input.unsetf (ios::skipws);
174 g_stylein = &definput;
183 // rcs: Note: This is my plagarism of the above code for print.
186 StyleSheetMgr::initPrintStyleSheet (UAS_Pointer<UAS_Common> &doc) {
187 UAS_List<UAS_StyleSheet> ssList = doc->style_sheet_list ();
188 UAS_Pointer<UAS_StyleSheet> printSS;
189 for (int i = 0; i < ssList.length(); i ++) {
190 if (ssList[i]->style_sheet_type() == SS_HARDCOPY) {
196 // SWM -- THROW EXCEPTION HERE OR USE A DEFAULT SS.
198 if ((fLastSS == printSS) &&
199 (fLastSS->style_sheet_type() == printSS->style_sheet_type())) {
205 fCurrent = new StyleSheet;
206 UAS_String sstextStr = fLastSS->data();
207 istrstream input ((char *) sstextStr);
209 #ifdef DUMP_STYLESHEETS
211 ofstream output("stylesheet.dmp");
212 output << (char *) sstextStr;
223 catch_noarg (StyleSheetSyntaxError) {
226 { // Don't remove these curlies. For destructors before rethrow
227 fCurrent = new StyleSheet;
229 "* { wrap: \"word\", break: \"line\", margin: { left: 20, right: 20} }";
230 istrstream definput(def);
231 input.unsetf (ios::skipws);
232 g_stylein = &definput;