1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: layerexp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include <tools/debug.hxx>
35 #include <com/sun/star/drawing/XLayerSupplier.hpp>
36 #include <com/sun/star/container/XIndexAccess.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <xmloff/xmltoken.hxx>
39 #include "xmlnmspe.hxx"
40 #include <xmloff/xmlexp.hxx>
41 #include <xmloff/xmlement.hxx>
42 #include <xmloff/nmspmap.hxx>
43 #include "layerexp.hxx"
45 using ::rtl::OUString
;
46 using ::rtl::OUStringBuffer
;
47 using ::com::sun::star::uno::Reference
;
49 using namespace ::cppu
;
50 using namespace ::com::sun::star
;
51 using namespace ::com::sun::star::uno
;
52 using namespace ::com::sun::star::drawing
;
53 using namespace ::com::sun::star::beans
;
54 using namespace ::com::sun::star::lang
;
55 using namespace ::com::sun::star::container
;
56 using namespace ::xmloff::token
;
58 void SdXMLayerExporter::exportLayer( SvXMLExport
& rExport
)
60 Reference
< XLayerSupplier
> xLayerSupplier( rExport
.GetModel(), UNO_QUERY
);
61 if( !xLayerSupplier
.is() )
64 Reference
< XIndexAccess
> xLayerManager( xLayerSupplier
->getLayerManager(), UNO_QUERY
);
65 if( !xLayerManager
.is() )
68 const sal_Int32 nCount
= xLayerManager
->getCount();
72 const OUString
strName( RTL_CONSTASCII_USTRINGPARAM( "Name" ) );
73 const OUString
strTitle( RTL_CONSTASCII_USTRINGPARAM( "Title" ) );
74 const OUString
strDescription( RTL_CONSTASCII_USTRINGPARAM( "Description" ) );
78 SvXMLElementExport
aElem( rExport
, XML_NAMESPACE_DRAW
, XML_LAYER_SET
, sal_True
, sal_True
);
80 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; nIndex
++ )
84 Reference
< XPropertySet
> xLayer( xLayerManager
->getByIndex( nIndex
), UNO_QUERY_THROW
);
85 xLayer
->getPropertyValue( strName
) >>= sTmp
;
87 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_NAME
, sTmp
);
89 SvXMLElementExport
aEle( rExport
, XML_NAMESPACE_DRAW
, XML_LAYER
, sal_True
, sal_True
);
91 // title property (as <svg:title> element)
92 xLayer
->getPropertyValue(strTitle
) >>= sTmp
;
95 SvXMLElementExport
aEventElemt(rExport
, XML_NAMESPACE_SVG
, XML_TITLE
, sal_True
, sal_False
);
96 rExport
.Characters(sTmp
);
99 // description property (as <svg:desc> element)
100 xLayer
->getPropertyValue(strDescription
) >>= sTmp
;
101 if(sTmp
.getLength() > 0)
103 SvXMLElementExport
aDesc(rExport
, XML_NAMESPACE_SVG
, XML_DESC
, sal_True
, sal_False
);
104 rExport
.Characters(sTmp
);
109 DBG_ERROR("SdXMLayerExporter::exportLayer(), exception caught during export of one layer!");