summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-01-08 17:13:59 +0100
committerMichael Stahl <mst@openoffice.org>2010-01-08 17:13:59 +0100
commitf3dca2c04f5bd6d30c33e06de2ef6f35636ddbe9 (patch)
tree10688d2581ed5dd82283618339512e1ff869b308 /sw
parent342e7b53a498adba704d9c177db58cdf3cf0733f (diff)
swunolocking1: #i105557#: SwXDocumentIndexes:
use new XServiceInfo helpers. clean up the implementation a little.
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/unoidx.hxx67
-rw-r--r--sw/source/core/unocore/unoidx.cxx150
2 files changed, 131 insertions, 86 deletions
diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx
index f3462a17bebb..8d432f9fdcf3 100644
--- a/sw/inc/unoidx.hxx
+++ b/sw/inc/unoidx.hxx
@@ -271,46 +271,57 @@ public:
SwDoc* pDoc);
void Invalidate();
};
+
/* -----------------05.05.99 12:27-------------------
*
* --------------------------------------------------*/
-
-class SwXDocumentIndexes : public SwCollectionBaseClass,
- public SwUnoCollection
+class SwXDocumentIndexes
+ : public SwCollectionBaseClass
+ , public SwUnoCollection
{
-protected:
- virtual ~SwXDocumentIndexes();
-public:
- SwXDocumentIndexes(SwDoc* pDoc);
-
-// SMART_UNO_DECLARATION( SwXDocumentIndexes, UsrObject );
+private:
-// automatisch auskommentiert - [getIdlClass or queryInterface] - Bitte XTypeProvider benutzen!
-// virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > > getIdlClasses(void)
+ virtual ~SwXDocumentIndexes();
-// throw( ::com::sun::star::uno::RuntimeException );
-// automatisch auskommentiert - [getIdlClass or queryInterface] - Bitte XTypeProvider benutzen!
-// virtual sal_Bool queryInterface( ::com::sun::star::uno::Uik aUik, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rOut );
+public:
+ SwXDocumentIndexes(SwDoc *const pDoc);
- //XNameAccess
- virtual ::com::sun::star::uno::Any SAL_CALL getByName(const rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException );
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(
+ const ::rtl::OUString& rServiceName)
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
+ getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
- //XIndexAccess
- virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements()
+ throw (::com::sun::star::uno::RuntimeException);
- //XElementAccess
- virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex)
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
- //XServiceInfo
- virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
+ // XNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName(
+ const ::rtl::OUString& rName)
+ throw (::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
+ getElementNames() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& rName)
+ throw (::com::sun::star::uno::RuntimeException);
};
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 4c55e3e1963f..0b6a3c8c93c2 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -2312,49 +2312,63 @@ void SwXDocumentIndexMark::Invalidate()
m_pDoc = 0;
}
}
-/* -----------------------------06.04.00 15:08--------------------------------
- ---------------------------------------------------------------------------*/
-OUString SwXDocumentIndexes::getImplementationName(void) throw( uno::RuntimeException )
+/******************************************************************
+ * SwXDocumentIndexes
+ ******************************************************************/
+/*-- 05.05.99 13:14:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwXDocumentIndexes::SwXDocumentIndexes(SwDoc *const _pDoc)
+ : SwUnoCollection(_pDoc)
{
- return C2U("SwXDocumentIndexes");
}
-/* -----------------------------06.04.00 15:08--------------------------------
+/*-- 05.05.99 13:15:00---------------------------------------------------
- ---------------------------------------------------------------------------*/
-BOOL SwXDocumentIndexes::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
+ -----------------------------------------------------------------------*/
+SwXDocumentIndexes::~SwXDocumentIndexes()
{
- return C2U("com.sun.star.text.DocumentIndexes") == rServiceName;
}
+
/* -----------------------------06.04.00 15:08--------------------------------
---------------------------------------------------------------------------*/
-uno::Sequence< OUString > SwXDocumentIndexes::getSupportedServiceNames(void) throw( uno::RuntimeException )
+OUString SAL_CALL
+SwXDocumentIndexes::getImplementationName() throw (uno::RuntimeException)
{
- uno::Sequence< OUString > aRet(1);
- OUString* pArray = aRet.getArray();
- pArray[0] = C2U("com.sun.star.text.DocumentIndexes");
- return aRet;
+ return C2U("SwXDocumentIndexes");
}
-/*-- 05.05.99 13:14:59---------------------------------------------------
- -----------------------------------------------------------------------*/
-SwXDocumentIndexes::SwXDocumentIndexes(SwDoc* _pDoc) :
- SwUnoCollection(_pDoc)
+static char const*const g_ServicesDocumentIndexes[] =
+{
+ "com.sun.star.text.DocumentIndexes",
+};
+static const size_t g_nServicesDocumentIndexes(
+ sizeof(g_ServicesDocumentIndexes)/sizeof(g_ServicesDocumentIndexes[0]));
+
+sal_Bool SAL_CALL
+SwXDocumentIndexes::supportsService(const OUString& rServiceName)
+throw (uno::RuntimeException)
{
+ return ::sw::SupportsServiceImpl(
+ g_nServicesDocumentIndexes, g_ServicesDocumentIndexes, rServiceName);
}
-/*-- 05.05.99 13:15:00---------------------------------------------------
- -----------------------------------------------------------------------*/
-SwXDocumentIndexes::~SwXDocumentIndexes()
+uno::Sequence< OUString > SAL_CALL
+SwXDocumentIndexes::getSupportedServiceNames() throw (uno::RuntimeException)
{
+ return ::sw::GetSupportedServiceNamesImpl(
+ g_nServicesDocumentIndexes, g_ServicesDocumentIndexes);
}
+
/*-- 05.05.99 13:15:01---------------------------------------------------
-----------------------------------------------------------------------*/
-sal_Int32 SwXDocumentIndexes::getCount(void) throw( uno::RuntimeException )
+sal_Int32 SAL_CALL
+SwXDocumentIndexes::getCount() throw (uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
+
if(!IsValid())
throw uno::RuntimeException();
@@ -2365,17 +2379,23 @@ sal_Int32 SwXDocumentIndexes::getCount(void) throw( uno::RuntimeException )
const SwSection* pSect = rFmts[ n ]->GetSection();
if( TOX_CONTENT_SECTION == pSect->GetType() &&
pSect->GetFmt()->GetSectionNode() )
+ {
++nRet;
+ }
}
return nRet;
}
+
/*-- 05.05.99 13:15:01---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex)
- throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
+uno::Any SAL_CALL
+SwXDocumentIndexes::getByIndex(sal_Int32 nIndex)
+throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
+
if(!IsValid())
throw uno::RuntimeException();
@@ -2388,14 +2408,14 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex)
if( TOX_CONTENT_SECTION == pSect->GetType() &&
pSect->GetFmt()->GetSectionNode() &&
nIdx++ == nIndex )
- {
- const uno::Reference< text::XDocumentIndex > xTmp =
- SwXDocumentIndex::CreateXDocumentIndex(
- *GetDoc(), static_cast<SwTOXBaseSection const&>(*pSect));
- uno::Any aRet;
- aRet <<= xTmp;
- return aRet;
- }
+ {
+ const uno::Reference< text::XDocumentIndex > xTmp =
+ SwXDocumentIndex::CreateXDocumentIndex(
+ *GetDoc(), static_cast<SwTOXBaseSection const&>(*pSect));
+ uno::Any aRet;
+ aRet <<= xTmp;
+ return aRet;
+ }
}
throw lang::IndexOutOfBoundsException();
@@ -2404,14 +2424,16 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex)
/*-- 31.01.00 10:12:31---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Any SwXDocumentIndexes::getByName(const OUString& rName)
- throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+uno::Any SAL_CALL
+SwXDocumentIndexes::getByName(const OUString& rName)
+throw (container::NoSuchElementException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
+
if(!IsValid())
throw uno::RuntimeException();
-
String sToFind(rName);
const SwSectionFmts& rFmts = GetDoc()->GetSections();
for( sal_uInt16 n = 0; n < rFmts.Count(); ++n )
@@ -2419,25 +2441,28 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName)
const SwSection* pSect = rFmts[ n ]->GetSection();
if( TOX_CONTENT_SECTION == pSect->GetType() &&
pSect->GetFmt()->GetSectionNode() &&
- ((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind)
- {
- const uno::Reference< text::XDocumentIndex > xTmp =
- SwXDocumentIndex::CreateXDocumentIndex(
- *GetDoc(), static_cast<SwTOXBaseSection const&>(*pSect));
- uno::Any aRet;
- aRet <<= xTmp;
- return aRet;
- }
+ (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()
+ == sToFind))
+ {
+ const uno::Reference< text::XDocumentIndex > xTmp =
+ SwXDocumentIndex::CreateXDocumentIndex(
+ *GetDoc(), static_cast<SwTOXBaseSection const&>(*pSect));
+ uno::Any aRet;
+ aRet <<= xTmp;
+ return aRet;
+ }
}
throw container::NoSuchElementException();
}
+
/*-- 31.01.00 10:12:31---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void)
- throw( uno::RuntimeException )
+uno::Sequence< OUString > SAL_CALL
+SwXDocumentIndexes::getElementNames() throw (uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
+
if(!IsValid())
throw uno::RuntimeException();
@@ -2446,10 +2471,12 @@ uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void)
sal_uInt16 n;
for( n = 0; n < rFmts.Count(); ++n )
{
- const SwSection* pSect = rFmts[ n ]->GetSection();
+ SwSection const*const pSect = rFmts[ n ]->GetSection();
if( TOX_CONTENT_SECTION == pSect->GetType() &&
pSect->GetFmt()->GetSectionNode() )
+ {
++nCount;
+ }
}
uno::Sequence< OUString > aRet(nCount);
@@ -2457,22 +2484,26 @@ uno::Sequence< OUString > SwXDocumentIndexes::getElementNames(void)
sal_uInt16 nCnt;
for( n = 0, nCnt = 0; n < rFmts.Count(); ++n )
{
- const SwSection* pSect = rFmts[ n ]->GetSection();
+ SwSection const*const pSect = rFmts[ n ]->GetSection();
if( TOX_CONTENT_SECTION == pSect->GetType() &&
pSect->GetFmt()->GetSectionNode())
{
- pArray[nCnt++] = OUString(((SwTOXBaseSection*)pSect)->GetTOXName());
+ pArray[nCnt++] = OUString(
+ static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName());
}
}
return aRet;
}
+
/*-- 31.01.00 10:12:31---------------------------------------------------
-----------------------------------------------------------------------*/
-sal_Bool SwXDocumentIndexes::hasByName(const OUString& rName)
- throw( uno::RuntimeException )
+sal_Bool SAL_CALL
+SwXDocumentIndexes::hasByName(const OUString& rName)
+throw (uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
+
if(!IsValid())
throw uno::RuntimeException();
@@ -2480,31 +2511,34 @@ sal_Bool SwXDocumentIndexes::hasByName(const OUString& rName)
const SwSectionFmts& rFmts = GetDoc()->GetSections();
for( sal_uInt16 n = 0; n < rFmts.Count(); ++n )
{
- const SwSection* pSect = rFmts[ n ]->GetSection();
+ SwSection const*const pSect = rFmts[ n ]->GetSection();
if( TOX_CONTENT_SECTION == pSect->GetType() &&
pSect->GetFmt()->GetSectionNode())
{
- if(((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind)
+ if (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()
+ == sToFind)
+ {
return sal_True;
+ }
}
}
return sal_False;
}
+
/*-- 05.05.99 13:15:01---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Type SwXDocumentIndexes::getElementType(void) throw( uno::RuntimeException )
+uno::Type SAL_CALL
+SwXDocumentIndexes::getElementType() throw (uno::RuntimeException)
{
- return ::getCppuType((uno::Reference< text::XDocumentIndex> *)0);
+ return text::XDocumentIndex::static_type();
}
/*-- 05.05.99 13:15:02---------------------------------------------------
-----------------------------------------------------------------------*/
-sal_Bool SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException )
+sal_Bool SAL_CALL
+SwXDocumentIndexes::hasElements() throw (uno::RuntimeException)
{
- vos::OGuard aGuard(Application::GetSolarMutex());
- if(!IsValid())
- throw uno::RuntimeException();
return 0 != getCount();
}