Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <com/sun/star/drawing/XLayerSupplier.hpp>
22 : #include <com/sun/star/container/XIndexAccess.hpp>
23 : #include <com/sun/star/beans/XPropertySet.hpp>
24 : #include <xmloff/xmltoken.hxx>
25 : #include <xmloff/xmlnmspe.hxx>
26 : #include <xmloff/xmlexp.hxx>
27 : #include <xmloff/xmlement.hxx>
28 : #include <xmloff/nmspmap.hxx>
29 : #include "layerexp.hxx"
30 :
31 : using ::com::sun::star::uno::Reference;
32 :
33 : using namespace ::cppu;
34 : using namespace ::com::sun::star;
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::drawing;
37 : using namespace ::com::sun::star::beans;
38 : using namespace ::com::sun::star::lang;
39 : using namespace ::com::sun::star::container;
40 : using namespace ::xmloff::token;
41 :
42 15 : void SdXMLayerExporter::exportLayer( SvXMLExport& rExport )
43 : {
44 15 : Reference< XLayerSupplier > xLayerSupplier( rExport.GetModel(), UNO_QUERY );
45 15 : if( !xLayerSupplier.is() )
46 0 : return;
47 :
48 30 : Reference< XIndexAccess > xLayerManager( xLayerSupplier->getLayerManager(), UNO_QUERY );
49 15 : if( !xLayerManager.is() )
50 0 : return;
51 :
52 15 : const sal_Int32 nCount = xLayerManager->getCount();
53 15 : if( nCount == 0 )
54 0 : return;
55 :
56 30 : const OUString strName( "Name" );
57 30 : const OUString strTitle( "Title" );
58 30 : const OUString strDescription( "Description" );
59 :
60 30 : OUString sTmp;
61 :
62 30 : SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_LAYER_SET, true, true );
63 :
64 90 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
65 : {
66 : try
67 : {
68 75 : Reference< XPropertySet> xLayer( xLayerManager->getByIndex( nIndex ), UNO_QUERY_THROW );
69 75 : xLayer->getPropertyValue( strName ) >>= sTmp;
70 75 : if(!sTmp.isEmpty())
71 75 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, sTmp );
72 :
73 150 : SvXMLElementExport aEle( rExport, XML_NAMESPACE_DRAW, XML_LAYER, true, true );
74 :
75 : // title property (as <svg:title> element)
76 75 : xLayer->getPropertyValue(strTitle) >>= sTmp;
77 75 : if(!sTmp.isEmpty())
78 : {
79 0 : SvXMLElementExport aEventElemt(rExport, XML_NAMESPACE_SVG, XML_TITLE, true, false);
80 0 : rExport.Characters(sTmp);
81 : }
82 :
83 : // description property (as <svg:desc> element)
84 75 : xLayer->getPropertyValue(strDescription) >>= sTmp;
85 75 : if(!sTmp.isEmpty())
86 : {
87 0 : SvXMLElementExport aDesc(rExport, XML_NAMESPACE_SVG, XML_DESC, true, false);
88 0 : rExport.Characters(sTmp);
89 75 : }
90 : }
91 0 : catch( Exception& )
92 : {
93 : OSL_FAIL("SdXMLayerExporter::exportLayer(), exception caught during export of one layer!");
94 : }
95 15 : }
96 : }
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|