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
23 /* $XConsortium: HardCopyFP.h /main/3 1996/06/11 17:04:22 cde-hal $ */
29 #include "FPExceptions.h"
30 #include "StyleSheet/Feature.h"
31 #include "StyleSheet/FeatureValue.h"
32 #include "StyleSheet/Element.h"
33 #include "StyleSheet/Const.h"
34 #include "StyleSheet/Debug.h"
36 enum BLOCK_MODE { NON_BLOCK, BLOCK };
37 extern enum BLOCK_MODE g_block_mode;
39 class featureProcessor : public Destructable
45 virtual const char* stringToCharPtr(const FeatureValue*) = 0;
46 virtual unsigned int dimensionToFloat(float& Y,
47 FeatureValueDimension::Unit& UnitOfY,
49 FeatureValueDimension::Unit) = 0;
50 virtual const char* dimensionToCharPtr(const FeatureValue*,
51 FeatureValueDimension::Unit) = 0;
53 // turn to Hard Copy engine specific literal
54 virtual const char* convertToLiteral(const char* str) = 0;
57 featureProcessor(featureProcessor& x): f_name(x.f_name) {};
58 featureProcessor(const char* name): f_name(name) {};
59 virtual ~featureProcessor() {};
61 virtual featureProcessor* clone() = 0;
63 virtual void handleBegElement(const Element &element, const FeatureSet&, const FeatureSet&, const FeatureSet&, const FeatureSet& initialFeatureSet, ostream&) = 0;
64 virtual void handleEndElement(ostream&) = 0;
65 virtual void handleData(const char *data, unsigned int size, ostream&)=0;
67 const char* name() { return f_name; };
69 // evaluate the variable (in x.y.z form) to a feature value.
70 virtual FeatureValue* evaluate(const char* variableName) = 0;
71 virtual unsigned int accept(const char* nm, const Expression*) = 0;
73 virtual void preEvaluate(const Element&) = 0;
74 virtual void postEvaluate(const Element&) = 0;
76 virtual void clear() = 0;
78 ////////////////////////////////////////
79 // functions for getting feature values.
83 // if ( getFeatureValue(x, FeatureSet.deep_lookup(FONT, FONT_SIZE)) ) {
86 ////////////////////////////////////////
89 // default value (NONE) means using whatever unit is available
90 // Otherwise, a conversion is performed
92 unsigned int getDimensionValue(float& y,
94 FeatureValueDimension::Unit = FeatureValueDimension::NONE);
96 const char *getDimensionValue(const Feature*,
97 FeatureValueDimension::Unit = FeatureValueDimension::NONE);
99 const char *getFeatureValue(const Feature*);
100 unsigned int getFeatureValue(int&, const Feature*);
101 unsigned int getFeatureValue(float&, const Feature*);
102 FeatureValueArray* getFeatureValueArray(const Feature*);
104 const FeatureSet *getFeatureSetValue(const Feature*);
107 typedef featureProcessor* featureProcessorPtr;
109 class loutFeatureProcessor : public featureProcessor
112 unsigned int f_change;
115 char* empty_string();
116 char* prepend(const char*, const char*);
118 // turn to Hard Copy engine specific literal
119 const char* convertToLiteral(const char* str);
122 loutFeatureProcessor(loutFeatureProcessor& x) :
123 f_change(x.f_change), featureProcessor(x) {};
125 loutFeatureProcessor(const char* name) :
126 featureProcessor(name), f_change(false) {};
127 ~loutFeatureProcessor() {};
129 virtual void handleEndElement(ostream& out) {
130 if ( f_change == true )
133 virtual void handleData(const char *data, unsigned int size, ostream&);
135 const char* stringToCharPtr(const FeatureValue*);
136 unsigned int dimensionToFloat(float&,
137 FeatureValueDimension::Unit& unitOfY,
139 FeatureValueDimension::Unit);
140 const char* dimensionToCharPtr(const FeatureValue*,
141 FeatureValueDimension::Unit);
143 virtual FeatureValue* evaluate(const char* variableName) ;
144 virtual unsigned int accept(const char* nm, const Expression*) ;
146 virtual void preEvaluate(const Element&) ;
147 virtual void postEvaluate(const Element&) ;
149 virtual void clear() ;