summaryrefslogtreecommitdiff
path: root/xmlscript
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2004-04-13 15:18:24 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2004-04-13 15:18:24 +0000
commitbb7db4b0145dc1732fb816f078953c0981c5b2fe (patch)
treeb7ac94d129e8279031ac8fea329e7d851cb36358 /xmlscript
parent9f695883135b259a2886094b086da9696feebaa9 (diff)
INTEGRATION: CWS unopkg1 (1.5.10); FILE MERGED
2003/11/04 14:50:38 dbo 1.5.10.1: #i20304# namespace mapping
Diffstat (limited to 'xmlscript')
-rw-r--r--xmlscript/source/xml_helper/xml_impctx.cxx101
1 files changed, 40 insertions, 61 deletions
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx
index 846b3794e22d..c67719d7a505 100644
--- a/xmlscript/source/xml_helper/xml_impctx.cxx
+++ b/xmlscript/source/xml_helper/xml_impctx.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xml_impctx.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: obo $ $Date: 2003-09-04 09:19:22 $
+ * last change: $Author: hr $ $Date: 2004-04-13 16:18:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -140,8 +140,8 @@ struct MGuard
//==============================================================================
class DocumentHandlerImpl :
- public ::cppu::WeakImplHelper3< container::XNameAccess,
- xml::sax::XDocumentHandler,
+ public ::cppu::WeakImplHelper3< xml::sax::XDocumentHandler,
+ xml::input::XNamespaceMapping,
lang::XInitialization >
{
friend class ExtendedAttributes;
@@ -223,20 +223,11 @@ public:
Reference< xml::sax::XLocator > const & xLocator )
throw (xml::sax::SAXException, RuntimeException);
- // XNameAccess
- virtual Any SAL_CALL getByName(
- OUString const & name )
- throw (container::NoSuchElementException, lang::WrappedTargetException,
- RuntimeException);
- virtual Sequence< OUString > SAL_CALL getElementNames()
- throw (RuntimeException);
- virtual sal_Bool SAL_CALL hasByName( OUString const & name )
- throw (RuntimeException);
- // XElementAccess
- virtual Type SAL_CALL getElementType()
- throw (RuntimeException);
- virtual sal_Bool SAL_CALL hasElements()
+ // XNamespaceMapping
+ virtual sal_Int32 SAL_CALL getUidByUri( OUString const & Uri )
throw (RuntimeException);
+ virtual OUString SAL_CALL getUriByUid( sal_Int32 Uid )
+ throw (container::NoSuchElementException, RuntimeException);
};
//______________________________________________________________________________
@@ -534,57 +525,33 @@ void DocumentHandlerImpl::initialize(
}
}
-// XNameAccess
+
+// XNamespaceMapping
//______________________________________________________________________________
-Any DocumentHandlerImpl::getByName( OUString const & name )
- throw (container::NoSuchElementException, lang::WrappedTargetException,
- RuntimeException)
+sal_Int32 DocumentHandlerImpl::getUidByUri( OUString const & Uri )
+ throw (RuntimeException)
{
- return makeAny( getUidByURI( name ) );
+ sal_Int32 uid = getUidByURI( Uri );
+ OSL_ASSERT( uid != UID_UNKNOWN );
+ return uid;
}
//______________________________________________________________________________
-Sequence< OUString > DocumentHandlerImpl::getElementNames()
- throw (RuntimeException)
+OUString DocumentHandlerImpl::getUriByUid( sal_Int32 Uid )
+ throw (container::NoSuchElementException, RuntimeException)
{
MGuard guard( m_pMutex );
- Sequence< OUString > names( m_URI2Uid.size() );
t_OUString2LongMap::const_iterator iPos( m_URI2Uid.begin() );
t_OUString2LongMap::const_iterator const iEnd( m_URI2Uid.end() );
- OUString * pNames = names.getArray();
- sal_Int32 nPos = 0;
for ( ; iPos != iEnd; ++iPos )
{
- pNames[ nPos ] = iPos->first;
- ++nPos;
+ if (iPos->second == Uid)
+ return iPos->first;
}
- return names;
-}
-
-//______________________________________________________________________________
-sal_Bool DocumentHandlerImpl::hasByName( OUString const & name )
- throw (RuntimeException)
-{
- MGuard guard( m_pMutex );
- return m_URI2Uid.find( name ) != m_URI2Uid.end();
-}
-
-// XElementAccess
-
-//______________________________________________________________________________
-Type DocumentHandlerImpl::getElementType()
- throw (RuntimeException)
-{
- return ::getCppuType( reinterpret_cast< sal_Int32 const * >( 0 ) );
-}
-
-//______________________________________________________________________________
-sal_Bool DocumentHandlerImpl::hasElements()
- throw (RuntimeException)
-{
- MGuard guard( m_pMutex );
- return ! m_URI2Uid.empty();
+ throw container::NoSuchElementException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no such xmlns uid!") ),
+ static_cast< OWeakObject * >(this) );
}
@@ -594,7 +561,8 @@ sal_Bool DocumentHandlerImpl::hasElements()
void DocumentHandlerImpl::startDocument()
throw (xml::sax::SAXException, RuntimeException)
{
- m_xRoot->startDocument( static_cast< container::XNameAccess * >( this ) );
+ m_xRoot->startDocument(
+ static_cast< xml::input::XNamespaceMapping * >( this ) );
}
//______________________________________________________________________________
@@ -858,15 +826,20 @@ sal_Int32 ExtendedAttributes::getLength()
OUString ExtendedAttributes::getLocalNameByIndex( sal_Int32 nIndex )
throw (RuntimeException)
{
- return m_pLocalNames[ nIndex ];
+ if (nIndex < m_nAttributes)
+ return m_pLocalNames[ nIndex ];
+ else
+ return OUString();
}
//______________________________________________________________________________
OUString ExtendedAttributes::getQNameByIndex( sal_Int32 nIndex )
throw (RuntimeException)
{
- OSL_ASSERT( nIndex < m_nAttributes );
- return m_pQNames[ nIndex ];
+ if (nIndex < m_nAttributes)
+ return m_pQNames[ nIndex ];
+ else
+ return OUString();
}
//______________________________________________________________________________
@@ -881,7 +854,10 @@ OUString ExtendedAttributes::getTypeByIndex( sal_Int32 nIndex )
OUString ExtendedAttributes::getValueByIndex( sal_Int32 nIndex )
throw (RuntimeException)
{
- return m_pValues[ nIndex ];
+ if (nIndex < m_nAttributes)
+ return m_pValues[ nIndex ];
+ else
+ return OUString();
}
//______________________________________________________________________________
@@ -903,7 +879,10 @@ sal_Int32 ExtendedAttributes::getIndexByUidName(
sal_Int32 ExtendedAttributes::getUidByIndex( sal_Int32 nIndex )
throw (RuntimeException)
{
- return m_pUids[ nIndex ];
+ if (nIndex < m_nAttributes)
+ return m_pUids[ nIndex ];
+ else
+ return -1;
}
//______________________________________________________________________________