/** When the USE_OPTIMIZATIONS symbol is defined then at some optimizations areactivatedthatworkonlytogetherwithXResourceIdobjectsthatare implementedbytheResourceIdclass.Forotherimplementationsofwhen theUSE_OPTIMIZATIONSsymbolisnotdefinedthenalternativecodeis usedinstead.
*/ #define USE_OPTIMIZATIONS
ResourceId::ResourceId ( const OUString& rsResourceURL)
: maResourceURLs(1, rsResourceURL)
{ // Handle the special case of an empty resource URL. if (rsResourceURL.isEmpty())
maResourceURLs.clear();
ParseResourceURL();
}
OUString SAL_CALL
ResourceId::getResourceTypePrefix()
{ if (!maResourceURLs.empty() )
{ // Return the "private:resource/<type>/" prefix.
// Get the prefix that ends with the second "/". const OUString& rsResourceURL (maResourceURLs[0]);
sal_Int32 nPrefixEnd (rsResourceURL.indexOf('/')); if (nPrefixEnd >= 0)
nPrefixEnd = rsResourceURL.indexOf('/', nPrefixEnd+1) + 1; else
nPrefixEnd = 0;
if ( ! rxResourceId.is())
{ // The empty reference is interpreted as empty resource id object. if (!maResourceURLs.empty())
nResult = +1; else
nResult = 0;
} else
{
ResourceId* pId = nullptr; #ifdef USE_OPTIMIZATIONS
pId = dynamic_cast<ResourceId*>(rxResourceId.get()); #endif if (pId != nullptr)
{ // We have direct access to the implementation of the given // resource id object.
nResult = CompareToLocalImplementation(*pId);
} else
{ // We have to do the comparison via the UNO interface of the // given resource id object.
nResult = CompareToExternalImplementation(rxResourceId);
}
}
// Start comparison with the top most anchors. for (sal_Int32 nIndex=nURLCount-1,nLocalIndex=nLocalURLCount-1;
nIndex>=0 && nLocalIndex>=0;
--nIndex,--nLocalIndex)
{ const OUString sLocalURL (maResourceURLs[nLocalIndex]); const OUString sURL (rId.maResourceURLs[nIndex]); const sal_Int32 nLocalResult (sURL.compareTo(sLocalURL)); if (nLocalResult != 0)
{ if (nLocalResult < 0)
nResult = -1; else
nResult = +1; break;
}
}
if (nResult == 0)
{ // No difference found yet. When the lengths are the same then the // two resource ids are equivalent. Otherwise the shorter comes // first. if (nLocalURLCount != nURLCount)
{ if (nLocalURLCount < nURLCount)
nResult = -1; else
nResult = +1;
}
}
// Start comparison with the top most anchors.
sal_Int32 nLocalResult (0); for (sal_Int32 nIndex=nURLCount-1,nLocalIndex=nLocalURLCount-1;
nIndex>=0&&nLocalIndex>=0;
--nIndex,--nLocalIndex)
{ if (nIndex == 0 )
nLocalResult = maResourceURLs[nIndex].compareTo(rxId->getResourceURL()); else
nLocalResult = maResourceURLs[nIndex].compareTo(aAnchorURLs[nIndex-1]); if (nLocalResult != 0)
{ if (nLocalResult < 0)
nResult = -1; else
nResult = +1; break;
}
}
if (nResult == 0)
{ // No difference found yet. When the lengths are the same then the // two resource ids are equivalent. Otherwise the shorter comes // first. if (nLocalURLCount != nURLCount)
{ if (nLocalURLCount < nURLCount)
nResult = -1; else
nResult = +1;
}
}
return nResult;
}
sal_Bool SAL_CALL
ResourceId::isBoundTo ( const Reference<XResourceId>& rxResourceId,
AnchorBindingMode eMode)
{ if ( ! rxResourceId.is())
{ // An empty reference is interpreted as empty resource id. return IsBoundToAnchor(nullptr, nullptr, eMode);
}
// Check the lengths. if (nLocalAnchorURLCount<nAnchorURLCount ||
(eMode==AnchorBindingMode_DIRECT && nLocalAnchorURLCount!=nAnchorURLCount))
{ returnfalse;
}
// Compare the nAnchorURLCount bottom-most anchor URLs of this resource // id and the given anchor. for (sal_uInt32 nOffset=0; nOffset<nAnchorURLCount; ++nOffset)
{ if ( maResourceURLs[nLocalAnchorURLCount - nOffset] !=
rAnchorURLs[nAnchorURLCount - 1 - nOffset] )
{ returnfalse;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.