summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-01-08 17:13:58 +0100
committerMichael Stahl <mst@openoffice.org>2010-01-08 17:13:58 +0100
commit399fb822ef81bd2440da8ab48cc2028a6b44d5b7 (patch)
tree6c3fec9e40e516e5b27bf39b22b4bc25ad640464 /sw
parent1f70baf3d1eaf363f0fb6281c7877a6ea783a667 (diff)
swunolocking1: #i105557#: fix locking for SwXDocumentIndex:
add Impl struct, and use UnoImplPtr to lock destructor. move all implementation details out of header, into Impl struct. replace broken SwClient iteration with a WeakReference in SwFrmFmt. make constructor private, and add factory function CreateXDocumentIndex. use new XUnoTunnel helpers. clean up the implementation a little. remove SwXDocumentIndexes::GetObject().
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/unoidx.hxx197
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx8
-rw-r--r--sw/source/core/unocore/unoidx.cxx1681
-rw-r--r--sw/source/core/unocore/unosect.cxx3
4 files changed, 1082 insertions, 807 deletions
diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx
index ef503926ad1f..f82e2c9984d2 100644
--- a/sw/inc/unoidx.hxx
+++ b/sw/inc/unoidx.hxx
@@ -53,101 +53,143 @@ class SwTOXType;
/* -----------------07.12.98 10:08-------------------
*
* --------------------------------------------------*/
-class SwDocIdxProperties_Impl;
class SwXIndexStyleAccess_Impl;
class SwXIndexTokenAccess_Impl;
-class SwXDocumentIndex : public cppu::WeakImplHelper5
-<
- ::com::sun::star::text::XDocumentIndex,
- ::com::sun::star::lang::XServiceInfo,
- ::com::sun::star::beans::XPropertySet,
- ::com::sun::star::container::XNamed,
- ::com::sun::star::lang::XUnoTunnel
->,
- public SwClient
-{
- friend class SwXIndexStyleAccess_Impl;
- friend class SwXIndexTokenAccess_Impl;
+typedef ::cppu::WeakImplHelper5
+< ::com::sun::star::lang::XUnoTunnel
+, ::com::sun::star::lang::XServiceInfo
+, ::com::sun::star::beans::XPropertySet
+, ::com::sun::star::container::XNamed
+, ::com::sun::star::text::XDocumentIndex
+> SwXDocumentIndex_Base;
- SwEventListenerContainer aLstnrCntnr;
- const SfxItemPropertySet* m_pPropSet;
- SwDoc* m_pDoc;
- const SwTOXBaseSection* pBase;
- TOXTypes eTOXType;
+class SwXDocumentIndex
+ : public SwXDocumentIndex_Base
+{
- //Descriptor-Interface
- sal_Bool bIsDescriptor;
- SwDocIdxProperties_Impl* pProps;
+private:
- SwXIndexStyleAccess_Impl* pStyleAccess;
- SwXIndexTokenAccess_Impl* pTokenAccess;
+ friend class SwXIndexStyleAccess_Impl;
+ friend class SwXIndexTokenAccess_Impl;
- SwSectionFmt* GetFmt()const {return (SwSectionFmt*)GetRegisteredIn();}
+ class Impl;
+ ::sw::UnoImplPtr<Impl> m_pImpl;
- sal_Bool IsDescriptor() const {return bIsDescriptor;}
- const SwDocIdxProperties_Impl* GetProperties_Impl() const { return pProps;}
- SwDocIdxProperties_Impl* GetProperties_Impl() { return pProps;}
- TOXTypes GetTOXType() const {return eTOXType;}
+ virtual ~SwXDocumentIndex();
- SwXIndexStyleAccess_Impl* GetStyleAccess() const {return pStyleAccess;}
- void SetStyleAccess(SwXIndexStyleAccess_Impl* pSet)
- {pStyleAccess = pSet;}
+ SwXDocumentIndex(SwTOXBaseSection const&, SwDoc &);
- SwXIndexTokenAccess_Impl* GetTokenAccess() const {return pTokenAccess;}
- void SetTokenAccess(SwXIndexTokenAccess_Impl* pSet)
- {pTokenAccess = pSet;}
-protected:
- virtual ~SwXDocumentIndex();
public:
- SwXDocumentIndex(const SwTOXBaseSection* = 0, SwDoc* = 0);
- //Descriptor-Ctor
- SwXDocumentIndex(TOXTypes eToxType, SwDoc& rDoc);
+ /// descriptor
+ SwXDocumentIndex(const TOXTypes eToxType, SwDoc& rDoc);
- TYPEINFO();
+ static ::com::sun::star::uno::Reference<
+ ::com::sun::star::text::XDocumentIndex>
+ CreateXDocumentIndex(SwDoc & rDoc, SwTOXBaseSection const& rSection);
static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
- //XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
-
- //XDocumentIndex
- virtual ::rtl::OUString SAL_CALL getServiceName( ) throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL update( ) throw(::com::sun::star::uno::RuntimeException);
+ // XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething(
+ const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
+ 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);
+
+ // XComponent
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener > & xListener)
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener > & xListener)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue(
+ const ::rtl::OUString& rPropertyName,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
+ const ::rtl::OUString& rPropertyName)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener(
+ const ::rtl::OUString& rPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertyChangeListener >& xListener)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener(
+ const ::rtl::OUString& rPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertyChangeListener >& xListener)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener(
+ const ::rtl::OUString& rPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XVetoableChangeListener >& xListener)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener(
+ const ::rtl::OUString& rPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XVetoableChangeListener >& xListener)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName(const ::rtl::OUString& rName)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XTextContent
+ virtual void SAL_CALL attach(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::text::XTextRange > & xTextRange)
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
+ throw (::com::sun::star::uno::RuntimeException);
+
+
+ // XDocumentIndex
+ virtual ::rtl::OUString SAL_CALL getServiceName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL update()
+ throw (::com::sun::star::uno::RuntimeException);
- //XPropertySet
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
-
- //XTextContent
- virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException );
-
- //XComponent
- virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
- virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
-
- //XNamed
- virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::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 );
-
- //SwClient
- virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew);
-
- void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
};
+
/* -----------------07.12.98 10:08-------------------
*
* --------------------------------------------------*/
@@ -274,7 +316,6 @@ public:
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 );
- static SwXDocumentIndex* GetObject(const SwTOXBaseSection* pTOX);
};
/* -----------------13.09.99 16:39-------------------
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 29318ce49986..df34c675bfa0 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -69,6 +69,7 @@
#include <docary.hxx>
#include <swtable.hxx>
#include <tox.hxx>
+#include <doctxm.hxx>
#include <fchrfmt.hxx>
#include <svx/flstitem.hxx>
#include <vcl/metric.hxx>
@@ -331,9 +332,10 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
{
if( pAny )
{
- uno::Reference< XDocumentIndex > aRef =
- SwXDocumentIndexes::GetObject((SwTOXBaseSection*)pBase);
- pAny->setValue(&aRef, ::getCppuType((uno::Reference<XDocumentIndex>*)0));
+ const uno::Reference< text::XDocumentIndex > xRef =
+ SwXDocumentIndex::CreateXDocumentIndex(*rPam.GetDoc(),
+ *static_cast<SwTOXBaseSection const*>(pBase));
+ (*pAny) <<= xRef;
}
}
else
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 8fad219d742e..d860cedd3fb7 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -31,19 +31,19 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
-#include <com/sun/star/text/XTextSection.hpp>
-
-#include <hints.hxx>
-#include <tools/debug.hxx>
-#include <vos/mutex.hxx>
-#include <vcl/svapp.hxx>
-#include <svx/unolingu.hxx>
#include <com/sun/star/text/ChapterFormat.hpp>
#include <com/sun/star/text/ReferenceFieldPart.hpp>
#include <com/sun/star/text/BibliographyDataField.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include <tools/debug.hxx>
+#include <vos/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/unolingu.hxx>
+
+#include <hints.hxx>
#include <cmdid.h>
#include <swtypes.hxx>
#include <shellres.hxx>
@@ -59,6 +59,7 @@
#include <unomap.hxx>
#include <unotextrange.hxx>
#include <unotextcursor.hxx>
+#include <unosection.hxx>
#include <doctxm.hxx>
#include <txttxmrk.hxx>
#include <unocrsr.hxx>
@@ -74,36 +75,61 @@ using namespace ::com::sun::star;
using ::rtl::OUString;
//-----------------------------------------------------------------------------
-String lcl_AnyToString(uno::Any rVal) throw(lang::IllegalArgumentException)
+static String
+lcl_AnyToString(uno::Any const& rVal) throw (lang::IllegalArgumentException)
{
OUString sRet;
if(!(rVal >>= sRet))
+ {
throw lang::IllegalArgumentException();
+ }
return sRet;
}
//-----------------------------------------------------------------------------
-sal_Int16 lcl_AnyToInt16(uno::Any rVal) throw(lang::IllegalArgumentException)
+static sal_Int16
+lcl_AnyToInt16(uno::Any const& rVal) throw (lang::IllegalArgumentException)
{
sal_Int16 nRet = 0;
if(!(rVal >>= nRet))
+ {
throw lang::IllegalArgumentException();
+ }
return nRet;
}
//-----------------------------------------------------------------------------
-sal_Bool lcl_AnyToBool(uno::Any rVal) throw(lang::IllegalArgumentException)
+static sal_Bool
+lcl_AnyToBool(uno::Any const& rVal) throw (lang::IllegalArgumentException)
{
sal_Bool bRet = sal_False;
if(!(rVal >>= bRet))
+ {
throw lang::IllegalArgumentException();
+ }
return bRet;
}
-/******************************************************************************
- *
- ******************************************************************************/
+
+static void
+lcl_AnyToBitMask(uno::Any const& rValue,
+ sal_uInt16 & rBitMask, const sal_uInt16 nBit)
+throw (lang::IllegalArgumentException)
+{
+ rBitMask = lcl_AnyToBool(rValue)
+ ? (rBitMask | nBit)
+ : (rBitMask & ~nBit);
+}
+static void
+lcl_BitMaskToAny(uno::Any & o_rValue,
+ const sal_uInt16 nBitMask, const sal_uInt16 nBit)
+{
+ const sal_Bool bRet = 0 != (nBitMask & nBit);
+ o_rValue <<= bRet;
+}
+
//-----------------------------------------------------------------------------
-void lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName)
+static void
+lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName)
{
- sal_uInt16 nUserCount = pDoc->GetTOXTypeCount( TOX_USER );
+ const sal_uInt16 nUserCount = pDoc->GetTOXTypeCount( TOX_USER );
const SwTOXType* pNewType = 0;
for(sal_uInt16 nUser = 0; nUser < nUserCount; nUser++)
{
@@ -133,14 +159,19 @@ void lcl_ConvertTOUNameToProgrammaticName(OUString& rTmp)
ShellResource* pShellRes = ViewShell::GetShellRes();
if(rTmp.equals(pShellRes->aTOXUserName))
+ {
rTmp = OUString(C2U(cUserDefined));
- //if the version is not English but the alternative index's name is "User-Defined"
- //a " (user)" is appended
+ }
+ // if the version is not English but the alternative index's name is
+ // "User-Defined" a " (user)" is appended
else if(rTmp.equalsAscii(cUserDefined))
+ {
rTmp += C2U(cUserSuffix);
+ }
}
//-----------------------------------------------------------------------------
-void lcl_ConvertTOUNameToUserName(OUString& rTmp)
+static void
+lcl_ConvertTOUNameToUserName(OUString& rTmp)
{
ShellResource* pShellRes = ViewShell::GetShellRes();
if(rTmp.equalsAscii(cUserDefined))
@@ -150,43 +181,189 @@ void lcl_ConvertTOUNameToUserName(OUString& rTmp)
else if(!pShellRes->aTOXUserName.EqualsAscii(cUserDefined) &&
USER_AND_SUFFIXLEN == rTmp.getLength())
{
- String sToChange(rTmp);
//make sure that in non-English versions the " (user)" suffix is removed
- if(!sToChange.SearchAscii(cUserDefined) && USER_LEN == sToChange.SearchAscii(cUserSuffix))
+ if (rTmp.matchAsciiL(cUserDefined, sizeof(cUserDefined)) &&
+ rTmp.matchAsciiL(cUserSuffix, sizeof(cUserSuffix), USER_LEN))
+ {
rTmp = C2U(cUserDefined);
+ }
}
}
/******************************************************************
* SwXDocumentIndex
******************************************************************/
+
/* -----------------20.06.98 11:06-------------------
*
* --------------------------------------------------*/
-class SwDocIdxProperties_Impl
+class SwDocIndexDescriptorProperties_Impl
{
- SwTOXBase* pTOXBase;
- OUString sUserTOXTypeName;
+private:
+ ::std::auto_ptr<SwTOXBase> m_pTOXBase;
+ OUString m_sUserTOXTypeName;
+
public:
- SwTOXBase& GetTOXBase() {return *pTOXBase;}
- SwDocIdxProperties_Impl(const SwTOXType* pType);
- ~SwDocIdxProperties_Impl(){delete pTOXBase;}
+ SwDocIndexDescriptorProperties_Impl(SwTOXType const*const pType);
- const OUString& GetTypeName()const {return sUserTOXTypeName;}
- void SetTypeName(const OUString& rSet) {sUserTOXTypeName = rSet;}
+ SwTOXBase & GetTOXBase() { return *m_pTOXBase; }
+ const OUString& GetTypeName() const { return m_sUserTOXTypeName; }
+ void SetTypeName(const OUString& rSet) { m_sUserTOXTypeName = rSet; }
};
/* -----------------20.06.98 11:41-------------------
*
* --------------------------------------------------*/
-SwDocIdxProperties_Impl::SwDocIdxProperties_Impl(const SwTOXType* pType)
+SwDocIndexDescriptorProperties_Impl::SwDocIndexDescriptorProperties_Impl(
+ SwTOXType const*const pType)
{
SwForm aForm(pType->GetType());
- pTOXBase = new SwTOXBase(pType, aForm,
- nsSwTOXElement::TOX_MARK, pType->GetTypeName());
+ m_pTOXBase.reset(new SwTOXBase(pType, aForm,
+ nsSwTOXElement::TOX_MARK, pType->GetTypeName()));
if(pType->GetType() == TOX_CONTENT || pType->GetType() == TOX_USER)
- pTOXBase->SetLevel(MAXLEVEL);
- sUserTOXTypeName = pType->GetTypeName();
+ {
+ m_pTOXBase->SetLevel(MAXLEVEL);
+ }
+ m_sUserTOXTypeName = pType->GetTypeName();
+}
+
+static sal_uInt16
+lcl_TypeToPropertyMap(const TOXTypes eType)
+{
+ switch (eType)
+ {
+ case TOX_INDEX: return PROPERTY_MAP_INDEX_IDX;
+ case TOX_CONTENT: return PROPERTY_MAP_INDEX_CNTNT;
+ case TOX_TABLES: return PROPERTY_MAP_INDEX_TABLES;
+ case TOX_ILLUSTRATIONS: return PROPERTY_MAP_INDEX_ILLUSTRATIONS;
+ case TOX_OBJECTS: return PROPERTY_MAP_INDEX_OBJECTS;
+ case TOX_AUTHORITIES: return PROPERTY_MAP_BIBLIOGRAPHY;
+ //case TOX_USER:
+ default:
+ return PROPERTY_MAP_INDEX_USER;
+ }
+}
+
+class SwXDocumentIndex::Impl
+ : public SwClient
+{
+
+public:
+
+ SfxItemPropertySet const& m_rPropSet;
+ const TOXTypes m_eTOXType;
+ SwEventListenerContainer m_ListenerContainer;
+ bool m_bIsDescriptor;
+ SwDoc * m_pDoc;
+ ::std::auto_ptr<SwDocIndexDescriptorProperties_Impl> m_pProps;
+ uno::WeakReference<container::XIndexReplace> m_wStyleAccess;
+ uno::WeakReference<container::XIndexReplace> m_wTokenAccess;
+
+ Impl( SwXDocumentIndex & rThis,
+ SwDoc & rDoc,
+ const TOXTypes eType,
+ SwTOXBaseSection const*const pBaseSection)
+ : SwClient((pBaseSection) ? pBaseSection->GetFmt() : 0)
+ , m_rPropSet(
+ *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap(eType)))
+ , m_eTOXType(eType)
+ , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis))
+ , m_bIsDescriptor(0 == pBaseSection)
+ , m_pDoc(&rDoc)
+ , m_pProps((m_bIsDescriptor)
+ ? new SwDocIndexDescriptorProperties_Impl(rDoc.GetTOXType(eType, 0))
+ : 0)
+ {
+ }
+
+ SwSectionFmt * GetSectionFmt() const {
+ return static_cast<SwSectionFmt *>(
+ const_cast<SwModify *>(GetRegisteredIn()));
+ }
+
+ SwTOXBase & GetTOXSectionOrThrow() const
+ {
+ SwSectionFmt *const pSectionFmt(GetSectionFmt());
+ SwTOXBase *const pTOXSection( (m_bIsDescriptor)
+ ? &m_pProps->GetTOXBase()
+ : ((pSectionFmt)
+ ? static_cast<SwTOXBaseSection*>(pSectionFmt->GetSection())
+ : 0));
+ if (!pTOXSection)
+ {
+ throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "SwXDocumentIndex: disposed or invalid")), 0);
+ }
+ return *pTOXSection;
+ }
+
+ sal_Int32 GetFormMax() const
+ {
+ SwTOXBase & rSection( GetTOXSectionOrThrow() );
+ return (m_bIsDescriptor)
+ ? SwForm::GetFormMaxLevel(m_eTOXType)
+ : rSection.GetTOXForm().GetFormMax();
+ }
+
+ // SwClient
+ virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew);
+
+};
+
+/*-- 14.12.98 09:35:07---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwXDocumentIndex::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew)
+{
+ ClientModify(this, pOld, pNew);
+
+ if (!GetRegisteredIn())
+ {
+ m_ListenerContainer.Disposing();
+ }
+}
+
+/*-- 14.12.98 09:35:03---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwXDocumentIndex::SwXDocumentIndex(
+ SwTOXBaseSection const& rBaseSection, SwDoc & rDoc)
+ : m_pImpl( new SwXDocumentIndex::Impl( *this,
+ rDoc, rBaseSection.SwTOXBase::GetType(), & rBaseSection) )
+{
+}
+/* -----------------15.01.99 14:59-------------------
+ *
+ * --------------------------------------------------*/
+SwXDocumentIndex::SwXDocumentIndex(const TOXTypes eType, SwDoc& rDoc)
+ : m_pImpl( new SwXDocumentIndex::Impl( *this, rDoc, eType, 0) )
+{
}
+
+/*-- 14.12.98 09:35:04---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwXDocumentIndex::~SwXDocumentIndex()
+{
+}
+
+uno::Reference<text::XDocumentIndex>
+SwXDocumentIndex::CreateXDocumentIndex(
+ SwDoc & rDoc, SwTOXBaseSection const& rSection)
+{
+ // re-use existing SwXDocumentIndex
+ // #i105557#: do not iterate over the registered clients: race condition
+ SwSectionFmt *const pFmt = rSection.GetFmt();
+ uno::Reference<text::XDocumentIndex> xIndex(pFmt->GetXObject(),
+ uno::UNO_QUERY);
+ if (!xIndex.is())
+ {
+ SwXDocumentIndex *const pIndex(new SwXDocumentIndex(rSection, rDoc));
+ xIndex.set(pIndex);
+ pFmt->SetXObject(uno::Reference<uno::XInterface>(xIndex));
+ }
+ return xIndex;
+}
+
/* -----------------------------10.03.00 18:02--------------------------------
---------------------------------------------------------------------------*/
@@ -198,505 +375,530 @@ const uno::Sequence< sal_Int8 > & SwXDocumentIndex::getUnoTunnelId()
/* -----------------------------10.03.00 18:04--------------------------------
---------------------------------------------------------------------------*/
-sal_Int64 SAL_CALL SwXDocumentIndex::getSomething( const uno::Sequence< sal_Int8 >& rId )
- throw(uno::RuntimeException)
+sal_Int64 SAL_CALL
+SwXDocumentIndex::getSomething(const uno::Sequence< sal_Int8 >& rId)
+throw (uno::RuntimeException)
{
- if( rId.getLength() == 16
- && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
- rId.getConstArray(), 16 ) )
- {
- return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
- }
- return 0;
+ return ::sw::UnoTunnelImpl<SwXDocumentIndex>(rId, this);
}
+
/* -----------------------------06.04.00 15:01--------------------------------
---------------------------------------------------------------------------*/
-OUString SwXDocumentIndex::getImplementationName(void) throw( uno::RuntimeException )
+OUString SAL_CALL
+SwXDocumentIndex::getImplementationName() throw (uno::RuntimeException)
{
return C2U("SwXDocumentIndex");
}
/* -----------------------------06.04.00 15:01--------------------------------
---------------------------------------------------------------------------*/
-BOOL SwXDocumentIndex::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
-{
- return C2U("com.sun.star.text.BaseIndex") == rServiceName ||
- ( TOX_INDEX == eTOXType && C2U("com.sun.star.text.DocumentIndex") == rServiceName) ||
- ( TOX_CONTENT == eTOXType && C2U("com.sun.star.text.ContentIndex") == rServiceName) ||
- ( TOX_USER == eTOXType && C2U("com.sun.star.text.UserDefinedIndex") == rServiceName) ||
- ( TOX_ILLUSTRATIONS == eTOXType && C2U("com.sun.star.text.IllustrationsIndex") == rServiceName) ||
- ( TOX_TABLES == eTOXType && C2U("com.sun.star.text.TableIndex") == rServiceName) ||
- ( TOX_OBJECTS == eTOXType && C2U("com.sun.star.text.ObjectIndex") == rServiceName) ||
- ( TOX_AUTHORITIES == eTOXType && C2U("com.sun.star.text.Bibliography") == rServiceName);
+sal_Bool SAL_CALL
+SwXDocumentIndex::supportsService(const OUString& rServiceName)
+throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ return C2U("com.sun.star.text.BaseIndex") == rServiceName
+ || ((TOX_INDEX == m_pImpl->m_eTOXType) &&
+ rServiceName.equalsAscii("com.sun.star.text.DocumentIndex"))
+ || ((TOX_CONTENT == m_pImpl->m_eTOXType) &&
+ rServiceName.equalsAscii("com.sun.star.text.ContentIndex"))
+ || ((TOX_USER == m_pImpl->m_eTOXType) &&
+ rServiceName.equalsAscii("com.sun.star.text.UserDefinedIndex"))
+ || ((TOX_ILLUSTRATIONS == m_pImpl->m_eTOXType) &&
+ rServiceName.equalsAscii("com.sun.star.text.IllustrationsIndex"))
+ || ((TOX_TABLES == m_pImpl->m_eTOXType) &&
+ rServiceName.equalsAscii("com.sun.star.text.TableIndex"))
+ || ((TOX_OBJECTS == m_pImpl->m_eTOXType) &&
+ rServiceName.equalsAscii("com.sun.star.text.ObjectIndex"))
+ || ((TOX_AUTHORITIES == m_pImpl->m_eTOXType) &&
+ rServiceName.equalsAscii("com.sun.star.text.Bibliography"));
}
/* -----------------------------06.04.00 15:01--------------------------------
---------------------------------------------------------------------------*/
-uno::Sequence< OUString > SwXDocumentIndex::getSupportedServiceNames(void) throw( uno::RuntimeException )
+uno::Sequence< OUString > SAL_CALL
+SwXDocumentIndex::getSupportedServiceNames() throw (uno::RuntimeException)
{
+ vos::OGuard g(Application::GetSolarMutex());
+
uno::Sequence< OUString > aRet(2);
OUString* pArray = aRet.getArray();
pArray[0] = C2U("com.sun.star.text.BaseIndex");
- switch( eTOXType )
- {
- case TOX_INDEX: pArray[1] = C2U("com.sun.star.text.DocumentIndex");break;
- case TOX_CONTENT: pArray[1] = C2U("com.sun.star.text.ContentIndex");break;
- case TOX_TABLES: pArray[1] = C2U("com.sun.star.text.TableIndex");break;
- case TOX_ILLUSTRATIONS: pArray[1] = C2U("com.sun.star.text.IllustrationsIndex");break;
- case TOX_OBJECTS: pArray[1] = C2U("com.sun.star.text.ObjectIndex");break;
- case TOX_AUTHORITIES : pArray[1] = C2U("com.sun.star.text.Bibliography");break;
+ switch (m_pImpl->m_eTOXType)
+ {
+ case TOX_INDEX:
+ pArray[1] = C2U("com.sun.star.text.DocumentIndex");
+ break;
+ case TOX_CONTENT:
+ pArray[1] = C2U("com.sun.star.text.ContentIndex");
+ break;
+ case TOX_TABLES:
+ pArray[1] = C2U("com.sun.star.text.TableIndex");
+ break;
+ case TOX_ILLUSTRATIONS:
+ pArray[1] = C2U("com.sun.star.text.IllustrationsIndex");
+ break;
+ case TOX_OBJECTS:
+ pArray[1] = C2U("com.sun.star.text.ObjectIndex");
+ break;
+ case TOX_AUTHORITIES:
+ pArray[1] = C2U("com.sun.star.text.Bibliography");
+ break;
//case TOX_USER:
default:
pArray[1] = C2U("com.sun.star.text.UserDefinedIndex");
}
return aRet;
}
-/*-- 14.12.98 09:35:03---------------------------------------------------
-
- -----------------------------------------------------------------------*/
-TYPEINIT1(SwXDocumentIndex, SwClient)
-SwXDocumentIndex::SwXDocumentIndex(const SwTOXBaseSection* pB, SwDoc* pDc) :
- aLstnrCntnr( (text::XTextContent*)this),
- m_pPropSet(0),
- m_pDoc(pDc),
- pBase(pB),
- eTOXType(TOX_USER),
- bIsDescriptor(sal_False),
- pProps(0),
- pStyleAccess(0),
- pTokenAccess(0)
-{
- if(pBase && m_pDoc)
- {
- pBase->GetFmt()->Add(this);
- sal_uInt16 PropertyId;
- eTOXType = pBase->SwTOXBase::GetType();
- switch( eTOXType )
- {
- case TOX_INDEX: PropertyId = PROPERTY_MAP_INDEX_IDX; break;
- case TOX_CONTENT: PropertyId = PROPERTY_MAP_INDEX_CNTNT; break;
- case TOX_TABLES: PropertyId = PROPERTY_MAP_INDEX_TABLES; break;
- case TOX_ILLUSTRATIONS: PropertyId = PROPERTY_MAP_INDEX_ILLUSTRATIONS; break;
- case TOX_OBJECTS: PropertyId = PROPERTY_MAP_INDEX_OBJECTS; break;
- case TOX_AUTHORITIES : PropertyId = PROPERTY_MAP_BIBLIOGRAPHY; break;
- //case TOX_USER:
- default:
- PropertyId = PROPERTY_MAP_INDEX_USER;
- }
- m_pPropSet = aSwMapProvider.GetPropertySet(PropertyId);
- }
-}
-/* -----------------15.01.99 14:59-------------------
- *
- * --------------------------------------------------*/
-SwXDocumentIndex::SwXDocumentIndex(TOXTypes eType, SwDoc& rDoc) :
- aLstnrCntnr( (text::XTextContent*)this),
- m_pDoc(0),
- pBase(0),
- eTOXType(eType),
- bIsDescriptor(sal_True),
- pProps(new SwDocIdxProperties_Impl(rDoc.GetTOXType(eType, 0))),
- pStyleAccess(0),
- pTokenAccess(0)
-{
- sal_uInt16 PropertyId;
- switch(eType)
- {
- case TOX_INDEX: PropertyId = PROPERTY_MAP_INDEX_IDX; break;
- case TOX_CONTENT: PropertyId = PROPERTY_MAP_INDEX_CNTNT; break;
- case TOX_TABLES: PropertyId = PROPERTY_MAP_INDEX_TABLES; break;
- case TOX_ILLUSTRATIONS: PropertyId = PROPERTY_MAP_INDEX_ILLUSTRATIONS; break;
- case TOX_OBJECTS: PropertyId = PROPERTY_MAP_INDEX_OBJECTS; break;
- case TOX_AUTHORITIES : PropertyId = PROPERTY_MAP_BIBLIOGRAPHY; break;
- //case TOX_USER:
- default:
- PropertyId = PROPERTY_MAP_INDEX_USER;
- }
- m_pPropSet = aSwMapProvider.GetPropertySet(PropertyId);
-}
-
-/*-- 14.12.98 09:35:04---------------------------------------------------
- -----------------------------------------------------------------------*/
-SwXDocumentIndex::~SwXDocumentIndex()
-{
- delete pProps;
-}
/*-- 14.12.98 09:35:05---------------------------------------------------
-----------------------------------------------------------------------*/
-OUString SwXDocumentIndex::getServiceName(void) throw( uno::RuntimeException )
+OUString SAL_CALL SwXDocumentIndex::getServiceName()
+throw (uno::RuntimeException)
{
+ vos::OGuard g(Application::GetSolarMutex());
+
USHORT nObjectType = SW_SERVICE_TYPE_INDEX;
- switch(eTOXType)
+ switch (m_pImpl->m_eTOXType)
{
// case TOX_INDEX: break;
- case TOX_USER: nObjectType = SW_SERVICE_USER_INDEX;break;
- case TOX_CONTENT: nObjectType = SW_SERVICE_CONTENT_INDEX;break;
- case TOX_ILLUSTRATIONS: nObjectType = SW_SERVICE_INDEX_ILLUSTRATIONS;break;
- case TOX_OBJECTS: nObjectType = SW_SERVICE_INDEX_OBJECTS;break;
- case TOX_TABLES: nObjectType = SW_SERVICE_INDEX_TABLES;break;
- case TOX_AUTHORITIES: nObjectType = SW_SERVICE_INDEX_BIBLIOGRAPHY;break;
+ case TOX_USER: nObjectType = SW_SERVICE_USER_INDEX;
+ break;
+ case TOX_CONTENT: nObjectType = SW_SERVICE_CONTENT_INDEX;
+ break;
+ case TOX_ILLUSTRATIONS: nObjectType = SW_SERVICE_INDEX_ILLUSTRATIONS;
+ break;
+ case TOX_OBJECTS: nObjectType = SW_SERVICE_INDEX_OBJECTS;
+ break;
+ case TOX_TABLES: nObjectType = SW_SERVICE_INDEX_TABLES;
+ break;
+ case TOX_AUTHORITIES: nObjectType = SW_SERVICE_INDEX_BIBLIOGRAPHY;
+ break;
default:
- ;
+ break;
}
return SwXServiceProvider::GetProviderName(nObjectType);
}
+
/*-- 14.12.98 09:35:05---------------------------------------------------
-----------------------------------------------------------------------*/
-void SwXDocumentIndex::update(void) throw( uno::RuntimeException )
+void SAL_CALL SwXDocumentIndex::update() throw (uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwSectionFmt *pFmt = GetFmt();
- SwTOXBase* pTOXBase = pFmt ? (SwTOXBaseSection*)pFmt->GetSection() : 0;
+
+ SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
+ SwTOXBaseSection *const pTOXBase = (pFmt) ?
+ static_cast<SwTOXBaseSection*>(pFmt->GetSection()) : 0;
if(!pTOXBase)
+ {
throw uno::RuntimeException();
- ((SwTOXBaseSection*)pTOXBase)->Update();
- // Seitennummern eintragen
- ((SwTOXBaseSection*)pTOXBase)->UpdatePageNum();
+ }
+ pTOXBase->Update();
+ // page numbers
+ pTOXBase->UpdatePageNum();
}
+
/*-- 14.12.98 09:35:05---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Reference< beans::XPropertySetInfo > SwXDocumentIndex::getPropertySetInfo(void) throw( uno::RuntimeException )
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+SwXDocumentIndex::getPropertySetInfo() throw (uno::RuntimeException)
{
- uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
- return aRef;
+ vos::OGuard g(Application::GetSolarMutex());
+
+ const uno::Reference< beans::XPropertySetInfo > xRef =
+ m_pImpl->m_rPropSet.getPropertySetInfo();
+ return xRef;
}
+
/*-- 14.12.98 09:35:05---------------------------------------------------
-----------------------------------------------------------------------*/
-void SwXDocumentIndex::setPropertyValue(const OUString& rPropertyName,
- const uno::Any& aValue)
- throw( beans::UnknownPropertyException, beans::PropertyVetoException,
- lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+void SAL_CALL
+SwXDocumentIndex::setPropertyValue(
+ const OUString& rPropertyName, const uno::Any& rValue)
+throw (beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
+
+ SfxItemPropertySimpleEntry const*const pEntry =
+ m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName);
if (!pEntry)
- throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
- if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
- throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
+ {
+ throw beans::UnknownPropertyException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
+ + rPropertyName,
+ static_cast<cppu::OWeakObject *>(this));
+ }
+ if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
+ {
+ throw beans::PropertyVetoException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: " ))
+ + rPropertyName,
+ static_cast<cppu::OWeakObject *>(this));
+ }
- SwTOXBase* pTOXBase = 0;
- if(GetFmt())
- pTOXBase = (SwTOXBaseSection*)GetFmt()->GetSection();
- else if(bIsDescriptor)
- pTOXBase = &pProps->GetTOXBase();
- if(pTOXBase)
+ SwSectionFmt *const pSectionFmt(m_pImpl->GetSectionFmt());
+ SwTOXBase & rTOXBase( m_pImpl->GetTOXSectionOrThrow() );
+
+ sal_uInt16 nCreate = rTOXBase.GetCreateType();
+ sal_uInt16 nTOIOptions = 0;
+ sal_uInt16 nOLEOptions = rTOXBase.GetOLEOptions();
+ const TOXTypes eTxBaseType = rTOXBase.GetTOXType()->GetType();
+ if (eTxBaseType == TOX_INDEX)
{
- sal_uInt16 nCreate = pTOXBase->GetCreateType();
- sal_uInt16 nTOIOptions = 0;
- sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions();
- TOXTypes eTxBaseType = pTOXBase->GetTOXType()->GetType();
- if( eTxBaseType == TOX_INDEX )
- nTOIOptions = pTOXBase->GetOptions();
- SwForm aForm(pTOXBase->GetTOXForm());
- sal_Bool bForm = sal_False;
- SfxItemSet* pAttrSet = 0;
- switch(pEntry->nWID)
+ nTOIOptions = rTOXBase.GetOptions();
+ }
+ SwForm aForm(rTOXBase.GetTOXForm());
+ sal_Bool bForm = sal_False;
+ switch (pEntry->nWID)
+ {
+ case WID_IDX_TITLE:
{
- case WID_IDX_TITLE :
+ OUString sNewName;
+ if (!(rValue >>= sNewName))
{
- OUString sNewName;
- aValue >>= sNewName;
- pTOXBase->SetTitle(sNewName);
- }
- break;
- case WID_IDX_NAME:
- {
- OUString sNewName;
- aValue >>= sNewName;
- pTOXBase->SetTOXName(sNewName);
- }
- break;
- case WID_USER_IDX_NAME:
- {
- OUString sNewName;
- aValue >>= sNewName;
- lcl_ConvertTOUNameToUserName(sNewName);
- DBG_ASSERT(TOX_USER == eTxBaseType, "tox type name can only be changed for user indexes");
- if(GetFmt())
- {
- OUString sTmp = pTOXBase->GetTOXType()->GetTypeName();
- if(sTmp != sNewName)
- {
- lcl_ReAssignTOXType(GetFmt()->GetDoc(), *pTOXBase, sNewName);
- }
- }
- else
- pProps->SetTypeName(sNewName);
+ throw lang::IllegalArgumentException();
}
- break;
- case WID_IDX_LOCALE:
+ rTOXBase.SetTitle(sNewName);
+ }
+ break;
+ case WID_IDX_NAME:
+ {
+ OUString sNewName;
+ if (!(rValue >>= sNewName))
{
- lang::Locale aLocale;
- if(aValue>>= aLocale)
- pTOXBase->SetLanguage(SvxLocaleToLanguage(aLocale));
- else
- throw lang::IllegalArgumentException();
+ throw lang::IllegalArgumentException();
}
- break;
- case WID_IDX_SORT_ALGORITHM:
+ rTOXBase.SetTOXName(sNewName);
+ }
+ break;
+ case WID_USER_IDX_NAME:
+ {
+ OUString sNewName;
+ if (!(rValue >>= sNewName))
{
- OUString sTmp;
- if(aValue >>= sTmp)
- pTOXBase->SetSortAlgorithm(sTmp);
- else
- throw lang::IllegalArgumentException();
+ throw lang::IllegalArgumentException();
}
- break;
- case WID_LEVEL :
- pTOXBase->SetLevel(lcl_AnyToInt16(aValue));
- break;
- case WID_CREATE_FROM_MARKS :
- nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_MARK: nCreate & ~nsSwTOXElement::TOX_MARK;
- break;
- case WID_CREATE_FROM_OUTLINE :
- nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_OUTLINELEVEL: nCreate & ~nsSwTOXElement::TOX_OUTLINELEVEL;
- break;
-// case WID_PARAGRAPH_STYLE_NAMES :DBG_ERROR("not implemented")
-// break;
- case WID_CREATE_FROM_CHAPTER :
- pTOXBase->SetFromChapter(lcl_AnyToBool(aValue));
- break;
- case WID_CREATE_FROM_LABELS :
- pTOXBase->SetFromObjectNames(! lcl_AnyToBool(aValue));
- break;
- case WID_PROTECTED :
+ lcl_ConvertTOUNameToUserName(sNewName);
+ DBG_ASSERT(TOX_USER == eTxBaseType,
+ "tox type name can only be changed for user indexes");
+ if (pSectionFmt)
{
- sal_Bool bSet = lcl_AnyToBool(aValue);
- pTOXBase->SetProtected(bSet);
- if(GetFmt())
- ((SwTOXBaseSection*)pTOXBase)->SetProtect(bSet);
+ OUString sTmp = rTOXBase.GetTOXType()->GetTypeName();
+ if (sTmp != sNewName)
+ {
+ lcl_ReAssignTOXType(pSectionFmt->GetDoc(),
+ rTOXBase, sNewName);
+ }
}
- break;
- case WID_USE_ALPHABETICAL_SEPARATORS:
- nTOIOptions = lcl_AnyToBool(aValue) ?
- nTOIOptions | nsSwTOIOptions::TOI_ALPHA_DELIMITTER : nTOIOptions & ~nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
- break;
- case WID_USE_KEY_AS_ENTRY :
- nTOIOptions = lcl_AnyToBool(aValue) ?
- nTOIOptions | nsSwTOIOptions::TOI_KEY_AS_ENTRY : nTOIOptions & ~nsSwTOIOptions::TOI_KEY_AS_ENTRY;
- break;
- case WID_USE_COMBINED_ENTRIES :
- nTOIOptions = lcl_AnyToBool(aValue) ?
- nTOIOptions | nsSwTOIOptions::TOI_SAME_ENTRY : nTOIOptions & ~nsSwTOIOptions::TOI_SAME_ENTRY;
- break;
- case WID_IS_CASE_SENSITIVE :
- nTOIOptions = lcl_AnyToBool(aValue) ?
- nTOIOptions | nsSwTOIOptions::TOI_CASE_SENSITIVE : nTOIOptions & ~nsSwTOIOptions::TOI_CASE_SENSITIVE;
- break;
- case WID_USE_P_P :
- nTOIOptions = lcl_AnyToBool(aValue) ?
- nTOIOptions | nsSwTOIOptions::TOI_FF : nTOIOptions & ~nsSwTOIOptions::TOI_FF;
- break;
- case WID_USE_DASH :
- nTOIOptions = lcl_AnyToBool(aValue) ?
- nTOIOptions | nsSwTOIOptions::TOI_DASH : nTOIOptions & ~nsSwTOIOptions::TOI_DASH;
- break;
- case WID_USE_UPPER_CASE :
- nTOIOptions = lcl_AnyToBool(aValue) ?
- nTOIOptions | nsSwTOIOptions::TOI_INITIAL_CAPS : nTOIOptions & ~nsSwTOIOptions::TOI_INITIAL_CAPS;
- break;
- case WID_IS_COMMA_SEPARATED :
- bForm = sal_True;
- aForm.SetCommaSeparated(lcl_AnyToBool(aValue));
- break;
- case WID_LABEL_CATEGORY :
+ else
{
- // convert file-format/API/external programmatic english name
- // to internal UI name before usage
- String aName( SwStyleNameMapper::GetSpecialExtraUIName(
- lcl_AnyToString(aValue) ) );
- pTOXBase->SetSequenceName( aName );
+ m_pImpl->m_pProps->SetTypeName(sNewName);
}
- break;
- case WID_LABEL_DISPLAY_TYPE :
+ }
+ break;
+ case WID_IDX_LOCALE:
+ {
+ lang::Locale aLocale;
+ if (!(rValue>>= aLocale))
{
- sal_Int16 nVal = lcl_AnyToInt16(aValue);
- sal_uInt16 nSet = CAPTION_COMPLETE;
- switch (nVal)
- {
- case text::ReferenceFieldPart::TEXT: nSet = CAPTION_COMPLETE;
- break;
- case text::ReferenceFieldPart::CATEGORY_AND_NUMBER : nSet = CAPTION_NUMBER;
- break;
- case text::ReferenceFieldPart::ONLY_CAPTION : nSet = CAPTION_TEXT;
- break;
- default:
- throw lang::IllegalArgumentException();
- }
- pTOXBase->SetCaptionDisplay((SwCaptionDisplay)nSet);
+ throw lang::IllegalArgumentException();
}
- break;
- case WID_USE_LEVEL_FROM_SOURCE :
- pTOXBase->SetLevelFromChapter(lcl_AnyToBool(aValue));
- break;
- case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME :
+ rTOXBase.SetLanguage(SvxLocaleToLanguage(aLocale));
+ }
+ break;
+ case WID_IDX_SORT_ALGORITHM:
+ {
+ OUString sTmp;
+ if (!(rValue >>= sTmp))
{
- String aString;
- SwStyleNameMapper::FillUIName(lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True);
- pTOXBase->SetMainEntryCharStyle( aString );
+ throw lang::IllegalArgumentException();
}
- break;
- case WID_CREATE_FROM_TABLES :
- nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_TABLE : nCreate & ~nsSwTOXElement::TOX_TABLE;
- break;
- case WID_CREATE_FROM_TEXT_FRAMES :
- nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_FRAME : nCreate & ~nsSwTOXElement::TOX_FRAME;
- break;
- case WID_CREATE_FROM_GRAPHIC_OBJECTS :
- nCreate = lcl_AnyToBool(aValue) ? nCreate | nsSwTOXElement::TOX_GRAPHIC : nCreate & ~nsSwTOXElement::TOX_GRAPHIC;
- break;
- case WID_CREATE_FROM_EMBEDDED_OBJECTS :
- if(lcl_AnyToBool(aValue))
- nCreate |= nsSwTOXElement::TOX_OLE;
- else
- nCreate &= ~nsSwTOXElement::TOX_OLE;
- break;
- case WID_CREATE_FROM_STAR_MATH:
- nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_MATH : nOLEOptions & ~nsSwTOOElements::TOO_MATH;
- break;
- case WID_CREATE_FROM_STAR_CHART :
- nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_CHART : nOLEOptions & ~nsSwTOOElements::TOO_CHART;
- break;
- case WID_CREATE_FROM_STAR_CALC :
- nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_CALC : nOLEOptions & ~nsSwTOOElements::TOO_CALC;
- break;
- case WID_CREATE_FROM_STAR_DRAW :
- nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_DRAW_IMPRESS : nOLEOptions & ~nsSwTOOElements::TOO_DRAW_IMPRESS;
- break;
- case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS:
- nOLEOptions = lcl_AnyToBool(aValue) ? nOLEOptions | nsSwTOOElements::TOO_OTHER : nOLEOptions & ~nsSwTOOElements::TOO_OTHER;
- break;
- case WID_PARA_HEAD :
+ rTOXBase.SetSortAlgorithm(sTmp);
+ }
+ break;
+ case WID_LEVEL:
+ {
+ rTOXBase.SetLevel(lcl_AnyToInt16(rValue));
+ }
+ break;
+ case WID_CREATE_FROM_MARKS:
+ lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_MARK);
+ break;
+ case WID_CREATE_FROM_OUTLINE:
+ lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OUTLINELEVEL);
+ break;
+// case WID_PARAGRAPH_STYLE_NAMES :DBG_ERROR("not implemented")
+// break;
+ case WID_CREATE_FROM_CHAPTER:
+ rTOXBase.SetFromChapter(lcl_AnyToBool(rValue));
+ break;
+ case WID_CREATE_FROM_LABELS:
+ rTOXBase.SetFromObjectNames(! lcl_AnyToBool(rValue));
+ break;
+ case WID_PROTECTED:
+ {
+ sal_Bool bSet = lcl_AnyToBool(rValue);
+ rTOXBase.SetProtected(bSet);
+ if (pSectionFmt)
{
- String aString;
- SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
- bForm = sal_True;
- //Header steht an Pos 0
- aForm.SetTemplate( 0, aString );
+ static_cast<SwTOXBaseSection &>(rTOXBase).SetProtect(bSet);
}
- break;
- case WID_IS_RELATIVE_TABSTOPS:
- bForm = sal_True;
- aForm.SetRelTabPos(lcl_AnyToBool(aValue));
- break;
- case WID_PARA_SEP :
+ }
+ break;
+ case WID_USE_ALPHABETICAL_SEPARATORS:
+ lcl_AnyToBitMask(rValue, nTOIOptions,
+ nsSwTOIOptions::TOI_ALPHA_DELIMITTER);
+ break;
+ case WID_USE_KEY_AS_ENTRY:
+ lcl_AnyToBitMask(rValue, nTOIOptions,
+ nsSwTOIOptions::TOI_KEY_AS_ENTRY);
+ break;
+ case WID_USE_COMBINED_ENTRIES:
+ lcl_AnyToBitMask(rValue, nTOIOptions,
+ nsSwTOIOptions::TOI_SAME_ENTRY);
+ break;
+ case WID_IS_CASE_SENSITIVE:
+ lcl_AnyToBitMask(rValue, nTOIOptions,
+ nsSwTOIOptions::TOI_CASE_SENSITIVE);
+ break;
+ case WID_USE_P_P:
+ lcl_AnyToBitMask(rValue, nTOIOptions, nsSwTOIOptions::TOI_FF);
+ break;
+ case WID_USE_DASH:
+ lcl_AnyToBitMask(rValue, nTOIOptions, nsSwTOIOptions::TOI_DASH);
+ break;
+ case WID_USE_UPPER_CASE:
+ lcl_AnyToBitMask(rValue, nTOIOptions,
+ nsSwTOIOptions::TOI_INITIAL_CAPS);
+ break;
+ case WID_IS_COMMA_SEPARATED:
+ bForm = sal_True;
+ aForm.SetCommaSeparated(lcl_AnyToBool(rValue));
+ break;
+ case WID_LABEL_CATEGORY:
+ {
+ // convert file-format/API/external programmatic english name
+ // to internal UI name before usage
+ String aName( SwStyleNameMapper::GetSpecialExtraUIName(
+ lcl_AnyToString(rValue) ) );
+ rTOXBase.SetSequenceName( aName );
+ }
+ break;
+ case WID_LABEL_DISPLAY_TYPE:
+ {
+ const sal_Int16 nVal = lcl_AnyToInt16(rValue);
+ sal_uInt16 nSet = CAPTION_COMPLETE;
+ switch (nVal)
{
- String aString;
- bForm = sal_True;
- SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
- aForm.SetTemplate( 1, aString );
+ case text::ReferenceFieldPart::TEXT:
+ nSet = CAPTION_COMPLETE;
+ break;
+ case text::ReferenceFieldPart::CATEGORY_AND_NUMBER:
+ nSet = CAPTION_NUMBER;
+ break;
+ case text::ReferenceFieldPart::ONLY_CAPTION:
+ nSet = CAPTION_TEXT;
+ break;
+ default:
+ throw lang::IllegalArgumentException();
}
- break;
- case WID_CREATE_FROM_PARAGRAPH_STYLES:
- nCreate = lcl_AnyToBool(aValue) ?
- (nCreate | nsSwTOXElement::TOX_TEMPLATE) : (nCreate & ~nsSwTOXElement::TOX_TEMPLATE);
- break;
-
- case WID_PARA_LEV1 :
- case WID_PARA_LEV2 :
- case WID_PARA_LEV3 :
- case WID_PARA_LEV4 :
- case WID_PARA_LEV5 :
- case WID_PARA_LEV6 :
- case WID_PARA_LEV7 :
- case WID_PARA_LEV8 :
- case WID_PARA_LEV9 :
- case WID_PARA_LEV10 :
+ rTOXBase.SetCaptionDisplay(static_cast<SwCaptionDisplay>(nSet));
+ }
+ break;
+ case WID_USE_LEVEL_FROM_SOURCE:
+ rTOXBase.SetLevelFromChapter(lcl_AnyToBool(rValue));
+ break;
+ case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME:
+ {
+ String aString;
+ SwStyleNameMapper::FillUIName(lcl_AnyToString(rValue),
+ aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True);
+ rTOXBase.SetMainEntryCharStyle( aString );
+ }
+ break;
+ case WID_CREATE_FROM_TABLES:
+ lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TABLE);
+ break;
+ case WID_CREATE_FROM_TEXT_FRAMES:
+ lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_FRAME);
+ break;
+ case WID_CREATE_FROM_GRAPHIC_OBJECTS:
+ lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_GRAPHIC);
+ break;
+ case WID_CREATE_FROM_EMBEDDED_OBJECTS:
+ lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_OLE);
+ break;
+ case WID_CREATE_FROM_STAR_MATH:
+ lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_MATH);
+ break;
+ case WID_CREATE_FROM_STAR_CHART:
+ lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CHART);
+ break;
+ case WID_CREATE_FROM_STAR_CALC:
+ lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CALC);
+ break;
+ case WID_CREATE_FROM_STAR_DRAW:
+ lcl_AnyToBitMask(rValue, nOLEOptions,
+ nsSwTOOElements::TOO_DRAW_IMPRESS);
+ break;
+ case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS:
+ lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_OTHER);
+ break;
+ case WID_PARA_HEAD:
+ {
+ String aString;
+ SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue),
+ aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
+ bForm = sal_True;
+ // Header is on Pos 0
+ aForm.SetTemplate( 0, aString );
+ }
+ break;
+ case WID_IS_RELATIVE_TABSTOPS:
+ bForm = sal_True;
+ aForm.SetRelTabPos(lcl_AnyToBool(rValue));
+ break;
+ case WID_PARA_SEP:
+ {
+ String aString;
+ bForm = sal_True;
+ SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue),
+ aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
+ aForm.SetTemplate( 1, aString );
+ }
+ break;
+ case WID_CREATE_FROM_PARAGRAPH_STYLES:
+ lcl_AnyToBitMask(rValue, nCreate, nsSwTOXElement::TOX_TEMPLATE);
+ break;
+
+ case WID_PARA_LEV1:
+ case WID_PARA_LEV2:
+ case WID_PARA_LEV3:
+ case WID_PARA_LEV4:
+ case WID_PARA_LEV5:
+ case WID_PARA_LEV6:
+ case WID_PARA_LEV7:
+ case WID_PARA_LEV8:
+ case WID_PARA_LEV9:
+ case WID_PARA_LEV10:
+ {
+ bForm = sal_True;
+ // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1
+ const sal_uInt16 nLPos = rTOXBase.GetType() == TOX_INDEX ? 2 : 1;
+ String aString;
+ SwStyleNameMapper::FillUIName( lcl_AnyToString(rValue),
+ aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
+ aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString );
+ }
+ break;
+ default:
+ //this is for items only
+ if (WID_PRIMARY_KEY > pEntry->nWID)
{
- bForm = sal_True;
- // im sdbcx::Index beginnt Lebel 1 bei Pos 2 sonst bei Pos 1
- sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1;
- String aString;
- SwStyleNameMapper::FillUIName( lcl_AnyToString(aValue), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
- aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString );
- }
- break;
- default:
- //this is for items only
- if(WID_PRIMARY_KEY > pEntry->nWID)
+ const SwAttrSet& rSet =
+ m_pImpl->m_pDoc->GetTOXBaseAttrSet(rTOXBase);
+ SfxItemSet aAttrSet(rSet);
+ m_pImpl->m_rPropSet.setPropertyValue(
+ rPropertyName, rValue, aAttrSet);
+
+ const SwSectionFmts& rSects = m_pImpl->m_pDoc->GetSections();
+ for (sal_uInt16 i = 0; i < rSects.Count(); i++)
{
- const SwAttrSet& rSet = m_pDoc->GetTOXBaseAttrSet(*pTOXBase);
- pAttrSet = new SfxItemSet(rSet);
- m_pPropSet->setPropertyValue(rPropertyName, aValue, *pAttrSet);
-
- const SwSectionFmts& rSects = m_pDoc->GetSections();
- const SwSectionFmt* pOwnFmt = GetFmt();
- for(sal_uInt16 i = 0; i < rSects.Count(); i++)
+ const SwSectionFmt* pTmpFmt = rSects[ i ];
+ if (pTmpFmt == pSectionFmt)
{
- const SwSectionFmt* pTmpFmt = rSects[ i ];
- if(pTmpFmt == pOwnFmt)
- {
- m_pDoc->ChgSection( i, *(SwTOXBaseSection*)pTOXBase, pAttrSet );
- break;
- }
+ m_pImpl->m_pDoc->ChgSection( i,
+ static_cast<SwTOXBaseSection&>(rTOXBase),
+ & aAttrSet);
+ break;
}
}
- }
- pTOXBase->SetCreate(nCreate);
- pTOXBase->SetOLEOptions(nOLEOptions);
- if(pTOXBase->GetTOXType()->GetType() == TOX_INDEX)
- pTOXBase->SetOptions(nTOIOptions);
- if(bForm)
- pTOXBase->SetTOXForm(aForm);
- delete pAttrSet;
+ }
+ }
+ rTOXBase.SetCreate(nCreate);
+ rTOXBase.SetOLEOptions(nOLEOptions);
+ if (rTOXBase.GetTOXType()->GetType() == TOX_INDEX)
+ {
+ rTOXBase.SetOptions(nTOIOptions);
+ }
+ if (bForm)
+ {
+ rTOXBase.SetTOXForm(aForm);
}
- else
- throw uno::RuntimeException();
-
}
+
/*-- 14.12.98 09:35:05---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
- throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+uno::Any SAL_CALL
+SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
+
uno::Any aRet;
- const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
+ SfxItemPropertySimpleEntry const*const pEntry =
+ m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName);
if (!pEntry)
- throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
+ {
+ throw beans::UnknownPropertyException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
+ + rPropertyName,
+ static_cast< cppu::OWeakObject * >(this));
+ }
+
+ SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
SwTOXBase* pTOXBase = 0;
- if(GetFmt())
- pTOXBase = (SwTOXBaseSection*)GetFmt()->GetSection();
- else if(bIsDescriptor)
- pTOXBase = &pProps->GetTOXBase();
+ if (pSectionFmt)
+ {
+ pTOXBase = static_cast<SwTOXBaseSection*>(pSectionFmt->GetSection());
+ }
+ else if (m_pImpl->m_bIsDescriptor)
+ {
+ pTOXBase = &m_pImpl->m_pProps->GetTOXBase();
+ }
if(pTOXBase)
{
- sal_uInt16 nCreate = pTOXBase->GetCreateType();
- sal_uInt16 nTOIOptions = 0;
- sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions();
- if(pTOXBase->GetTOXType()->GetType() == TOX_INDEX)
- nTOIOptions = pTOXBase->GetOptions();
+ const sal_uInt16 nCreate = pTOXBase->GetCreateType();
+ const sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions();
+ const sal_uInt16 nTOIOptions =
+ (pTOXBase->GetTOXType()->GetType() == TOX_INDEX)
+ ? pTOXBase->GetOptions()
+ : 0U;
const SwForm& rForm = pTOXBase->GetTOXForm();
- sal_Bool bBOOL = sal_True;
- sal_Bool bRet = sal_False;
switch(pEntry->nWID)
{
case WID_IDX_CONTENT_SECTION:
case WID_IDX_HEADER_SECTION :
- bBOOL = sal_False;
if(WID_IDX_CONTENT_SECTION == pEntry->nWID)
{
- uno::Reference <text::XTextSection> xContentSect = SwXTextSections::GetObject( *GetFmt() );
+ const uno::Reference <text::XTextSection> xContentSect =
+ SwXTextSection::CreateXTextSection( pSectionFmt );
aRet <<= xContentSect;
}
else
{
SwSections aSectArr;
- GetFmt()->GetChildSections( aSectArr, SORTSECT_NOT, FALSE);
+ pSectionFmt->GetChildSections(aSectArr,
+ SORTSECT_NOT, FALSE);
for(USHORT i = 0; i < aSectArr.Count(); i++)
{
SwSection* pSect = aSectArr[i];
if(pSect->GetType() == TOX_HEADER_SECTION)
{
- uno::Reference <text::XTextSection> xHeaderSect = SwXTextSections::GetObject( *pSect->GetFmt() );
- aRet <<= xHeaderSect;
+ const uno::Reference <text::XTextSection> xHeader =
+ SwXTextSection::CreateXTextSection(
+ pSect->GetFmt() );
+ aRet <<= xHeader;
break;
}
}
@@ -704,80 +906,96 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
break;
case WID_IDX_TITLE :
{
- bBOOL = sal_False;
OUString uRet(pTOXBase->GetTitle());
aRet <<= uRet;
break;
}
case WID_IDX_NAME:
- bBOOL = sal_False;
aRet <<= OUString(pTOXBase->GetTOXName());
break;
case WID_USER_IDX_NAME:
{
- bBOOL = sal_False;
OUString sTmp;
- if(!IsDescriptor())
+ if (!m_pImpl->m_bIsDescriptor)
+ {
sTmp = pTOXBase->GetTOXType()->GetTypeName();
+ }
else
- sTmp = pProps->GetTypeName();
+ {
+ sTmp = m_pImpl->m_pProps->GetTypeName();
+ }
//I18N
lcl_ConvertTOUNameToProgrammaticName(sTmp);
aRet <<= sTmp;
}
break;
case WID_IDX_LOCALE:
- bBOOL = sal_False;
aRet <<= SvxCreateLocale(pTOXBase->GetLanguage());
break;
case WID_IDX_SORT_ALGORITHM:
- bBOOL = sal_False;
aRet <<= OUString(pTOXBase->GetSortAlgorithm());
break;
case WID_LEVEL :
- bBOOL = sal_False;
- aRet <<= (sal_Int16)pTOXBase->GetLevel();
+ aRet <<= static_cast<sal_Int16>(pTOXBase->GetLevel());
break;
- case WID_CREATE_FROM_MARKS :
- bRet = 0 != (nCreate & nsSwTOXElement::TOX_MARK);
+ case WID_CREATE_FROM_MARKS:
+ lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_MARK);
break;
- case WID_CREATE_FROM_OUTLINE :
- bRet = 0 != (nCreate & nsSwTOXElement::TOX_OUTLINELEVEL);
+ case WID_CREATE_FROM_OUTLINE:
+ lcl_BitMaskToAny(aRet, nCreate,
+ nsSwTOXElement::TOX_OUTLINELEVEL);
break;
- case WID_CREATE_FROM_CHAPTER :
- bRet = pTOXBase->IsFromChapter();
+ case WID_CREATE_FROM_CHAPTER:
+ {
+ const sal_Bool bRet = pTOXBase->IsFromChapter();
+ aRet <<= bRet;
+ }
break;
- case WID_CREATE_FROM_LABELS :
- bRet = ! pTOXBase->IsFromObjectNames();
+ case WID_CREATE_FROM_LABELS:
+ {
+ const sal_Bool bRet = ! pTOXBase->IsFromObjectNames();
+ aRet <<= bRet;
+ }
break;
- case WID_PROTECTED :
- bRet = pTOXBase->IsProtected();
+ case WID_PROTECTED:
+ {
+ const sal_Bool bRet = pTOXBase->IsProtected();
+ aRet <<= bRet;
+ }
break;
case WID_USE_ALPHABETICAL_SEPARATORS:
- bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_ALPHA_DELIMITTER);
+ lcl_BitMaskToAny(aRet, nTOIOptions,
+ nsSwTOIOptions::TOI_ALPHA_DELIMITTER);
break;
- case WID_USE_KEY_AS_ENTRY :
- bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_KEY_AS_ENTRY);
+ case WID_USE_KEY_AS_ENTRY:
+ lcl_BitMaskToAny(aRet, nTOIOptions,
+ nsSwTOIOptions::TOI_KEY_AS_ENTRY);
break;
- case WID_USE_COMBINED_ENTRIES :
- bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_SAME_ENTRY);
+ case WID_USE_COMBINED_ENTRIES:
+ lcl_BitMaskToAny(aRet, nTOIOptions,
+ nsSwTOIOptions::TOI_SAME_ENTRY);
break;
- case WID_IS_CASE_SENSITIVE :
- bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_CASE_SENSITIVE);
+ case WID_IS_CASE_SENSITIVE:
+ lcl_BitMaskToAny(aRet, nTOIOptions,
+ nsSwTOIOptions::TOI_CASE_SENSITIVE);
break;
case WID_USE_P_P:
- bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_FF);
+ lcl_BitMaskToAny(aRet, nTOIOptions, nsSwTOIOptions::TOI_FF);
break;
- case WID_USE_DASH :
- bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_DASH);
+ case WID_USE_DASH:
+ lcl_BitMaskToAny(aRet, nTOIOptions, nsSwTOIOptions::TOI_DASH);
break;
- case WID_USE_UPPER_CASE :
- bRet = 0 != (nTOIOptions & nsSwTOIOptions::TOI_INITIAL_CAPS);
+ case WID_USE_UPPER_CASE:
+ lcl_BitMaskToAny(aRet, nTOIOptions,
+ nsSwTOIOptions::TOI_INITIAL_CAPS);
break;
- case WID_IS_COMMA_SEPARATED :
- bRet = rForm.IsCommaSeparated();
+ case WID_IS_COMMA_SEPARATED:
+ {
+ const sal_Bool bRet = rForm.IsCommaSeparated();
+ aRet <<= bRet;
+ }
break;
- case WID_LABEL_CATEGORY :
+ case WID_LABEL_CATEGORY:
{
// convert internal UI name to
// file-format/API/external programmatic english name
@@ -785,50 +1003,58 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
String aName( SwStyleNameMapper::GetSpecialExtraProgName(
pTOXBase->GetSequenceName() ) );
aRet <<= OUString( aName );
- bBOOL = sal_False;
}
break;
- case WID_LABEL_DISPLAY_TYPE :
+ case WID_LABEL_DISPLAY_TYPE:
{
- bBOOL = sal_False;
sal_Int16 nSet = text::ReferenceFieldPart::TEXT;
switch (pTOXBase->GetCaptionDisplay())
{
- case CAPTION_COMPLETE: nSet = text::ReferenceFieldPart::TEXT;break;
- case CAPTION_NUMBER : nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER; break;
- case CAPTION_TEXT : nSet = text::ReferenceFieldPart::ONLY_CAPTION; break;
+ case CAPTION_COMPLETE:
+ nSet = text::ReferenceFieldPart::TEXT;
+ break;
+ case CAPTION_NUMBER:
+ nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER;
+ break;
+ case CAPTION_TEXT:
+ nSet = text::ReferenceFieldPart::ONLY_CAPTION;
+ break;
}
aRet <<= nSet;
}
break;
- case WID_USE_LEVEL_FROM_SOURCE :
- bRet = pTOXBase->IsLevelFromChapter();
+ case WID_USE_LEVEL_FROM_SOURCE:
+ {
+ const sal_Bool bRet = pTOXBase->IsLevelFromChapter();
+ aRet <<= bRet;
+ }
break;
- case WID_LEVEL_FORMAT :
+ case WID_LEVEL_FORMAT:
{
- uno::Reference< container::XIndexReplace > xTokenAcc =
- ((SwXDocumentIndex*)this)->GetTokenAccess();
- if(!xTokenAcc.is())
- xTokenAcc = new SwXIndexTokenAccess_Impl(*
- (SwXDocumentIndex*)this);
- aRet.setValue(&xTokenAcc, ::getCppuType((const uno::Reference<container::XIndexReplace>*)0));
- bBOOL = sal_False;
+ uno::Reference< container::XIndexReplace > xTokenAccess(
+ m_pImpl->m_wTokenAccess);
+ if (!xTokenAccess.is())
+ {
+ xTokenAccess = new SwXIndexTokenAccess_Impl(*this);
+ m_pImpl->m_wTokenAccess = xTokenAccess;
+ }
+ aRet <<= xTokenAccess;
}
break;
- case WID_LEVEL_PARAGRAPH_STYLES :
+ case WID_LEVEL_PARAGRAPH_STYLES:
{
- uno::Reference< container::XIndexReplace > xStyleAcc =
- ((SwXDocumentIndex*)this)->GetStyleAccess();
- if(!xStyleAcc.is())
- xStyleAcc = new SwXIndexStyleAccess_Impl(*
- (SwXDocumentIndex*)this);
- aRet.setValue(&xStyleAcc, ::getCppuType((const uno::Reference<container::XIndexReplace>*)0));
- bBOOL = sal_False;
+ uno::Reference< container::XIndexReplace > xStyleAccess(
+ m_pImpl->m_wStyleAccess);
+ if (!xStyleAccess.is())
+ {
+ xStyleAccess = new SwXIndexStyleAccess_Impl(*this);
+ m_pImpl->m_wStyleAccess = xStyleAccess;
+ }
+ aRet <<= xStyleAccess;
}
break;
- case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME :
+ case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME:
{
- bBOOL = sal_False;
String aString;
SwStyleNameMapper::FillProgName(
pTOXBase->GetMainEntryCharStyle(),
@@ -838,47 +1064,47 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
aRet <<= OUString( aString );
}
break;
- case WID_CREATE_FROM_TABLES :
- bRet = 0 != (nCreate & nsSwTOXElement::TOX_TABLE);
+ case WID_CREATE_FROM_TABLES:
+ lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_TABLE);
break;
- case WID_CREATE_FROM_TEXT_FRAMES :
- bRet = 0 != (nCreate & nsSwTOXElement::TOX_FRAME);
+ case WID_CREATE_FROM_TEXT_FRAMES:
+ lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_FRAME);
break;
- case WID_CREATE_FROM_GRAPHIC_OBJECTS :
- bRet = 0 != (nCreate & nsSwTOXElement::TOX_GRAPHIC);
+ case WID_CREATE_FROM_GRAPHIC_OBJECTS:
+ lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_GRAPHIC);
break;
- case WID_CREATE_FROM_EMBEDDED_OBJECTS :
- bRet = 0 != (nCreate & nsSwTOXElement::TOX_OLE);
+ case WID_CREATE_FROM_EMBEDDED_OBJECTS:
+ lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_OLE);
break;
case WID_CREATE_FROM_STAR_MATH:
- bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_MATH);
+ lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_MATH);
break;
- case WID_CREATE_FROM_STAR_CHART :
- bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_CHART);
+ case WID_CREATE_FROM_STAR_CHART:
+ lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CHART);
break;
- case WID_CREATE_FROM_STAR_CALC :
- bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_CALC);
+ case WID_CREATE_FROM_STAR_CALC:
+ lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CALC);
break;
- case WID_CREATE_FROM_STAR_DRAW :
- bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_DRAW_IMPRESS);
+ case WID_CREATE_FROM_STAR_DRAW:
+ lcl_BitMaskToAny(aRet, nOLEOptions,
+ nsSwTOOElements::TOO_DRAW_IMPRESS);
break;
case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS:
- bRet = 0 != (nOLEOptions & nsSwTOOElements::TOO_OTHER);
+ lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_OTHER);
break;
case WID_CREATE_FROM_PARAGRAPH_STYLES:
- bRet = 0 != (nCreate & nsSwTOXElement::TOX_TEMPLATE);
+ lcl_BitMaskToAny(aRet, nCreate, nsSwTOXElement::TOX_TEMPLATE);
break;
- case WID_PARA_HEAD :
+ case WID_PARA_HEAD:
{
//Header steht an Pos 0
String aString;
SwStyleNameMapper::FillProgName(rForm.GetTemplate( 0 ), aString,
nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
aRet <<= OUString( aString );
- bBOOL = sal_False;
}
break;
- case WID_PARA_SEP :
+ case WID_PARA_SEP:
{
String aString;
SwStyleNameMapper::FillProgName(
@@ -887,21 +1113,20 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
sal_True);
aRet <<= OUString( aString );
- bBOOL = sal_False;
}
break;
- case WID_PARA_LEV1 :
- case WID_PARA_LEV2 :
- case WID_PARA_LEV3 :
- case WID_PARA_LEV4 :
- case WID_PARA_LEV5 :
- case WID_PARA_LEV6 :
- case WID_PARA_LEV7 :
- case WID_PARA_LEV8 :
- case WID_PARA_LEV9 :
- case WID_PARA_LEV10 :
+ case WID_PARA_LEV1:
+ case WID_PARA_LEV2:
+ case WID_PARA_LEV3:
+ case WID_PARA_LEV4:
+ case WID_PARA_LEV5:
+ case WID_PARA_LEV6:
+ case WID_PARA_LEV7:
+ case WID_PARA_LEV8:
+ case WID_PARA_LEV9:
+ case WID_PARA_LEV10:
{
- // im sdbcx::Index beginnt Lebel 1 bei Pos 2 sonst bei Pos 1
+ // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1
sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1;
String aString;
SwStyleNameMapper::FillProgName(
@@ -910,282 +1135,319 @@ uno::Any SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
sal_True);
aRet <<= OUString( aString );
- bBOOL = sal_False;
}
break;
case WID_IS_RELATIVE_TABSTOPS:
- bRet = rForm.IsRelTabPos();
+ {
+ const sal_Bool bRet = rForm.IsRelTabPos();
+ aRet <<= bRet;
+ }
break;
case WID_INDEX_MARKS:
{
SwTOXMarks aMarks;
- const SwTOXType* pType = pTOXBase->GetTOXType();
- SwClientIter aIter(*(SwTOXType*)pType);
- SwTOXMark* pMark = (SwTOXMark*)aIter.First(TYPE(SwTOXMark));
+ SwTOXType const*const pType = pTOXBase->GetTOXType();
+ SwClientIter aIter(*pType);
+ SwTOXMark * pMark =
+ static_cast<SwTOXMark*>(aIter.First(TYPE(SwTOXMark)));
while( pMark )
{
if(pMark->GetTxtTOXMark())
+ {
aMarks.C40_INSERT(SwTOXMark, pMark, aMarks.Count());
- pMark = (SwTOXMark*)aIter.Next();
+ }
+ pMark = static_cast<SwTOXMark*>(aIter.Next());
}
- uno::Sequence< uno::Reference < text::XDocumentIndexMark > > aXMarks(aMarks.Count());
- uno::Reference<text::XDocumentIndexMark>* pxMarks = aXMarks.getArray();
+ uno::Sequence< uno::Reference<text::XDocumentIndexMark> >
+ aXMarks(aMarks.Count());
+ uno::Reference<text::XDocumentIndexMark>* pxMarks =
+ aXMarks.getArray();
for(USHORT i = 0; i < aMarks.Count(); i++)
{
pMark = aMarks.GetObject(i);
- pxMarks[i] = SwXDocumentIndexMark::GetObject((SwTOXType*)pType, pMark, m_pDoc);
+ pxMarks[i] = SwXDocumentIndexMark::GetObject(
+ const_cast<SwTOXType*>(pType), pMark, m_pImpl->m_pDoc);
}
- aRet.setValue(&aXMarks, ::getCppuType((uno::Sequence< uno::Reference< text::XDocumentIndexMark > >*)0));
- bBOOL = sal_False;
+ aRet <<= aXMarks;
}
break;
default:
//this is for items only
- bBOOL = sal_False;
if(WID_PRIMARY_KEY > pEntry->nWID)
{
- const SwAttrSet& rSet = m_pDoc->GetTOXBaseAttrSet(*pTOXBase);
- aRet = m_pPropSet->getPropertyValue(rPropertyName, rSet);
+ const SwAttrSet& rSet =
+ m_pImpl->m_pDoc->GetTOXBaseAttrSet(*pTOXBase);
+ aRet = m_pImpl->m_rPropSet.getPropertyValue(
+ rPropertyName, rSet);
}
}
- if(bBOOL)
- aRet.setValue(&bRet, ::getCppuBooleanType());
}
return aRet;
}
-/*-- 14.12.98 09:35:06---------------------------------------------------
- -----------------------------------------------------------------------*/
-void SwXDocumentIndex::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
-{
- DBG_WARNING("not implemented");
-}
/*-- 14.12.98 09:35:06---------------------------------------------------
-----------------------------------------------------------------------*/
-void SwXDocumentIndex::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+void SAL_CALL
+SwXDocumentIndex::addPropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
- DBG_WARNING("not implemented");
+ OSL_ENSURE(false,
+ "SwXDocumentIndex::addPropertyChangeListener(): not implemented");
}
-/*-- 14.12.98 09:35:06---------------------------------------------------
- -----------------------------------------------------------------------*/
-void SwXDocumentIndex::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+void SAL_CALL
+SwXDocumentIndex::removePropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
- DBG_WARNING("not implemented");
+ OSL_ENSURE(false,
+ "SwXDocumentIndex::removePropertyChangeListener(): not implemented");
}
-/*-- 14.12.98 09:35:07---------------------------------------------------
- -----------------------------------------------------------------------*/
-void SwXDocumentIndex::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+void SAL_CALL
+SwXDocumentIndex::addVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
- DBG_WARNING("not implemented");
+ OSL_ENSURE(false,
+ "SwXDocumentIndex::addVetoableChangeListener(): not implemented");
}
-/*-- 14.12.98 09:35:07---------------------------------------------------
- -----------------------------------------------------------------------*/
-void SwXDocumentIndex::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
+void SAL_CALL
+SwXDocumentIndex::removeVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
- BOOL bRemove = FALSE;
- switch( pOld ? pOld->Which() : 0 )
- {
- case RES_REMOVE_UNO_OBJECT:
- case RES_OBJECTDYING:
- bRemove = (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject;
- break;
- case RES_FMT_CHG:
- // wurden wir an das neue umgehaengt und wird das alte geloscht?
- bRemove = ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() &&
- ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR();
- break;
- }
- if( bRemove )
- {
- ((SwModify*)GetRegisteredIn())->Remove( this );
- aLstnrCntnr.Disposing();
- }
+ OSL_ENSURE(false,
+ "SwXDocumentIndex::removeVetoableChangeListener(): not implemented");
}
+
/* -----------------18.02.99 13:39-------------------
*
* --------------------------------------------------*/
-void SwXDocumentIndex::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
- throw( lang::IllegalArgumentException, uno::RuntimeException )
+void SAL_CALL
+SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange)
+throw (lang::IllegalArgumentException, uno::RuntimeException)
{
- if(!bIsDescriptor)
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ if (!m_pImpl->m_bIsDescriptor)
+ {
throw uno::RuntimeException();
- uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
- SwXTextRange* pRange = 0;
- OTextCursorHelper* pCursor = 0;
- if(xRangeTunnel.is())
+ }
+ const uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
+ SwXTextRange *const pRange =
+ ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
+ OTextCursorHelper *const pCursor =
+ ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
+
+ SwDoc *const pDoc =
+ (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0);
+ if (!pDoc)
{
- pRange = reinterpret_cast< SwXTextRange * >(
- sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
- pCursor = reinterpret_cast< OTextCursorHelper * >(
- sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
+ throw lang::IllegalArgumentException();
}
- SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0;
- if(pDoc )
+ SwUnoInternalPaM aPam(*pDoc);
+ //das muss jetzt sal_True liefern
+ ::sw::XTextRangeToSwPaM(aPam, xTextRange);
+
+ const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() );
+ if (pOld)
{
- SwUnoInternalPaM aPam(*pDoc);
- //das muss jetzt sal_True liefern
- ::sw::XTextRangeToSwPaM(aPam, xTextRange);
+ throw lang::IllegalArgumentException();
+ }
- const SwTOXBase* pOld = pDoc->GetCurTOX( *aPam.Start() );
- if(!pOld)
- {
- UnoActionContext aAction(pDoc);
- if(aPam.HasMark())
- pDoc->DeleteAndJoin(aPam);
+ UnoActionContext aAction(pDoc);
+ if (aPam.HasMark())
+ {
+ pDoc->DeleteAndJoin(aPam);
+ }
- SwTOXBase& rTOXBase = pProps->GetTOXBase();
- const SwTOXType* pTOXType = rTOXBase.GetTOXType();
- if(TOX_USER == pTOXType->GetType() && !pProps->GetTypeName().equals(pTOXType->GetTypeName()))
- {
- lcl_ReAssignTOXType(pDoc, rTOXBase, pProps->GetTypeName());
- }
- //TODO: apply Section attributes (columns and background)
- const SwTOXBaseSection* pTOX = pDoc->InsertTableOf(
- *aPam.GetPoint(), rTOXBase, 0, sal_False );
+ SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase();
+ SwTOXType const*const pTOXType = rTOXBase.GetTOXType();
+ if ((TOX_USER == pTOXType->GetType()) &&
+ !m_pImpl->m_pProps->GetTypeName().equals(pTOXType->GetTypeName()))
+ {
+ lcl_ReAssignTOXType(pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName());
+ }
+ //TODO: apply Section attributes (columns and background)
+ SwTOXBaseSection const*const pTOX =
+ pDoc->InsertTableOf( *aPam.GetPoint(), rTOXBase, 0, sal_False );
- pDoc->SetTOXBaseName( *pTOX, pProps->GetTOXBase().GetTOXName() );
+ pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_pProps->GetTOXBase().GetTOXName());
- // Seitennummern eintragen
- pBase = (const SwTOXBaseSection*)pTOX;
- pBase->GetFmt()->Add(this);
- ((SwTOXBaseSection*)pTOX)->UpdatePageNum();
- }
- else
- throw lang::IllegalArgumentException();
+ // update page numbers
+ pTOX->GetFmt()->Add(m_pImpl.get());
+ pTOX->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this));
+ const_cast<SwTOXBaseSection*>(pTOX)->UpdatePageNum();
- DELETEZ(pProps);
- m_pDoc = pDoc;
- bIsDescriptor = sal_False;
- }
+ m_pImpl->m_pProps.reset();
+ m_pImpl->m_pDoc = pDoc;
+ m_pImpl->m_bIsDescriptor = sal_False;
}
-/*-- 15.01.99 14:23:51---------------------------------------------------
- -----------------------------------------------------------------------*/
-void SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange)
- throw( lang::IllegalArgumentException, uno::RuntimeException )
-{
- vos::OGuard aGuard(Application::GetSolarMutex());
- attachToRange( xTextRange );
-}
/*-- 15.01.99 14:23:56---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Reference< text::XTextRange > SwXDocumentIndex::getAnchor(void) throw( uno::RuntimeException )
+uno::Reference< text::XTextRange > SAL_CALL
+SwXDocumentIndex::getAnchor() throw (uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- uno::Reference< text::XTextRange > xRet;
- if(GetRegisteredIn())
+
+ SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
+ if (!pSectionFmt)
{
- SwSectionFmt* pSectFmt = GetFmt();
- const SwNodeIndex* pIdx;
- if( 0 != ( pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) &&
- pIdx->GetNode().GetNodes().IsDocNodes() )
- {
- SwPaM aPaM(*pIdx);
- aPaM.Move( fnMoveForward, fnGoCntnt );
- aPaM.SetMark();
- aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode();
- aPaM.Move( fnMoveBackward, fnGoCntnt );
- xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(),
- *aPaM.GetMark(), aPaM.GetPoint());
- }
- }
- else
throw uno::RuntimeException();
+ }
+
+ uno::Reference< text::XTextRange > xRet;
+ SwNodeIndex const*const pIdx( pSectionFmt->GetCntnt().GetCntntIdx() );
+ if (pIdx && pIdx->GetNode().GetNodes().IsDocNodes())
+ {
+ SwPaM aPaM(*pIdx);
+ aPaM.Move( fnMoveForward, fnGoCntnt );
+ aPaM.SetMark();
+ aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode();
+ aPaM.Move( fnMoveBackward, fnGoCntnt );
+ xRet = SwXTextRange::CreateXTextRange(*pSectionFmt->GetDoc(),
+ *aPaM.GetMark(), aPaM.GetPoint());
+ }
return xRet;
}
+
/*-- 15.01.99 15:46:48---------------------------------------------------
-----------------------------------------------------------------------*/
void lcl_RemoveChildSections(SwSectionFmt& rParentFmt)
{
SwSections aTmpArr;
- SwDoc* pDoc = rParentFmt.GetDoc();
- sal_uInt16 nCnt = rParentFmt.GetChildSections(aTmpArr,SORTSECT_POS);
+ SwDoc *const pDoc = rParentFmt.GetDoc();
+ const sal_uInt16 nCnt = rParentFmt.GetChildSections(aTmpArr, SORTSECT_POS);
if( nCnt )
{
for( sal_uInt16 n = 0; n < nCnt; ++n )
+ {
if( aTmpArr[n]->GetFmt()->IsInNodesArr() )
{
SwSectionFmt* pFmt = aTmpArr[n]->GetFmt();
lcl_RemoveChildSections(*pFmt);
pDoc->DelSectionFmt( pFmt );
}
+ }
}
}
-void SwXDocumentIndex::dispose(void) throw( uno::RuntimeException )
+
+void SAL_CALL SwXDocumentIndex::dispose() throw (uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- if(GetRegisteredIn())
+
+ SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
+ if (pSectionFmt)
{
- SwSectionFmt* pSectFmt = GetFmt();
- pSectFmt->GetDoc()->DeleteTOX( *(SwTOXBaseSection*)pSectFmt->GetSection(), sal_True);
+ pSectionFmt->GetDoc()->DeleteTOX(
+ *static_cast<SwTOXBaseSection*>(pSectionFmt->GetSection()),
+ sal_True);
}
- else
- throw uno::RuntimeException();
}
+
/*-- 15.01.99 15:46:49---------------------------------------------------
-----------------------------------------------------------------------*/
-void SwXDocumentIndex::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
+void SAL_CALL
+SwXDocumentIndex::addEventListener(
+ const uno::Reference< lang::XEventListener > & xListener)
+throw (uno::RuntimeException)
{
- if(!GetRegisteredIn())
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (!m_pImpl->GetRegisteredIn())
+ {
throw uno::RuntimeException();
- aLstnrCntnr.AddListener(aListener);
+ }
+ m_pImpl->m_ListenerContainer.AddListener(xListener);
}
/*-- 15.01.99 15:46:54---------------------------------------------------
-----------------------------------------------------------------------*/
-void SwXDocumentIndex::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
+void SAL_CALL
+SwXDocumentIndex::removeEventListener(
+ const uno::Reference< lang::XEventListener > & xListener)
+throw (uno::RuntimeException)
{
- if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener))
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (!m_pImpl->GetRegisteredIn() ||
+ !m_pImpl->m_ListenerContainer.RemoveListener(xListener))
+ {
throw uno::RuntimeException();
+ }
}
+
/* -----------------30.07.99 11:28-------------------
--------------------------------------------------*/
-OUString SwXDocumentIndex::getName(void) throw( uno::RuntimeException )
+OUString SAL_CALL SwXDocumentIndex::getName() throw (uno::RuntimeException)
{
- SwSectionFmt* pSectionFmt = GetFmt();
+ vos::OGuard g(Application::GetSolarMutex());
+
OUString uRet;
- if(bIsDescriptor)
+ SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
+ if (m_pImpl->m_bIsDescriptor)
{
- uRet = OUString(pProps->GetTOXBase().GetTOXName());
+ uRet = OUString(m_pImpl->m_pProps->GetTOXBase().GetTOXName());
}
else if(pSectionFmt)
{
uRet = OUString(pSectionFmt->GetSection()->GetName());
}
else
+ {
throw uno::RuntimeException();
+ }
return uRet;
}
/* -----------------30.07.99 11:28-------------------
--------------------------------------------------*/
-void SwXDocumentIndex::setName(const OUString& rName) throw( uno::RuntimeException )
+void SAL_CALL
+SwXDocumentIndex::setName(const OUString& rName) throw (uno::RuntimeException)
{
- SwSectionFmt* pSectionFmt = GetFmt();
- String sNewName(rName);
- sal_Bool bExcept = sal_False;
- if(!sNewName.Len())
- bExcept = sal_True;
- if(bIsDescriptor)
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (!rName.getLength())
{
- pProps->GetTOXBase().SetTOXName(sNewName);
+ throw uno::RuntimeException();
}
- else if(!pSectionFmt ||
- !pSectionFmt->GetDoc()->SetTOXBaseName(
- *(SwTOXBaseSection*)pSectionFmt->GetSection(), sNewName))
- bExcept = sal_True;
- if(bExcept)
+ SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
+ if (m_pImpl->m_bIsDescriptor)
+ {
+ m_pImpl->m_pProps->GetTOXBase().SetTOXName(rName);
+ }
+ else if (pSectionFmt)
+ {
+ const bool bSuccess = pSectionFmt->GetDoc()->SetTOXBaseName(
+ *static_cast<SwTOXBaseSection*>(pSectionFmt->GetSection()), rName);
+ if (!bSuccess)
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ else
+ {
throw uno::RuntimeException();
+ }
}
/******************************************************************
@@ -2018,7 +2280,6 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex)
if(!IsValid())
throw uno::RuntimeException();
- uno::Any aRet;
sal_Int32 nIdx = 0;
const SwSectionFmts& rFmts = GetDoc()->GetSections();
@@ -2029,9 +2290,11 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex)
pSect->GetFmt()->GetSectionNode() &&
nIdx++ == nIndex )
{
- uno::Reference< text::XDocumentIndex > xTmp = new SwXDocumentIndex(
- (SwTOXBaseSection*)pSect, GetDoc() );
- aRet.setValue(&xTmp, ::getCppuType((uno::Reference<text::XDocumentIndex>*)0));
+ const uno::Reference< text::XDocumentIndex > xTmp =
+ SwXDocumentIndex::CreateXDocumentIndex(
+ *GetDoc(), static_cast<SwTOXBaseSection const&>(*pSect));
+ uno::Any aRet;
+ aRet <<= xTmp;
return aRet;
}
}
@@ -2049,7 +2312,6 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName)
if(!IsValid())
throw uno::RuntimeException();
- uno::Any aRet;
String sToFind(rName);
const SwSectionFmts& rFmts = GetDoc()->GetSections();
@@ -2060,9 +2322,11 @@ uno::Any SwXDocumentIndexes::getByName(const OUString& rName)
pSect->GetFmt()->GetSectionNode() &&
((SwTOXBaseSection*)pSect)->GetTOXName() == sToFind)
{
- uno::Reference< text::XDocumentIndex > xTmp = new SwXDocumentIndex(
- (SwTOXBaseSection*)pSect, GetDoc() );
- aRet.setValue(&xTmp, ::getCppuType((uno::Reference<text::XDocumentIndex>*)0));
+ const uno::Reference< text::XDocumentIndex > xTmp =
+ SwXDocumentIndex::CreateXDocumentIndex(
+ *GetDoc(), static_cast<SwTOXBaseSection const&>(*pSect));
+ uno::Any aRet;
+ aRet <<= xTmp;
return aRet;
}
}
@@ -2145,17 +2409,6 @@ sal_Bool SwXDocumentIndexes::hasElements(void) throw( uno::RuntimeException )
return 0 != getCount();
}
-SwXDocumentIndex* SwXDocumentIndexes::GetObject(const SwTOXBaseSection* pTOX)
-{
- SwSectionFmt* pFmt = pTOX->GetFmt();
- SwClientIter aIter(*pFmt);
- SwXDocumentIndex* pxIdx = (SwXDocumentIndex*)aIter.First(TYPE(SwXDocumentIndex));
- if(pxIdx)
- return pxIdx;
- else
- return new SwXDocumentIndex(pTOX, pFmt->GetDoc());
-}
-
/* -----------------------------06.04.00 15:08--------------------------------
---------------------------------------------------------------------------*/
@@ -2187,16 +2440,12 @@ SwXIndexStyleAccess_Impl::SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx)
rParent(rParentIdx),
xParent(&rParentIdx)
{
- vos::OGuard aGuard(Application::GetSolarMutex());
- rParent.SetStyleAccess(this);
}
/*-- 13.09.99 16:52:29---------------------------------------------------
-----------------------------------------------------------------------*/
SwXIndexStyleAccess_Impl::~SwXIndexStyleAccess_Impl()
{
- vos::OGuard aGuard(Application::GetSolarMutex());
- rParent.SetStyleAccess(0);
}
/*-- 13.09.99 16:52:29---------------------------------------------------
@@ -2206,14 +2455,13 @@ void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any&
lang::WrappedTargetException, uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- const sal_Bool bDescriptor = rParent.IsDescriptor();
- SwSectionFmt* pSectFmt = rParent.GetFmt();
- if(!pSectFmt && !bDescriptor)
- throw uno::RuntimeException();
+
if(nIndex < 0 || nIndex > MAXLEVEL)
+ {
throw lang::IndexOutOfBoundsException();
- SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() :
- (SwTOXBaseSection*)pSectFmt->GetSection();
+ }
+
+ SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() );
uno::Sequence<OUString> aSeq;
if(!(rElement >>= aSeq))
@@ -2247,14 +2495,13 @@ uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex)
uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- const sal_Bool bDescriptor = rParent.IsDescriptor();
- SwSectionFmt* pSectFmt = rParent.GetFmt();
- if(!pSectFmt && !bDescriptor)
- throw uno::RuntimeException();
+
if(nIndex < 0 || nIndex > MAXLEVEL)
+ {
throw lang::IndexOutOfBoundsException();
- SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() :
- (SwTOXBaseSection*)pSectFmt->GetSection();
+ }
+
+ SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() );
const String& rStyles = pTOXBase->GetStyleNames((sal_uInt16) nIndex);
sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER);
@@ -2322,18 +2569,14 @@ uno::Sequence< OUString > SwXIndexTokenAccess_Impl::getSupportedServiceNames(voi
SwXIndexTokenAccess_Impl::SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx) :
rParent(rParentIdx),
xParent(&rParentIdx),
- nCount(SwForm::GetFormMaxLevel(rParent.GetTOXType()))
+ nCount(0)
{
- vos::OGuard aGuard(Application::GetSolarMutex());
- rParent.SetTokenAccess(this);
}
/*-- 13.09.99 16:52:29---------------------------------------------------
-----------------------------------------------------------------------*/
SwXIndexTokenAccess_Impl::~SwXIndexTokenAccess_Impl()
{
- vos::OGuard aGuard(Application::GetSolarMutex());
- rParent.SetTokenAccess(0);
}
/*-- 13.09.99 16:52:29---------------------------------------------------
@@ -2343,13 +2586,9 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any&
lang::WrappedTargetException, uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- const sal_Bool bDescriptor = rParent.IsDescriptor();
- SwSectionFmt* pSectFmt = rParent.GetFmt();
- if(!pSectFmt && !bDescriptor)
- throw uno::RuntimeException();
- SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() :
- (SwTOXBaseSection*)pSectFmt->GetSection();
+ SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() );
+
if(nIndex < 0 ||
(nIndex > pTOXBase->GetTOXForm().GetFormMax()))
throw lang::IndexOutOfBoundsException();
@@ -2358,6 +2597,7 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any&
if(!(rElement >>= aSeq))
throw lang::IllegalArgumentException();
+
String sPattern;
sal_Int32 nTokens = aSeq.getLength();
const beans::PropertyValues* pTokens = aSeq.getConstArray();
@@ -2519,14 +2759,8 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any&
sal_Int32 SwXIndexTokenAccess_Impl::getCount(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- const sal_Bool bDescriptor = rParent.IsDescriptor();
- SwSectionFmt* pSectFmt = rParent.GetFmt();
- if(!pSectFmt && !bDescriptor)
- throw uno::RuntimeException();
- sal_Int32 nRet = bDescriptor ?
- nCount :
- ((SwTOXBaseSection*)pSectFmt->GetSection())->
- GetTOXForm().GetFormMax();
+
+ const sal_Int32 nRet = rParent.m_pImpl->GetFormMax();
return nRet;
}
/*-- 13.09.99 16:52:30---------------------------------------------------
@@ -2537,12 +2771,9 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex)
uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- const sal_Bool bDescriptor = rParent.IsDescriptor();
- SwSectionFmt* pSectFmt = rParent.GetFmt();
- if(!pSectFmt && !bDescriptor)
- throw uno::RuntimeException();
- SwTOXBase* pTOXBase = bDescriptor ? &rParent.GetProperties_Impl()->GetTOXBase() :
- (SwTOXBaseSection*)pSectFmt->GetSection();
+
+ SwTOXBase * pTOXBase( &rParent.m_pImpl->GetTOXSectionOrThrow() );
+
if(nIndex < 0 ||
(nIndex > pTOXBase->GetTOXForm().GetFormMax()))
throw lang::IndexOutOfBoundsException();
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index 907a2a617c9b..6eeb9757e47a 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -1169,7 +1169,8 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
SwTOXBaseSection *const pTOXBaseSect =
PTR_CAST(SwTOXBaseSection, pEnclosingSection);
const uno::Reference<text::XDocumentIndex> xIndex =
- SwXDocumentIndexes::GetObject(pTOXBaseSect);
+ SwXDocumentIndex::CreateXDocumentIndex(
+ *pTOXBaseSect->GetFmt()->GetDoc(), *pTOXBaseSect);
pRet[nProperty] <<= xIndex;
}
// else: no enclosing index found -> empty return value