vcl: allow for overriding the default PDF rendering resolution
[LibreOffice.git] / xmlscript / source / xmllib_imexp / xmllib_export.cxx
blob97764e4292c2547f8934f2205523b906c7b0f654
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <rtl/ref.hxx>
21 #include <xmlscript/xmllib_imexp.hxx>
22 #include <xmlscript/xml_helper.hxx>
23 #include <xmlscript/xmlns.h>
24 #include <com/sun/star/xml/sax/XWriter.hpp>
26 using namespace com::sun::star::uno;
27 using namespace com::sun::star;
29 namespace xmlscript
32 const char aTrueStr[] = "true";
33 const char aFalseStr[] = "false";
35 void
36 exportLibraryContainer(
37 Reference< xml::sax::XWriter > const & xOut,
38 const LibDescriptorArray* pLibArray )
40 xOut->startDocument();
42 xOut->unknown(
43 "<!DOCTYPE library:libraries PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
44 " \"libraries.dtd\">" );
45 xOut->ignorableWhitespace( OUString() );
47 OUString aLibrariesName( XMLNS_LIBRARY_PREFIX ":libraries" );
48 XMLElement* pLibsElement = new XMLElement( aLibrariesName );
49 Reference< xml::sax::XAttributeList > xAttributes( pLibsElement );
51 pLibsElement->addAttribute( "xmlns:" XMLNS_LIBRARY_PREFIX, XMLNS_LIBRARY_URI );
52 pLibsElement->addAttribute( "xmlns:" XMLNS_XLINK_PREFIX, XMLNS_XLINK_URI );
54 xOut->ignorableWhitespace( OUString() );
55 xOut->startElement( aLibrariesName, xAttributes );
57 OUString sTrueStr(aTrueStr);
58 OUString sFalseStr(aFalseStr);
60 int nLibCount = pLibArray->mnLibCount;
61 for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
63 LibDescriptor& rLib = pLibArray->mpLibs[i];
65 XMLElement* pLibElement = new XMLElement( XMLNS_LIBRARY_PREFIX ":library" );
66 Reference< xml::sax::XAttributeList > xLibElementAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement );
68 pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":name", rLib.aName );
70 if( !rLib.aStorageURL.isEmpty() )
72 pLibElement->addAttribute( XMLNS_XLINK_PREFIX ":href", rLib.aStorageURL );
73 pLibElement->addAttribute( XMLNS_XLINK_PREFIX ":type", "simple" );
76 pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":link", rLib.bLink ? sTrueStr : sFalseStr );
78 if( rLib.bLink )
80 pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":readonly", rLib.bReadOnly ? sTrueStr : sFalseStr );
83 pLibElement->dump( xOut.get() );
86 xOut->ignorableWhitespace( OUString() );
87 xOut->endElement( aLibrariesName );
89 xOut->endDocument();
92 void
93 exportLibrary(
94 css::uno::Reference< css::xml::sax::XWriter > const & xOut,
95 const LibDescriptor& rLib )
97 xOut->startDocument();
99 xOut->unknown(
100 "<!DOCTYPE library:library PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
101 " \"library.dtd\">" );
102 xOut->ignorableWhitespace( OUString() );
104 rtl::Reference<XMLElement> pLibElement = new XMLElement( XMLNS_LIBRARY_PREFIX ":library" );
106 pLibElement->addAttribute( "xmlns:" XMLNS_LIBRARY_PREFIX, XMLNS_LIBRARY_URI );
108 pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":name", rLib.aName );
110 OUString sTrueStr(aTrueStr);
111 OUString sFalseStr(aFalseStr);
113 pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":readonly", rLib.bReadOnly ? sTrueStr : sFalseStr );
115 pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":passwordprotected", rLib.bPasswordProtected ? sTrueStr : sFalseStr );
117 if( rLib.bPreload )
118 pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":preload", sTrueStr );
120 for( const auto& rElementName : rLib.aElementNames )
122 XMLElement* pElement = new XMLElement( XMLNS_LIBRARY_PREFIX ":element" );
123 Reference< xml::sax::XAttributeList > xElementAttribs = static_cast< xml::sax::XAttributeList* >( pElement );
125 pElement->addAttribute( XMLNS_LIBRARY_PREFIX ":name",
126 rElementName );
128 pLibElement->addSubElement( pElement );
131 pLibElement->dump( xOut.get() );
133 xOut->endDocument();
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */