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 #ifndef _SFX_XMLIDREGISTRY_HXX_ 25 #define _SFX_XMLIDREGISTRY_HXX_ 26 27 #include <sal/config.h> 28 29 #include <sfx2/dllapi.h> 30 31 #include <com/sun/star/beans/StringPair.hpp> 32 33 34 namespace com { namespace sun { namespace star { namespace rdf { 35 class XMetadatable; 36 } } } } 37 38 namespace sfx2 { 39 40 // XML ID utilities -------------------------------------------------- 41 42 /** is i_rIdref a valid NCName ? */ 43 bool SFX2_DLLPUBLIC isValidNCName(::rtl::OUString const & i_rIdref); 44 45 extern inline bool isValidXmlId(::rtl::OUString const & i_rStreamName,::rtl::OUString const & i_rIdref)46isValidXmlId(::rtl::OUString const & i_rStreamName, 47 ::rtl::OUString const & i_rIdref) 48 { 49 return isValidNCName(i_rIdref) && 50 (i_rStreamName.equalsAscii("content.xml") || 51 i_rStreamName.equalsAscii("styles.xml")); 52 } 53 54 55 // XML ID handling --------------------------------------------------- 56 57 /** interface for getElementByMetadataReference; 58 for use by sfx2::DocumentMetadataAccess 59 */ 60 class SFX2_DLLPUBLIC IXmlIdRegistry 61 { 62 63 public: ~IXmlIdRegistry()64 virtual ~IXmlIdRegistry() { } 65 66 virtual ::com::sun::star::uno::Reference< 67 ::com::sun::star::rdf::XMetadatable > SAL_CALL 68 GetElementByMetadataReference( 69 const ::com::sun::star::beans::StringPair & i_rXmlId) const = 0; 70 71 }; 72 73 /** supplier interface for the registry. 74 75 This indirection is unfortunately necessary, because the SwDocShell 76 is not always connected to a SwDoc, so we cannot guarantee that a 77 registry given to a SfxBaseModel/DocumentMetadataAccess remains valid; 78 it has to be retrieved from this supplier interface on access. 79 */ 80 class SFX2_DLLPUBLIC IXmlIdRegistrySupplier 81 { 82 83 public: ~IXmlIdRegistrySupplier()84 virtual ~IXmlIdRegistrySupplier() { } 85 86 /** override this if you have a XmlIdRegistry. */ GetXmlIdRegistry() const87 virtual const IXmlIdRegistry* GetXmlIdRegistry() const { return 0; } 88 89 }; 90 91 } // namespace sfx2 92 93 #endif // _SFX_XMLIDREGISTRY_HXX_ 94 95