Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "sal/config.h"
21 :
22 : #include <tools/debug.hxx>
23 : #include <rtl/ustring.hxx>
24 : #include <rtl/ustrbuf.hxx>
25 :
26 : #include <xmloff/xmltoken.hxx>
27 : #include <xmloff/nmspmap.hxx>
28 :
29 : #include "xmloff/xmlnmspe.hxx"
30 :
31 :
32 : using ::rtl::OUString;
33 : using ::rtl::OUStringBuffer;
34 : using namespace ::xmloff::token;
35 :
36 : /* The basic idea of this class is that we have two two ways to search our
37 : * data...by prefix and by key. We use an STL boost::unordered_map for fast prefix
38 : * searching and an STL map for fast key searching.
39 : *
40 : * The references to an 'Index' refer to an earlier implementation of the
41 : * name space map and remain to support code which uses these interfaces.
42 : *
43 : * In this implementation, key and index should always be the same number.
44 : *
45 : * All references to Indices are now deprecated and the corresponding
46 : * 'Key' methods should be used instead
47 : *
48 : * Martin 13/06/01
49 : */
50 :
51 3854 : SvXMLNamespaceMap::SvXMLNamespaceMap()
52 3854 : : sXMLNS( GetXMLToken ( XML_XMLNS ) )
53 : {
54 3854 : }
55 :
56 1482 : SvXMLNamespaceMap::SvXMLNamespaceMap( const SvXMLNamespaceMap& rMap )
57 1482 : : sXMLNS( GetXMLToken ( XML_XMLNS ) )
58 : {
59 1482 : aNameHash = rMap.aNameHash;
60 1482 : aNameMap = rMap.aNameMap;
61 1482 : }
62 :
63 0 : void SvXMLNamespaceMap::operator=( const SvXMLNamespaceMap& rMap )
64 : {
65 0 : aNameHash = rMap.aNameHash;
66 0 : aNameMap = rMap.aNameMap;
67 0 : }
68 :
69 4625 : SvXMLNamespaceMap::~SvXMLNamespaceMap()
70 : {
71 4625 : }
72 :
73 966 : int SvXMLNamespaceMap::operator ==( const SvXMLNamespaceMap& rCmp ) const
74 : {
75 966 : return static_cast < int > (aNameHash == rCmp.aNameHash);
76 : }
77 :
78 43500 : sal_uInt16 SvXMLNamespaceMap::_Add( const OUString& rPrefix, const OUString &rName, sal_uInt16 nKey )
79 : {
80 43500 : if( XML_NAMESPACE_UNKNOWN == nKey )
81 : {
82 : // create a new unique key with UNKNOWN flag set
83 520 : nKey = XML_NAMESPACE_UNKNOWN_FLAG;
84 208 : do
85 : {
86 728 : NameSpaceMap::const_iterator aIter = aNameMap.find ( nKey );
87 728 : if( aIter == aNameMap.end() )
88 : break;
89 208 : nKey++;
90 : }
91 : while ( sal_True );
92 : }
93 43500 : ::rtl::Reference<NameSpaceEntry> pEntry(new NameSpaceEntry);
94 43500 : pEntry->sName = rName;
95 43500 : pEntry->nKey = nKey;
96 43500 : pEntry->sPrefix = rPrefix;
97 43500 : aNameHash[ rPrefix ] = pEntry;
98 43500 : aNameMap [ nKey ] = pEntry;
99 43500 : return nKey;
100 : }
101 :
102 37436 : sal_uInt16 SvXMLNamespaceMap::Add( const OUString& rPrefix, const OUString& rName,
103 : sal_uInt16 nKey )
104 : {
105 37436 : if( XML_NAMESPACE_UNKNOWN == nKey )
106 520 : nKey = GetKeyByName( rName );
107 :
108 : DBG_ASSERT( XML_NAMESPACE_NONE != nKey,
109 : "SvXMLNamespaceMap::Add: invalid namespace key" );
110 :
111 37436 : if( XML_NAMESPACE_NONE == nKey )
112 0 : return USHRT_MAX;
113 :
114 37436 : if ( aNameHash.find ( rPrefix ) == aNameHash.end() )
115 36812 : nKey = _Add( rPrefix, rName, nKey );
116 :
117 37436 : return nKey;
118 : }
119 :
120 7404 : sal_uInt16 SvXMLNamespaceMap::AddIfKnown( const OUString& rPrefix, const OUString& rName )
121 : {
122 7404 : sal_uInt16 nKey = GetKeyByName( rName );
123 :
124 : DBG_ASSERT( XML_NAMESPACE_NONE != nKey,
125 : "SvXMLNamespaceMap::AddIfKnown: invalid namespace key" );
126 :
127 7404 : if( XML_NAMESPACE_NONE == nKey )
128 0 : return XML_NAMESPACE_UNKNOWN;
129 :
130 7404 : if( XML_NAMESPACE_UNKNOWN != nKey )
131 : {
132 6882 : NameSpaceHash::const_iterator aIter = aNameHash.find( rPrefix );
133 6882 : if( aIter == aNameHash.end() || (*aIter).second->sName != rName )
134 6688 : nKey = _Add( rPrefix, rName, nKey );
135 : }
136 :
137 7404 : return nKey;
138 : }
139 :
140 :
141 0 : sal_uInt16 SvXMLNamespaceMap::GetKeyByPrefix( const OUString& rPrefix ) const
142 : {
143 0 : NameSpaceHash::const_iterator aIter = aNameHash.find(rPrefix);
144 0 : return (aIter != aNameHash.end()) ? (*aIter).second->nKey : USHRT_MAX;
145 : }
146 :
147 7924 : sal_uInt16 SvXMLNamespaceMap::GetKeyByName( const OUString& rName ) const
148 : {
149 7924 : sal_uInt16 nKey = XML_NAMESPACE_UNKNOWN;
150 7924 : NameSpaceHash::const_iterator aIter = aNameHash.begin(), aEnd = aNameHash.end();
151 252668 : while (aIter != aEnd )
152 : {
153 243702 : if ((*aIter).second->sName == rName)
154 : {
155 6882 : nKey = (*aIter).second->nKey;
156 6882 : break;
157 : }
158 236820 : ++aIter;
159 : }
160 7924 : return nKey;
161 : }
162 :
163 0 : const OUString& SvXMLNamespaceMap::GetPrefixByKey( sal_uInt16 nKey ) const
164 : {
165 0 : NameSpaceMap::const_iterator aIter = aNameMap.find (nKey);
166 0 : return (aIter != aNameMap.end()) ? (*aIter).second->sPrefix : sEmpty;
167 : }
168 :
169 3498 : const OUString& SvXMLNamespaceMap::GetNameByKey( sal_uInt16 nKey ) const
170 : {
171 3498 : NameSpaceMap::const_iterator aIter = aNameMap.find (nKey);
172 3498 : return (aIter != aNameMap.end()) ? (*aIter).second->sName : sEmpty;
173 : }
174 :
175 3652 : OUString SvXMLNamespaceMap::GetAttrNameByKey( sal_uInt16 nKey ) const
176 : {
177 3652 : OUStringBuffer sAttrName;
178 3652 : NameSpaceMap::const_iterator aIter = aNameMap.find ( nKey );
179 3652 : if (aIter != aNameMap.end())
180 : {
181 3652 : sAttrName.append( sXMLNS );
182 3652 : const ::rtl::OUString & prefix( (*aIter).second->sPrefix );
183 3652 : if (!prefix.isEmpty()) // not default namespace
184 : {
185 3084 : sAttrName.append( sal_Unicode(':') );
186 3084 : sAttrName.append( prefix );
187 : }
188 : }
189 3652 : return sAttrName.makeStringAndClear();
190 : }
191 :
192 132387 : OUString SvXMLNamespaceMap::GetQNameByKey( sal_uInt16 nKey,
193 : const OUString& rLocalName,
194 : sal_Bool bCache) const
195 : {
196 : // We always want to return at least the rLocalName...
197 :
198 132387 : switch ( nKey )
199 : {
200 : case XML_NAMESPACE_UNKNOWN:
201 : // ...if it's a completely unknown namespace, assert and return the local name
202 : DBG_ASSERT( sal_False, "SvXMLNamespaceMap::GetQNameByKey: invalid namespace key" );
203 : case XML_NAMESPACE_NONE:
204 : // ...if there isn't one, return the local name
205 0 : return rLocalName;
206 : case XML_NAMESPACE_XMLNS:
207 : {
208 : // ...if it's in the xmlns namespace, make the prefix
209 : // don't bother caching this, it rarely happens
210 0 : OUStringBuffer sQName;
211 0 : sQName.append ( sXMLNS );
212 0 : if (!rLocalName.isEmpty()) // not default namespace
213 : {
214 0 : sQName.append ( sal_Unicode(':') );
215 0 : sQName.append ( rLocalName );
216 : }
217 0 : return sQName.makeStringAndClear();
218 : }
219 : case XML_NAMESPACE_XML:
220 : {
221 : // this namespace is reserved, and needs not to be declared
222 0 : OUStringBuffer sQName;
223 0 : sQName.append ( GetXMLToken(XML_XML) );
224 0 : sQName.append ( sal_Unicode(':') );
225 0 : sQName.append ( rLocalName );
226 0 : return sQName.makeStringAndClear();
227 : }
228 : default:
229 : {
230 132387 : QNameCache::const_iterator aQCacheIter;
231 132387 : if (bCache)
232 132383 : aQCacheIter = aQNameCache.find ( QNamePair ( nKey, rLocalName ) );
233 : else
234 4 : aQCacheIter = aQNameCache.end();
235 132387 : if ( aQCacheIter != aQNameCache.end() )
236 119093 : return (*aQCacheIter).second;
237 : else
238 : {
239 13294 : NameSpaceMap::const_iterator aIter = aNameMap.find ( nKey );
240 13294 : if ( aIter != aNameMap.end() )
241 : {
242 13294 : OUStringBuffer sQName;
243 : // ...if it's in our map, make the prefix
244 13294 : const OUString & prefix( (*aIter).second->sPrefix );
245 13294 : if (!prefix.isEmpty()) // not default namespace
246 : {
247 7438 : sQName.append( prefix );
248 7438 : sQName.append( sal_Unicode(':') );
249 : }
250 13294 : sQName.append ( rLocalName );
251 13294 : if (bCache)
252 : {
253 13290 : OUString sString(sQName.makeStringAndClear());
254 : aQNameCache.insert(
255 : QNameCache::value_type(
256 13290 : QNamePair(nKey, rLocalName), sString));
257 13290 : return sString;
258 : }
259 : else
260 4 : return sQName.makeStringAndClear();
261 : }
262 : else
263 : {
264 : // ... if it isn't, this is a Bad Thing, assert and return the local name
265 : DBG_ASSERT( sal_False, "SvXMLNamespaceMap::GetQNameByKey: invalid namespace key" );
266 0 : return rLocalName;
267 : }
268 : }
269 : }
270 : }
271 : }
272 :
273 2 : sal_uInt16 SvXMLNamespaceMap::_GetKeyByAttrName(
274 : const OUString& rAttrName,
275 : OUString *pLocalName,
276 : sal_Bool bCache) const
277 : {
278 2 : return _GetKeyByAttrName( rAttrName, 0, pLocalName, 0, bCache );
279 : }
280 :
281 144443 : sal_uInt16 SvXMLNamespaceMap::_GetKeyByAttrName( const OUString& rAttrName,
282 : OUString *pPrefix,
283 : OUString *pLocalName,
284 : OUString *pNamespace,
285 : sal_Bool bCache) const
286 : {
287 144443 : sal_uInt16 nKey = XML_NAMESPACE_UNKNOWN;
288 :
289 144443 : NameSpaceHash::const_iterator it;
290 144443 : if (bCache)
291 143655 : it = aNameCache.find ( rAttrName );
292 : else
293 788 : it = aNameCache.end();
294 144443 : if ( it != aNameCache.end() )
295 : {
296 126048 : const NameSpaceEntry &rEntry = *((*it).second);
297 126048 : if ( pPrefix )
298 7254 : *pPrefix = rEntry.sPrefix;
299 126048 : if ( pLocalName )
300 126048 : *pLocalName = rEntry.sName;
301 126048 : nKey = rEntry.nKey;
302 126048 : if ( pNamespace )
303 : {
304 7254 : NameSpaceMap::const_iterator aMapIter = aNameMap.find (nKey);
305 7254 : *pNamespace = aMapIter != aNameMap.end() ? (*aMapIter).second->sName : sEmpty;
306 : }
307 : }
308 : else
309 : {
310 18395 : rtl::Reference<NameSpaceEntry> xEntry(new NameSpaceEntry());
311 :
312 18395 : sal_Int32 nColonPos = rAttrName.indexOf( sal_Unicode(':') );
313 18395 : if( -1L == nColonPos )
314 : {
315 : // case: no ':' found -> default namespace
316 56 : xEntry->sPrefix = OUString();
317 56 : xEntry->sName = rAttrName;
318 : }
319 : else
320 : {
321 : // normal case: ':' found -> get prefix/suffix
322 18339 : xEntry->sPrefix = rAttrName.copy( 0L, nColonPos );
323 18339 : xEntry->sName = rAttrName.copy( nColonPos + 1L );
324 : }
325 :
326 18395 : if( pPrefix )
327 5257 : *pPrefix = xEntry->sPrefix;
328 18395 : if( pLocalName )
329 18395 : *pLocalName = xEntry->sName;
330 :
331 18395 : NameSpaceHash::const_iterator aIter = aNameHash.find( xEntry->sPrefix );
332 18395 : if ( aIter != aNameHash.end() )
333 : {
334 : // found: retrieve namespace key
335 18341 : nKey = xEntry->nKey = (*aIter).second->nKey;
336 18341 : if ( pNamespace )
337 5995 : *pNamespace = (*aIter).second->sName;
338 : }
339 54 : else if ( xEntry->sPrefix == sXMLNS )
340 : // not found, but xmlns prefix: return xmlns 'namespace'
341 6 : nKey = xEntry->nKey = XML_NAMESPACE_XMLNS;
342 48 : else if( nColonPos == -1L )
343 : // not found, and no namespace: 'namespace' none
344 40 : nKey = xEntry->nKey = XML_NAMESPACE_NONE;
345 :
346 18395 : if (bCache)
347 : {
348 17607 : aNameCache.insert(NameSpaceHash::value_type(rAttrName, xEntry));
349 18395 : }
350 : }
351 :
352 144443 : return nKey;
353 : }
354 :
355 656 : sal_uInt16 SvXMLNamespaceMap::GetFirstKey() const
356 : {
357 656 : return aNameMap.empty() ? USHRT_MAX : (*aNameMap.begin()).second->nKey;
358 : }
359 :
360 3024 : sal_uInt16 SvXMLNamespaceMap::GetNextKey( sal_uInt16 nLastKey ) const
361 : {
362 3024 : NameSpaceMap::const_iterator aIter = aNameMap.find ( nLastKey );
363 3024 : return (++aIter == aNameMap.end()) ? USHRT_MAX : (*aIter).second->nKey;
364 : }
365 :
366 :
367 : // All methods after this are deprecated...
368 :
369 0 : sal_uInt16 SvXMLNamespaceMap::GetIndexByKey( sal_uInt16 nKey ) const
370 : {
371 0 : return nKey;
372 : }
373 0 : sal_uInt16 SvXMLNamespaceMap::GetFirstIndex() const
374 : {
375 0 : return aNameMap.empty() ? USHRT_MAX : (*aNameMap.begin()).second->nKey;
376 : }
377 :
378 0 : sal_uInt16 SvXMLNamespaceMap::GetNextIndex( sal_uInt16 nOldIdx ) const
379 : {
380 0 : NameSpaceMap::const_iterator aIter = aNameMap.find ( nOldIdx );
381 0 : return (++aIter == aNameMap.end()) ? USHRT_MAX : (*aIter).second->nKey;
382 : }
383 :
384 0 : sal_Bool SvXMLNamespaceMap::AddAtIndex( sal_uInt16 /*nIdx*/, const OUString& rPrefix,
385 : const OUString& rName, sal_uInt16 nKey )
386 : {
387 0 : sal_Bool bRet = sal_False;
388 :
389 0 : if( XML_NAMESPACE_UNKNOWN == nKey )
390 0 : nKey = GetKeyByName( rName );
391 :
392 : DBG_ASSERT( XML_NAMESPACE_NONE != nKey,
393 : "SvXMLNamespaceMap::AddAtIndex: invalid namespace key" );
394 0 : if( XML_NAMESPACE_NONE != nKey && ! ( aNameHash.count ( rPrefix ) ) )
395 : {
396 0 : _Add( rPrefix, rName, nKey );
397 0 : bRet = sal_True;
398 : }
399 0 : return bRet;
400 : }
401 :
402 0 : OUString SvXMLNamespaceMap::GetAttrNameByIndex( sal_uInt16 nIdx ) const
403 : {
404 0 : return GetAttrNameByKey( nIdx );
405 : }
406 :
407 62 : OUString SvXMLNamespaceMap::GetQNameByIndex( sal_uInt16 nIdx,
408 : const OUString& rLocalName ) const
409 : {
410 62 : return GetQNameByKey( nIdx, rLocalName );
411 : }
412 :
413 0 : const OUString& SvXMLNamespaceMap::GetPrefixByIndex( sal_uInt16 nIdx ) const
414 : {
415 0 : NameSpaceMap::const_iterator aIter = aNameMap.find (nIdx);
416 0 : return (aIter != aNameMap.end()) ? (*aIter).second->sPrefix : sEmpty;
417 : }
418 :
419 0 : const OUString& SvXMLNamespaceMap::GetNameByIndex( sal_uInt16 nIdx ) const
420 : {
421 0 : NameSpaceMap::const_iterator aIter = aNameMap.find (nIdx);
422 0 : return (aIter != aNameMap.end()) ? (*aIter).second->sName : sEmpty;
423 : }
424 :
425 0 : sal_uInt16 SvXMLNamespaceMap::GetIndexByPrefix( const OUString& rPrefix ) const
426 : {
427 0 : NameSpaceHash::const_iterator aIter = aNameHash.find(rPrefix);
428 0 : return (aIter != aNameHash.end()) ? (*aIter).second->nKey : USHRT_MAX;
429 : }
430 131144 : sal_uInt16 SvXMLNamespaceMap::GetKeyByAttrName(
431 : const OUString& rAttrName,
432 : OUString *pLocalName,
433 : sal_uInt16 /*nIdxGuess*/) const
434 : {
435 131144 : return _GetKeyByAttrName( rAttrName, 0, pLocalName, 0 );
436 : }
437 :
438 12511 : sal_uInt16 SvXMLNamespaceMap::GetKeyByAttrName( const OUString& rAttrName,
439 : OUString *pPrefix,
440 : OUString *pLocalName,
441 : OUString *pNamespace,
442 : sal_uInt16 /*nIdxGuess*/ ) const
443 : {
444 12511 : return _GetKeyByAttrName ( rAttrName, pPrefix, pLocalName, pNamespace );
445 : }
446 :
447 522 : sal_Bool SvXMLNamespaceMap::NormalizeURI( ::rtl::OUString& rName )
448 : {
449 : // try OASIS + W3 URI normalization
450 522 : sal_Bool bSuccess = NormalizeOasisURN( rName );
451 522 : if( ! bSuccess )
452 520 : bSuccess = NormalizeW3URI( rName );
453 522 : return bSuccess;
454 : }
455 :
456 520 : sal_Bool SvXMLNamespaceMap::NormalizeW3URI( ::rtl::OUString& rName )
457 : {
458 : // check if URI matches:
459 : // http://www.w3.org/[0-9]*/[:letter:]*
460 : // (year)/(WG name)
461 : // For the following WG/standards names:
462 : // - xforms
463 :
464 520 : sal_Bool bSuccess = sal_False;
465 520 : const OUString sURIPrefix = GetXMLToken( XML_URI_W3_PREFIX );
466 520 : if( rName.compareTo( sURIPrefix, sURIPrefix.getLength() ) == 0 )
467 : {
468 312 : const OUString sURISuffix = GetXMLToken( XML_URI_XFORMS_SUFFIX );
469 312 : sal_Int32 nCompareFrom = rName.getLength() - sURISuffix.getLength();
470 312 : if( rName.copy( nCompareFrom ).equals( sURISuffix ) )
471 : {
472 : // found W3 prefix, and xforms suffix
473 0 : rName = GetXMLToken( XML_N_XFORMS_1_0 );
474 0 : bSuccess = sal_True;
475 312 : }
476 : }
477 520 : return bSuccess;
478 : }
479 :
480 522 : sal_Bool SvXMLNamespaceMap::NormalizeOasisURN( ::rtl::OUString& rName )
481 : {
482 : // #i38644#
483 : // we exported the wrong namespace for smil, so we correct this here on load
484 : // for older documents
485 522 : if( IsXMLToken( rName, ::xmloff::token::XML_N_SVG ) )
486 : {
487 2 : rName = GetXMLToken( ::xmloff::token::XML_N_SVG_COMPAT );
488 2 : return sal_True;
489 : }
490 520 : else if( IsXMLToken( rName, ::xmloff::token::XML_N_FO ) )
491 : {
492 0 : rName = GetXMLToken( ::xmloff::token::XML_N_FO_COMPAT );
493 0 : return sal_True;
494 : }
495 1040 : else if( IsXMLToken( rName, ::xmloff::token::XML_N_SMIL ) ||
496 520 : IsXMLToken( rName, ::xmloff::token::XML_N_SMIL_OLD ) )
497 : {
498 0 : rName = GetXMLToken( ::xmloff::token::XML_N_SMIL_COMPAT );
499 0 : return sal_True;
500 : }
501 :
502 : //
503 : // Check if URN matches
504 : // :urn:oasis:names:tc:[^:]*:xmlns:[^:]*:1.[^:]*
505 : // |---| |---| |-----|
506 : // TC-Id Sub-Id Version
507 :
508 520 : sal_Int32 nNameLen = rName.getLength();
509 : // :urn:oasis:names:tc.*
510 520 : const OUString& rOasisURN = GetXMLToken( XML_URN_OASIS_NAMES_TC );
511 520 : if( 0 != rName.compareTo( rOasisURN, rOasisURN.getLength() ) )
512 520 : return sal_False;
513 :
514 : // :urn:oasis:names:tc:.*
515 0 : sal_Int32 nPos = rOasisURN.getLength();
516 0 : if( nPos >= nNameLen || rName[nPos] != ':' )
517 0 : return sal_False;
518 :
519 : // :urn:oasis:names:tc:[^:]:.*
520 0 : sal_Int32 nTCIdStart = nPos+1;
521 0 : sal_Int32 nTCIdEnd = rName.indexOf( ':', nTCIdStart );
522 0 : if( -1 == nTCIdEnd )
523 0 : return sal_False;
524 :
525 : // :urn:oasis:names:tc:[^:]:xmlns.*
526 0 : nPos = nTCIdEnd + 1;
527 0 : OUString sTmp( rName.copy( nPos ) );
528 0 : const OUString& rXMLNS = GetXMLToken( XML_XMLNS );
529 0 : if( 0!= sTmp.compareTo( rXMLNS, rXMLNS.getLength() ) )
530 0 : return sal_False;
531 :
532 : // :urn:oasis:names:tc:[^:]:xmlns:.*
533 0 : nPos += rXMLNS.getLength();
534 0 : if( nPos >= nNameLen || rName[nPos] != ':' )
535 0 : return sal_False;
536 :
537 : // :urn:oasis:names:tc:[^:]:xmlns:[^:]*:.*
538 0 : nPos = rName.indexOf( ':', nPos+1 );
539 0 : if( -1 == nPos )
540 0 : return sal_False;
541 :
542 : // :urn:oasis:names:tc:[^:]:xmlns:[^:]*:[^:][^:][^:][^:]*
543 0 : sal_Int32 nVersionStart = nPos+1;
544 0 : if( nVersionStart+2 >= nNameLen ||
545 0 : -1 != rName.indexOf( ':', nVersionStart ) )
546 0 : return sal_False;
547 :
548 : // :urn:oasis:names:tc:[^:]:xmlns:[^:]*:1\.[^:][^:]*
549 0 : if( rName[nVersionStart] != '1' || rName[nVersionStart+1] != '.' )
550 0 : return sal_False;
551 :
552 : // replace [tcid] with current TCID and version with current version.
553 0 : OUStringBuffer aNewName( nNameLen +20 );
554 0 : aNewName.append( rName.copy( 0, nTCIdStart ) );
555 0 : aNewName.append( GetXMLToken( XML_OPENDOCUMENT ) );
556 0 : aNewName.append( rName.copy( nTCIdEnd, nVersionStart-nTCIdEnd ) );
557 0 : aNewName.append( GetXMLToken( XML_1_0 ) );
558 :
559 0 : rName = aNewName.makeStringAndClear();
560 :
561 0 : return sal_True;
562 : }
563 :
564 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|