xref: /trunk/main/svx/workben/msview/xmlconfig.hxx (revision 3334a7e6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef _XMLCONFIG_HXX_
23 #define _XMLCONFIG_HXX_
24 
25 #include <map>
26 #include <list>
27 #include <boost/shared_ptr.hpp>
28 
29 ///////////////////////////////////////////////////////////////////////
30 
31 enum ElementConfigType { ECT_HEXDUMP, ECT_BYTE, ECT_UINT, ECT_UNISTRING, ETC_FLOAT, ETC_CONTAINER };
32 
33 class ElementConfig
34 {
35 public:
ElementConfig()36 	ElementConfig() : mnType( ECT_HEXDUMP ) {}
ElementConfig(const rtl::OUString & rName,ElementConfigType rType)37 	ElementConfig( const rtl::OUString& rName, ElementConfigType rType ) : maName( rName ), mnType( rType ) {}
ElementConfig(const rtl::OUString & rName)38 	ElementConfig( const rtl::OUString& rName ) : maName( rName ) {}
ElementConfig(ElementConfigType rType)39 	ElementConfig( ElementConfigType rType ) : mnType( rType ) {}
40 
41 	virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const;
42 
getName() const43 	const rtl::OUString& getName() const { return maName; }
getType() const44 	ElementConfigType getType() const { return mnType; }
45 
46 	static rtl::OUString dump_hex( SvStream& rStream, sal_Size& nLength );
47 	static rtl::OUString dump_byte( SvStream& rStream, sal_Size& nLength );
48 	static rtl::OUString dump_uint( SvStream& rStream, sal_Size& nLength );
49 	static rtl::OUString dump_unistring( SvStream& rStream, sal_Size& nLength );
50 	static rtl::OUString dump_float( SvStream& rStream, sal_Size& nLength );
51 private:
52 	rtl::OUString maName;
53 	ElementConfigType mnType;
54 };
55 typedef boost::shared_ptr< ElementConfig > ElementConfigPtr;
56 typedef std::list< ElementConfigPtr > ElementConfigList;
57 
58 ///////////////////////////////////////////////////////////////////////
59 
60 class ElementValueConfig : public ElementConfig
61 {
62 public:
ElementValueConfig(const rtl::OUString & rName,const rtl::OUString & rValue)63 	ElementValueConfig( const rtl::OUString& rName, const rtl::OUString& rValue ) : ElementConfig( rName ), maValue( rValue ) {}
64 
getValue() const65 	const rtl::OUString& getValue() const { return maValue; }
66 
67 private:
68 	rtl::OUString maValue;
69 };
70 
71 ///////////////////////////////////////////////////////////////////////
72 
73 class ElementConfigContainer : public ElementConfig
74 {
75 public:
ElementConfigContainer()76 	ElementConfigContainer() : ElementConfig( ETC_CONTAINER ) {}
ElementConfigContainer(const::rtl::OUString & rName,ElementConfigType rType)77 	ElementConfigContainer( const ::rtl::OUString& rName, ElementConfigType rType ) : ElementConfig( rName, rType ) {}
ElementConfigContainer(const::rtl::OUString & rName)78 	ElementConfigContainer( const ::rtl::OUString& rName ) : ElementConfig( rName, ETC_CONTAINER ) {}
ElementConfigContainer(ElementConfigType rType)79 	ElementConfigContainer( ElementConfigType rType ) : ElementConfig( rType ) {}
80 
81 	virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const;
82 
addElementConfig(ElementConfigPtr p)83 	void addElementConfig( ElementConfigPtr p ) { maElementConfigList.push_back( p ); }
84 
85 protected:
86 	ElementConfigList maElementConfigList;
87 };
88 
89 ///////////////////////////////////////////////////////////////////////
90 
91 class CaseElementConfig : public ElementConfigContainer
92 {
93 public:
CaseElementConfig(const rtl::OUString & rValue)94 	CaseElementConfig( const rtl::OUString& rValue ) : maValue( rValue ) {}
95 
getValue() const96 	const rtl::OUString& getValue() const { return maValue; }
97 
98 private:
99 	rtl::OUString maValue;
100 };
101 
102 ///////////////////////////////////////////////////////////////////////
103 
104 class SwitchElementConfig : public ElementConfigContainer
105 {
106 public:
SwitchElementConfig(ElementConfigType rType)107 	SwitchElementConfig( ElementConfigType rType ) : ElementConfigContainer( rType ) {}
108 
109 	virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const;
110 };
111 
112 ///////////////////////////////////////////////////////////////////////
113 
114 class AtomConfig : public ElementConfigContainer
115 {
116 public:
AtomConfig(const::rtl::OUString & rName,bool bIsContainer)117 	AtomConfig( const ::rtl::OUString& rName, bool bIsContainer ) : ElementConfigContainer( rName ), mbIsContainer( bIsContainer ) {}
118 
isContainer() const119 	bool isContainer() const { return mbIsContainer; }
120 
121 protected:
122 	bool mbIsContainer;
123 };
124 
125 typedef std::map< UINT16, ElementConfigPtr > AtomConfigMap;
126 
127 extern AtomConfigMap gAtomConfigMap;
128 
129 #endif
130