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 31 #include <tools/debug.hxx> 32 #include <com/sun/star/drawing/XLayerSupplier.hpp> 33 #include <com/sun/star/container/XIndexAccess.hpp> 34 #include <com/sun/star/beans/XPropertySet.hpp> 35 #include <xmloff/xmltoken.hxx> 36 #include "xmloff/xmlnmspe.hxx" 37 #include <xmloff/xmlexp.hxx> 38 #include <xmloff/xmlement.hxx> 39 #include <xmloff/nmspmap.hxx> 40 #include "layerexp.hxx" 41 42 using ::rtl::OUString; 43 using ::rtl::OUStringBuffer; 44 using ::com::sun::star::uno::Reference; 45 46 using namespace ::cppu; 47 using namespace ::com::sun::star; 48 using namespace ::com::sun::star::uno; 49 using namespace ::com::sun::star::drawing; 50 using namespace ::com::sun::star::beans; 51 using namespace ::com::sun::star::lang; 52 using namespace ::com::sun::star::container; 53 using namespace ::xmloff::token; 54 55 void SdXMLayerExporter::exportLayer( SvXMLExport& rExport ) 56 { 57 Reference< XLayerSupplier > xLayerSupplier( rExport.GetModel(), UNO_QUERY ); 58 if( !xLayerSupplier.is() ) 59 return; 60 61 Reference< XIndexAccess > xLayerManager( xLayerSupplier->getLayerManager(), UNO_QUERY ); 62 if( !xLayerManager.is() ) 63 return; 64 65 const sal_Int32 nCount = xLayerManager->getCount(); 66 if( nCount == 0 ) 67 return; 68 69 const OUString strName( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ); 70 const OUString strTitle( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ); 71 const OUString strDescription( RTL_CONSTASCII_USTRINGPARAM( "Description" ) ); 72 73 OUString sTmp; 74 75 SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_LAYER_SET, sal_True, sal_True ); 76 77 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) 78 { 79 try 80 { 81 Reference< XPropertySet> xLayer( xLayerManager->getByIndex( nIndex ), UNO_QUERY_THROW ); 82 xLayer->getPropertyValue( strName ) >>= sTmp; 83 if(sTmp.getLength()) 84 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, sTmp ); 85 86 SvXMLElementExport aEle( rExport, XML_NAMESPACE_DRAW, XML_LAYER, sal_True, sal_True ); 87 88 // title property (as <svg:title> element) 89 xLayer->getPropertyValue(strTitle) >>= sTmp; 90 if(sTmp.getLength()) 91 { 92 SvXMLElementExport aEventElemt(rExport, XML_NAMESPACE_SVG, XML_TITLE, sal_True, sal_False); 93 rExport.Characters(sTmp); 94 } 95 96 // description property (as <svg:desc> element) 97 xLayer->getPropertyValue(strDescription) >>= sTmp; 98 if(sTmp.getLength() > 0) 99 { 100 SvXMLElementExport aDesc(rExport, XML_NAMESPACE_SVG, XML_DESC, sal_True, sal_False); 101 rExport.Characters(sTmp); 102 } 103 } 104 catch( Exception& ) 105 { 106 DBG_ERROR("SdXMLayerExporter::exportLayer(), exception caught during export of one layer!"); 107 } 108 } 109 } 110