xref: /aoo42x/main/svx/workben/msview/xmlconfig.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir #ifndef _XMLCONFIG_HXX_
2*cdf0e10cSrcweir #define _XMLCONFIG_HXX_
3*cdf0e10cSrcweir 
4*cdf0e10cSrcweir #include <map>
5*cdf0e10cSrcweir #include <list>
6*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
7*cdf0e10cSrcweir 
8*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
9*cdf0e10cSrcweir 
10*cdf0e10cSrcweir enum ElementConfigType { ECT_HEXDUMP, ECT_BYTE, ECT_UINT, ECT_UNISTRING, ETC_FLOAT, ETC_CONTAINER };
11*cdf0e10cSrcweir 
12*cdf0e10cSrcweir class ElementConfig
13*cdf0e10cSrcweir {
14*cdf0e10cSrcweir public:
15*cdf0e10cSrcweir 	ElementConfig() : mnType( ECT_HEXDUMP ) {}
16*cdf0e10cSrcweir 	ElementConfig( const rtl::OUString& rName, ElementConfigType rType ) : maName( rName ), mnType( rType ) {}
17*cdf0e10cSrcweir 	ElementConfig( const rtl::OUString& rName ) : maName( rName ) {}
18*cdf0e10cSrcweir 	ElementConfig( ElementConfigType rType ) : mnType( rType ) {}
19*cdf0e10cSrcweir 
20*cdf0e10cSrcweir 	virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const;
21*cdf0e10cSrcweir 
22*cdf0e10cSrcweir 	const rtl::OUString& getName() const { return maName; }
23*cdf0e10cSrcweir 	ElementConfigType getType() const { return mnType; }
24*cdf0e10cSrcweir 
25*cdf0e10cSrcweir 	static rtl::OUString dump_hex( SvStream& rStream, sal_Size& nLength );
26*cdf0e10cSrcweir 	static rtl::OUString dump_byte( SvStream& rStream, sal_Size& nLength );
27*cdf0e10cSrcweir 	static rtl::OUString dump_uint( SvStream& rStream, sal_Size& nLength );
28*cdf0e10cSrcweir 	static rtl::OUString dump_unistring( SvStream& rStream, sal_Size& nLength );
29*cdf0e10cSrcweir 	static rtl::OUString dump_float( SvStream& rStream, sal_Size& nLength );
30*cdf0e10cSrcweir private:
31*cdf0e10cSrcweir 	rtl::OUString maName;
32*cdf0e10cSrcweir 	ElementConfigType mnType;
33*cdf0e10cSrcweir };
34*cdf0e10cSrcweir typedef boost::shared_ptr< ElementConfig > ElementConfigPtr;
35*cdf0e10cSrcweir typedef std::list< ElementConfigPtr > ElementConfigList;
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir class ElementValueConfig : public ElementConfig
40*cdf0e10cSrcweir {
41*cdf0e10cSrcweir public:
42*cdf0e10cSrcweir 	ElementValueConfig( const rtl::OUString& rName, const rtl::OUString& rValue ) : ElementConfig( rName ), maValue( rValue ) {}
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 	const rtl::OUString& getValue() const { return maValue; }
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir private:
47*cdf0e10cSrcweir 	rtl::OUString maValue;
48*cdf0e10cSrcweir };
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir class ElementConfigContainer : public ElementConfig
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir public:
55*cdf0e10cSrcweir 	ElementConfigContainer() : ElementConfig( ETC_CONTAINER ) {}
56*cdf0e10cSrcweir 	ElementConfigContainer( const ::rtl::OUString& rName, ElementConfigType rType ) : ElementConfig( rName, rType ) {}
57*cdf0e10cSrcweir 	ElementConfigContainer( const ::rtl::OUString& rName ) : ElementConfig( rName, ETC_CONTAINER ) {}
58*cdf0e10cSrcweir 	ElementConfigContainer( ElementConfigType rType ) : ElementConfig( rType ) {}
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 	virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 	void addElementConfig( ElementConfigPtr p ) { maElementConfigList.push_back( p ); }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir protected:
65*cdf0e10cSrcweir 	ElementConfigList maElementConfigList;
66*cdf0e10cSrcweir };
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir class CaseElementConfig : public ElementConfigContainer
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir public:
73*cdf0e10cSrcweir 	CaseElementConfig( const rtl::OUString& rValue ) : maValue( rValue ) {}
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	const rtl::OUString& getValue() const { return maValue; }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir private:
78*cdf0e10cSrcweir 	rtl::OUString maValue;
79*cdf0e10cSrcweir };
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir class SwitchElementConfig : public ElementConfigContainer
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir public:
86*cdf0e10cSrcweir 	SwitchElementConfig( ElementConfigType rType ) : ElementConfigContainer( rType ) {}
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const;
89*cdf0e10cSrcweir };
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir class AtomConfig : public ElementConfigContainer
94*cdf0e10cSrcweir {
95*cdf0e10cSrcweir public:
96*cdf0e10cSrcweir 	AtomConfig( const ::rtl::OUString& rName, bool bIsContainer ) : ElementConfigContainer( rName ), mbIsContainer( bIsContainer ) {}
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	bool isContainer() const { return mbIsContainer; }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir protected:
101*cdf0e10cSrcweir 	bool mbIsContainer;
102*cdf0e10cSrcweir };
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir typedef std::map< UINT16, ElementConfigPtr > AtomConfigMap;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir extern AtomConfigMap gAtomConfigMap;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir #endif
109