xref: /aoo41x/main/sfx2/inc/sfx2/XmlIdRegistry.hxx (revision 353d8f4d)
1*353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*353d8f4dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*353d8f4dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*353d8f4dSAndrew Rist  * distributed with this work for additional information
6*353d8f4dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*353d8f4dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*353d8f4dSAndrew Rist  * "License"); you may not use this file except in compliance
9*353d8f4dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*353d8f4dSAndrew Rist  *
11*353d8f4dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*353d8f4dSAndrew Rist  *
13*353d8f4dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*353d8f4dSAndrew Rist  * software distributed under the License is distributed on an
15*353d8f4dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*353d8f4dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*353d8f4dSAndrew Rist  * specific language governing permissions and limitations
18*353d8f4dSAndrew Rist  * under the License.
19*353d8f4dSAndrew Rist  *
20*353d8f4dSAndrew Rist  *************************************************************/
21*353d8f4dSAndrew Rist 
22*353d8f4dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SFX_XMLIDREGISTRY_HXX_
25cdf0e10cSrcweir #define _SFX_XMLIDREGISTRY_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/config.h>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <sfx2/dllapi.h>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/beans/StringPair.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace rdf {
35cdf0e10cSrcweir     class XMetadatable;
36cdf0e10cSrcweir } } } }
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace sfx2 {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir // XML ID utilities --------------------------------------------------
41cdf0e10cSrcweir 
42cdf0e10cSrcweir /** is i_rIdref a valid NCName ? */
43cdf0e10cSrcweir bool SFX2_DLLPUBLIC isValidNCName(::rtl::OUString const & i_rIdref);
44cdf0e10cSrcweir 
45cdf0e10cSrcweir extern inline bool
isValidXmlId(::rtl::OUString const & i_rStreamName,::rtl::OUString const & i_rIdref)46cdf0e10cSrcweir isValidXmlId(::rtl::OUString const & i_rStreamName,
47cdf0e10cSrcweir     ::rtl::OUString const & i_rIdref)
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     return isValidNCName(i_rIdref) &&
50cdf0e10cSrcweir         (i_rStreamName.equalsAscii("content.xml") ||
51cdf0e10cSrcweir          i_rStreamName.equalsAscii("styles.xml"));
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir // XML ID handling ---------------------------------------------------
56cdf0e10cSrcweir 
57cdf0e10cSrcweir /** interface for getElementByMetadataReference;
58cdf0e10cSrcweir     for use by sfx2::DocumentMetadataAccess
59cdf0e10cSrcweir  */
60cdf0e10cSrcweir class SFX2_DLLPUBLIC IXmlIdRegistry
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 
63cdf0e10cSrcweir public:
~IXmlIdRegistry()64cdf0e10cSrcweir     virtual ~IXmlIdRegistry() { }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
67cdf0e10cSrcweir             ::com::sun::star::rdf::XMetadatable > SAL_CALL
68cdf0e10cSrcweir         GetElementByMetadataReference(
69cdf0e10cSrcweir             const ::com::sun::star::beans::StringPair & i_rXmlId) const = 0;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir /** supplier interface for the registry.
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     This indirection is unfortunately necessary, because the SwDocShell
76cdf0e10cSrcweir     is not always connected to a SwDoc, so we cannot guarantee that a
77cdf0e10cSrcweir     registry given to a SfxBaseModel/DocumentMetadataAccess remains valid;
78cdf0e10cSrcweir     it has to be retrieved from this supplier interface on access.
79cdf0e10cSrcweir  */
80cdf0e10cSrcweir class SFX2_DLLPUBLIC IXmlIdRegistrySupplier
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 
83cdf0e10cSrcweir public:
~IXmlIdRegistrySupplier()84cdf0e10cSrcweir     virtual ~IXmlIdRegistrySupplier() { }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     /** override this if you have a XmlIdRegistry. */
GetXmlIdRegistry() const87cdf0e10cSrcweir     virtual const IXmlIdRegistry* GetXmlIdRegistry() const { return 0; }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir };
90cdf0e10cSrcweir 
91cdf0e10cSrcweir } // namespace sfx2
92cdf0e10cSrcweir 
93cdf0e10cSrcweir #endif // _SFX_XMLIDREGISTRY_HXX_
94cdf0e10cSrcweir 
95