1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef METAINFOREADER_HXX_INCLUDED
29 #define METAINFOREADER_HXX_INCLUDED
30 
31 #include "internal/basereader.hxx"
32 #include "internal/types.hxx"
33 
34 class ITag;
35 class CKeywordsTag;
36 class CSimpleTag;
37 class CDummyTag;
38 
39 class CMetaInfoReader : public CBaseReader
40 {
41 public:
42 	virtual ~CMetaInfoReader();
43 
44 	CMetaInfoReader( const std::string& DocumentName );
45 
46 	CMetaInfoReader( void* stream, zlib_filefunc_def* fa);
47 
48 	/** check if the Tag is in the target meta.xml file.
49 
50 		@param TagName
51 		the name of the tag that will be retrive.
52 	*/
53 	bool hasTag(std::wstring TagName) const;
54 
55 
56 	/** Get a specific tag content, compound tags will be returned as comma separated list.
57 
58 		@param TagName
59 		the name of the tag that will be retrive.
60 	*/
61 	std::wstring getTagData( const std::wstring& TagName);
62 
63 	/** check if the a tag has the specific attribute.
64 
65 		@param TagName
66 		the name of the tag.
67 		@param AttributeName
68 		the name of the attribute.
69 	*/
70 	bool hasTagAttribute( const std::wstring TagName,  std::wstring AttributeName);
71 
72 	/** Get a specific attribute content.
73 
74 		@param TagName
75 		the name of the tag.
76 		@param AttributeName
77 		the name of the attribute.
78 	*/
79 	std::wstring getTagAttribute( const std::wstring TagName,  std::wstring AttributeName);
80 
81 	/** Get the default language of the whole document.
82 	*/
83 	LocaleSet_t getDefaultLocale( );
84 
85 protected: // protected because its only an implementation relevant class
86 
87 	/** start_element occurs when a tag is start.
88 
89 		@param raw_name
90 		raw name of the tag.
91 		@param local_name
92 		local name of the tag.
93 		@param attributes
94 		attribute structure.
95 	*/
96 	virtual void start_element(
97 		const std::wstring& raw_name,
98 		const std::wstring& local_name,
99 		const XmlTagAttributes_t& attributes);
100 
101 	/** end_element occurs when a tag is closed
102 
103 		@param raw_name
104 		raw name of the tag.
105 		@param local_name
106 		local name of the tag.
107 	*/
108 	virtual void end_element(
109 		const std::wstring& raw_name, const std::wstring& local_name);
110 
111 	/** characters occurs when receiving characters
112 
113 		@param character
114 		content of the information received.
115 	*/
116 	virtual void characters(const std::wstring& character);
117 
118 protected:
119 	/** choose an appropriate tag reader to handle the tag.
120 
121 		@param tag_name
122 		the name of the tag.
123 		@param XmlAttributes
124 		attribute structure of the tag to save in.
125 	*/
126 	ITag* chooseTagReader(
127 		const std::wstring& tag_name, const XmlTagAttributes_t& XmlAttributes );
128 
129 	/** save the received content into structure.
130 
131 		@param tag_name
132 		the name of the tag.
133 	*/
134 	void saveTagContent( const std::wstring& tag_name );
135 
136 private:
137 	XmlTags_t      m_AllMetaInfo;
138 
139 private:
140     std::stack<ITag*> m_TagBuilderStack;
141 
142 private:
143 	CKeywordsTag* m_pKeywords_Builder;
144 	CDummyTag*   m_pDummy_Builder;
145 	CSimpleTag* m_pSimple_Builder;
146 };
147 
148 #endif
149