2
0

HardCopyFP.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  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)
  10. * any later version.
  11. *
  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
  16. * details.
  17. *
  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
  22. */
  23. /* $XConsortium: HardCopyFP.h /main/3 1996/06/11 17:04:22 cde-hal $ */
  24. #ifndef _fp_h
  25. #define _fp_h 1
  26. #include <iostream>
  27. using namespace std;
  28. #include "FPExceptions.h"
  29. #include "StyleSheet/Feature.h"
  30. #include "StyleSheet/FeatureValue.h"
  31. #include "StyleSheet/Element.h"
  32. #include "StyleSheet/Const.h"
  33. #include "StyleSheet/Debug.h"
  34. #include "utility/funcs.h"
  35. enum BLOCK_MODE { NON_BLOCK, BLOCK };
  36. extern enum BLOCK_MODE g_block_mode;
  37. class featureProcessor : public Destructable
  38. {
  39. protected:
  40. const char* f_name;
  41. virtual const char* stringToCharPtr(const FeatureValue*) = 0;
  42. virtual unsigned int dimensionToFloat(float& Y,
  43. FeatureValueDimension::Unit& UnitOfY,
  44. const FeatureValue*,
  45. FeatureValueDimension::Unit) = 0;
  46. virtual const char* dimensionToCharPtr(const FeatureValue*,
  47. FeatureValueDimension::Unit) = 0;
  48. // turn to Hard Copy engine specific literal
  49. virtual const char* convertToLiteral(const char* str) = 0;
  50. public:
  51. featureProcessor(featureProcessor& x): f_name(x.f_name) {};
  52. featureProcessor(const char* name): f_name(name) {};
  53. virtual ~featureProcessor() {};
  54. virtual featureProcessor* clone() = 0;
  55. virtual void handleBegElement(const Element &element, const FeatureSet&, const FeatureSet&, const FeatureSet&, const FeatureSet& initialFeatureSet, ostream&) = 0;
  56. virtual void handleEndElement(ostream&) = 0;
  57. virtual void handleData(const char *data, unsigned int size, ostream&)=0;
  58. const char* name() { return f_name; };
  59. // evaluate the variable (in x.y.z form) to a feature value.
  60. virtual FeatureValue* evaluate(const char* variableName) = 0;
  61. virtual unsigned int accept(const char* nm, const Expression*) = 0;
  62. virtual void preEvaluate(const Element&) = 0;
  63. virtual void postEvaluate(const Element&) = 0;
  64. virtual void clear() = 0;
  65. ////////////////////////////////////////
  66. // functions for getting feature values.
  67. //
  68. // Sample usage:
  69. // int x;
  70. // if ( getFeatureValue(x, FeatureSet.deep_lookup(FONT, FONT_SIZE)) ) {
  71. // //use x here
  72. // }
  73. ////////////////////////////////////////
  74. //
  75. // default value (NONE) means using whatever unit is available
  76. // Otherwise, a conversion is performed
  77. //
  78. unsigned int getDimensionValue(float& y,
  79. const Feature*,
  80. FeatureValueDimension::Unit = FeatureValueDimension::NONE);
  81. const char *getDimensionValue(const Feature*,
  82. FeatureValueDimension::Unit = FeatureValueDimension::NONE);
  83. const char *getFeatureValue(const Feature*);
  84. unsigned int getFeatureValue(int&, const Feature*);
  85. unsigned int getFeatureValue(float&, const Feature*);
  86. FeatureValueArray* getFeatureValueArray(const Feature*);
  87. const FeatureSet *getFeatureSetValue(const Feature*);
  88. };
  89. typedef featureProcessor* featureProcessorPtr;
  90. class loutFeatureProcessor : public featureProcessor
  91. {
  92. protected:
  93. unsigned int f_change;
  94. protected:
  95. char* empty_string();
  96. char* prepend(const char*, const char*);
  97. // turn to Hard Copy engine specific literal
  98. const char* convertToLiteral(const char* str);
  99. public:
  100. loutFeatureProcessor(loutFeatureProcessor& x) :
  101. featureProcessor(x), f_change(x.f_change) {};
  102. loutFeatureProcessor(const char* name) :
  103. featureProcessor(name), f_change(false) {};
  104. ~loutFeatureProcessor() {};
  105. virtual void handleEndElement(ostream& out) {
  106. if ( f_change == true )
  107. out << "}";
  108. };
  109. virtual void handleData(const char *data, unsigned int size, ostream&);
  110. const char* stringToCharPtr(const FeatureValue*);
  111. unsigned int dimensionToFloat(float&,
  112. FeatureValueDimension::Unit& unitOfY,
  113. const FeatureValue*,
  114. FeatureValueDimension::Unit);
  115. const char* dimensionToCharPtr(const FeatureValue*,
  116. FeatureValueDimension::Unit);
  117. virtual FeatureValue* evaluate(const char* variableName) ;
  118. virtual unsigned int accept(const char* nm, const Expression*) ;
  119. virtual void preEvaluate(const Element&) ;
  120. virtual void postEvaluate(const Element&) ;
  121. virtual void clear() ;
  122. };
  123. #endif