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 #include <xmlscript/xmlmod_imexp.hxx> 25 26 #include <cppuhelper/implbase1.hxx> 27 #include <rtl/ustrbuf.hxx> 28 29 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 30 #include <com/sun/star/container/XNameContainer.hpp> 31 #include <com/sun/star/beans/XPropertySet.hpp> 32 33 #include <com/sun/star/awt/XControlModel.hpp> 34 #include <com/sun/star/awt/FontDescriptor.hpp> 35 36 #include <com/sun/star/xml/input/XRoot.hpp> 37 38 #include <vector> 39 40 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) 41 42 43 using namespace ::rtl; 44 using namespace ::std; 45 using namespace ::com::sun::star; 46 using namespace ::com::sun::star::uno; 47 48 namespace xmlscript 49 { 50 51 //================================================================================================== 52 // Script module import 53 54 //================================================================================================== 55 struct ModuleImport 56 : public ::cppu::WeakImplHelper1< xml::input::XRoot > 57 { 58 friend class ModuleElement; 59 60 ModuleDescriptor& mrModuleDesc; 61 62 sal_Int32 XMLNS_SCRIPT_UID; 63 sal_Int32 XMLNS_LIBRARY_UID; 64 sal_Int32 XMLNS_XLINK_UID; 65 66 public: 67 inline ModuleImport( ModuleDescriptor& rModuleDesc ) 68 SAL_THROW( () ) 69 : mrModuleDesc( rModuleDesc ) {} 70 virtual ~ModuleImport() 71 SAL_THROW( () ); 72 73 // XRoot 74 virtual void SAL_CALL startDocument( 75 Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping ) 76 throw (xml::sax::SAXException, RuntimeException); 77 virtual void SAL_CALL endDocument() 78 throw (xml::sax::SAXException, RuntimeException); 79 virtual void SAL_CALL processingInstruction( 80 OUString const & rTarget, OUString const & rData ) 81 throw (xml::sax::SAXException, RuntimeException); 82 virtual void SAL_CALL setDocumentLocator( 83 Reference< xml::sax::XLocator > const & xLocator ) 84 throw (xml::sax::SAXException, RuntimeException); 85 virtual Reference< xml::input::XElement > SAL_CALL startRootElement( 86 sal_Int32 nUid, OUString const & rLocalName, 87 Reference< xml::input::XAttributes > const & xAttributes ) 88 throw (xml::sax::SAXException, RuntimeException); 89 }; 90 91 //================================================================================================== 92 class ModuleElement 93 : public ::cppu::WeakImplHelper1< xml::input::XElement > 94 { 95 protected: 96 ModuleImport * _pImport; 97 ModuleElement * _pParent; 98 99 OUString _aLocalName; 100 Reference< xml::input::XAttributes > _xAttributes; 101 ::rtl::OUStringBuffer _StrBuffer; 102 103 public: 104 ModuleElement( 105 OUString const & rLocalName, 106 Reference< xml::input::XAttributes > const & xAttributes, 107 ModuleElement * pParent, ModuleImport * pImport ) 108 SAL_THROW( () ); 109 virtual ~ModuleElement() 110 SAL_THROW( () ); 111 112 // XElement 113 virtual Reference< xml::input::XElement > SAL_CALL getParent() 114 throw (RuntimeException); 115 virtual OUString SAL_CALL getLocalName() 116 throw (RuntimeException); 117 virtual sal_Int32 SAL_CALL getUid() 118 throw (RuntimeException); 119 virtual Reference< xml::input::XAttributes > SAL_CALL getAttributes() 120 throw (RuntimeException); 121 virtual void SAL_CALL ignorableWhitespace( 122 OUString const & rWhitespaces ) 123 throw (xml::sax::SAXException, RuntimeException); 124 virtual void SAL_CALL characters( OUString const & rChars ) 125 throw (xml::sax::SAXException, RuntimeException); 126 virtual void SAL_CALL processingInstruction( 127 OUString const & rTarget, OUString const & rData ) 128 throw (xml::sax::SAXException, RuntimeException); 129 virtual void SAL_CALL endElement() 130 throw (xml::sax::SAXException, RuntimeException); 131 virtual Reference< xml::input::XElement > SAL_CALL startChildElement( 132 sal_Int32 nUid, OUString const & rLocalName, 133 Reference< xml::input::XAttributes > const & xAttributes ) 134 throw (xml::sax::SAXException, RuntimeException); 135 }; 136 137 //================================================================================================== 138 139 } 140