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