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_xmloff.hxx"
30 #include "XMLTextCharStyleNamesElementExport.hxx"
31 #include "xmloff/xmlnmspe.hxx"
32 #include <xmloff/nmspmap.hxx>
33 #include <xmloff/xmlexp.hxx>
34 
35 namespace com { namespace sun { namespace star {
36 	namespace beans { class XPropertySet; }
37 } } }
38 
39 using namespace ::com::sun::star::uno;
40 using ::com::sun::star::beans::XPropertySet;
41 using ::rtl::OUString;
42 using namespace ::xmloff::token;
43 
44 XMLTextCharStyleNamesElementExport::XMLTextCharStyleNamesElementExport(
45 	SvXMLExport& rExp,
46 	sal_Bool bDoSth,
47     sal_Bool bAllStyles,
48 	const Reference < XPropertySet > & rPropSet,
49 	const OUString& rPropName ) :
50 	rExport( rExp ),
51 	nCount( 0 )
52 {
53 	if( bDoSth )
54 	{
55 		Any aAny = rPropSet->getPropertyValue( rPropName );
56 		Sequence < OUString > aNames;
57 		if( aAny >>= aNames )
58 		{
59 			nCount = aNames.getLength();
60 			OSL_ENSURE( nCount > 0, "no char style found" );
61             if ( bAllStyles ) ++nCount;
62 			if( nCount > 1 )
63 			{
64     			aName = rExport.GetNamespaceMap().GetQNameByKey(
65 								XML_NAMESPACE_TEXT, GetXMLToken(XML_SPAN) );
66 				sal_Int32 i = nCount;
67 				const OUString *pName = aNames.getConstArray();
68 				while( --i )
69 				{
70 					rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
71 										  rExport.EncodeStyleName( *pName ) );
72 					rExport.StartElement( aName, sal_False );
73 					++pName;
74 				}
75 			}
76 		}
77 	}
78 }
79 
80 XMLTextCharStyleNamesElementExport::~XMLTextCharStyleNamesElementExport()
81 {
82 	if( nCount > 1 )
83 	{
84 		sal_Int32 i = nCount;
85 		while( --i )
86 			rExport.EndElement( aName, sal_False );
87 	}
88 }
89 
90