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