Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "framework/ResourceId.hxx"
31 : : #include "framework/FrameworkHelper.hxx"
32 : : #include "tools/SdGlobalResourceContainer.hxx"
33 : : #include <com/sun/star/lang/IllegalArgumentException.hpp>
34 : : #include <com/sun/star/uno/XComponentContext.hpp>
35 : : #include <com/sun/star/util/URLTransformer.hpp>
36 : : #include <comphelper/processfactory.hxx>
37 : : #include <rtl/ref.hxx>
38 : :
39 : : using namespace ::com::sun::star;
40 : : using namespace ::com::sun::star::uno;
41 : : using namespace ::com::sun::star::lang;
42 : : using namespace ::com::sun::star::drawing::framework;
43 : : using ::rtl::OUString;
44 : :
45 : : /** When the USE_OPTIMIZATIONS symbol is defined then at some optimizations
46 : : are activated that work only together with XResourceId objects that are
47 : : implemented by the ResourceId class. For other implementations of when
48 : : the USE_OPTIMIZATIONS symbol is not defined then alternative code is
49 : : used instead.
50 : : */
51 : : #define USE_OPTIMIZATIONS
52 : :
53 : : namespace sd { namespace framework {
54 : :
55 : 189 : Reference<XInterface> SAL_CALL ResourceId_createInstance (
56 : : const Reference<XComponentContext>& rxContext)
57 : : {
58 : : (void)rxContext;
59 [ + - ]: 189 : return Reference<XInterface>(static_cast<XWeak*>(new ::sd::framework::ResourceId()));
60 : : }
61 : :
62 : :
63 : :
64 : :
65 : 38 : ::rtl::OUString ResourceId_getImplementationName (void) throw(RuntimeException)
66 : : {
67 : 38 : return ::rtl::OUString("com.sun.star.comp.Draw.framework.ResourceId");
68 : : }
69 : :
70 : :
71 : :
72 : :
73 : 16 : Sequence<rtl::OUString> SAL_CALL ResourceId_getSupportedServiceNames (void)
74 : : throw (RuntimeException)
75 : : {
76 [ + - ][ + - ]: 16 : static const ::rtl::OUString sServiceName("com.sun.star.drawing.framework.ResourceId");
77 : 16 : return Sequence<rtl::OUString>(&sServiceName, 1);
78 : : }
79 : :
80 : :
81 : :
82 : :
83 : : //===== ResourceId ============================================================
84 : :
85 : 25 : WeakReference<util::XURLTransformer> ResourceId::mxURLTransformerWeak;
86 : :
87 : 1663 : ResourceId::ResourceId (void)
88 : : : ResourceIdInterfaceBase(),
89 : : maResourceURLs(0),
90 [ + - ]: 1663 : mpURL()
91 : : {
92 : 1663 : }
93 : :
94 : :
95 : :
96 : :
97 : 0 : ResourceId::ResourceId (
98 : : const std::vector<OUString>& rResourceURLs)
99 : : : ResourceIdInterfaceBase(),
100 : : maResourceURLs(rResourceURLs),
101 [ # # ]: 0 : mpURL()
102 : : {
103 [ # # ]: 0 : ParseResourceURL();
104 : 0 : }
105 : :
106 : :
107 : :
108 : :
109 : 8331 : ResourceId::ResourceId (
110 : : const OUString& rsResourceURL)
111 : : : ResourceIdInterfaceBase(),
112 : : maResourceURLs(1, rsResourceURL),
113 [ + - ]: 8331 : mpURL()
114 : : {
115 : : // Handle the special case of an empty resource URL.
116 [ - + ]: 8331 : if (rsResourceURL.isEmpty())
117 : 0 : maResourceURLs.clear();
118 [ + - ]: 8331 : ParseResourceURL();
119 : 8331 : }
120 : :
121 : :
122 : :
123 : :
124 : 568 : ResourceId::ResourceId (
125 : : const OUString& rsResourceURL,
126 : : const OUString& rsAnchorURL)
127 : : : ResourceIdInterfaceBase(),
128 : : maResourceURLs(2),
129 [ + - ]: 568 : mpURL()
130 : : {
131 : 568 : maResourceURLs[0] = rsResourceURL;
132 : 568 : maResourceURLs[1] = rsAnchorURL;
133 [ + - ]: 568 : ParseResourceURL();
134 : 568 : }
135 : :
136 : :
137 : :
138 : :
139 : 52 : ResourceId::ResourceId (
140 : : const OUString& rsResourceURL,
141 : : const ::std::vector<OUString>& rAnchorURLs)
142 : : : ResourceIdInterfaceBase(),
143 : 52 : maResourceURLs(1+rAnchorURLs.size()),
144 [ + - ]: 104 : mpURL()
145 : : {
146 : 52 : maResourceURLs[0] = rsResourceURL;
147 [ + + ]: 156 : for (sal_uInt32 nIndex=0; nIndex<rAnchorURLs.size(); ++nIndex)
148 : 104 : maResourceURLs[nIndex+1] = rAnchorURLs[nIndex];
149 [ + - ]: 52 : ParseResourceURL();
150 : 52 : }
151 : :
152 : :
153 : :
154 : :
155 : 234 : ResourceId::ResourceId (
156 : : const OUString& rsResourceURL,
157 : : const OUString& rsFirstAnchorURL,
158 : : const Sequence<OUString>& rAnchorURLs)
159 : : : ResourceIdInterfaceBase(),
160 : 234 : maResourceURLs(2+rAnchorURLs.getLength()),
161 [ + - ]: 468 : mpURL()
162 : : {
163 : 234 : maResourceURLs[0] = rsResourceURL;
164 : 234 : maResourceURLs[1] = rsFirstAnchorURL;
165 [ - + ]: 234 : for (sal_Int32 nIndex=0; nIndex<rAnchorURLs.getLength(); ++nIndex)
166 : 0 : maResourceURLs[nIndex+2] = rAnchorURLs[nIndex];
167 [ + - ]: 234 : ParseResourceURL();
168 : 234 : }
169 : :
170 : :
171 : :
172 : :
173 [ + - ]: 10692 : ResourceId::~ResourceId (void)
174 : : {
175 [ + - ]: 10692 : mpURL.reset();
176 [ - + ]: 21384 : }
177 : :
178 : :
179 : :
180 : :
181 : : OUString SAL_CALL
182 : 27079 : ResourceId::getResourceURL (void)
183 : : throw(com::sun::star::uno::RuntimeException)
184 : : {
185 [ + + ]: 27079 : if (!maResourceURLs.empty())
186 : 27035 : return maResourceURLs[0];
187 : : else
188 : 27079 : return OUString();
189 : : }
190 : :
191 : :
192 : :
193 : :
194 : : util::URL SAL_CALL
195 : 0 : ResourceId::getFullResourceURL (void)
196 : : throw(com::sun::star::uno::RuntimeException)
197 : : {
198 [ # # ]: 0 : if (mpURL.get() != NULL)
199 : 0 : return *mpURL;
200 : :
201 [ # # ]: 0 : Reference<util::XURLTransformer> xURLTransformer (mxURLTransformerWeak);
202 [ # # ][ # # ]: 0 : if (xURLTransformer.is() && !maResourceURLs.empty() )
[ # # ]
203 : : {
204 [ # # ][ # # ]: 0 : mpURL.reset(new util::URL);
205 : 0 : mpURL->Complete = maResourceURLs[0];
206 [ # # ][ # # ]: 0 : xURLTransformer->parseStrict(*mpURL);
207 : 0 : return *mpURL;
208 : : }
209 : :
210 : 0 : util::URL aURL;
211 [ # # ]: 0 : if (!maResourceURLs.empty())
212 : 0 : aURL.Complete = maResourceURLs[0];
213 : 0 : return aURL;
214 : : }
215 : :
216 : :
217 : :
218 : :
219 : : sal_Bool SAL_CALL
220 : 0 : ResourceId::hasAnchor (void)
221 : : throw (RuntimeException)
222 : : {
223 : 0 : return maResourceURLs.size()>1;
224 : : }
225 : :
226 : :
227 : :
228 : :
229 : : Reference<XResourceId> SAL_CALL
230 : 1474 : ResourceId::getAnchor (void)
231 : : throw (RuntimeException)
232 : : {
233 [ + - ]: 1474 : ::rtl::Reference<ResourceId> rResourceId (new ResourceId());
234 : 1474 : const sal_Int32 nAnchorCount (maResourceURLs.size()-1);
235 [ + + ]: 1474 : if (nAnchorCount > 0)
236 : : {
237 [ + - ]: 1430 : rResourceId->maResourceURLs.resize(nAnchorCount);
238 [ + + ]: 2972 : for (sal_Int32 nIndex=0; nIndex<nAnchorCount; ++nIndex)
239 : 1542 : rResourceId->maResourceURLs[nIndex] = maResourceURLs[nIndex+1];
240 : : }
241 [ + - ][ + - ]: 1474 : return Reference<XResourceId>(rResourceId.get());
242 : : }
243 : :
244 : :
245 : :
246 : :
247 : : Sequence<OUString> SAL_CALL
248 : 234 : ResourceId::getAnchorURLs (void)
249 : : throw (RuntimeException)
250 : : {
251 : 234 : const sal_Int32 nAnchorCount (maResourceURLs.size() - 1);
252 [ - + ]: 234 : if (nAnchorCount > 0)
253 : : {
254 [ # # ]: 0 : Sequence<OUString> aAnchorURLs (nAnchorCount);
255 [ # # ]: 0 : for (sal_Int32 nIndex=0; nIndex<nAnchorCount; ++nIndex)
256 [ # # ]: 0 : aAnchorURLs[nIndex] = maResourceURLs[nIndex+1];
257 [ # # ][ # # ]: 0 : return aAnchorURLs;
258 : : }
259 : : else
260 : 234 : return Sequence<OUString>();
261 : : }
262 : :
263 : :
264 : :
265 : :
266 : : OUString SAL_CALL
267 : 1439 : ResourceId::getResourceTypePrefix (void)
268 : : throw (RuntimeException)
269 : : {
270 [ + - ]: 1439 : if (!maResourceURLs.empty() )
271 : : {
272 : : // Return the "private:resource/<type>/" prefix.
273 : :
274 : : // Get the the prefix that ends with the second "/".
275 : 1439 : const OUString& rsResourceURL (maResourceURLs[0]);
276 : 1439 : sal_Int32 nPrefixEnd (rsResourceURL.indexOf(sal_Unicode('/'), 0));
277 [ + - ]: 1439 : if (nPrefixEnd >= 0)
278 : 1439 : nPrefixEnd = rsResourceURL.indexOf(sal_Unicode('/'), nPrefixEnd+1) + 1;
279 : : else
280 : 0 : nPrefixEnd = 0;
281 : :
282 : 1439 : return rsResourceURL.copy(0,nPrefixEnd);
283 : : }
284 : : else
285 : 1439 : return OUString();
286 : : }
287 : :
288 : :
289 : :
290 : :
291 : : sal_Int16 SAL_CALL
292 : 59582 : ResourceId::compareTo (const Reference<XResourceId>& rxResourceId)
293 : : throw (RuntimeException)
294 : : {
295 : 59582 : sal_Int16 nResult (0);
296 : :
297 [ - + ]: 59582 : if ( ! rxResourceId.is())
298 : : {
299 : : // The empty reference is interpreted as empty resource id object.
300 [ # # ]: 0 : if (!maResourceURLs.empty())
301 : 0 : nResult = +1;
302 : : else
303 : 0 : nResult = 0;
304 : : }
305 : : else
306 : : {
307 : 59582 : ResourceId* pId = NULL;
308 : : #ifdef USE_OPTIMIZATIONS
309 [ - + ]: 59582 : pId = dynamic_cast<ResourceId*>(rxResourceId.get());
310 : : #endif
311 [ + - ]: 59582 : if (pId != NULL)
312 : : {
313 : : // We have direct access to the implementation of the given
314 : : // resource id object.
315 : 59582 : nResult = CompareToLocalImplementation(*pId);
316 : : }
317 : : else
318 : : {
319 : : // We have to do the comparison via the UNO interface of the
320 : : // given resource id object.
321 : 0 : nResult = CompareToExternalImplementation(rxResourceId);
322 : : }
323 : : }
324 : :
325 : 59582 : return nResult;
326 : : }
327 : :
328 : :
329 : :
330 : :
331 : 59582 : sal_Int16 ResourceId::CompareToLocalImplementation (const ResourceId& rId) const
332 : : {
333 : 59582 : sal_Int16 nResult (0);
334 : :
335 : 59582 : const sal_uInt32 nLocalURLCount (maResourceURLs.size());
336 : 59582 : const sal_uInt32 nURLCount(rId.maResourceURLs.size());
337 : :
338 : : // Start comparison with the top most anchors.
339 [ + + ][ + + ]: 142345 : for (sal_Int32 nIndex=nURLCount-1,nLocalIndex=nLocalURLCount-1;
[ + + ]
340 : : nIndex>=0 && nLocalIndex>=0;
341 : : --nIndex,--nLocalIndex)
342 : : {
343 : 82763 : const OUString sLocalURL (maResourceURLs[nLocalIndex]);
344 : 82763 : const OUString sURL (rId.maResourceURLs[nIndex]);
345 : 82763 : const sal_Int32 nLocalResult (sURL.compareTo(sLocalURL));
346 [ + + ]: 82763 : if (nLocalResult != 0)
347 : : {
348 [ + + ]: 16994 : if (nLocalResult < 0)
349 : 10880 : nResult = -1;
350 : : else
351 : 82763 : nResult = +1;
352 : : break;
353 : : }
354 [ + + ][ + + ]: 82763 : }
355 : :
356 [ + + ]: 59582 : if (nResult == 0)
357 : : {
358 : : // No difference found yet. When the lengths are the same then the
359 : : // two resource ids are equivalent. Otherwise the shorter comes
360 : : // first.
361 [ + + ]: 42588 : if (nLocalURLCount != nURLCount)
362 : : {
363 [ + + ]: 14383 : if (nLocalURLCount < nURLCount)
364 : 12234 : nResult = -1;
365 : : else
366 : 2149 : nResult = +1;
367 : : }
368 : : }
369 : :
370 : 59582 : return nResult;
371 : : }
372 : :
373 : :
374 : :
375 : :
376 : 0 : sal_Int16 ResourceId::CompareToExternalImplementation (const Reference<XResourceId>& rxId) const
377 : : {
378 : 0 : sal_Int16 nResult (0);
379 : :
380 [ # # ][ # # ]: 0 : const Sequence<OUString> aAnchorURLs (rxId->getAnchorURLs());
381 : 0 : const sal_uInt32 nLocalURLCount (maResourceURLs.size());
382 : 0 : const sal_uInt32 nURLCount(1+aAnchorURLs.getLength());
383 : :
384 : : // Start comparison with the top most anchors.
385 : 0 : sal_Int32 nLocalResult (0);
386 [ # # ][ # # ]: 0 : for (sal_Int32 nIndex=nURLCount-1,nLocalIndex=nLocalURLCount-1;
[ # # ]
387 : : nIndex>=0&&nLocalIndex>=0;
388 : : --nIndex,--nLocalIndex)
389 : : {
390 [ # # ]: 0 : if (nIndex == 0 )
391 [ # # ][ # # ]: 0 : nLocalResult = maResourceURLs[nIndex].compareTo(rxId->getResourceURL());
392 : : else
393 : 0 : nLocalResult = maResourceURLs[nIndex].compareTo(aAnchorURLs[nIndex-1]);
394 [ # # ]: 0 : if (nLocalResult != 0)
395 : : {
396 [ # # ]: 0 : if (nLocalResult < 0)
397 : 0 : nResult = -1;
398 : : else
399 : 0 : nResult = +1;
400 : 0 : break;
401 : : }
402 : : }
403 : :
404 [ # # ]: 0 : if (nResult == 0)
405 : : {
406 : : // No difference found yet. When the lengths are the same then the
407 : : // two resource ids are equivalent. Otherwise the shorter comes
408 : : // first.
409 [ # # ]: 0 : if (nLocalURLCount != nURLCount)
410 : : {
411 [ # # ]: 0 : if (nLocalURLCount < nURLCount)
412 : 0 : nResult = -1;
413 : : else
414 : 0 : nResult = +1;
415 : : }
416 : : }
417 : :
418 [ # # ]: 0 : return nResult;
419 : : }
420 : :
421 : :
422 : :
423 : :
424 : : sal_Bool SAL_CALL
425 : 69271 : ResourceId::isBoundTo (
426 : : const Reference<XResourceId>& rxResourceId,
427 : : AnchorBindingMode eMode)
428 : : throw (RuntimeException)
429 : : {
430 [ + + ]: 69271 : if ( ! rxResourceId.is())
431 : : {
432 : : // An empty reference is interpreted as empty resource id.
433 : 10564 : return IsBoundToAnchor(NULL, NULL, eMode);
434 : : }
435 : :
436 : 58707 : ResourceId* pId = NULL;
437 : : #ifdef USE_OPTIMIZATIONS
438 [ - + ]: 58707 : pId = dynamic_cast<ResourceId*>(rxResourceId.get());
439 : : #endif
440 [ + - ]: 58707 : if (pId != NULL)
441 : : {
442 : 58707 : return IsBoundToAnchor(pId->maResourceURLs, eMode);
443 : : }
444 : : else
445 : : {
446 [ # # ][ # # ]: 0 : const OUString sResourceURL (rxResourceId->getResourceURL());
447 [ # # ][ # # ]: 0 : const Sequence<OUString> aAnchorURLs (rxResourceId->getAnchorURLs());
448 [ # # ][ # # ]: 69271 : return IsBoundToAnchor(&sResourceURL, &aAnchorURLs, eMode);
449 : : }
450 : : }
451 : :
452 : :
453 : :
454 : :
455 : : sal_Bool SAL_CALL
456 : 2618 : ResourceId::isBoundToURL (
457 : : const OUString& rsAnchorURL,
458 : : AnchorBindingMode eMode)
459 : : throw (RuntimeException)
460 : : {
461 : 2618 : return IsBoundToAnchor(&rsAnchorURL, NULL, eMode);
462 : : }
463 : :
464 : :
465 : :
466 : :
467 : : Reference<XResourceId> SAL_CALL
468 : 0 : ResourceId::clone (void)
469 : : throw(RuntimeException)
470 : : {
471 [ # # ][ # # ]: 0 : return new ResourceId(maResourceURLs);
472 : : }
473 : :
474 : :
475 : :
476 : :
477 : : //----- XInitialization -------------------------------------------------------
478 : :
479 : 189 : void SAL_CALL ResourceId::initialize (const Sequence<Any>& aArguments)
480 : : throw (RuntimeException)
481 : : {
482 : 189 : sal_uInt32 nCount (aArguments.getLength());
483 [ + + ]: 378 : for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
484 : : {
485 : 189 : OUString sResourceURL;
486 [ + - ]: 189 : if (aArguments[nIndex] >>= sResourceURL)
487 [ + - ]: 189 : maResourceURLs.push_back(sResourceURL);
488 : : else
489 : : {
490 : 0 : Reference<XResourceId> xAnchor;
491 [ # # ][ # # ]: 0 : if (aArguments[nIndex] >>= xAnchor)
492 : : {
493 [ # # ]: 0 : if (xAnchor.is())
494 : : {
495 [ # # ][ # # ]: 0 : maResourceURLs.push_back(xAnchor->getResourceURL());
[ # # ]
496 [ # # ][ # # ]: 0 : Sequence<OUString> aAnchorURLs (xAnchor->getAnchorURLs());
497 [ # # ]: 0 : for (sal_Int32 nURLIndex=0; nURLIndex<aAnchorURLs.getLength(); ++nURLIndex)
498 : : {
499 [ # # ][ # # ]: 0 : maResourceURLs.push_back(aAnchorURLs[nURLIndex]);
500 [ # # ]: 0 : }
501 : : }
502 : 0 : }
503 : : }
504 : 189 : }
505 : 189 : ParseResourceURL();
506 : 189 : }
507 : :
508 : :
509 : :
510 : :
511 : : //-----------------------------------------------------------------------------
512 : :
513 : : /** When eMode is DIRECTLY then the anchor of the called object and the
514 : : anchor represented by the given sequence of anchor URLs have to be
515 : : identical. When eMode is RECURSIVE then the anchor of the called
516 : : object has to start with the given anchor URLs.
517 : : */
518 : 13182 : bool ResourceId::IsBoundToAnchor (
519 : : const OUString* psFirstAnchorURL,
520 : : const Sequence<OUString>* paAnchorURLs,
521 : : AnchorBindingMode eMode) const
522 : : {
523 : 13182 : const sal_uInt32 nLocalAnchorURLCount (maResourceURLs.size() - 1);
524 : 13182 : const bool bHasFirstAnchorURL (psFirstAnchorURL!=NULL);
525 : : const sal_uInt32 nAnchorURLCount ((bHasFirstAnchorURL?1:0)
526 [ - + ][ + + ]: 13182 : + (paAnchorURLs!=NULL ? paAnchorURLs->getLength() : 0));
527 : :
528 : : // Check the lengths.
529 [ + + ][ + + ]: 13182 : if (nLocalAnchorURLCount<nAnchorURLCount ||
[ + + ]
530 : : (eMode==AnchorBindingMode_DIRECT && nLocalAnchorURLCount!=nAnchorURLCount))
531 : : {
532 : 2528 : return false;
533 : : }
534 : :
535 : : // Compare the nAnchorURLCount bottom-most anchor URLs of this resource
536 : : // id and the given anchor.
537 : 10654 : sal_uInt32 nOffset = 0;
538 [ - + ]: 10654 : if (paAnchorURLs != NULL)
539 : : {
540 : 0 : sal_uInt32 nCount = paAnchorURLs->getLength();
541 [ # # ]: 0 : while (nOffset < nCount)
542 : : {
543 [ # # ]: 0 : if ( ! maResourceURLs[nLocalAnchorURLCount - nOffset].equals(
544 : 0 : (*paAnchorURLs)[nCount - 1 - nOffset]))
545 : : {
546 : 0 : return false;
547 : : }
548 : 0 : ++nOffset;
549 : : }
550 : : }
551 [ + + ]: 10654 : if (bHasFirstAnchorURL)
552 : : {
553 [ + + ]: 2210 : if ( ! psFirstAnchorURL->equals(maResourceURLs[nLocalAnchorURLCount - nOffset]))
554 : 1144 : return false;
555 : : }
556 : :
557 : 13182 : return true;
558 : : }
559 : :
560 : :
561 : :
562 : :
563 : 58707 : bool ResourceId::IsBoundToAnchor (
564 : : const ::std::vector<OUString>& rAnchorURLs,
565 : : AnchorBindingMode eMode) const
566 : : {
567 : 58707 : const sal_uInt32 nLocalAnchorURLCount (maResourceURLs.size() - 1);
568 : 58707 : const sal_uInt32 nAnchorURLCount (rAnchorURLs.size());
569 : :
570 : : // Check the lengths.
571 [ + + ][ + + ]: 58707 : if (nLocalAnchorURLCount<nAnchorURLCount ||
[ + + ]
572 : : (eMode==AnchorBindingMode_DIRECT && nLocalAnchorURLCount!=nAnchorURLCount))
573 : : {
574 : 32338 : return false;
575 : : }
576 : :
577 : : // Compare the nAnchorURLCount bottom-most anchor URLs of this resource
578 : : // id and the given anchor.
579 [ + + ]: 39008 : for (sal_uInt32 nOffset=0; nOffset<nAnchorURLCount; ++nOffset)
580 : : {
581 [ + + ]: 52934 : if ( ! maResourceURLs[nLocalAnchorURLCount - nOffset].equals(
582 : 52934 : rAnchorURLs[nAnchorURLCount - 1 - nOffset]))
583 : : {
584 : 13828 : return false;
585 : : }
586 : : }
587 : :
588 : 58707 : return true;
589 : : }
590 : :
591 : :
592 : :
593 : :
594 : 9374 : void ResourceId::ParseResourceURL (void)
595 : : {
596 [ + - ][ + - ]: 9374 : ::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex());
597 [ + - ]: 9374 : Reference<util::XURLTransformer> xURLTransformer (mxURLTransformerWeak);
598 [ + + ]: 9374 : if ( ! xURLTransformer.is())
599 : : {
600 : : // Create the URL transformer.
601 [ + - ]: 16 : Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
602 [ + - ][ + - ]: 16 : xURLTransformer = Reference<util::XURLTransformer>(util::URLTransformer::create(xContext));
603 [ + - ]: 16 : mxURLTransformerWeak = xURLTransformer;
604 [ + - ]: 16 : SdGlobalResourceContainer::Instance().AddResource(
605 [ + - ][ + - ]: 32 : Reference<XInterface>(xURLTransformer,UNO_QUERY));
606 : : }
607 : :
608 [ + - ][ + - ]: 9374 : if (xURLTransformer.is() && !maResourceURLs.empty() )
[ + - ]
609 : : {
610 [ + - ][ + - ]: 9374 : mpURL.reset(new util::URL);
611 : 9374 : mpURL->Complete = maResourceURLs[0];
612 [ + - ][ + - ]: 9374 : xURLTransformer->parseStrict(*mpURL);
613 [ + - ]: 9374 : if (mpURL->Main == maResourceURLs[0])
614 [ + - ]: 9374 : mpURL.reset();
615 : : else
616 : 0 : maResourceURLs[0] = mpURL->Main;
617 [ + - ]: 9374 : }
618 : 9374 : }
619 : :
620 : :
621 [ + - ][ + - ]: 75 : } } // end of namespace sd::framework
622 : :
623 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|