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 virtual void SAL_CALL endDocument(); 77 virtual void SAL_CALL processingInstruction( 78 OUString const & rTarget, OUString const & rData ); 79 virtual void SAL_CALL setDocumentLocator( 80 Reference< xml::sax::XLocator > const & xLocator ); 81 virtual Reference< xml::input::XElement > SAL_CALL startRootElement( 82 sal_Int32 nUid, OUString const & rLocalName, 83 Reference< xml::input::XAttributes > const & xAttributes ); 84 }; 85 86 //================================================================================================== 87 class ModuleElement 88 : public ::cppu::WeakImplHelper1< xml::input::XElement > 89 { 90 protected: 91 ModuleImport * _pImport; 92 ModuleElement * _pParent; 93 94 OUString _aLocalName; 95 Reference< xml::input::XAttributes > _xAttributes; 96 ::rtl::OUStringBuffer _StrBuffer; 97 98 public: 99 ModuleElement( 100 OUString const & rLocalName, 101 Reference< xml::input::XAttributes > const & xAttributes, 102 ModuleElement * pParent, ModuleImport * pImport ) 103 SAL_THROW( () ); 104 virtual ~ModuleElement() 105 SAL_THROW( () ); 106 107 // XElement 108 virtual Reference< xml::input::XElement > SAL_CALL getParent(); 109 virtual OUString SAL_CALL getLocalName(); 110 virtual sal_Int32 SAL_CALL getUid(); 111 virtual Reference< xml::input::XAttributes > SAL_CALL getAttributes(); 112 virtual void SAL_CALL ignorableWhitespace( 113 OUString const & rWhitespaces ); 114 virtual void SAL_CALL characters( OUString const & rChars ); 115 virtual void SAL_CALL processingInstruction( 116 OUString const & rTarget, OUString const & rData ); 117 virtual void SAL_CALL endElement(); 118 virtual Reference< xml::input::XElement > SAL_CALL startChildElement( 119 sal_Int32 nUid, OUString const & rLocalName, 120 Reference< xml::input::XAttributes > const & xAttributes ); 121 }; 122 123 //================================================================================================== 124 125 } 126