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