1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_WORKBEN_MSVIEW_XMLCONFIG_HXX
21 #define INCLUDED_SVX_WORKBEN_MSVIEW_XMLCONFIG_HXX
25 #include <boost/shared_ptr.hpp>
29 enum ElementConfigType
{ ECT_HEXDUMP
, ECT_BYTE
, ECT_UINT
, ECT_UNISTRING
, ETC_FLOAT
, ETC_CONTAINER
};
34 ElementConfig() : mnType( ECT_HEXDUMP
) {}
35 ElementConfig( const OUString
& rName
, ElementConfigType rType
) : maName( rName
), mnType( rType
) {}
36 ElementConfig( const OUString
& rName
) : maName( rName
) {}
37 ElementConfig( ElementConfigType rType
) : mnType( rType
) {}
39 virtual OUString
format( SvStream
& rStream
, sal_Size
& nLength
) const;
41 const OUString
& getName() const { return maName
; }
42 ElementConfigType
getType() const { return mnType
; }
44 static OUString
dump_hex( SvStream
& rStream
, sal_Size
& nLength
);
45 static OUString
dump_byte( SvStream
& rStream
, sal_Size
& nLength
);
46 static OUString
dump_uint( SvStream
& rStream
, sal_Size
& nLength
);
47 static OUString
dump_unistring( SvStream
& rStream
, sal_Size
& nLength
);
48 static OUString
dump_float( SvStream
& rStream
, sal_Size
& nLength
);
51 ElementConfigType mnType
;
53 typedef boost::shared_ptr
< ElementConfig
> ElementConfigPtr
;
54 typedef std::list
< ElementConfigPtr
> ElementConfigList
;
58 class ElementValueConfig
: public ElementConfig
61 ElementValueConfig( const OUString
& rName
, const OUString
& rValue
) : ElementConfig( rName
), maValue( rValue
) {}
63 const OUString
& getValue() const { return maValue
; }
71 class ElementConfigContainer
: public ElementConfig
74 ElementConfigContainer() : ElementConfig( ETC_CONTAINER
) {}
75 ElementConfigContainer( const OUString
& rName
, ElementConfigType rType
) : ElementConfig( rName
, rType
) {}
76 ElementConfigContainer( const OUString
& rName
) : ElementConfig( rName
, ETC_CONTAINER
) {}
77 ElementConfigContainer( ElementConfigType rType
) : ElementConfig( rType
) {}
79 virtual OUString
format( SvStream
& rStream
, sal_Size
& nLength
) const;
81 void addElementConfig( ElementConfigPtr p
) { maElementConfigList
.push_back( p
); }
84 ElementConfigList maElementConfigList
;
89 class CaseElementConfig
: public ElementConfigContainer
92 CaseElementConfig( const OUString
& rValue
) : maValue( rValue
) {}
94 const OUString
& getValue() const { return maValue
; }
102 class SwitchElementConfig
: public ElementConfigContainer
105 SwitchElementConfig( ElementConfigType rType
) : ElementConfigContainer( rType
) {}
107 virtual OUString
format( SvStream
& rStream
, sal_Size
& nLength
) const;
112 class AtomConfig
: public ElementConfigContainer
115 AtomConfig( const OUString
& rName
, bool bIsContainer
) : ElementConfigContainer( rName
), mbIsContainer( bIsContainer
) {}
117 bool isContainer() const { return mbIsContainer
; }
123 typedef std::map
< UINT16
, ElementConfigPtr
> AtomConfigMap
;
125 extern AtomConfigMap gAtomConfigMap
;
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */