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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_shell.hxx"
30 #include "autostyletag.hxx"
31 
32 /***********************   CAutoStyleTag  ***********************/
33 
34 CAutoStyleTag::CAutoStyleTag( const XmlTagAttributes_t& attributes ):
35 		m_CurrentStyleLocalePair( EMPTY_STYLELOCALE_PAIR )
36 {
37 	addAttributes( attributes);
38 };
39 
40 void CAutoStyleTag::startTag()
41 {
42 }
43 
44 void CAutoStyleTag::endTag()
45 {
46 }
47 
48 void CAutoStyleTag::addCharacters(const std::wstring&)
49 {
50 }
51 
52 void CAutoStyleTag::addAttributes(const XmlTagAttributes_t& attributes)
53 {
54     if ( EMPTY_STYLELOCALE_PAIR == m_CurrentStyleLocalePair )
55     {
56         // the style-locale pair should be empty when entering STYLE_STYLE
57         // tag, and otherwise should be STYLE_PROPERTIES.
58 
59 		XmlTagAttributes_t::const_iterator iter = attributes.find(CONTENT_STYLE_STYLE_NAME);
60 
61         if  ( iter != attributes.end())
62             setStyle( iter->second );
63     }
64     else
65     {
66         // tag STYLE_PROPERTIES entered.
67 
68 		XmlTagAttributes_t::const_iterator iter_lan = attributes.find(CONTENT_STYLE_PROPERTIES_LANGUAGE);
69 		XmlTagAttributes_t::const_iterator iter_con = attributes.find(CONTENT_STYLE_PROPERTIES_COUNTRY);
70 		XmlTagAttributes_t::const_iterator iter_lan_asain = attributes.find(CONTENT_STYLE_PROPERTIES_LANGUAGEASIAN);
71 		XmlTagAttributes_t::const_iterator iter_con_asain = attributes.find(CONTENT_STYLE_PROPERTIES_COUNTRYASIAN);
72 
73         // if style:properties | fo:language or style:language-asian is exist,
74 		// set the locale field, otherwise clear the style-locale pair;
75         if ( ( iter_lan!= attributes.end() ) && ( iter_con != attributes.end() ) )
76             setLocale( ::std::make_pair( iter_lan->second,iter_con->second ) );
77         else if ( ( iter_lan_asain!= attributes.end() ) && ( iter_con_asain != attributes.end() ) )
78 				setLocale( ::std::make_pair( iter_lan_asain->second,iter_con_asain->second ) );
79 		else
80 			clearStyleLocalePair();
81     }
82 
83 }
84 
85 void CAutoStyleTag::setStyle( ::std::wstring const & Style )
86 {
87     m_CurrentStyleLocalePair.first = Style;
88 }
89 
90 void CAutoStyleTag::setLocale( LocaleSet_t Locale )
91 {
92     m_CurrentStyleLocalePair.second = Locale;
93 }
94 
95 void CAutoStyleTag::clearStyleLocalePair(  )
96 {
97     m_CurrentStyleLocalePair  = EMPTY_STYLELOCALE_PAIR;
98 }
99 
100 
101