DtMmdb: move to lib directory as a standalone library.
This commit is contained in:
43
cde/lib/DtMmdb/HardCopy/FPExceptions.h
Normal file
43
cde/lib/DtMmdb/HardCopy/FPExceptions.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $TOG: FPExceptions.h /main/4 1998/04/17 11:46:25 mgreess $ */
|
||||
|
||||
|
||||
#ifndef _FPExceptions_h
|
||||
#define _FPExceptions_h
|
||||
|
||||
#include "dti_excs/Exceptions.hh"
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
class hardCopyRendererException : public Exception
|
||||
{
|
||||
public:
|
||||
DECLARE_EXCEPTION(hardCopyRendererException, Exception)
|
||||
};
|
||||
|
||||
#define CASTHCREXCEPT
|
||||
|
||||
#endif /* _FPExceptions_h */
|
||||
/* DO NOT ADD ANY LINES AFTER THIS #endif */
|
||||
51
cde/lib/DtMmdb/HardCopy/FPset.C
Normal file
51
cde/lib/DtMmdb/HardCopy/FPset.C
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $TOG: FPset.C /main/4 1998/04/17 11:46:42 mgreess $
|
||||
|
||||
#include "HardCopy/FPset.h"
|
||||
|
||||
FPset::FPset(int s, const Element& element,
|
||||
const FeatureSet& local,
|
||||
const FeatureSet& complete,
|
||||
const FeatureSet& parent) :
|
||||
ptrs(0), count(s), f_QuaddingString(0),
|
||||
f_element(&element),
|
||||
f_local(&local),
|
||||
f_complete(&complete),
|
||||
f_parent(&parent)
|
||||
{
|
||||
ptrs = new featureProcessorPtr[count];
|
||||
}
|
||||
|
||||
unsigned int FPset::operator==(const FPset&)
|
||||
{
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
return 1;
|
||||
}
|
||||
|
||||
FPset::~FPset()
|
||||
{
|
||||
for (int i=0; i<count; i++ )
|
||||
delete ptrs[i];
|
||||
delete ptrs;
|
||||
}
|
||||
66
cde/lib/DtMmdb/HardCopy/FPset.h
Normal file
66
cde/lib/DtMmdb/HardCopy/FPset.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: FPset.h /main/3 1996/06/11 17:04:12 cde-hal $ */
|
||||
|
||||
#ifndef _FPset_h
|
||||
#define _FPset_h
|
||||
|
||||
#include "StyleSheet/Renderer.h"
|
||||
#include "StyleSheet/Const.h"
|
||||
#include "StyleSheet/Element.h"
|
||||
|
||||
#include "HardCopy/FPExceptions.h"
|
||||
#include "HardCopy/HardCopyFP.h"
|
||||
#include "HardCopy/lout_limits.h"
|
||||
|
||||
class FPset
|
||||
{
|
||||
public:
|
||||
/*
|
||||
FPset(const FPset& fps) : ptrs(fps.ptrs), count(fps.count), f_QuaddingString(0) {};
|
||||
FPset(featureProcessorPtr* p, int s) : ptrs(p), count(s), f_QuaddingString(0) {};
|
||||
*/
|
||||
FPset(int s, const Element&, const FeatureSet&,
|
||||
const FeatureSet&, const FeatureSet&);
|
||||
~FPset();
|
||||
|
||||
const Element& element() { return *f_element; };
|
||||
const FeatureSet& local() { return *f_local; };
|
||||
const FeatureSet& complete() { return *f_complete; };
|
||||
const FeatureSet& parent() { return *f_parent; };
|
||||
|
||||
FPset operator=(const FPset&);
|
||||
unsigned int operator==(const FPset&);
|
||||
|
||||
featureProcessorPtr* ptrs;
|
||||
int count;
|
||||
|
||||
const char* f_QuaddingString;
|
||||
|
||||
const Element* f_element;
|
||||
const FeatureSet* f_local;
|
||||
const FeatureSet* f_complete;
|
||||
const FeatureSet* f_parent;
|
||||
};
|
||||
|
||||
#endif
|
||||
283
cde/lib/DtMmdb/HardCopy/HardCopyFP.C
Normal file
283
cde/lib/DtMmdb/HardCopy/HardCopyFP.C
Normal file
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $TOG: HardCopyFP.C /main/4 1998/04/17 11:46:58 mgreess $
|
||||
|
||||
|
||||
#include "HardCopyFP.h"
|
||||
|
||||
char* loutFeatureProcessor::empty_string()
|
||||
{
|
||||
char* x = new char[1]; x[0] = 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
char*
|
||||
loutFeatureProcessor::prepend(const char* header, const char* body)
|
||||
{
|
||||
int hlen = strlen(header);
|
||||
int blen = strlen(body);
|
||||
|
||||
char* x = new char[hlen + blen + 1];
|
||||
|
||||
*((char *) memcpy (x, header, hlen) + hlen) = '\0';
|
||||
*((char *) memcpy (x + hlen, body, blen) + blen) = '\0';
|
||||
return x;
|
||||
}
|
||||
|
||||
void
|
||||
loutFeatureProcessor::handleData(const char *data, unsigned int size, ostream& out)
|
||||
{
|
||||
for (unsigned int i=0; i<size; i++ )
|
||||
out << data[i];
|
||||
}
|
||||
|
||||
char* literalBuffer = new char[1024];
|
||||
int literalBufferSize = 1024;
|
||||
|
||||
const char* loutFeatureProcessor::convertToLiteral(const char* str)
|
||||
{
|
||||
int size = strlen(str);
|
||||
for (int i=0; i<size; i++ )
|
||||
if ( str[i] == '\\' || str[i] == '"' ) {
|
||||
|
||||
if ( literalBufferSize < 2*size + 3 ) {
|
||||
literalBufferSize = 2*size + 3;
|
||||
literalBufferSize *= 2;
|
||||
delete [] literalBuffer;
|
||||
literalBuffer = new char[literalBufferSize];
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
literalBuffer[j++] = '"';
|
||||
for (int i=0; i<size; i++ ) {
|
||||
if ( str[i] == '\\' || str[i] == '"' ) {
|
||||
literalBuffer[j++] = '\\';
|
||||
}
|
||||
literalBuffer[j++] = str[i];
|
||||
}
|
||||
|
||||
literalBuffer[j++] = '"';
|
||||
literalBuffer[j] = 0;
|
||||
|
||||
return literalBuffer;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
const char* loutFeatureProcessor::stringToCharPtr(const FeatureValue* f)
|
||||
{
|
||||
if ( f ) {
|
||||
if ( f -> type() == FeatureValue::string ) {
|
||||
const char* x = *f;
|
||||
return x;
|
||||
} else
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
loutFeatureProcessor::dimensionToFloat(
|
||||
float& y,
|
||||
FeatureValueDimension::Unit& unitOfY,
|
||||
const FeatureValue* f,
|
||||
FeatureValueDimension::Unit u
|
||||
)
|
||||
{
|
||||
if ( f ) {
|
||||
if ( f -> type() == FeatureValue::dimension ) {
|
||||
FeatureValueDimension* x = (FeatureValueDimension*)f;
|
||||
|
||||
unitOfY = x -> unit();
|
||||
|
||||
if ( u == FeatureValueDimension::NONE ) {
|
||||
if ( x -> unit() == FeatureValueDimension::PICA ) {
|
||||
y = x -> getValue(FeatureValueDimension::POINT);
|
||||
unitOfY = FeatureValueDimension::POINT;
|
||||
} else
|
||||
y = *x;
|
||||
} else {
|
||||
y = x -> getValue(u);
|
||||
}
|
||||
return 1;
|
||||
} else
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
} else {
|
||||
y = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
loutFeatureProcessor::dimensionToCharPtr(const FeatureValue* f,
|
||||
FeatureValueDimension::Unit u)
|
||||
{
|
||||
static char dBuf[50];
|
||||
float y;
|
||||
FeatureValueDimension::Unit unitOfY;
|
||||
|
||||
if ( dimensionToFloat(y, unitOfY, f, u) ) {
|
||||
|
||||
if ( u != FeatureValueDimension::NONE ) {
|
||||
unitOfY = u;
|
||||
}
|
||||
|
||||
switch ( unitOfY ) {
|
||||
case FeatureValueDimension::INCH:
|
||||
snprintf(dBuf, sizeof(dBuf), "%.2fi", y);
|
||||
break;
|
||||
|
||||
case FeatureValueDimension::PICA:
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
break;
|
||||
|
||||
case FeatureValueDimension::POINT:
|
||||
snprintf(dBuf, sizeof(dBuf), "%.2fp", y);
|
||||
break;
|
||||
|
||||
case FeatureValueDimension::CM:
|
||||
snprintf(dBuf, sizeof(dBuf), "%.2fc", y);
|
||||
break;
|
||||
|
||||
case FeatureValueDimension::PIXEL:
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
return (const char*)dBuf;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
featureProcessor::getFeatureValue(const Feature* f)
|
||||
{
|
||||
if ( f )
|
||||
return stringToCharPtr(f -> value());
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
FeatureValueArray*
|
||||
featureProcessor::getFeatureValueArray(const Feature* f)
|
||||
{
|
||||
if ( f ) {
|
||||
if ( f -> value() -> type() == FeatureValue::array )
|
||||
return (FeatureValueArray*)(f -> value());
|
||||
else {
|
||||
MESSAGE(cerr, form("%s is not of an array type.", f -> name().name()));
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
featureProcessor::getDimensionValue(float& x, const Feature* f,
|
||||
FeatureValueDimension::Unit u)
|
||||
{
|
||||
FeatureValueDimension::Unit unit;
|
||||
|
||||
if ( f )
|
||||
return dimensionToFloat(x, unit, f -> value(), u);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
featureProcessor::getDimensionValue(const Feature* f,
|
||||
FeatureValueDimension::Unit u)
|
||||
{
|
||||
if ( f )
|
||||
return dimensionToCharPtr(f -> value(), u);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
featureProcessor::getFeatureValue(int& x, const Feature* f)
|
||||
{
|
||||
if ( f ) {
|
||||
x = *(f -> value());
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
featureProcessor::getFeatureValue(float& x, const Feature* f)
|
||||
{
|
||||
if ( f ) {
|
||||
x = *(f -> value());
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
const FeatureSet *
|
||||
featureProcessor::getFeatureSetValue(const Feature* f)
|
||||
{
|
||||
if ( f && f -> value() -> type() == FeatureValue::featureset )
|
||||
return ((const FeatureValueFeatureSet *)f->value())->value();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
FeatureValue*
|
||||
loutFeatureProcessor::evaluate(const char*)
|
||||
{
|
||||
MESSAGE(cerr, "featureProcessor::evaluate(): FP specific function should be called.");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
loutFeatureProcessor::accept(const char*, const Expression*)
|
||||
{
|
||||
MESSAGE(cerr, "featureProcessor::accept(): FP specific function should be called");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
return false;
|
||||
}
|
||||
|
||||
void loutFeatureProcessor::clear()
|
||||
{
|
||||
MESSAGE(cerr, "featureProcessor::clear(): FP specific function should be called");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
void
|
||||
loutFeatureProcessor::preEvaluate(const Element& e)
|
||||
{
|
||||
MESSAGE(cerr, "featureProcessor::preEvaluate(): FP specific function should be called");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
void
|
||||
loutFeatureProcessor::postEvaluate(const Element& e)
|
||||
{
|
||||
MESSAGE(cerr, "featureProcessor::postEvaluate(): FP specific function should be called");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
154
cde/lib/DtMmdb/HardCopy/HardCopyFP.h
Normal file
154
cde/lib/DtMmdb/HardCopy/HardCopyFP.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: HardCopyFP.h /main/3 1996/06/11 17:04:22 cde-hal $ */
|
||||
|
||||
#ifndef _fp_h
|
||||
#define _fp_h 1
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
#include "FPExceptions.h"
|
||||
#include "StyleSheet/Feature.h"
|
||||
#include "StyleSheet/FeatureValue.h"
|
||||
#include "StyleSheet/Element.h"
|
||||
#include "StyleSheet/Const.h"
|
||||
#include "StyleSheet/Debug.h"
|
||||
#include "utility/funcs.h"
|
||||
|
||||
enum BLOCK_MODE { NON_BLOCK, BLOCK };
|
||||
extern enum BLOCK_MODE g_block_mode;
|
||||
|
||||
class featureProcessor : public Destructable
|
||||
{
|
||||
|
||||
protected:
|
||||
const char* f_name;
|
||||
|
||||
virtual const char* stringToCharPtr(const FeatureValue*) = 0;
|
||||
virtual unsigned int dimensionToFloat(float& Y,
|
||||
FeatureValueDimension::Unit& UnitOfY,
|
||||
const FeatureValue*,
|
||||
FeatureValueDimension::Unit) = 0;
|
||||
virtual const char* dimensionToCharPtr(const FeatureValue*,
|
||||
FeatureValueDimension::Unit) = 0;
|
||||
|
||||
// turn to Hard Copy engine specific literal
|
||||
virtual const char* convertToLiteral(const char* str) = 0;
|
||||
|
||||
public:
|
||||
featureProcessor(featureProcessor& x): f_name(x.f_name) {};
|
||||
featureProcessor(const char* name): f_name(name) {};
|
||||
virtual ~featureProcessor() {};
|
||||
|
||||
virtual featureProcessor* clone() = 0;
|
||||
|
||||
virtual void handleBegElement(const Element &element, const FeatureSet&, const FeatureSet&, const FeatureSet&, const FeatureSet& initialFeatureSet, ostream&) = 0;
|
||||
virtual void handleEndElement(ostream&) = 0;
|
||||
virtual void handleData(const char *data, unsigned int size, ostream&)=0;
|
||||
|
||||
const char* name() { return f_name; };
|
||||
|
||||
// evaluate the variable (in x.y.z form) to a feature value.
|
||||
virtual FeatureValue* evaluate(const char* variableName) = 0;
|
||||
virtual unsigned int accept(const char* nm, const Expression*) = 0;
|
||||
|
||||
virtual void preEvaluate(const Element&) = 0;
|
||||
virtual void postEvaluate(const Element&) = 0;
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
////////////////////////////////////////
|
||||
// functions for getting feature values.
|
||||
//
|
||||
// Sample usage:
|
||||
// int x;
|
||||
// if ( getFeatureValue(x, FeatureSet.deep_lookup(FONT, FONT_SIZE)) ) {
|
||||
// //use x here
|
||||
// }
|
||||
////////////////////////////////////////
|
||||
|
||||
//
|
||||
// default value (NONE) means using whatever unit is available
|
||||
// Otherwise, a conversion is performed
|
||||
//
|
||||
unsigned int getDimensionValue(float& y,
|
||||
const Feature*,
|
||||
FeatureValueDimension::Unit = FeatureValueDimension::NONE);
|
||||
|
||||
const char *getDimensionValue(const Feature*,
|
||||
FeatureValueDimension::Unit = FeatureValueDimension::NONE);
|
||||
|
||||
const char *getFeatureValue(const Feature*);
|
||||
unsigned int getFeatureValue(int&, const Feature*);
|
||||
unsigned int getFeatureValue(float&, const Feature*);
|
||||
FeatureValueArray* getFeatureValueArray(const Feature*);
|
||||
|
||||
const FeatureSet *getFeatureSetValue(const Feature*);
|
||||
};
|
||||
|
||||
typedef featureProcessor* featureProcessorPtr;
|
||||
|
||||
class loutFeatureProcessor : public featureProcessor
|
||||
{
|
||||
protected:
|
||||
unsigned int f_change;
|
||||
|
||||
protected:
|
||||
char* empty_string();
|
||||
char* prepend(const char*, const char*);
|
||||
|
||||
// turn to Hard Copy engine specific literal
|
||||
const char* convertToLiteral(const char* str);
|
||||
|
||||
public:
|
||||
loutFeatureProcessor(loutFeatureProcessor& x) :
|
||||
featureProcessor(x), f_change(x.f_change) {};
|
||||
|
||||
loutFeatureProcessor(const char* name) :
|
||||
featureProcessor(name), f_change(false) {};
|
||||
~loutFeatureProcessor() {};
|
||||
|
||||
virtual void handleEndElement(ostream& out) {
|
||||
if ( f_change == true )
|
||||
out << "}";
|
||||
};
|
||||
virtual void handleData(const char *data, unsigned int size, ostream&);
|
||||
|
||||
const char* stringToCharPtr(const FeatureValue*);
|
||||
unsigned int dimensionToFloat(float&,
|
||||
FeatureValueDimension::Unit& unitOfY,
|
||||
const FeatureValue*,
|
||||
FeatureValueDimension::Unit);
|
||||
const char* dimensionToCharPtr(const FeatureValue*,
|
||||
FeatureValueDimension::Unit);
|
||||
|
||||
virtual FeatureValue* evaluate(const char* variableName) ;
|
||||
virtual unsigned int accept(const char* nm, const Expression*) ;
|
||||
|
||||
virtual void preEvaluate(const Element&) ;
|
||||
virtual void postEvaluate(const Element&) ;
|
||||
|
||||
virtual void clear() ;
|
||||
};
|
||||
|
||||
#endif
|
||||
11
cde/lib/DtMmdb/HardCopy/Makefile.am
Normal file
11
cde/lib/DtMmdb/HardCopy/Makefile.am
Normal file
@@ -0,0 +1,11 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
noinst_LTLIBRARIES = libHardCopy.la
|
||||
|
||||
libHardCopy_la_CXXFLAGS = -DEXPAND_TEMPLATES -DCDE_NEXT -I..
|
||||
|
||||
libHardCopy_la_SOURCES = FPset.C \
|
||||
HardCopyFP.C \
|
||||
TemplatesAutoNumber.C \
|
||||
autoNumber.C \
|
||||
autoNumberFP.C
|
||||
85
cde/lib/DtMmdb/HardCopy/TemplatesAutoNumber.C
Normal file
85
cde/lib/DtMmdb/HardCopy/TemplatesAutoNumber.C
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: TemplatesAutoNumber.C /main/9 1996/10/08 19:23:56 cde-hal $
|
||||
|
||||
|
||||
#include "HardCopy/autoNumber.h"
|
||||
|
||||
#ifdef CDE_NEXT
|
||||
|
||||
//#include <StyleSheet/cde_next.h>
|
||||
#include "dti_cc/CC_String.h"
|
||||
#include "dti_cc/cc_hdict.h"
|
||||
#include "dti_cc/CC_Dlist.h"
|
||||
#include "dti_cc/CC_Stack.C"
|
||||
|
||||
#endif /* end of CDE_NEXT */
|
||||
|
||||
#if defined(sun) || defined(hpux)
|
||||
|
||||
#ifndef CDE_NEXT /* { */
|
||||
|
||||
typedef hashTable<CC_String,autoNumberListT> _f10_;
|
||||
typedef hashTable<CC_String,autoNumber> _f11_;
|
||||
|
||||
typedef CC_TPtrSlistDictionary<CC_String,autoNumberListT> _f12_;
|
||||
typedef CC_TPtrSlistDictionary<CC_String,autoNumber> _f13_;
|
||||
|
||||
typedef hashTableIterator<CC_String,autoNumber> _f14_;
|
||||
typedef hashTableIterator<CC_String, autoNumberListT> _f15;
|
||||
|
||||
#else
|
||||
|
||||
typedef CC_TPtrSlist<autoNumber> _CC_TPtrSlist_autoNumber_;
|
||||
|
||||
typedef hashTable<CC_String, autoNumberListT> _hashTable_CC_String_autoNumberListT_;
|
||||
typedef hashTable<CC_String,autoNumber> _hashTable_CC_String_autoNumber_;
|
||||
|
||||
typedef hashTableIterator<CC_String,autoNumber> _hashTableIterator_CC_String_autoNumber_;
|
||||
|
||||
typedef hashTableIterator<CC_String, autoNumberListT> _hashTableIterator_CC_String_autoNumberListT_;
|
||||
|
||||
typedef Stack<int> _Stack_int_;
|
||||
|
||||
#endif /* end of CDE_NEXT } */
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _IBMR2
|
||||
|
||||
#pragma define ( hashTable<CC_String,autoNumberListT> )
|
||||
#pragma define ( hashTable<CC_String,autoNumber> )
|
||||
|
||||
#ifndef CDE_NEXT
|
||||
#pragma define ( CC_TPtrSlistDictionary<CC_String,autoNumberListT> )
|
||||
#pragma define ( CC_TPtrSlistDictionary<CC_String,autoNumber> )
|
||||
#endif
|
||||
|
||||
#pragma define ( CC_TPtrSlist<autoNumber> )
|
||||
|
||||
#pragma define ( hashTableIterator<CC_String,autoNumber> )
|
||||
#pragma define ( hashTableIterator<CC_String,autoNumberListT> )
|
||||
|
||||
#pragma define ( Stack<int> )
|
||||
|
||||
#endif
|
||||
528
cde/lib/DtMmdb/HardCopy/autoNumber.C
Normal file
528
cde/lib/DtMmdb/HardCopy/autoNumber.C
Normal file
@@ -0,0 +1,528 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $TOG: autoNumber.C /main/6 1998/04/17 11:47:13 mgreess $
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#if defined(CSRG_BASED)
|
||||
#define MAXINT INT_MAX
|
||||
#else
|
||||
#include <values.h>
|
||||
#endif
|
||||
|
||||
#include "HardCopy/autoNumber.h"
|
||||
#include "HardCopy/FPExceptions.h"
|
||||
|
||||
buffer autoNumber::f_buf(128);
|
||||
|
||||
autoNumber::autoNumber(const char* nm, enum autoNumberType t, int delta, const char* prefix, const char* postfix) :
|
||||
f_name(strdup(nm)), f_type(t), f_delta(delta),
|
||||
f_prefix(strdup(prefix)), f_postfix(strdup(postfix)),
|
||||
f_initialValue(0)
|
||||
{
|
||||
int x = strlen(prefix) + strlen(postfix) + 12;
|
||||
if ( x > f_buf.buf_sz() )
|
||||
f_buf.expand_chunk(x);
|
||||
}
|
||||
|
||||
autoNumber::~autoNumber()
|
||||
{
|
||||
delete f_name;
|
||||
delete f_prefix;
|
||||
delete f_postfix;
|
||||
|
||||
while (f_values.entries())
|
||||
f_values.pop();
|
||||
while (f_serial_nums.entries())
|
||||
f_serial_nums.pop();
|
||||
}
|
||||
|
||||
void autoNumber::setNumTagsSeen()
|
||||
{
|
||||
if (f_serial_nums.entries() > 0 && f_serial_nums.top() < MAXINT)
|
||||
f_serial_nums.top()++;
|
||||
}
|
||||
|
||||
void
|
||||
autoNumber::reset()
|
||||
{
|
||||
// reset stack of values
|
||||
while (f_values.entries() > 1) // leave one entry for re-use
|
||||
f_values.pop();
|
||||
f_values.top() = f_initialValue;
|
||||
|
||||
// reset stack of serial numbers
|
||||
while (f_serial_nums.entries() > 1) // leave one entry for re-use
|
||||
f_serial_nums.pop();
|
||||
f_serial_nums.top() = 0;
|
||||
}
|
||||
|
||||
void
|
||||
autoNumber::push()
|
||||
{
|
||||
f_values.push(f_initialValue);
|
||||
f_serial_nums.push(0);
|
||||
}
|
||||
|
||||
void
|
||||
autoNumber::pop()
|
||||
{
|
||||
if (f_values.entries() > 1)
|
||||
f_values.pop();
|
||||
if (f_serial_nums.entries() > 1)
|
||||
f_serial_nums.pop();
|
||||
}
|
||||
|
||||
unsigned int autoNumber::operator==(const autoNumber&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& out, const autoNumber& an)
|
||||
{
|
||||
debug(cerr, an.f_name);
|
||||
debug(cerr, an.f_delta);
|
||||
debug(cerr, an.f_prefix);
|
||||
debug(cerr, an.f_postfix);
|
||||
debug(cerr, an.f_type);
|
||||
debug(cerr, an.f_serial_nums.top());
|
||||
return out;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
autoNumberNumeric::autoNumberNumeric(const char* nm, int delta, int inv,
|
||||
const char* prefix, const char* postfix) :
|
||||
autoNumber(nm, NUMERIC, delta, prefix, postfix)
|
||||
{
|
||||
f_initialValue = inv;
|
||||
|
||||
f_values.push(f_initialValue);
|
||||
f_serial_nums.push(0);
|
||||
}
|
||||
|
||||
autoNumberNumeric::~autoNumberNumeric()
|
||||
{
|
||||
}
|
||||
|
||||
void autoNumberNumeric::setNextValue()
|
||||
{
|
||||
if (f_serial_nums.entries() && f_values.entries())
|
||||
{
|
||||
if (f_serial_nums.top() >= 2)
|
||||
f_values.top() += f_delta;
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
autoNumberNumeric::getValue()
|
||||
{
|
||||
char* ptr = f_buf.get_base();
|
||||
int ptrlen = f_buf.buf_sz();
|
||||
|
||||
if (f_values.entries())
|
||||
snprintf(ptr, ptrlen, "%s",
|
||||
form("%s%d%s", f_prefix, f_values.top(), f_postfix));
|
||||
else
|
||||
*ptr = 0;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
autoNumberCased::autoNumberCased(const char* nm, autoNumberType an_t,
|
||||
int delta, enum CaseType ct, const char* prefix, const char* postfix) :
|
||||
autoNumber(nm, an_t, delta, prefix, postfix), f_case(ct)
|
||||
{
|
||||
}
|
||||
|
||||
autoNumberCased::~autoNumberCased()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
char autoNumberAlphabetic::f_lowerCaseLetters[26] =
|
||||
{
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
|
||||
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z'
|
||||
};
|
||||
|
||||
char autoNumberAlphabetic::f_upperCaseLetters[26] =
|
||||
{
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
|
||||
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'T', 'T', 'U', 'V',
|
||||
'W', 'X', 'Y', 'Z'
|
||||
};
|
||||
|
||||
autoNumberAlphabetic::autoNumberAlphabetic(
|
||||
const char* nm,
|
||||
int delta,
|
||||
CaseType ct,
|
||||
const char* InitialValue, const char* prefix, const char* postfix
|
||||
) :
|
||||
autoNumberCased(nm, ALPHABETIC, delta, ct, prefix, postfix)
|
||||
{
|
||||
f_initialValue = alphaToInt(InitialValue, f_case);
|
||||
|
||||
f_values.push(f_initialValue);
|
||||
f_serial_nums.push(0);
|
||||
}
|
||||
|
||||
autoNumberAlphabetic::~autoNumberAlphabetic()
|
||||
{
|
||||
}
|
||||
|
||||
static const int base = 26;
|
||||
|
||||
int autoNumberAlphabetic::alphaToInt(const char* alpha, enum CaseType a_case)
|
||||
{
|
||||
int digits = strlen(alpha);
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
switch ( a_case ) {
|
||||
case UPPER:
|
||||
for (i=0; i<digits; i++)
|
||||
if ( isupper(alpha[i]) == 0 ) {
|
||||
MESSAGE(cerr,
|
||||
"Initial alphabetic autonumber value is not capitalized");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
offset = 'A';
|
||||
break;
|
||||
case LOWER:
|
||||
for (i=0; i<digits; i++)
|
||||
if ( islower(alpha[i]) == 0 ) {
|
||||
MESSAGE(cerr,
|
||||
"Initial alphabetic autonumber value is not in small case");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
offset = 'a';
|
||||
break;
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
int expansionFactor = 1;
|
||||
for ( i=digits-1; i>=0; i-- ) {
|
||||
x += (alpha[i] - offset)*expansionFactor;
|
||||
expansionFactor *= base;
|
||||
}
|
||||
|
||||
x += int((pow((double)base, digits)-1) / (base-1)) - 1;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
// Algorithm: converting integer values to/from alphabetic autonumbers
|
||||
|
||||
// The alphabetic autonumbers are grouped into blocks where each
|
||||
// block represents autonumbers with same number of digits. The size
|
||||
// of a block of d digts = 26^d. Now assigning a sequece number (an integer)
|
||||
// to each autonumber in blocks. This number in fact is the integer
|
||||
// value (internal) of the autonumber.
|
||||
//
|
||||
// block 1: [a, b, c, ..., z]
|
||||
// seq num: [0, 1, 2, 25]
|
||||
//
|
||||
// block 2: [aa, ab, ac, ..., zz]
|
||||
// seq num: [26, 27, 28, 701]
|
||||
//
|
||||
// In general, the 1st sequence number in a block for d digits:
|
||||
// x = int((pow(26, d)-1) / (26-1)) - 1;
|
||||
//
|
||||
// given an integer x, its number of ditigs when converted to an autonumber:
|
||||
// digits = int(log((26-1)*x + 26) / log(26));
|
||||
|
||||
|
||||
const char* autoNumberAlphabetic::intToAlpha(int x, enum CaseType a_case)
|
||||
{
|
||||
if ( x < 0 ) {
|
||||
MESSAGE(cerr, "Negaitve alphabetic autonumber value");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
int digits = int(log((double)(base-1)*x + base) / log((double)base));
|
||||
|
||||
if ( digits > 50 ) {
|
||||
MESSAGE(cerr, "alphabetic autonumber value too large");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
//debug(cerr, digits);
|
||||
//debug(cerr, (pow(base, digits)-1) / (25) -1);
|
||||
|
||||
x -= int((pow((double)base, digits)-1) / (base-1)) - 1;
|
||||
|
||||
char* letters =
|
||||
(a_case == UPPER ) ? f_upperCaseLetters : f_lowerCaseLetters;
|
||||
|
||||
int y, z;
|
||||
static char buf[51], buf1[51];
|
||||
int i =0;
|
||||
|
||||
while (1) {
|
||||
y = x % base;
|
||||
z = x / base;
|
||||
buf1[i++] = letters[y];
|
||||
if ( z == 0 )
|
||||
break;
|
||||
x = z;
|
||||
}
|
||||
|
||||
int k;
|
||||
for (k=0; k<digits-i; k++ )
|
||||
buf[k] = letters[0];
|
||||
|
||||
int n;
|
||||
for (n=0; n<i; n++ )
|
||||
buf[k+n] = buf1[n];
|
||||
|
||||
buf[k+n] = 0;
|
||||
|
||||
//debug(cerr, buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void autoNumberAlphabetic::setNextValue()
|
||||
{
|
||||
if (f_serial_nums.entries() && f_values.entries())
|
||||
{
|
||||
if (f_serial_nums.top() >= 2)
|
||||
f_values.top() += f_delta;
|
||||
}
|
||||
}
|
||||
|
||||
const char* autoNumberAlphabetic::getValue()
|
||||
{
|
||||
char* ptr = f_buf.get_base();
|
||||
int ptrlen = f_buf.buf_sz();
|
||||
|
||||
if (f_values.entries())
|
||||
snprintf(ptr, ptrlen, "%s", form("%s%s%s", f_prefix,
|
||||
intToAlpha(f_values.top(), f_case), f_postfix));
|
||||
else
|
||||
*ptr = 0;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
char autoNumberRoman::RomanNumberBuf[256];
|
||||
|
||||
autoNumberRoman::autoNumberRoman(
|
||||
const char* nm,
|
||||
int delta,
|
||||
CaseType ct,
|
||||
const char* InitialValue, const char* prefix, const char* postfix
|
||||
) :
|
||||
autoNumberCased(nm, ROMAN, delta, ct, prefix, postfix)
|
||||
{
|
||||
f_initialValue = RomanToArabic(InitialValue);
|
||||
|
||||
f_values.push(f_initialValue);
|
||||
f_serial_nums.push(0);
|
||||
}
|
||||
|
||||
autoNumberRoman::~autoNumberRoman()
|
||||
{
|
||||
}
|
||||
|
||||
void autoNumberRoman::setNextValue()
|
||||
{
|
||||
if (f_serial_nums.entries() && f_values.entries())
|
||||
{
|
||||
if (f_serial_nums.top() >= 2) {
|
||||
f_values.top() += f_delta;
|
||||
|
||||
if (f_values.top() < 1) {
|
||||
MESSAGE(cerr, "Value too small.");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* autoNumberRoman::getValue()
|
||||
{
|
||||
char* ptr;
|
||||
|
||||
if (f_values.entries())
|
||||
return ArabicToRoman(f_values.top());
|
||||
else {
|
||||
ptr = f_buf.get_base();
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int autoNumberRoman::getDigit(const char*& p)
|
||||
{
|
||||
int x = 0;
|
||||
switch ( p[0] ) {
|
||||
case 'I':
|
||||
case 'i':
|
||||
if ( p[1] != 0 && p[1] == 'V' ) {
|
||||
p++;
|
||||
x = 4;
|
||||
} else
|
||||
x = 1;
|
||||
break;
|
||||
case 'V':
|
||||
case 'v':
|
||||
x = 5;
|
||||
break;
|
||||
case 'X':
|
||||
case 'x':
|
||||
if ( p[1] != 0 && p[1] == 'I' ) {
|
||||
x = 9;
|
||||
p++;
|
||||
} else
|
||||
x = 10;
|
||||
break;
|
||||
case 'L': //50
|
||||
case 'l':
|
||||
if ( p[1] != 0 && p[1] == 'X' ) {
|
||||
x = 40;
|
||||
p++;
|
||||
} else
|
||||
x = 50;
|
||||
break;
|
||||
case 'C': // 100
|
||||
case 'c':
|
||||
if ( p[1] != 0 && p[1] == 'X' ) {
|
||||
x = 90;
|
||||
p++;
|
||||
} else
|
||||
x = 100;
|
||||
break;
|
||||
case 'D': // 500
|
||||
case 'd':
|
||||
if ( p[1] != 0 && p[1] == 'C' ) {
|
||||
x = 400;
|
||||
p++;
|
||||
} else
|
||||
x = 500;
|
||||
break;
|
||||
case 'M': //1000
|
||||
case 'm':
|
||||
if ( p[1] != 0 && p[1] == 'C' ) {
|
||||
x = 900;
|
||||
p++;
|
||||
} else
|
||||
x = 1000;
|
||||
break;
|
||||
default:
|
||||
MESSAGE(cerr, "unknown roman numeral letter");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
p++;
|
||||
return x;
|
||||
}
|
||||
|
||||
int autoNumberRoman::RomanToArabic(const char* romanString)
|
||||
{
|
||||
int x = 0;
|
||||
const char* bound = romanString + strlen(romanString);
|
||||
const char* p = (char*)romanString;
|
||||
|
||||
while ( p != bound ) {
|
||||
x += getDigit(p);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
const char* romanCardinals[4][9] =
|
||||
{
|
||||
{ "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" },
|
||||
{ "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" },
|
||||
{ "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" },
|
||||
{ "M", "MM", "MMM", "MV", "V", "VM", "VMM", "VMMM", "MX" }
|
||||
};
|
||||
|
||||
const char*
|
||||
autoNumberRoman::ArabicToRoman(int x)
|
||||
{
|
||||
unsigned int len, slen;
|
||||
|
||||
RomanNumberBuf[0] = 0;
|
||||
if ( x > 3999 ) {
|
||||
MESSAGE(cerr, "Value too large.");
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
char* buf = form("%d", x);
|
||||
|
||||
int j=strlen(buf)-1;
|
||||
for ( unsigned int i=0; i<strlen(buf); i++ ) {
|
||||
if ( buf[i] != '0' )
|
||||
{
|
||||
const char* romanCardinal = romanCardinals[j][buf[i]-'1'];
|
||||
char precise_romanCardinal[8];
|
||||
|
||||
int k;
|
||||
if (f_case == UPPER) {
|
||||
for (k=0; romanCardinal[k]; k++)
|
||||
precise_romanCardinal[k] = romanCardinal[k];
|
||||
precise_romanCardinal[k] = 0;
|
||||
}
|
||||
else {
|
||||
for (k=0; romanCardinal[k]; k++)
|
||||
precise_romanCardinal[k] = tolower(romanCardinal[k]);
|
||||
precise_romanCardinal[k] = 0;
|
||||
}
|
||||
|
||||
slen = strlen(RomanNumberBuf);
|
||||
len = MIN(strlen(precise_romanCardinal), 256 - 1 - slen);
|
||||
*((char *) memcpy(RomanNumberBuf + slen,
|
||||
precise_romanCardinal, len) + len) = '\0';
|
||||
}
|
||||
j--;
|
||||
}
|
||||
|
||||
return RomanNumberBuf;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
unsigned int
|
||||
autoNumberListT::operator==(const autoNumberListT&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
186
cde/lib/DtMmdb/HardCopy/autoNumber.h
Normal file
186
cde/lib/DtMmdb/HardCopy/autoNumber.h
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: autoNumber.h /main/6 1996/10/08 19:24:51 cde-hal $ */
|
||||
|
||||
#ifndef _autoNumber_h
|
||||
#define _autoNumber_h 1
|
||||
|
||||
#ifndef CDE_NEXT
|
||||
|
||||
#else
|
||||
#include "dti_cc/CC_Slist.h"
|
||||
#include "dti_cc/CC_Stack.h"
|
||||
#endif
|
||||
|
||||
#include "utility/buffer.h"
|
||||
#include "FPExceptions.h"
|
||||
|
||||
|
||||
class autoNumber : public Destructable
|
||||
{
|
||||
public:
|
||||
enum autoNumberType { NUMERIC, ALPHABETIC, ROMAN };
|
||||
|
||||
autoNumber(const char* nm, enum autoNumberType, int delta, const char* prefix, const char* postfix);
|
||||
virtual ~autoNumber();
|
||||
|
||||
void setNumTagsSeen();
|
||||
|
||||
virtual const char* getValue() = 0;
|
||||
virtual void setNextValue() = 0;
|
||||
virtual void reset();
|
||||
|
||||
void push();
|
||||
void pop();
|
||||
|
||||
unsigned int operator==(const autoNumber&);
|
||||
|
||||
friend ostream& operator<<(ostream&, const autoNumber&) ;
|
||||
|
||||
protected:
|
||||
static buffer f_buf;
|
||||
char* f_name;
|
||||
enum autoNumberType f_type;
|
||||
int f_delta;
|
||||
char* f_prefix;
|
||||
char* f_postfix;
|
||||
|
||||
int f_initialValue;
|
||||
Stack<int> f_values;
|
||||
Stack<int> f_serial_nums;
|
||||
};
|
||||
|
||||
class autoNumberNumeric : public autoNumber
|
||||
{
|
||||
public:
|
||||
autoNumberNumeric (const char* name, int delta, int initialValue, const char* prefix, const char* postfix);
|
||||
~autoNumberNumeric();
|
||||
|
||||
void setNextValue() ;
|
||||
const char* getValue() ;
|
||||
};
|
||||
|
||||
class autoNumberCased : public autoNumber
|
||||
{
|
||||
public:
|
||||
enum CaseType { UPPER, LOWER};
|
||||
|
||||
autoNumberCased(const char* name,
|
||||
enum autoNumberType,
|
||||
int delta,
|
||||
CaseType,
|
||||
const char* prefix,
|
||||
const char* postfix
|
||||
);
|
||||
~autoNumberCased();
|
||||
|
||||
protected:
|
||||
CaseType f_case;
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// Sequence example:
|
||||
// a, b, ..., z,
|
||||
// aa, ab, az,
|
||||
// ba, bb, bz,
|
||||
// ... ...
|
||||
//////////////////////////////////////////////////////
|
||||
class autoNumberAlphabetic : public autoNumberCased
|
||||
{
|
||||
private:
|
||||
static const int f_base;
|
||||
|
||||
static char f_lowerCaseLetters[26];
|
||||
static char f_upperCaseLetters[26];
|
||||
|
||||
public:
|
||||
autoNumberAlphabetic
|
||||
(const char* name,
|
||||
int delta,
|
||||
CaseType,
|
||||
const char* initialValue,
|
||||
const char* prefix,
|
||||
const char* postfix
|
||||
);
|
||||
~autoNumberAlphabetic();
|
||||
|
||||
void setNextValue() ;
|
||||
const char* getValue() ;
|
||||
|
||||
// convert an integer to an alphabetic autonumber
|
||||
// Example
|
||||
// a <- 0, b <- 1, ..., z <- 25
|
||||
// aa <- 26, ab <- 27, ..., az <- 51
|
||||
static const char* intToAlpha(int, enum CaseType);
|
||||
|
||||
// convert an alphabetic autonumber to an integer
|
||||
// Example
|
||||
// a -> 0, b -> 1, ..., z -> 25
|
||||
// aa -> 26, ab -> 27, ..., az -> 51
|
||||
static int alphaToInt(const char*, enum CaseType);
|
||||
|
||||
};
|
||||
|
||||
class autoNumberRoman : public autoNumberCased
|
||||
{
|
||||
private:
|
||||
static char RomanNumberBuf[256];
|
||||
|
||||
private:
|
||||
static int getDigit(const char*&);
|
||||
|
||||
public:
|
||||
autoNumberRoman
|
||||
(const char* name,
|
||||
int delta,
|
||||
CaseType,
|
||||
const char* initialValue,
|
||||
const char* prefix,
|
||||
const char* postfix
|
||||
);
|
||||
~autoNumberRoman();
|
||||
|
||||
void setNextValue() ;
|
||||
const char* getValue() ;
|
||||
|
||||
static int RomanToArabic(const char*);
|
||||
// ArabicToRoman needs to be non-static because of the requirement of
|
||||
// case sensitiveness
|
||||
const char* ArabicToRoman(int);
|
||||
|
||||
};
|
||||
|
||||
#ifndef CDE_NEXT
|
||||
class autoNumberListT : public CC_TPtrSlist<autoNumber>
|
||||
#else
|
||||
class autoNumberListT : public CC_TPtrSlist<autoNumber>
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
autoNumberListT() {};
|
||||
virtual ~autoNumberListT() {};
|
||||
unsigned int operator==(const autoNumberListT&);
|
||||
} ;
|
||||
|
||||
#endif
|
||||
466
cde/lib/DtMmdb/HardCopy/autoNumberFP.C
Normal file
466
cde/lib/DtMmdb/HardCopy/autoNumberFP.C
Normal file
@@ -0,0 +1,466 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $TOG: autoNumberFP.C /main/7 1998/04/17 11:47:29 mgreess $ */
|
||||
|
||||
#include "autoNumberFP.h"
|
||||
#include "StyleSheet/Const.h"
|
||||
#include "StyleSheet/Expression.h"
|
||||
|
||||
autoNumberFP gAutoNumberFP;
|
||||
|
||||
#ifndef CDE_NEXT
|
||||
typedef CC_TPtrSlistIterator<autoNumber> autoNumberListIteratorT;
|
||||
unsigned ANP_StringHash(const CC_String& str)
|
||||
{
|
||||
return str.hash();
|
||||
}
|
||||
#else
|
||||
typedef CC_TPtrSlistIterator<autoNumber> autoNumberListIteratorT;
|
||||
unsigned ANP_StringHash(const CC_String& str)
|
||||
{
|
||||
return str.hash();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// static member initialization
|
||||
///////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
f_autoNumberSet_t autoNumberFP::f_autoNumberSet(ANP_StringHash);
|
||||
f_resetControlList_t autoNumberFP::f_resetControlList(ANP_StringHash);
|
||||
f_registerList_t autoNumberFP::f_registerList(ANP_StringHash);
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////
|
||||
|
||||
|
||||
autoNumberFP::autoNumberFP() :
|
||||
f_autoNumberSet(ANP_StringHash),
|
||||
f_resetControlList(ANP_StringHash),
|
||||
f_registerList(ANP_StringHash)
|
||||
{
|
||||
}
|
||||
|
||||
autoNumberFP::~autoNumberFP()
|
||||
{
|
||||
f_autoNumberSet.clearAndDestroy();
|
||||
f_resetControlList.clearAndDestroy();
|
||||
f_registerList.clearAndDestroy();
|
||||
}
|
||||
|
||||
const char* autoNumberFP::stringToCharPtr(const FeatureValue* f)
|
||||
{
|
||||
if ( f ) {
|
||||
if ( f -> type() == FeatureValue::string ) {
|
||||
const char* x = *f;
|
||||
return x;
|
||||
} else
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// reset autonumbers
|
||||
void autoNumberFP::resetAutoNumbers(const char* name)
|
||||
{
|
||||
CC_String key(name);
|
||||
|
||||
autoNumberListT* anList = f_resetControlList.findValue(&key);
|
||||
|
||||
if ( anList == 0 )
|
||||
return;
|
||||
|
||||
autoNumberListIteratorT l_iter(*anList);
|
||||
|
||||
while ( ++l_iter ) {
|
||||
l_iter.key() -> reset();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
autoNumberFP::pushAutoNumbers(const char* giname)
|
||||
{
|
||||
if (giname && *giname)
|
||||
{
|
||||
CC_String key(giname);
|
||||
|
||||
autoNumberListT* anList = f_resetControlList.findValue(&key);
|
||||
|
||||
if (anList)
|
||||
{
|
||||
autoNumberListIteratorT l_iter(*anList);
|
||||
while ( ++l_iter )
|
||||
l_iter.key()->push();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
autoNumberFP::popAutoNumbers(const char* giname)
|
||||
{
|
||||
if (giname && *giname)
|
||||
{
|
||||
CC_String key(giname);
|
||||
|
||||
autoNumberListT* anList = f_resetControlList.findValue(&key);
|
||||
|
||||
if (anList)
|
||||
{
|
||||
autoNumberListIteratorT l_iter(*anList);
|
||||
while ( ++l_iter )
|
||||
l_iter.key()->pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update autonumbers
|
||||
void autoNumberFP::updateAutoNumbers(const char* name)
|
||||
{
|
||||
CC_String key(name);
|
||||
autoNumberListT* anList = f_registerList.findValue(&key);
|
||||
|
||||
if ( anList == 0 )
|
||||
return;
|
||||
|
||||
autoNumberListIteratorT l_iter(*anList);
|
||||
|
||||
while ( ++l_iter ) {
|
||||
l_iter.key() -> setNextValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Array fields:
|
||||
// Type, InitValue, Delta, RegisterList, ControlList, [Prefix], [PostFix]
|
||||
//
|
||||
// Type, Pretfix and Postfix are strings.
|
||||
// RegisterList and ControlList are array.
|
||||
// InitValue and Delta are integers.
|
||||
// Prefix and Postfix are optional
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
autoNumberFP::defineAutoNumber(const char* nm, const FeatureValue* f)
|
||||
{
|
||||
if ( f -> type() != FeatureValue::array ) {
|
||||
debug(cerr, f -> type());
|
||||
cerr << "Autonumber: should use an array to define.\n";
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
FeatureValueArray* fa = (FeatureValueArray*)f;
|
||||
|
||||
if ( fa -> length() != 5 ) {
|
||||
cerr << "Autonumber: invalid number of arguments.\n";
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
// name
|
||||
const char* name = nm;
|
||||
|
||||
// type
|
||||
if ( (*fa)[0] -> type() != FeatureValue::string ) {
|
||||
cerr << "Autonumber: type should be a string.\n";
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
const char* type = stringToCharPtr((*fa)[0]);
|
||||
|
||||
// init value
|
||||
if ( (*fa)[1] -> type() != FeatureValue::string ) {
|
||||
cerr << "Autonumber: initial value should be a string.\n";
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
const char* initvalue = stringToCharPtr((*fa)[1]);
|
||||
|
||||
// delta
|
||||
if ( (*fa)[2] -> type() != FeatureValue::string ) {
|
||||
cerr << "Autonumber: delta value should be a string.\n";
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
int delta = atoi(stringToCharPtr((*fa)[2]));
|
||||
|
||||
|
||||
// register list
|
||||
FeatureValueArray* registerList = 0;
|
||||
if ( (*fa)[3] -> type() != FeatureValue::array ) {
|
||||
cerr << "Autonumber: counter list should be an array\n.";
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
} else {
|
||||
registerList = (FeatureValueArray*)(*fa)[3];
|
||||
}
|
||||
|
||||
// control list
|
||||
FeatureValueArray* controlList = 0;
|
||||
if ( (*fa)[4] -> type() != FeatureValue::array ) {
|
||||
cerr << "Autonumber: reset list should be an array\n.";
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
} else {
|
||||
controlList = (FeatureValueArray*)(*fa)[4];
|
||||
}
|
||||
|
||||
// prefix
|
||||
const char* prefix = "";
|
||||
|
||||
// postfix
|
||||
const char* postfix = "";
|
||||
|
||||
//////////////////////////////////
|
||||
// create the autonumber object
|
||||
//////////////////////////////////
|
||||
autoNumber* an = 0;
|
||||
if ( strcasecmp(type, AUTO_NUMBER_NUMERIC) == 0 )
|
||||
an = new autoNumberNumeric(
|
||||
name, delta, atoi(initvalue), prefix, postfix
|
||||
);
|
||||
else
|
||||
if ( strcasecmp(type, AUTO_NUMBER_ALPHABETIC_UPPERCASE) == 0 ) {
|
||||
an = new autoNumberAlphabetic(
|
||||
name, delta, autoNumberCased::UPPER, initvalue, prefix, postfix
|
||||
);
|
||||
} else
|
||||
if ( strcasecmp(type, AUTO_NUMBER_ALPHABETIC_LOWERCASE) == 0 ) {
|
||||
an = new autoNumberAlphabetic(
|
||||
name, delta, autoNumberCased::LOWER, initvalue, prefix, postfix
|
||||
);
|
||||
} else
|
||||
if ( strcasecmp(type, AUTO_NUMBER_ROMAN_UPPERCASE) == 0 )
|
||||
an = new autoNumberRoman(
|
||||
name, delta, autoNumberCased::UPPER, initvalue, prefix, postfix
|
||||
);
|
||||
else
|
||||
if ( strcasecmp(type, AUTO_NUMBER_ROMAN_LOWERCASE) == 0 )
|
||||
an = new autoNumberRoman(
|
||||
name, delta, autoNumberCased::LOWER, initvalue, prefix, postfix
|
||||
);
|
||||
else {
|
||||
MESSAGE(cerr, form("unknown type: %s", type));
|
||||
cerr << form("Autonumber: unknown type %s.", type) << "\n";
|
||||
throw(CASTHCREXCEPT hardCopyRendererException());
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// log the new autonumber
|
||||
//////////////////////////
|
||||
CC_String *key = new CC_String(name);
|
||||
|
||||
if ( f_autoNumberSet.findValue(key) ) {
|
||||
delete key;
|
||||
delete an;
|
||||
return;
|
||||
} else
|
||||
f_autoNumberSet.insertKeyAndValue(key, an);
|
||||
|
||||
///////////////////////////////
|
||||
// log into reset control list
|
||||
///////////////////////////////
|
||||
|
||||
const char* gi = 0;
|
||||
autoNumberListT* anList = 0;
|
||||
unsigned int i;
|
||||
for (i=0; i<controlList -> length(); i++ ) {
|
||||
|
||||
gi = stringToCharPtr((*controlList)[i]);
|
||||
key = new CC_String(gi);
|
||||
|
||||
anList = f_resetControlList.findValue(key);
|
||||
|
||||
if ( anList == 0 ) {
|
||||
anList = new autoNumberListT();
|
||||
f_resetControlList.insertKeyAndValue(key, anList);
|
||||
} else
|
||||
delete key;
|
||||
|
||||
anList -> append(an);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// log into register list
|
||||
////////////////////////////////
|
||||
for (i=0; i<registerList -> length(); i++ ) {
|
||||
|
||||
gi = stringToCharPtr((*registerList)[i]);
|
||||
key = new CC_String(gi);
|
||||
|
||||
anList = f_registerList.findValue(key);
|
||||
|
||||
if ( anList == 0 ) {
|
||||
anList = new autoNumberListT();
|
||||
f_registerList.insertKeyAndValue(key, anList);
|
||||
} else
|
||||
delete key;
|
||||
|
||||
anList -> append(an);
|
||||
}
|
||||
}
|
||||
|
||||
void autoNumberFP::setSeenTagStatus(const char* tagName)
|
||||
{
|
||||
CC_String key(tagName);
|
||||
autoNumberListT* anList = f_registerList.findValue(&key);
|
||||
|
||||
if ( anList == 0 )
|
||||
return;
|
||||
|
||||
autoNumberListIteratorT next(*anList);
|
||||
while ( ++next ) {
|
||||
next.key() -> setNumTagsSeen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FeatureValue*
|
||||
autoNumberFP::evaluate(const char* varName)
|
||||
{
|
||||
CC_String key(varName);
|
||||
autoNumber* an = f_autoNumberSet.findValue(&key);
|
||||
|
||||
if ( an == 0 ) {
|
||||
MESSAGE(cerr, form("Warning: unknown autonumber name %s.", varName));
|
||||
return 0;
|
||||
} else
|
||||
return new FeatureValueString(an -> getValue());
|
||||
}
|
||||
|
||||
unsigned int
|
||||
autoNumberFP::accept(const char* name, const Expression* expr)
|
||||
{
|
||||
FeatureValue* fv = 0;
|
||||
|
||||
mtry
|
||||
{
|
||||
fv = expr -> evaluate();
|
||||
}
|
||||
mcatch_any()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
end_try;
|
||||
|
||||
/*
|
||||
debug(cerr, name);
|
||||
fv -> print(cerr);
|
||||
*/
|
||||
|
||||
if ( fv -> type() != FeatureValue::array ) {
|
||||
delete fv;
|
||||
return false;
|
||||
}
|
||||
|
||||
FeatureValueArray* fvArray = (FeatureValueArray*) fv;
|
||||
|
||||
/*
|
||||
debug(cerr, fvArray -> length());
|
||||
debug(cerr, fvArray -> name());
|
||||
*/
|
||||
|
||||
if ( fvArray -> length() >= 1 &&
|
||||
strcasecmp(fvArray -> name(), AUTO_NUMBER) == 0
|
||||
)
|
||||
{
|
||||
defineAutoNumber(name, fv);
|
||||
delete fv;
|
||||
return true;
|
||||
} else {
|
||||
delete fv;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
autoNumberFP::beginElement(const Element& element)
|
||||
{
|
||||
const char* giname = element.gi().name();
|
||||
|
||||
if (giname && *giname)
|
||||
{
|
||||
pushAutoNumbers(giname);
|
||||
|
||||
setSeenTagStatus(giname);
|
||||
updateAutoNumbers(giname);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
autoNumberFP::endElement(const Symbol& sym)
|
||||
{
|
||||
const char* giname = sym.name();
|
||||
|
||||
if (giname && *giname)
|
||||
{
|
||||
popAutoNumbers(giname);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
void autoNumberFP::preEvaluate(const Element& element)
|
||||
{
|
||||
setSeenTagStatus(element.gi().name());
|
||||
updateAutoNumbers(element.gi().name());
|
||||
}
|
||||
|
||||
void autoNumberFP::postEvaluate(const Element& element)
|
||||
{
|
||||
resetAutoNumbers(element.gi().name());
|
||||
}
|
||||
#endif
|
||||
|
||||
void autoNumberFP::clear()
|
||||
{
|
||||
f_autoNumberSet.clearAndDestroy();
|
||||
f_resetControlList.clearAndDestroy();
|
||||
f_registerList.clearAndDestroy();
|
||||
}
|
||||
|
||||
// reset All autonumbers
|
||||
void autoNumberFP::resetAllAutoNumbers()
|
||||
{
|
||||
hashTableIterator<CC_String, autoNumberListT> l_rc_iterator(f_resetControlList);
|
||||
|
||||
while ( ++l_rc_iterator ) {
|
||||
|
||||
autoNumberListT* anList = l_rc_iterator.value();
|
||||
|
||||
autoNumberListIteratorT l_iter(*anList);
|
||||
|
||||
while ( ++l_iter ) {
|
||||
l_iter.key() -> reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
102
cde/lib/DtMmdb/HardCopy/autoNumberFP.h
Normal file
102
cde/lib/DtMmdb/HardCopy/autoNumberFP.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: autoNumberFP.h /main/7 1996/10/08 19:25:47 cde-hal $ */
|
||||
|
||||
#ifndef _autoNumber_fp_h
|
||||
#define _autoNumber_fp_h 1
|
||||
|
||||
#ifndef CDE_NEXT
|
||||
|
||||
#else
|
||||
#include "dti_cc/CC_String.h"
|
||||
#include "dti_cc/cc_hdict.h"
|
||||
#endif
|
||||
|
||||
#include "StyleSheet/SymTab.h"
|
||||
#include "StyleSheet/Element.h"
|
||||
#include "StyleSheet/FeatureValue.h"
|
||||
#include "HardCopy/autoNumber.h"
|
||||
|
||||
#ifndef CDE_NEXT
|
||||
typedef hashTable<CC_String, autoNumber> f_autoNumberSet_t ;
|
||||
typedef hashTable<CC_String, autoNumberListT> f_resetControlList_t;
|
||||
typedef hashTable<CC_String, autoNumberListT> f_registerList_t;
|
||||
#else
|
||||
typedef hashTable<CC_String, autoNumber> f_autoNumberSet_t ;
|
||||
typedef hashTable<CC_String, autoNumberListT> f_resetControlList_t;
|
||||
typedef hashTable<CC_String, autoNumberListT> f_registerList_t;
|
||||
#endif
|
||||
|
||||
class autoNumberFP
|
||||
{
|
||||
private:
|
||||
// autoNumber FPs that are known through their names
|
||||
|
||||
f_autoNumberSet_t f_autoNumberSet;
|
||||
|
||||
// Inverted reset control list.
|
||||
// A reset control list records a list of tags that
|
||||
// once are met, the autonumber the list is associated with
|
||||
// will be reset to its initial value.
|
||||
|
||||
// Each <String, autoNumberList> pair in the dictionary has the
|
||||
// meaning that when the tag with String GI is encounted in the doucument,
|
||||
// all autonumber in the autoNumberList will reset.
|
||||
|
||||
f_resetControlList_t f_resetControlList;
|
||||
|
||||
// Each <String, autoNumberList> pair in the dictionary has the
|
||||
// meaning that all autonumber in the autoNumberList are defined
|
||||
// in the style sheet under tag with String GI.
|
||||
|
||||
f_registerList_t f_registerList;
|
||||
|
||||
private:
|
||||
void pushAutoNumbers(const char *);
|
||||
void popAutoNumbers (const char *);
|
||||
void updateAutoNumbers(const char*);
|
||||
|
||||
void defineAutoNumber(const char*, const FeatureValue*);
|
||||
|
||||
void setSeenTagStatus(const char* tagName);
|
||||
|
||||
const char* stringToCharPtr(const FeatureValue* f);
|
||||
|
||||
public:
|
||||
autoNumberFP();
|
||||
~autoNumberFP();
|
||||
|
||||
FeatureValue* evaluate(const char* varName) ;
|
||||
unsigned int accept(const char*, const Expression*);
|
||||
|
||||
void beginElement(const Element &);
|
||||
void endElement (const Symbol &);
|
||||
|
||||
void clear();
|
||||
|
||||
void resetAllAutoNumbers();
|
||||
};
|
||||
|
||||
extern autoNumberFP gAutoNumberFP;
|
||||
|
||||
#endif
|
||||
31
cde/lib/DtMmdb/HardCopy/lout_limits.h
Normal file
31
cde/lib/DtMmdb/HardCopy/lout_limits.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: lout_limits.h /main/3 1996/06/11 17:04:59 cde-hal $ */
|
||||
|
||||
#ifndef _lout_limit_
|
||||
#define _lout_limit_ 1
|
||||
|
||||
|
||||
#define LOUT_MAX_CHARS_PER_LINE 2000
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user